]> git.mdlowis.com Git - proto/obnc.git/commitdiff
added symbol copying for imports
authorMichael D. Lowis <mike.lowis@gentex.com>
Fri, 2 Dec 2022 21:08:04 +0000 (16:08 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Fri, 2 Dec 2022 21:08:04 +0000 (16:08 -0500)
cerise/src/grammar.c
cerise/tests/Module.m

index 56870ab7ca2c336f010ccd4d457280c003dbf05a..33f7c05e585edd4587a1ebb0a53cda4147230c9f 100644 (file)
@@ -714,6 +714,7 @@ static void init_parser(Parser* p, char* path)
 
 static void import(Parser* curr, char* modname, char* alias)
 {
+    /* parse the module */
     Parser p = {0};
     char* path = fs_modfind(curr, modname);
     if (!path)
@@ -724,17 +725,18 @@ static void import(Parser* curr, char* modname, char* alias)
     module(&p);
     (void)alias;
 
-//    Symbol* sym = symbol_new(p, 0, modname,  SYM_MODULE, 0);
-//    size_t modid = sym - &p->syms[0];
-//
-//    for (size_t i = 0; i < p.nsyms; i++)
-//    {
-//        if (p.syms[i].export)
-//        {
-////            printf("sym: %s\n", p.syms[i].name);
-////            (void)alias;
-//        }
-//    }
+    /* copy exported symbols to our symbol table */
+    Symbol* sym = symbol_new(curr, 0, modname,  SYM_MODULE, 0);
+    size_t modid = sym - &curr->syms[0];
+    printf("%lu\n", modid);
+    for (size_t i = 0; i < p.nsyms; i++)
+    {
+        if (p.syms[i].export)
+        {
+            Symbol* sym = symbol_new(curr, 0, p.syms[i].name, p.syms[i].class, 0);
+            sym->module = modid;
+        }
+    }
 }
 
 void compile(char* path)
index a24ea430a337c52f6149b6237af714229aeec503..b491d90ea9098bac7b5b989532538c71010be6a7 100644 (file)
@@ -1,4 +1,5 @@
-import A
+import
+    A
 
 const
   FOO* = 42