ref: 24572d7623dc7497d48c4e36f3250761377aba2f
parent: bce2cfac7f576b3a9afe811fd9a6d71ae18d3cb0
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed May 6 14:13:15 EDT 2015
Unify emitbin() and emitunary()
--- a/cc1/code.c
+++ b/cc1/code.c
@@ -61,10 +61,10 @@
[OADD] = emitbin,
[OSUB] = emitbin,
[OMUL] = emitbin,
- [OINC] = emitunary,
- [ODEC] = emitunary,
+ [OINC] = emitbin,
+ [ODEC] = emitbin,
[OSIZE] = emitsizeof,
- [OPTR] = emitunary,
+ [OPTR] = emitbin,
[OMOD] = emitbin,
[ODIV] = emitbin,
[OSHL] = emitbin,
@@ -74,7 +74,7 @@
[OGE] = emitbin,
[OLE] = emitbin,
[OEQ] = emitbin,
- [ONE] = emitunary,
+ [ONE] = emitbin,
[OBAND] = emitbin,
[OBXOR] = emitbin,
[OBOR] = emitbin,
@@ -89,9 +89,9 @@
[OA_AND] = emitbin,
[OA_XOR] = emitbin,
[OA_OR] = emitbin,
- [OADDR] = emitunary,
- [ONEG] = emitunary,
- [OCPL] = emitunary,
+ [OADDR] = emitbin,
+ [ONEG] = emitbin,
+ [OCPL] = emitbin,
[OAND] = emitbin,
[OOR] = emitbin,
[OCOMMA] = emitbin,
@@ -189,18 +189,6 @@
}
void
-emitunary(void *arg)
-{
- Node *lp, *np = arg;
- char letter;
-
- letter = np->type->letter;
- lp = np->left;
- (*opcode[lp->op])(lp);
- printf("\t%s%c", optxt[np->op], letter);
-}
-
-void
emitbin(void *arg)
{
Node *lp, *rp, *np = arg;
@@ -207,8 +195,10 @@
lp = np->left;
rp = np->rigth;
- (*opcode[lp->op])(lp);
- (*opcode[rp->op])(rp);
+ if (lp)
+ (*opcode[lp->op])(lp);
+ if (rp)
+ (*opcode[rp->op])(rp);
printf("\t%s%c", optxt[np->op], np->type->letter);
}