diff cbackend.js @ 67:42d5660b30b4

added remainder operator
author William Morgan <bill@mrgn.org>
date Sat, 14 Jul 2012 13:31:05 -0700
parents 25b697c91629
children 3a169ebb3224
line wrap: on
line diff
--- a/cbackend.js	Sat Jul 14 12:30:25 2012 -0700
+++ b/cbackend.js	Sat Jul 14 13:31:05 2012 -0700
@@ -40,7 +40,7 @@
 }
 
 op.prototype.toC = function(isReceiver) {
-	var optoMeth = {'+': 'ADD_', '-': 'SUB_', '*': 'MUL_', '/': 'DIV_', '=': 'EQ_', '!=': 'NEQ_', '<': 'LT_', '>': 'GT_', '>=': 'GEQ_', '<=': 'LEQ_', '.': 'CAT_'};
+	var optoMeth = {'+': 'ADD_', '-': 'SUB_', '*': 'MUL_', '/': 'DIV_', '%': 'MOD_', '=': 'EQ_', '!=': 'NEQ_', '<': 'LT_', '>': 'GT_', '>=': 'GEQ_', '<=': 'LEQ_', '.': 'CAT_'};
 	var method = optoMeth[this.op];
 	return 'mcall(' + getMethodId(method) + '/* ' + method + ' */, 2, (object *)' + this.left.toC() + ', ' + this.right.toC() + ')\n';
 };
@@ -415,6 +415,7 @@
 	addBinaryOp(int32, 'SUB_', '-', 'obj_int32');
 	addBinaryOp(int32, 'MUL_', '*', 'obj_int32');
 	addBinaryOp(int32, 'DIV_', '/', 'obj_int32');
+	addBinaryOp(int32, 'MOD_', '%', 'obj_int32');
 	addCompOp(int32, 'LT_', '<', 'obj_int32');
 	addCompOp(int32, 'GT_', '>', 'obj_int32');
 	addCompOp(int32, 'EQ_', '==', 'obj_int32');