shithub: scc

Download patch

ref: fc93bb35a8cebade80d9f0b920bb93b2b78aa81d
parent: f2c0749ff6ad1041feb2cdb8ac164fd37b6f2e8c
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Feb 10 13:05:06 EST 2015

Rename emit() to code()

The idea in some moment is to store the code in an array,
so code is a better name for this function, because we
don't want to emit code, we want to create code in our
vector of code.

--- a/cc2/cc2.h
+++ b/cc2/cc2.h
@@ -115,4 +115,4 @@
 extern void genstack(Symbol *fun);
 extern void apply(Node *list[], void (*fun)(Node *));
 extern Symbol *parse(void);
-extern void emit(char op, ...);
+extern void code(char op, ...);
--- a/cc2/cgen.c
+++ b/cc2/cgen.c
@@ -74,11 +74,11 @@
 		sym = np->u.sym;
 		switch (tp->size) {
 		case 1:
-			emit(LDFX, reg, IX, sym->u.v.off);
+			code(LDFX, reg, IX, sym->u.v.off);
 			break;
 		case 2:
-			emit(LDFX, lower[reg], IX, sym->u.v.off);
-			emit(LDFX, upper[reg], IX, sym->u.v.off+1);
+			code(LDFX, lower[reg], IX, sym->u.v.off);
+			code(LDFX, upper[reg], IX, sym->u.v.off+1);
 			break;
 		case 4:
 		case 8:
@@ -146,10 +146,10 @@
 				rp = np->right;
 			} else if (lp->u.reg != A) {
 				/* TODO: Move A to variable */
-				emit(PUSH, AF);
-				emit(LD, A, lp->u.reg);
+				code(PUSH, AF);
+				code(LD, A, lp->u.reg);
 			}
-			emit(ADD, A, rp->u.reg);
+			code(ADD, A, rp->u.reg);
 			break;
 		case 2:
 			if (rp->u.reg == HL || rp->u.reg == IY) {
@@ -158,11 +158,11 @@
 				rp = np->right;
 			} else if (lp->u.reg != HL && lp->u.reg != IY) {
 				/* TODO: Move HL to variable */
-				emit(PUSH, HL);
-				emit(LD, H, upper[lp->u.reg]);
-				emit(LD, L, lower[lp->u.reg]);
+				code(PUSH, HL);
+				code(LD, H, upper[lp->u.reg]);
+				code(LD, L, lower[lp->u.reg]);
 			}
-			emit(ADD, lp->u.reg, rp->u.reg);
+			code(ADD, lp->u.reg, rp->u.reg);
 			break;
 		case 4:
 		case 8:
@@ -180,21 +180,21 @@
 	extern char odebug;
 	char frame = fun->u.f.locals != 0 || odebug;
 
-	emit(ADDR, fun->name);
+	code(ADDR, fun->name);
 	if (frame) {
-		emit(PUSH, IX);
-		emit(LD, IX, SP);
-		emit(LDI, HL, -fun->u.f.locals);
-		emit(ADD, HL, SP);
-		emit(LD, SP, HL);
+		code(PUSH, IX);
+		code(LD, IX, SP);
+		code(LDI, HL, -fun->u.f.locals);
+		code(ADD, HL, SP);
+		code(LD, SP, HL);
 	}
 
 	apply(fun->u.f.body, cgen);
 
 	if (frame) {
-		emit(LD, SP, IX);
-		emit(POP, IX);
-		emit(RET);
+		code(LD, SP, IX);
+		code(POP, IX);
+		code(RET);
 	}
 }
 
--- a/cc2/code.c
+++ b/cc2/code.c
@@ -23,7 +23,7 @@
 };
 
 void
-emit(char op, ...)
+code(char op, ...)
 {
 	va_list va;
 	uint8_t reg1, reg2;