shithub: scc

Download patch

ref: 57ca51bc90319ba7b58eefac227b3dfa8c671032
parent: 7b85dc85c01282002571b52f207747da080c2802
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed May 6 15:28:36 EDT 2015

Convert emitdcl into private of code.c

--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -155,7 +155,7 @@
 	OCOMMA, OCAST, OSYM, OASK, OFIELD, OTYP,
 	OLABEL, ODEFAULT, OCASE, OSTRUCT, OJUMP, OBRANCH,
 	OEXPR, OEFUN, OESTRUCT, OELOOP, OBLOOP, OPRINT,
-	OFUN, ORET,
+	OFUN, ORET, ODECL,
 	/* TODO: This order is important, but must be changed */
 	OAND, OOR,
 	/*
@@ -167,7 +167,6 @@
 
 /*TODO: clean these declarations */
 extern void
-	emitdcl(Symbol *),
 	emit(uint8_t, void *),
 	emitswitch(short);
 
--- a/cc1/code.c
+++ b/cc1/code.c
@@ -13,7 +13,7 @@
             emitsizeof(uint8_t, void *), emitexp(uint8_t, void *),
             emitsymid(uint8_t, void *), emittext(uint8_t, void *),
             emitprint(uint8_t, void *), emitfun(uint8_t, void *),
-            emitret(uint8_t, void *);
+            emitret(uint8_t, void *), emitdcl(uint8_t, void *);
 
 char *optxt[] = {
 	[OADD] = "+",
@@ -120,7 +120,8 @@
 	[OBLOOP] = emittext,
 	[OPRINT] = emitprint,
 	[OFUN] = emitfun,
-	[ORET] = emitret
+	[ORET] = emitret,
+	[ODECL] = emitdcl
 };
 
 void
@@ -201,9 +202,11 @@
 	putchar(tp->letter);
 }
 
-void
-emitdcl(Symbol *sym)
+static void
+emitdcl(uint8_t op, void *arg)
 {
+	Symbol *sym = arg;
+
 	emitvar(sym);
 	putchar('\t');
 	emittype(sym->type);
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -82,7 +82,7 @@
 			error("parameter name omitted");
 		sp = syms;
 		for (i = 0; i < n; ++i)
-			emitdcl(*sp++);
+			emit(ODECL, *sp++);
 	}
 
 	return queue(dp, FTN, n, tp);
@@ -346,7 +346,7 @@
 			if (bp == &buff[NR_MAXSTRUCTS])
 				error("too much fields in struct/union");
 			*bp++ = sym->type;
-			emitdcl(sym);
+			emit(ODECL, sym);
 		} while (accept(','));
 		expect(';');
 	}
@@ -467,7 +467,7 @@
 		}
 		if (accept('='))
 			initializer(sym);
-		emitdcl(sym);
+		emit(ODECL, sym);
 	} while (accept(','));
 
 	expect(';');
@@ -533,7 +533,7 @@
 			if (tp->op != FTN) {
 				if (accept('='))
 					initializer(sym);
-				emitdcl(sym);
+				emit(ODECL, sym);
 			} else if (yytoken == '{') {
 				curfun = sym;
 				emit(OFUN, sym);