diff cbackend.js @ 265:d6a4c9e7716e

Remove remapping of most operators
author Michael Pavone <pavone@retrodev.com>
date Mon, 14 Jul 2014 19:03:46 -0700
parents 2557ce4e671f
children 75dc7161c1ca
line wrap: on
line diff
--- a/cbackend.js	Mon Jul 14 09:33:41 2014 -0700
+++ b/cbackend.js	Mon Jul 14 19:03:46 2014 -0700
@@ -15,9 +15,7 @@
 
 function getOpMethodName(opname)
 {
-	var optoMeth = {'+': 'ADD_', '-': 'SUB_', '*': 'MUL_', '/': 'DIV_', '%': 'MOD_',
-	                '=': 'EQ_', '!=': 'NEQ_', '<': 'LT_', '>': 'GT_', '>=': 'GEQ_', '<=': 'LEQ_',
-					'.': 'CAT_', '&&':'if', '||':'ifnot', '|': 'CONS_'};
+	var optoMeth = {'&&':'if', '||':'ifnot'};
 	if (opname in optoMeth) {
 		return optoMeth[opname];
 	} else {
@@ -611,7 +609,13 @@
 			} else if(messages[i].name == 'llProperty:withType:' && messages[i].args.length == 2) {
 				me.addProperty(messages[i].args[0].name, null, messages[i].args[1].toCTypeName());
 			} else if(messages[i].name == 'llMessage:withVars:andCode:' && messages[i].args.length == 3) {
-				var msgname = messages[i].args[0].name
+				if (messages[i].args[0] instanceof symbol) {
+					var msgname = messages[i].args[0].name;
+				} else if (messages[i].args[0] instanceof strlit) {
+					var msgname = messages[i].args[0].val;
+				} else {
+					throw new Error('First argument to llMessage:withVars:andCode must be a symbol or string');
+				}
 				var rawvars = messages[i].args[1].expressions;
 				var vars = {};
 				for(var v in rawvars) {
@@ -674,22 +678,22 @@
 	var typename = 'obj_' + (unsigned ? 'u' : '') + 'int' + bits;
 	var intObj = new cObject(typename);
 	intObj.addProperty('num', null, (unsigned ? 'u' : '') + 'int' + bits +'_t');
-	addBinaryOp(intObj, 'ADD_', '+', typename);
-	addBinaryOp(intObj, 'SUB_', '-', typename);
-	addBinaryOp(intObj, 'MUL_', '*', typename);
-	addBinaryOp(intObj, 'DIV_', '/', typename);
-	addBinaryOp(intObj, 'MOD_', '%', typename);
+	addBinaryOp(intObj, '+', '+', typename);
+	addBinaryOp(intObj, '-', '-', typename);
+	addBinaryOp(intObj, '*', '*', typename);
+	addBinaryOp(intObj, '/', '/', typename);
+	addBinaryOp(intObj, '%', '%', typename);
 	addBinaryOp(intObj, 'or', '|', typename);
 	addBinaryOp(intObj, 'xor', '^', typename);
 	addBinaryOp(intObj, 'and', '&', typename);
 	addBinaryOp(intObj, 'lshift:by', '<<', typename);
 	addBinaryOp(intObj, 'rshift:by', '>>', typename);
-	addCompOp(intObj, 'LT_', '<', typename);
-	addCompOp(intObj, 'GT_', '>', typename);
-	addCompOp(intObj, 'EQ_', '==', typename);
-	addCompOp(intObj, 'NEQ_', '!=', typename);
-	addCompOp(intObj, 'GEQ_', '>=', typename);
-	addCompOp(intObj, 'LEQ_', '<=', typename);
+	addCompOp(intObj, '<', '<', typename);
+	addCompOp(intObj, '>', '>', typename);
+	addCompOp(intObj, '=', '==', typename);
+	addCompOp(intObj, '!=', '!=', typename);
+	addCompOp(intObj, '>=', '>=', typename);
+	addCompOp(intObj, '<=', '<=', typename);
 	intObj.addInclude('<string.h>');
 	//-9223372036854775808
 	//01234567890123456789