ref: 91886b417645874398263b84f186d8bffe40e805
parent: 203eee14a2e6b32e23d94c0dfff68b32346609d3
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Aug 8 12:35:33 EDT 2014
Add type field in Symbols This field is necessary if we want to know what we have.
--- a/cc2/cc2.h
+++ b/cc2/cc2.h
@@ -1,6 +1,7 @@
typedef struct symbol {
char public;
+ char type;
struct symbol *next;
union {
struct {
@@ -46,6 +47,7 @@
};
#define FUNCTION 0
+#define VARIABLE 1
#define AUTO 'A'
#define REGISTER 'R'
#define STATIC 'T'
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -208,6 +208,7 @@
case 'G': case 'R': case 'T':
break;
}
+ sym->type = VARIABLE;
sym->u.v.storage = class;
sym->u.v.type = gettype(strtok(NULL, "\t"));
}
@@ -218,6 +219,7 @@
Symbol *sym;
sym = local(token);
+ sym->type = LABEL;
sym->u.l.addr = listp - listexp;
}
@@ -228,6 +230,7 @@
curfun = global(token);
if ((token = strtok(NULL, "\t")) == NULL)
error(ESYNTAX);
+ curfun->type = FUNCTION;
curfun->u.f.name = xstrdup(token);
listp = listexp;
newp = nodepool;