shithub: scc

Download patch

ref: e22a6ae23cdf560dffb4df84e01c57de1224cdb6
parent: e5501c13c9f2706fe5f5dafc23b0706a3cd1fc14
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Mar 20 07:33:23 EDT 2015

Remove non needed field in opnodes elements

This op parameter is only a field of first parameter np,
so it is a bit stupid pass it again.

--- a/cc2/cgen.c
+++ b/cc2/cgen.c
@@ -260,7 +260,7 @@
 }
 
 static void
-add(Node *np, uint8_t op)
+add(Node *np)
 {
 	Node *lp = np->left, *rp = np->right;
 	uint8_t i;
@@ -321,7 +321,7 @@
 			abort();
 		}
 	add_A:
-		code((op == OADD) ? ADD : SUB, lp, rp);
+		code((np->op == OADD) ? ADD : SUB, lp, rp);
 		np->op = REG;
 		np->reg = A;
 		break;
@@ -333,7 +333,7 @@
 }
 
 static void
-assign(Node *np, uint8_t op)
+assign(Node *np)
 {
 	Node *lp = np->left, *rp = np->right;
 	Symbol *sym = lp->sym;
@@ -368,7 +368,7 @@
 	np->reg = rp->reg;
 }
 
-static void (*opnodes[])(Node *, uint8_t) = {
+static void (*opnodes[])(Node *) = {
 	[OADD] = add,
 	[OSUB] = add,
 	[OASSIG] = assign
@@ -378,7 +378,6 @@
 cgen(Node *np, Node *parent)
 {
 	Node *lp, *rp;
-	uint8_t op;
 
 	if (!np)
 		return;
@@ -401,8 +400,7 @@
 		cgen(p, np);
 		cgen(q, np);
 	}
-	op = np->op;
-	(*opnodes[op])(np, op);
+	(*opnodes[np->op])(np);
 }
 
 static Node *