diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-30 20:42:31 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-30 20:42:31 -0400 |
| commit | dfedf3f2bb434065da3ddbc931e87a4017535f80 (patch) | |
| tree | 6c7d9e5e35fd4fd612d51285dcae7d6c06b8838a /src/parse.c | |
| parent | 46818674d3588dd15ebca5cb7be4afa8cd485cfe (diff) | |
Update compiler to use randomly generated unique-per-file symbol
suffixes instead of needing to rename symbols with objcopy
Diffstat (limited to 'src/parse.c')
| -rw-r--r-- | src/parse.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/parse.c b/src/parse.c index 12fafc0c..fcbf7e6b 100644 --- a/src/parse.c +++ b/src/parse.c @@ -1723,6 +1723,13 @@ PARSER(parse_declaration) { return NewAST(ctx->file, start, pos, Declare, .var=var, .type=type, .value=val); } +PARSER(parse_top_declaration) { + ast_t *declaration = parse_declaration(ctx, pos); + if (declaration) + declaration->__data.Declare.top_level = true; + return declaration; +} + PARSER(parse_update) { const char *start = pos; ast_t *lhs = optional(ctx, &pos, parse_expr); @@ -1948,7 +1955,7 @@ PARSER(parse_file_body) { ||(stmt=optional(ctx, &pos, parse_use)) ||(stmt=optional(ctx, &pos, parse_extern)) ||(stmt=optional(ctx, &pos, parse_inline_c)) - ||(stmt=optional(ctx, &pos, parse_declaration))) + ||(stmt=optional(ctx, &pos, parse_top_declaration))) { statements = new(ast_list_t, .ast=stmt, .next=statements); pos = stmt->end; |
