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;
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
*/
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;
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: