#include "entity_t.h"
#include "type.h"
#include "adt/error.h"
+#include "printer.h"
static const scope_t *global_scope;
static FILE *out;
case ATOMIC_TYPE_CHAR: return "byte";
case ATOMIC_TYPE_SCHAR: return "byte";
case ATOMIC_TYPE_UCHAR: return "unsigned byte";
- case ATOMIC_TYPE_SHORT: return "short";
+ case ATOMIC_TYPE_SHORT: return "short";
case ATOMIC_TYPE_USHORT: return "unsigned short";
case ATOMIC_TYPE_INT: return "int";
case ATOMIC_TYPE_UINT: return "unsigned int";
case TYPE_FUNCTION:
write_function_type(&type->function);
return;
- case TYPE_INVALID:
- panic("invalid type found");
case TYPE_COMPLEX:
case TYPE_IMAGINARY:
default:
static void write_expression(const expression_t *expression)
{
- const const_expression_t *constant;
- /* TODO */
switch(expression->kind) {
- case EXPR_CONST:
- constant = &expression->conste;
- if(is_type_integer(expression->base.type)) {
- fprintf(out, "%lld", constant->v.int_value);
- } else {
- fprintf(out, "%Lf", constant->v.float_value);
- }
+ case EXPR_LITERAL_INTEGER:
+ fprintf(out, "%s", expression->literal.value.begin);
break;
EXPR_UNARY_CASES
write_unary_expression((const unary_expression_t*) expression);
out = output;
global_scope = &unit->scope;
- ast_set_output(out);
- type_set_output(out);
+ print_to_file(out);
fprintf(out, "/* WARNING: Automatically generated file */\n");
/* write structs,unions + enums */