X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=wrappergen%2Fwrite_fluffy.c;h=ddf940f0b9b4ec8419a387c4f3e297dd0fc33437;hb=6405da9f810302a2b2799968a5891184a8a578fa;hp=dadf9432dc27386fec267c1dac3708f8791bba33;hpb=943bc48a155169ae3d8357a2aecd405247852426;p=cparser diff --git a/wrappergen/write_fluffy.c b/wrappergen/write_fluffy.c index dadf943..ddf940f 100644 --- a/wrappergen/write_fluffy.c +++ b/wrappergen/write_fluffy.c @@ -1,6 +1,6 @@ /* * This file is part of cparser. - * Copyright (C) 2007-2008 Matthias Braun + * Copyright (C) 2007-2009 Matthias Braun * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -29,6 +29,7 @@ #include "entity_t.h" #include "type.h" #include "adt/error.h" +#include "printer.h" static const scope_t *global_scope; static FILE *out; @@ -42,7 +43,7 @@ static const char *get_atomic_type_string(const atomic_type_kind_t type) 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"; @@ -172,8 +173,6 @@ static void write_type(const type_t *type) case TYPE_FUNCTION: write_function_type(&type->function); return; - case TYPE_INVALID: - panic("invalid type found"); case TYPE_COMPLEX: case TYPE_IMAGINARY: default: @@ -222,18 +221,11 @@ static void write_unary_expression(const unary_expression_t *expression) 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 + case EXPR_UNARY_CASES: write_unary_expression((const unary_expression_t*) expression); break; default: @@ -305,7 +297,7 @@ static void write_function(const entity_t *entity) fprintf(out, ")"); const type_t *return_type = skip_typeref(function_type->return_type); - if(!is_type_atomic(return_type, ATOMIC_TYPE_VOID)) { + if (!is_type_void(return_type)) { fprintf(out, " : "); write_type(return_type); } @@ -317,8 +309,7 @@ void write_fluffy_decls(FILE *output, const translation_unit_t *unit) 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 */