scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 49a6da6aba2474bc86f8b5335b45f8959c078b18
parent b3cee02be5e427122cee8123813b96968b7443dd
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed,  9 Jul 2014 11:46:10 +0200

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.

Diffstat:
Mcc1/cc1.h | 6++----
Mcc1/decl.c | 2+-
Mcc1/stmt.c | 2+-
Mcc1/symbol.c | 4++--
4 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -101,12 +101,10 @@ extern Symbol *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); diff --git a/cc1/decl.c b/cc1/decl.c @@ -468,7 +468,7 @@ extdecl(void) curfun = sym; emitfun(sym); emitsframe(sym); - context(compound, NULL, NULL, NULL); + context(NULL, NULL, NULL); emiteframe(); freesyms(NS_LABEL); return; diff --git a/cc1/stmt.c b/cc1/stmt.c @@ -301,7 +301,7 @@ stmt(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) 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; diff --git a/cc1/symbol.c b/cc1/symbol.c @@ -59,10 +59,10 @@ aggregate(Type * (*fun)(void)) } 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);