X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ast.c;h=164c8646160d7790595f0eb173371c4f93cdb37a;hb=610d20bcf83b946c7c97835c7bb87707853a44dd;hp=5c700768ea7e5b147ba70e265f0237f0745b5f72;hpb=f6feab51a8537815a941fce7aea6f338e0695c20;p=cparser diff --git a/ast.c b/ast.c index 5c70076..164c864 100644 --- a/ast.c +++ b/ast.c @@ -196,7 +196,9 @@ static void print_const(const const_expression_t *cnst) const type_t *const type = skip_typeref(cnst->base.type); - if (is_type_integer(type)) { + if (is_type_atomic(type, ATOMIC_TYPE_BOOL)) { + fputs(cnst->v.int_value ? "true" : "false", out); + } else if (is_type_integer(type)) { fprintf(out, "%lld", cnst->v.int_value); } else if (is_type_float(type)) { long double const val = cnst->v.float_value; @@ -1475,6 +1477,34 @@ static void print_ms_modifiers(const declaration_t *declaration) fputs(") ", out); } +static void print_scope(const scope_t *scope) +{ + const entity_t *entity = scope->entities; + for ( ; entity != NULL; entity = entity->base.next) { + print_indent(); + print_entity(entity); + fputs("\n", out); + } +} + +static void print_namespace(const namespace_t *namespace) +{ + fputs("namespace ", out); + if (namespace->base.symbol != NULL) { + fputs(namespace->base.symbol->string, out); + fputc(' ', out); + } + + fputs("{\n", out); + ++indent; + + print_scope(&namespace->members); + + --indent; + print_indent(); + fputs("}\n", out); +} + /** * Print a variable or function declaration */ @@ -1541,10 +1571,12 @@ void print_entity(const entity_t *entity) switch ((entity_kind_tag_t) entity->kind) { case ENTITY_VARIABLE: - case ENTITY_FUNCTION: case ENTITY_COMPOUND_MEMBER: print_declaration(entity); return; + case ENTITY_FUNCTION: + print_declaration(entity); + return; case ENTITY_TYPEDEF: print_typedef(entity); return; @@ -1573,6 +1605,9 @@ void print_entity(const entity_t *entity) print_enum_definition(&entity->enume); fputc(';', out); return; + case ENTITY_NAMESPACE: + print_namespace(&entity->namespacee); + return; case ENTITY_LABEL: case ENTITY_ENUM_VALUE: case ENTITY_LOCAL_LABEL: