scc

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

commit 1f93655144cbf4a81858966ea37b38a792a16aa5
parent 1f26fd0dd93bed2e76b19b73f40c59bae22be15c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 10 Aug 2014 23:20:57 +0200

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.

Diffstat:
Mcc1/code.c | 2+-
Mcc2/parser.c | 7++-----
2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/cc1/code.c b/cc1/code.c @@ -88,7 +88,7 @@ emitconst(Node *np) 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) diff --git a/cc2/parser.c b/cc2/parser.c @@ -193,14 +193,11 @@ variable(char *token) 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); }