ref: 26d9afbaac70ccfc12c91f54b05166d38769284f
parent: aab1653d3e737964ae91755448b23c8f9b2bbfc5
author: Ori Bernstein <[email protected]>
date: Thu Dec 19 17:34:59 EST 2013
Push and pop stabs correctly when loading usefiles.
--- a/parse/dump.c
+++ b/parse/dump.c
@@ -176,6 +176,8 @@
fprintf(fd, " (name = %s, islocal = %d)\n", n->use.name, n->use.islocal);
break;
case Nexpr:
+ if (exprop(n) == Ovar)
+ assert(decls[n->expr.did]->decl.did == n->expr.did);
ty = tystr(n->expr.type);
if (n->expr.type)
tid = n->expr.type->tid;
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1161,7 +1161,7 @@
s = getdcl(curstab(), args[0]);
if (!s)
fatal(n->line, "Undeclared var %s", ctxstr(st, args[0]));
- t = initvar(st, n, s);
+ initvar(st, n, s);
break;
case Oucon:
inferucon(st, n, &n->expr.isconst);
--- a/parse/stab.c
+++ b/parse/stab.c
@@ -34,6 +34,7 @@
/* scope management */
Stab *curstab()
{
+ assert(stabstkoff > 0);
return stabstk[stabstkoff - 1];
}
@@ -45,6 +46,7 @@
void popstab(void)
{
+ assert(stabstkoff > 0);
stabstkoff--;
}
--- a/parse/use.c
+++ b/parse/use.c
@@ -647,6 +647,7 @@
Type *t;
int c;
+ pushstab(file->file.globls);
if (!dedup)
dedup = mkht(namehash, nameeq);
if (fgetc(f) != 'U')
@@ -700,6 +701,7 @@
}
fixmappings(s);
htfree(tidmap);
+ popstab();
return 1;
}