scc

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

commit 5dd0e7ed4619141a86023783b34c3e981025e003
parent a8877ebf2f19bf0301f90d9bdff9e23605acfe97
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 16 Sep 2014 16:06:09 +0200

Use better names for cgen and xcgen

xcgen was a bad idea (imitation of Thompson style), but it could
be better. This patch uses generate for the extern function and
cgen for the static.

Diffstat:
Mcc2/cc2.h | 2+-
Mcc2/cgen.c | 17++++++++---------
Mcc2/parser.c | 2+-
3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/cc2/cc2.h b/cc2/cc2.h @@ -92,5 +92,5 @@ enum nerrors { extern void error(unsigned nerror, ...); extern void genaddable(Node *list[]); -extern void cgen(Symbol *sym, Node *list[]); +extern void generate(Symbol *sym, Node *list[]); extern void genstack(Symbol *fun); diff --git a/cc2/cgen.c b/cc2/cgen.c @@ -84,28 +84,27 @@ emit(char op, ...) } void -xcgen(Node *np) +cgen(Node *np) { Node *lp, *rp; - /* TODO: define a macro with the default integer type */ - unsigned imm, off; + INT imm; if (!np || np->complex == 0) return; lp = np->left; rp = np->right; if (!lp) { - xcgen(rp); + cgen(rp); } else if (!rp) { - xcgen(lp); + cgen(lp); } else { Node *p, *q; if (lp->complex > rp->complex) p = lp, q = rp; else p = rp, q = lp; - xcgen(p); - xcgen(q); + cgen(p); + cgen(q); } switch (np->op) { @@ -115,7 +114,7 @@ xcgen(Node *np) } void -cgen(Symbol *sym, Node *list[]) +generate(Symbol *sym, Node *list[]) { extern char odebug; Node *np; @@ -131,7 +130,7 @@ cgen(Symbol *sym, Node *list[]) } while (np = *list++) - xcgen(np); + cgen(np); if (frame) { emit(LD, SP, IX); diff --git a/cc2/parser.c b/cc2/parser.c @@ -371,7 +371,7 @@ endfunction(char *token) error(ESYNTAX); listp = NULL; genaddable(listexp); - cgen(curfun, listexp); + generate(curfun, listexp); curfun = NULL; }