ref: 1f93655144cbf4a81858966ea37b38a792a16aa5
parent: 1f26fd0dd93bed2e76b19b73f40c59bae22be15c
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Aug 10 19:20:57 EDT 2014
Add information about type in constants This modification makes more regular the intermediate code and allows don't have to deal with default types in cc2.
--- a/cc1/code.c
+++ b/cc1/code.c
@@ -88,7 +88,7 @@
Symbol *sym = np->u.sym;
if (np->type == inttype) {
- printf("#%x", sym->u.i);
+ printf("#%c%x", np->type->letter, sym->u.i);
} else {
putchar('"');
for (bp = sym->u.s; c = *bp; ++bp)
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -193,14 +193,11 @@
static void
immediate(char *token)
{
- static char buf[2];
Node *np = newnode();
np->op = CONST;
- /* TODO: deal with constant non integer */
- buf[0] = L_INT;
- np->type = gettype(buf);
- np->u.imm = atoi(token+1);
+ np->type = gettype(token+1);
+ np->u.imm = atoi(token+2);
np->left = np->right = NULL;
push(np);
}
--
⑨