scc

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

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

Convert emitret into private of code.c

Diffstat:
Mcc1/cc1.h | 5++---
Mcc1/code.c | 12++++++++----
Mcc1/stmt.c | 2+-
3 files changed, 11 insertions(+), 8 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, + OFUN, ORET, /* TODO: This order is important, but must be changed */ OAND, OOR, /* @@ -169,8 +169,7 @@ enum { extern void emitdcl(Symbol *), emit(uint8_t, void *), - emitswitch(short), - emitret(Type *tp); + emitswitch(short); extern Node *node(uint8_t op, Type *tp, Node *left, Node *rigth); extern Node *symbol(Symbol *sym); diff --git a/cc1/code.c b/cc1/code.c @@ -12,7 +12,8 @@ static void emitbin(uint8_t, void *), emitunary(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 *), - emitprint(uint8_t, void *), emitfun(uint8_t, void *); + emitprint(uint8_t, void *), emitfun(uint8_t, void *), + emitret(uint8_t, void *); char *optxt[] = { [OADD] = "+", @@ -118,7 +119,8 @@ void (*opcode[])(uint8_t, void *) = { [OELOOP] = emittext, [OBLOOP] = emittext, [OPRINT] = emitprint, - [OFUN] = emitfun + [OFUN] = emitfun, + [ORET] = emitret }; void @@ -276,9 +278,11 @@ emitfun(uint8_t op, void *arg) sym->isglobal ? 'G' : 'Y', sym->id, sym->name); } -void -emitret(Type *tp) +static void +emitret(uint8_t op, void *arg) { + Type *tp = arg; + fputs("\ty", stdout); emittype(tp); } diff --git a/cc1/stmt.c b/cc1/stmt.c @@ -174,7 +174,7 @@ Return(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) else if ((np = convert(np, tp, 0)) == NULL) error("incorrect type in return"); } - emitret(tp); + emit(ORET, tp); emit(OEXPR, np); freetree(np); }