scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 170fd78d99f38db3e0548cd87a5ed382ca620c28
parent 96d3397e927cf497d7d25116dbd25dc965f80ac8
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 30 Dec 2024 10:18:51 +0100

cc2: Remove mode parameter of addstmt()

This parameter was needed only to keep running over the normal
list when new nodes were added. As we use the node returned
by the visitor function we don't care anymore about the changes
made inside the visitor function and then we can remove this
parameter.

Diffstat:
Msrc/cmd/scc-cc/cc2/cc2.h | 4+---
Msrc/cmd/scc-cc/cc2/node.c | 6++----
Msrc/cmd/scc-cc/cc2/parser.c | 8++++----
Msrc/cmd/scc-cc/cc2/qbe/cgen.c | 2+-
4 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/cmd/scc-cc/cc2/cc2.h b/src/cmd/scc-cc/cc2/cc2.h @@ -256,8 +256,6 @@ extern void pprint(char *s); extern void deftype(Type *); /* node.c */ -#define SETCUR 1 -#define KEEPCUR 0 extern void newfun(Symbol *, Node *); extern void apply(Node *(*fun)(Node *)); extern void cleannodes(void); @@ -265,7 +263,7 @@ extern void delnode(Node *np); extern void deltree(Node *np); extern void prtree(Node *np), prforest(char *msg); extern Node *node(int op); -extern Node *addstmt(Node *np, int flags); +extern Node *addstmt(Node *); extern Node *delstmt(void); extern Node *insstmt(Node *, Node *); extern void delrange(Node *, Node *); diff --git a/src/cmd/scc-cc/cc2/node.c b/src/cmd/scc-cc/cc2/node.c @@ -116,12 +116,10 @@ waftstmt(Node *at) } Node * -addstmt(Node *np, int mode) +addstmt(Node *np) { insstmt(np, curstmt); - if (mode == SETCUR) - curstmt = np; - return np; + return curstmt = np; } Node * diff --git a/src/cmd/scc-cc/cc2/parser.c b/src/cmd/scc-cc/cc2/parser.c @@ -353,7 +353,7 @@ waft(Node *np) error(EWTACKU); cur = swp - 1; - addstmt(np, SETCUR); + addstmt(np); waftstmt(cur->last); cur->last = np; cur->nr++; @@ -660,7 +660,7 @@ labeldcl(void) sym->kind = SLABEL; sym->u.stmt = np; np->label = sym; - addstmt(np, SETCUR); + addstmt(np); } static void @@ -676,7 +676,7 @@ stmt(void) deltree(np); return; } - addstmt(np, SETCUR); + addstmt(np); } static void @@ -691,7 +691,7 @@ static void endfun(void) { endf = 1; - laststmt = addstmt(node(OEFUN), SETCUR); + laststmt = addstmt(node(OEFUN)); } void diff --git a/src/cmd/scc-cc/cc2/qbe/cgen.c b/src/cmd/scc-cc/cc2/qbe/cgen.c @@ -808,7 +808,7 @@ norm(Node *np) */ op = (np->prev) ? np->prev->op : 0; if (!op || op == ONOP || op == OBRANCH || (op != ORET && op != OJMP)) - addstmt(node(ORET), KEEPCUR); + addstmt(node(ORET)); break; case OBRANCH: if (!next->label) {