scc

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

commit a12c51a51689cbb223951ffba05880813a0fefa0
parent ecd4d6b2a8336c5afbfaf469ada838d850755234
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed,  6 May 2015 19:24:18 +0200

Conver emitprint into private function

Diffstat:
Mcc1/cc1.h | 3+--
Mcc1/code.c | 12++++++++----
Mcc1/stmt.c | 2+-
3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -154,7 +154,7 @@ enum { OA_AND, OA_XOR, OA_OR, OADDR,ONEG, OCPL, OEXC, OCOMMA, OCAST, OSYM, OASK, OFIELD, OTYP, OLABEL, ODEFAULT, OCASE, OSTRUCT, OJUMP, OBRANCH, - OEXPR, OEFUN, OESTRUCT, OELOOP, OBLOOP, + OEXPR, OEFUN, OESTRUCT, OELOOP, OBLOOP, OPRINT, /* TODO: This order is important, but must be changed */ OAND, OOR, /* @@ -168,7 +168,6 @@ enum { extern void emitdcl(Symbol *), emit(uint8_t, void *), - emitprint(Node *), emitswitch(short), emitret(Type *tp), emitfun(Symbol *sym); diff --git a/cc1/code.c b/cc1/code.c @@ -11,7 +11,8 @@ static void emitbin(uint8_t, void *), emitunary(uint8_t, void *), emitternary(uint8_t, void *), emitcast(uint8_t, void *), emitsym(uint8_t, void *), emitfield(uint8_t, void *), emitsizeof(uint8_t, void *), emitexp(uint8_t, void *), - emitsymid(uint8_t, void *), emittext(uint8_t, void *); + emitsymid(uint8_t, void *), emittext(uint8_t, void *), + emitprint(uint8_t, void *); char *optxt[] = { [OADD] = "+", @@ -115,7 +116,8 @@ void (*opcode[])(uint8_t, void *) = { [OEFUN] = emittext, [OESTRUCT] = emittext, [OELOOP] = emittext, - [OBLOOP] = emittext + [OBLOOP] = emittext, + [OPRINT] = emitprint }; void @@ -254,9 +256,11 @@ emitexp(uint8_t op, void *arg) putchar('\n'); } -void -emitprint(Node *np) +static void +emitprint(uint8_t op, void *arg) { + Node *np = arg; + emitnode(np); printf("\tk%c\n", np->type->letter); fflush(stdout); diff --git a/cc1/stmt.c b/cc1/stmt.c @@ -379,7 +379,7 @@ stmt(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) case '@': next(); np = expr(); - emitprint(np); + emit(OPRINT, np); freetree(np); return; }