Skip to content

Commit

Permalink
Add globals to -P output.
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Aug 13, 2024
1 parent 9228dbb commit 6bc4864
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/compiler/json_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,20 @@ static inline void emit_types(FILE *file)
}
fputs("\n\t}\n", file);
}

static inline void emit_globals(FILE *file)
{
fputs("\t\"globals\": [\n", file);
{
bool first = true;
FOREACH_DECL(Decl *decl, compiler.context.module_list)
if (decl->decl_kind != DECL_VAR || decl->var.kind != VARDECL_GLOBAL) continue;
if (decl_is_hidden(decl)) continue;
INERT_COMMA;
PRINTF("\t\t\"%s::%s\"", module->name->module, decl->name);
FOREACH_DECL_END;
}
PRINTF("\n\t],");
}
static inline void emit_functions(FILE *file)
{
fputs("\t\"functions\": {\n", file);
Expand Down Expand Up @@ -269,6 +282,7 @@ static inline void emit_json_to_file(FILE *file)
emit_modules(file);
emit_types(file);
emit_functions(file);
emit_globals(file);
fputs("\n}", file);
}

Expand Down

0 comments on commit 6bc4864

Please sign in to comment.