scc

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

commit 57ca51bc90319ba7b58eefac227b3dfa8c671032
parent 7b85dc85c01282002571b52f207747da080c2802
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed,  6 May 2015 19:28:36 +0200

Convert emitdcl into private of code.c

Diffstat:
Mcc1/cc1.h | 3+--
Mcc1/code.c | 11+++++++----
Mcc1/decl.c | 8++++----
3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -155,7 +155,7 @@ enum { 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 @@ enum { /*TODO: clean these declarations */ extern void - emitdcl(Symbol *), emit(uint8_t, void *), emitswitch(short); diff --git a/cc1/code.c b/cc1/code.c @@ -13,7 +13,7 @@ static void emitbin(uint8_t, void *), emitunary(uint8_t, void *), 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 @@ void (*opcode[])(uint8_t, void *) = { [OBLOOP] = emittext, [OPRINT] = emitprint, [OFUN] = emitfun, - [ORET] = emitret + [ORET] = emitret, + [ODECL] = emitdcl }; void @@ -201,9 +202,11 @@ emittype(Type *tp) 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); diff --git a/cc1/decl.c b/cc1/decl.c @@ -82,7 +82,7 @@ fundcl(struct dcldata *dp) 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 @@ structdcl(void) 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 @@ decl(void) } if (accept('=')) initializer(sym); - emitdcl(sym); + emit(ODECL, sym); } while (accept(',')); expect(';'); @@ -533,7 +533,7 @@ extdecl(void) if (tp->op != FTN) { if (accept('=')) initializer(sym); - emitdcl(sym); + emit(ODECL, sym); } else if (yytoken == '{') { curfun = sym; emit(OFUN, sym);