commit eda1a5eb2a36e7274ac0af63604abbd95347a564
parent a12c51a51689cbb223951ffba05880813a0fefa0
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 6 May 2015 19:28:36 +0200
Convert emitfun into private of code.c
Diffstat:
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/cc1/cc1.h b/cc1/cc1.h
@@ -155,6 +155,7 @@ enum {
OCOMMA, OCAST, OSYM, OASK, OFIELD, OTYP,
OLABEL, ODEFAULT, OCASE, OSTRUCT, OJUMP, OBRANCH,
OEXPR, OEFUN, OESTRUCT, OELOOP, OBLOOP, OPRINT,
+ OFUN,
/* TODO: This order is important, but must be changed */
OAND, OOR,
/*
@@ -169,8 +170,7 @@ extern void
emitdcl(Symbol *),
emit(uint8_t, void *),
emitswitch(short),
- emitret(Type *tp),
- emitfun(Symbol *sym);
+ emitret(Type *tp);
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,7 @@ 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 *);
+ emitprint(uint8_t, void *), emitfun(uint8_t, void *);
char *optxt[] = {
[OADD] = "+",
@@ -117,7 +117,8 @@ void (*opcode[])(uint8_t, void *) = {
[OESTRUCT] = emittext,
[OELOOP] = emittext,
[OBLOOP] = emittext,
- [OPRINT] = emitprint
+ [OPRINT] = emitprint,
+ [OFUN] = emitfun
};
void
@@ -266,9 +267,11 @@ emitprint(uint8_t op, void *arg)
fflush(stdout);
}
-void
-emitfun(Symbol *sym)
+static void
+emitfun(uint8_t op, void *arg)
{
+ Symbol *sym = arg;
+
printf("%c%d\tF\t%s\t{\n",
sym->isglobal ? 'G' : 'Y', sym->id, sym->name);
}
diff --git a/cc1/decl.c b/cc1/decl.c
@@ -536,7 +536,7 @@ extdecl(void)
emitdcl(sym);
} else if (yytoken == '{') {
curfun = sym;
- emitfun(sym);
+ emit(OFUN, sym);
compound(NULL, NULL, NULL);
emit(OEFUN, NULL);
popctx();