ref: a12c51a51689cbb223951ffba05880813a0fefa0
parent: ecd4d6b2a8336c5afbfaf469ada838d850755234
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed May 6 15:24:18 EDT 2015
Conver emitprint into private function
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -154,7 +154,7 @@
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 @@
extern void
emitdcl(Symbol *),
emit(uint8_t, void *),
- emitprint(Node *),
emitswitch(short),
emitret(Type *tp),
emitfun(Symbol *sym);
--- a/cc1/code.c
+++ b/cc1/code.c
@@ -11,7 +11,8 @@
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 @@
[OEFUN] = emittext,
[OESTRUCT] = emittext,
[OELOOP] = emittext,
- [OBLOOP] = emittext
+ [OBLOOP] = emittext,
+ [OPRINT] = emitprint
};
void
@@ -254,9 +256,11 @@
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);
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
@@ -379,7 +379,7 @@
case '@':
next();
np = expr();
- emitprint(np);
+ emit(OPRINT, np);
freetree(np);
return;
}