shithub: scc

Download patch

ref: 49a6da6aba2474bc86f8b5335b45f8959c078b18
parent: b3cee02be5e427122cee8123813b96968b7443dd
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Jul 9 07:46:10 EDT 2014

Remove function parameter of context

A context is only created when a compound statement is found
(function bodies are compound statements), so it is not needed
pass an explicit function pointer.

--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -101,12 +101,10 @@
 	*install(char *s, unsigned char ns);
 
 typedef struct caselist Caselist;
-typedef void Ctxfun(Symbol *, Symbol *, Caselist *);
 
-extern Ctxfun compound;
+extern void compound(Symbol *lbreak, Symbol *lcont, Caselist *lswitch);
 extern Type *aggregate(Type *(*fun)(void));
-extern void context(Ctxfun *fun,
-                    Symbol *lbreak, Symbol *lcont, Caselist *lswitch);
+extern void context(Symbol *lbreak, Symbol *lcont, Caselist *lswitch);
 
 extern Type *typename(void);
 
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -468,7 +468,7 @@
 			curfun = sym;
 			emitfun(sym);
 			emitsframe(sym);
-			context(compound, NULL, NULL, NULL);
+			context(NULL, NULL, NULL);
 			emiteframe();
 			freesyms(NS_LABEL);
 			return;
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
@@ -301,7 +301,7 @@
 
 repeat:
 	switch (yytoken) {
-	case '{':      context(compound, lbreak, lcont, lswitch); break;
+	case '{':      context(lbreak, lcont, lswitch); break;
 	case RETURN:   Return(); break;
 	case WHILE:    While(lswitch); break;
 	case FOR:      For(lswitch); break;
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -59,10 +59,10 @@
 }
 
 void
-context(Ctxfun *fun, Symbol *lbreak, Symbol *lcont, Caselist *lswitch)
+context(Symbol *lbreak, Symbol *lcont, Caselist *lswitch)
 {
 	++curctx;
-	(*fun)(lbreak, lcont, lswitch);
+	compound(lbreak, lcont, lswitch);
 	--curctx;
 	freesyms(NS_IDEN);
 	freesyms(NS_TAG);