ref: a69ea8a24e8ea6fef1e8f26e290aad181837a330
parent: 4d521c0af7bf9278ff10e38434ddb61c80db8861
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Sep 14 10:53:39 EDT 2017
[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).
--- a/cc2/cc2.h
+++ b/cc2/cc2.h
@@ -238,7 +238,7 @@
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);
--- a/cc2/code.c
+++ b/cc2/code.c
@@ -72,7 +72,7 @@
if(!sym)
sym = newlabel();
if (!np)
- np = newnode(OLABEL);
+ np = node(OLABEL);
np->op = OLABEL;
np->u.sym = sym;
@@ -83,7 +83,7 @@
constnode(Node *np, TUINT n, Type *tp)
{
if (!np)
- np = newnode(OCONST);
+ np = node(OCONST);
np->op = OCONST;
np->left = NULL;
np->right = NULL;
--- a/cc2/node.c
+++ b/cc2/node.c
@@ -15,7 +15,7 @@
Node *
-newnode(int op)
+node(int op)
{
struct arena *ap;
Node *np;
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -196,7 +196,7 @@
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 @@
++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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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,7 +697,7 @@
curfun = lastfun;
inpars = 1;
pushctx();
- addstmt(newnode(OBFUN), SETCUR);
+ addstmt(node(OBFUN), SETCUR);
}
static void
@@ -704,7 +704,7 @@
endfun(void)
{
endf = 1;
- addstmt(newnode(OEFUN), SETCUR);
+ addstmt(node(OEFUN), SETCUR);
}
void
--- a/cc2/target/qbe/cgen.c
+++ b/cc2/target/qbe/cgen.c
@@ -85,7 +85,7 @@
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 @@
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);
--- a/cc2/target/qbe/optm.c
+++ b/cc2/target/qbe/optm.c
@@ -26,7 +26,7 @@
*/
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) {