shithub: scc

Download patch

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

Convert emitfun into private of code.c

--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -155,6 +155,7 @@
 	OCOMMA, OCAST, OSYM, OASK, OFIELD, OTYP,
 	OLABEL, ODEFAULT, OCASE, OSTRUCT, OJUMP, OBRANCH,
 	OEXPR, OEFUN, OESTRUCT, OELOOP, OBLOOP, OPRINT,
+	OFUN,
 	/* TODO: This order is important, but must be changed */
 	OAND, OOR,
 	/*
@@ -169,8 +170,7 @@
 	emitdcl(Symbol *),
 	emit(uint8_t, void *),
 	emitswitch(short),
-	emitret(Type *tp),
-	emitfun(Symbol *sym);
+	emitret(Type *tp);
 
 extern Node *node(uint8_t op, Type *tp, Node *left, Node *rigth);
 extern Node *symbol(Symbol *sym);
--- a/cc1/code.c
+++ b/cc1/code.c
@@ -12,7 +12,7 @@
             emitsym(uint8_t, void *), emitfield(uint8_t, void *),
             emitsizeof(uint8_t, void *), emitexp(uint8_t, void *),
             emitsymid(uint8_t, void *), emittext(uint8_t, void *),
-            emitprint(uint8_t, void *);
+            emitprint(uint8_t, void *), emitfun(uint8_t, void *);
 
 char *optxt[] = {
 	[OADD] = "+",
@@ -117,7 +117,8 @@
 	[OESTRUCT] = emittext,
 	[OELOOP] = emittext,
 	[OBLOOP] = emittext,
-	[OPRINT] = emitprint
+	[OPRINT] = emitprint,
+	[OFUN] = emitfun
 };
 
 void
@@ -266,9 +267,11 @@
 	fflush(stdout);
 }
 
-void
-emitfun(Symbol *sym)
+static void
+emitfun(uint8_t op, void *arg)
 {
+	Symbol *sym = arg;
+
 	printf("%c%d\tF\t%s\t{\n",
 	       sym->isglobal ? 'G' : 'Y', sym->id, sym->name);
 }
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -536,7 +536,7 @@
 				emitdcl(sym);
 			} else if (yytoken == '{') {
 				curfun = sym;
-				emitfun(sym);
+				emit(OFUN, sym);
 				compound(NULL, NULL, NULL);
 				emit(OEFUN, NULL);
 				popctx();