ref: 4858c0d0e802307875e8fe191a52946f05f7907d
parent: 242f9e6a3592eff25aa71efec50442dde00a71f9
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Mar 24 17:30:54 EDT 2014
Add id field to symbol structure This field will e used to generate the name of the variable in the intermediate code.
--- a/symbol.c
+++ b/symbol.c
@@ -85,6 +85,7 @@
register struct symbol *sym;
register struct symbol **t;
struct symtab *tbl;
+ static short id;
if (ns == NS_KEYWORD)
ns = NS_IDEN;
@@ -96,6 +97,7 @@
sym->ctx = curctx;
sym->token = IDEN;
sym->ns = ns;
+ sym->id = id++;
tbl = &symtab[(ns >= NR_NAMESPACES) ? NS_IDEN : ns];
sym->next = tbl->head;
tbl->head = sym;
--- a/symbol.h
+++ b/symbol.h
@@ -57,6 +57,7 @@
struct symbol {
char *name;
struct ctype *type;
+ short id;
uint8_t ctx;
uint8_t token;
uint8_t ns;