]> git.mdlowis.com Git - proto/obnc.git/commitdiff
emit symbols with the module name
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 9 Mar 2022 02:51:09 +0000 (21:51 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 9 Mar 2022 02:51:09 +0000 (21:51 -0500)
cerise/backend/ssa/codegen.c

index 01ad1ac49e80ab10fd178200038c09c76d0e3f47..7a9ae30f12333c6f0d6545a9afeb4cf390505259 100644 (file)
@@ -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
     {