scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 742a008857ece4651a448d49954a08383dc714fc
parent ae0f567bba4dd727c7f2f72764b04e9540c36850
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 24 Sep 2015 23:11:33 +0200

Remove the difference between local and global id

These difference were created long time ago to have different tables
for locals and global identifiers, but this was a stupid solution.
We are using this id now only how an identifier to find symbols
in a common hash, so this difference was creating collisions in the
table.

Diffstat:
Mcc1/symbol.c | 8+++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/cc1/symbol.c b/cc1/symbol.c @@ -12,8 +12,7 @@ #define NR_SYM_HASH 64 unsigned curctx; -static unsigned short localcnt; -static unsigned short globalcnt; +static unsigned short counterid; static Symbol *head, *labels; static Symbol *htab[NR_SYM_HASH]; @@ -105,7 +104,6 @@ popctx(void) short f; if (--curctx == GLOBALCTX) { - localcnt = 0; for (sym = labels; sym; sym = next) { next = sym->next; killsym(sym); @@ -125,7 +123,7 @@ newid(void) { unsigned short id; - id = (curctx) ? ++localcnt : ++globalcnt; + id = ++counterid; if (id == 0) { die("Overflow in %s identifiers", (curctx) ? "internal" : "external"); @@ -375,6 +373,6 @@ ikeywords(void) * will make faster some operations. There is no problem of memory * leakeage because this memory is not ever freed */ - globalcnt = 0; + counterid = 0; head = NULL; }