scc

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

commit a6d242a2c229a19a8b2bf7ab2fb9735f270f948f
parent c01d1eb8e78865be5a2c83944539f13974c008b1
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 14 Sep 2017 14:53:39 +0100

[cc2] Rename newnode() no node()

cc1 already followed this convention, and it is a good idea
to have the same name convention between the different
programs of the toolchain (and of course node is shorter).

Diffstat:
Mcc2/cc2.h | 2+-
Mcc2/code.c | 4++--
Mcc2/node.c | 2+-
Mcc2/parser.c | 30+++++++++++++++---------------
Mcc2/target/qbe/cgen.c | 4++--
Mcc2/target/qbe/optm.c | 2+-
6 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/cc2/cc2.h b/cc2/cc2.h @@ -238,7 +238,7 @@ extern void cleannodes(void); extern void delnode(Node *np); extern void deltree(Node *np); extern void prtree(Node *np), prforest(char *msg); -extern Node *newnode(int op); +extern Node *node(int op); extern Node *addstmt(Node *np, int flags); extern Node *delstmt(void); extern Node *nextstmt(void); diff --git a/cc2/code.c b/cc2/code.c @@ -72,7 +72,7 @@ label2node(Node *np, Symbol *sym) if(!sym) sym = newlabel(); if (!np) - np = newnode(OLABEL); + np = node(OLABEL); np->op = OLABEL; np->u.sym = sym; @@ -83,7 +83,7 @@ Node * constnode(Node *np, TUINT n, Type *tp) { if (!np) - np = newnode(OCONST); + np = node(OCONST); np->op = OCONST; np->left = NULL; np->right = NULL; diff --git a/cc2/node.c b/cc2/node.c @@ -15,7 +15,7 @@ static Alloc *arena; Node * -newnode(int op) +node(int op) { struct arena *ap; Node *np; diff --git a/cc2/parser.c b/cc2/parser.c @@ -196,7 +196,7 @@ getname(char *t, union tokenop u) static void symbol(char *token, union tokenop u) { - Node *np = newnode(u.op & 0xFF); + Node *np = node(u.op & 0xFF); Symbol *sym = getsym(atoi(token+1)); sclass = u.op >> 8; @@ -228,13 +228,13 @@ constant(char *token, union tokenop u) ++token; if (*token == '"') { ++token; - np = newnode(OSTRING); + np = node(OSTRING); np->type.flags = STRF; np->type.size = strlen(token); np->type.align = int8type.align; np->u.s = xstrdup(token); } else { - np = newnode(OCONST); + np = node(OCONST); np->type = *gettype(token++); for (v = 0; c = *token++; v += c) { v <<= 4; @@ -249,7 +249,7 @@ static void assign(char *token, union tokenop u) { int subop; - Node *np = newnode(u.op); + Node *np = node(u.op); switch (subop = *++token) { case '+': @@ -282,7 +282,7 @@ assign(char *token, union tokenop u) static void ternary(char *token, union tokenop u) { - Node *ask = newnode(OASK), *colon = newnode(OCOLON); + Node *ask = node(OASK), *colon = node(OCOLON); Type *tp = gettype(token+1); colon->right = pop(); @@ -337,7 +337,7 @@ repeat: static void oreturn(char *token, union tokenop u) { - Node *np = newnode(u.op); + Node *np = node(u.op); if (token = strtok(NULL, "\t\n")) eval(token); @@ -384,7 +384,7 @@ static void bswitch(char *token, union tokenop u) { struct swtch *cur; - Node *np = newnode(u.op); + Node *np = node(u.op); if (swp == &swtbl[NR_BLOCK]) error(EWTACKO); @@ -420,7 +420,7 @@ ocase(char *token, union tokenop u) static void jump(char *token, union tokenop u) { - Node *aux, *np = newnode(u.op); + Node *aux, *np = node(u.op); eval(strtok(NULL, "\t\n")); @@ -435,13 +435,13 @@ jump(char *token, union tokenop u) static void loop(char *token, union tokenop u) { - push(newnode(u.op)); + push(node(u.op)); } static void unary(char *token, union tokenop u) { - Node *np = newnode(u.op); + Node *np = node(u.op); np->type = *gettype(token+1); np->left = pop(); @@ -452,7 +452,7 @@ unary(char *token, union tokenop u) static void call(char *token, union tokenop u) { - Node *np, *par, *fun = newnode(u.op); + Node *np, *par, *fun = node(u.op); for (par = NULL;; par = np) { np = pop(); @@ -470,7 +470,7 @@ call(char *token, union tokenop u) static void builtin(char *token, union tokenop u) { - Node *np = newnode(u.op); + Node *np = node(u.op); char *name; unsigned subop, nchilds; @@ -504,7 +504,7 @@ builtin(char *token, union tokenop u) static void binary(char *token, union tokenop u) { - Node *np = newnode(u.op); + Node *np = node(u.op); np->type = *gettype(token+1); np->right = pop(); @@ -697,14 +697,14 @@ beginfun(void) curfun = lastfun; inpars = 1; pushctx(); - addstmt(newnode(OBFUN), SETCUR); + addstmt(node(OBFUN), SETCUR); } static void endfun(void) { endf = 1; - addstmt(newnode(OEFUN), SETCUR); + addstmt(node(OEFUN), SETCUR); } void diff --git a/cc2/target/qbe/cgen.c b/cc2/target/qbe/cgen.c @@ -85,7 +85,7 @@ tmpnode(Node *np, Type *tp) Symbol *sym; if (!np) - np = newnode(OTMP); + np = node(OTMP); sym = getsym(TMPSYM); sym->type = np->type = *tp; flags = tp->flags & ~(PARF|INITF); @@ -222,7 +222,7 @@ call(Node *np, Node *fun, Node *ret) Node aux, **q, *p, *pars[NR_FUNPARAM]; for (n = 0, p = np->right; p; p = p->right) - pars[n++] = rhs(p->left, newnode(OTMP)); + pars[n++] = rhs(p->left, node(OTMP)); tp = &np->type; code(ASCALL, tmpnode(ret, tp), fun, NULL); diff --git a/cc2/target/qbe/optm.c b/cc2/target/qbe/optm.c @@ -26,7 +26,7 @@ optm_dep(Node *np) */ op = (np->prev) ? np->prev->op : 0; if (!op || op == ONOP || op == OBRANCH || (op != ORET && op != OJMP)) - addstmt(newnode(ORET), KEEPCUR); + addstmt(node(ORET), KEEPCUR); break; case OBRANCH: if (!next->label) {