projects
/
cparser
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
finished implementation of __func__ and _PRETTY_FUNC__
[cparser]
/
write_fluffy.c
diff --git
a/write_fluffy.c
b/write_fluffy.c
index
4895a36
..
2956231
100644
(file)
--- a/
write_fluffy.c
+++ b/
write_fluffy.c
@@
-131,7
+131,7
@@
static void write_function_type(const function_type_t *type)
}
fprintf(out, ") : ");
}
fprintf(out, ") : ");
- write_type(type->re
sult
_type);
+ write_type(type->re
turn
_type);
fprintf(out, ")");
}
fprintf(out, ")");
}
@@
-200,11
+200,11
@@
static void write_expression(const expression_t *expression);
static void write_unary_expression(const unary_expression_t *expression)
{
static void write_unary_expression(const unary_expression_t *expression)
{
- switch(expression->type) {
- case
UNEXPR
_NEGATE:
+ switch(expression->
expression.
type) {
+ case
EXPR_UNARY
_NEGATE:
fputc('-', out);
break;
fputc('-', out);
break;
- case
UNEXPR
_NOT:
+ case
EXPR_UNARY
_NOT:
fputc('!', out);
break;
default:
fputc('!', out);
break;
default:
@@
-226,7
+226,7
@@
static void write_expression(const expression_t *expression)
fprintf(out, "%Lf", constant->v.float_value);
}
break;
fprintf(out, "%Lf", constant->v.float_value);
}
break;
- case EXPR_UNARY:
+ EXPR_UNARY_CASES
write_unary_expression((const unary_expression_t*) expression);
break;
default:
write_unary_expression((const unary_expression_t*) expression);
break;
default:
@@
-298,27
+298,20
@@
static void write_function(const declaration_t *declaration)
}
fprintf(out, ")");
}
fprintf(out, ")");
- const type_t *result_type = function_type->result_type;
- if(result_type->type != TYPE_ATOMIC ||
- ((const atomic_type_t*) result_type)->atype != ATOMIC_TYPE_VOID) {
+ const type_t *return_type = function_type->return_type;
+ if(!is_type_atomic(return_type, ATOMIC_TYPE_VOID)) {
fprintf(out, " : ");
fprintf(out, " : ");
- write_type(re
sult
_type);
+ write_type(re
turn
_type);
}
fputc('\n', out);
}
}
fputc('\n', out);
}
-void write_fluffy_decls(const translation_unit_t *unit)
+void write_fluffy_decls(
FILE *output,
const translation_unit_t *unit)
{
{
-#if 0
- out = fopen("out.fluffy", "w");
- if(out == NULL) {
- fprintf(stderr, "Couldn't open out.fluffy: %s\n", strerror(errno));
- exit(1);
- }
-#endif
- out = stdout;
+ out = output;
global_context = &unit->context;
global_context = &unit->context;
+ ast_set_output(out);
fprintf(out, "/* WARNING: Automatically generated file */\n");
/* write structs,unions + enums */
fprintf(out, "/* WARNING: Automatically generated file */\n");
/* write structs,unions + enums */
@@
-369,6
+362,4
@@
void write_fluffy_decls(const translation_unit_t *unit)
write_function(declaration);
}
write_function(declaration);
}
-
- //fclose(out);
}
}