From d1630b184ab4f88e5ec4145895da554d6581ce43 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Tue, 8 Mar 2022 21:51:09 -0500 Subject: [PATCH] emit symbols with the module name --- cerise/backend/ssa/codegen.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cerise/backend/ssa/codegen.c b/cerise/backend/ssa/codegen.c index 01ad1ac..7a9ae30 100644 --- a/cerise/backend/ssa/codegen.c +++ b/cerise/backend/ssa/codegen.c @@ -102,7 +102,9 @@ void codegen_symbol(Parser* p, Symbol* sym) (void)p; if (sym->class == SYM_VAR) { - printf("@%s = global ", sym->name); + char* modname = (sym->module == 0 + ? p->name : symbol_getbyid(p, sym->module)->name); + printf("@%s_%s = global ", modname, sym->name); emit_type(sym->type); if (sym->type->form == FORM_ARRAY || sym->type->form == FORM_RECORD) @@ -168,7 +170,9 @@ static void print_ident(Parser* p, SsaVar* var) char* name = (s->name[0] == '$' ? "" : s->name); if ((s->global || s->class == SYM_PROC) && (s->class != SYM_TYPE)) { - printf("@%s", name); + char* modname = (s->module == 0 + ? p->name : symbol_getbyid(p, s->module)->name); + printf("@%s_%s", modname, name); } else { -- 2.49.0