From dfedf3f2bb434065da3ddbc931e87a4017535f80 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 30 Apr 2025 20:42:31 -0400 Subject: Update compiler to use randomly generated unique-per-file symbol suffixes instead of needing to rename symbols with objcopy --- src/parse.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/parse.c') 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; -- cgit v1.2.3