shithub: scc

Download patch

ref: 27b3c745a4bbdf3c0e6ed5d482b2fd673ba0fd83
parent: 797ee1ebf6f6949ded2a493fcd0ebd844f4463db
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Apr 21 02:59:50 EDT 2014

Add symbol flag in Symbol

This flag help to detect when a node is a symbol.

--- a/cc1.h
+++ b/cc1.h
@@ -193,6 +193,7 @@
 	uint8_t typeop;
 	struct {
 		bool lvalue : 1;
+		bool symbol: 1;
 	} b;
 	union unode {
 		Symbol *sym;
--- a/code.c
+++ b/code.c
@@ -57,7 +57,7 @@
 	np->utype = UNQUAL(tp);
 	np->typeop = np->utype->op;
 	np->u = u;
-	np->b.lvalue = 0;
+	np->b.symbol = np->b.lvalue = 0;
 
 	return np;
 }
@@ -246,5 +246,9 @@
 Node *
 constcode(Symbol *sym)
 {
-	return node(emitconst, inttype, SYM(sym), 0);
+	Node *np;
+
+	np = node(emitconst, inttype, SYM(sym), 0);
+	np->b.symbol = 1;
+	return np;
 }
--- a/expr.c
+++ b/expr.c
@@ -355,7 +355,7 @@
 		if ((sym = yylval.sym) == NULL)
 			error("'%s' undeclared", yytext);
 		np = node(emitsym, sym->type, SYM(sym), 0);
-		np->b.lvalue = 1;
+		np->b.symbol = np->b.lvalue = 1;
 		next();
 		break;
 	case CONSTANT: