ref: ec60839982dffcb2212f6b7e9eeb8b11a0b4d292
parent: 26d9afbaac70ccfc12c91f54b05166d38769284f
author: Ori Bernstein <[email protected]>
date: Thu Dec 19 17:58:57 EST 2013
We don't need both maxdid and ndecls. These two variables should always be the same.
--- a/parse/node.c
+++ b/parse/node.c
@@ -13,7 +13,6 @@
#include "parse.h"
size_t maxnid;
-size_t maxdid;
Node **decls;
size_t ndecls;
@@ -264,7 +263,7 @@
Node *n;
n = mknode(line, Ndecl);
- n->decl.did = maxdid++;
+ n->decl.did = ndecls;
n->decl.name = name;
n->decl.type = ty;
lappend(&decls, &ndecls, n);
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -278,7 +278,6 @@
extern Node **decls; /* decl id -> decl map */
extern size_t ndecls;
extern size_t maxnid; /* the maximum node id generated so far */
-extern size_t maxdid; /* the maximum decl id generated so far */
extern int ispureop[];
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -303,7 +303,7 @@
popstab();
break;
case Ndecl:
- r->decl.did = maxdid++;
+ r->decl.did = ndecls;
/* sym */
r->decl.name = specializenode(n->decl.name, tsmap);
r->decl.type = tysubst(n->decl.type, tsmap);
@@ -317,6 +317,7 @@
/* init */
r->decl.init = specializenode(n->decl.init, tsmap);
+ lappend(&decls, &ndecls, r);
break;
case Nfunc:
r->func.scope = mkstab();
--- a/parse/use.c
+++ b/parse/use.c
@@ -539,7 +539,7 @@
popstab();
break;
case Ndecl:
- n->decl.did = maxdid++; /* unique within file */
+ n->decl.did = ndecls; /* unique within file */
/* sym */
n->decl.name = unpickle(fd);
rdtype(fd, &n->decl.type);