shithub: mc

Download patch

ref: 762e7638bf6344ef81bdf95b5b9687542ed23f72
parent: a9735e1242911e9c51f8d7b0de75772ef7b5cfb6
author: Ori Bernstein <[email protected]>
date: Tue Oct 7 14:31:44 EDT 2014

Write out all important attrs on decls in usefiles.

--- a/libstd/alloc.myr
+++ b/libstd/alloc.myr
@@ -391,6 +391,7 @@
 	else
 		-> align(sz, Pagesz)
 	;;
+	die("Size does not match any buckets")
 }
 
 /*
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -861,6 +861,21 @@
     free(k);
 }
 
+static void mergeattrs(Node *a, Node *b)
+{
+    if (!a || !b)
+        return;
+
+    a->decl.isglobl = a->decl.isglobl || b->decl.isglobl;
+    a->decl.isconst = a->decl.isconst || b->decl.isconst;
+    a->decl.isextern = a->decl.isextern || b->decl.isextern;
+    a->decl.ispkglocal = a->decl.ispkglocal || b->decl.ispkglocal;
+    a->decl.ishidden = a->decl.ishidden || b->decl.ishidden;
+    a->decl.isimport = a->decl.isimport || b->decl.isimport;
+    a->decl.isnoret = a->decl.isnoret || b->decl.isnoret;
+    a->decl.isexportinit = a->decl.isexportinit || b->decl.isexportinit;
+}
+
 /* The exports in package declarations
  * need to be merged with the declarations
  * at the global scope. Declarations in
@@ -970,7 +985,8 @@
                 fatal(nx->line, "Export %s double-defined on line %d", ctxstr(st, nx), ng->line);
             if (nx->decl.isgeneric != ng->decl.isgeneric)
                 fatal(nx->line, "Export %s defined with different genericness on line %d", ctxstr(st, nx), ng->line);
-            ng->decl.ispkglocal = nx->decl.ispkglocal;
+            mergeattrs(ng, nx);
+            mergeattrs(nx, ng);
             unify(st, nx, type(st, ng), type(st, nx));
         } else {
             if (!nx->decl.isextern && !nx->decl.isimport && !nx->decl.trait)
--- a/parse/use.c
+++ b/parse/use.c
@@ -493,9 +493,11 @@
             wrtype(fd, n->decl.type);
 
             /* symflags */
-            wrint(fd, n->decl.isconst);
-            wrint(fd, n->decl.isgeneric);
-            wrint(fd, n->decl.isextern);
+            wrbool(fd, n->decl.isconst);
+            wrbool(fd, n->decl.isgeneric);
+            wrbool(fd, n->decl.isextern);
+            wrbool(fd, n->decl.isnoret);
+            wrbool(fd, n->decl.ispkglocal);
 
             /* init */
             pickle(fd, n->decl.init);
@@ -628,9 +630,11 @@
             rdtype(fd, &n->decl.type);
 
             /* symflags */
-            n->decl.isconst = rdint(fd);
-            n->decl.isgeneric = rdint(fd);
-            n->decl.isextern = rdint(fd);
+            n->decl.isconst = rdbool(fd);
+            n->decl.isgeneric = rdbool(fd);
+            n->decl.isextern = rdbool(fd);
+            n->decl.isnoret = rdbool(fd);
+            n->decl.ispkglocal = rdbool(fd);
 
             /* init */
             n->decl.init = unpickle(fd);