comparison 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
comparison
equal deleted inserted replaced
66:25b697c91629 67:42d5660b30b4
38 } 38 }
39 return obj; 39 return obj;
40 } 40 }
41 41
42 op.prototype.toC = function(isReceiver) { 42 op.prototype.toC = function(isReceiver) {
43 var optoMeth = {'+': 'ADD_', '-': 'SUB_', '*': 'MUL_', '/': 'DIV_', '=': 'EQ_', '!=': 'NEQ_', '<': 'LT_', '>': 'GT_', '>=': 'GEQ_', '<=': 'LEQ_', '.': 'CAT_'}; 43 var optoMeth = {'+': 'ADD_', '-': 'SUB_', '*': 'MUL_', '/': 'DIV_', '%': 'MOD_', '=': 'EQ_', '!=': 'NEQ_', '<': 'LT_', '>': 'GT_', '>=': 'GEQ_', '<=': 'LEQ_', '.': 'CAT_'};
44 var method = optoMeth[this.op]; 44 var method = optoMeth[this.op];
45 return 'mcall(' + getMethodId(method) + '/* ' + method + ' */, 2, (object *)' + this.left.toC() + ', ' + this.right.toC() + ')\n'; 45 return 'mcall(' + getMethodId(method) + '/* ' + method + ' */, 2, (object *)' + this.left.toC() + ', ' + this.right.toC() + ')\n';
46 }; 46 };
47 47
48 function escapeCName(name) 48 function escapeCName(name)
413 int32.addProperty('num', null, 'int32_t'); 413 int32.addProperty('num', null, 'int32_t');
414 addBinaryOp(int32, 'ADD_', '+', 'obj_int32'); 414 addBinaryOp(int32, 'ADD_', '+', 'obj_int32');
415 addBinaryOp(int32, 'SUB_', '-', 'obj_int32'); 415 addBinaryOp(int32, 'SUB_', '-', 'obj_int32');
416 addBinaryOp(int32, 'MUL_', '*', 'obj_int32'); 416 addBinaryOp(int32, 'MUL_', '*', 'obj_int32');
417 addBinaryOp(int32, 'DIV_', '/', 'obj_int32'); 417 addBinaryOp(int32, 'DIV_', '/', 'obj_int32');
418 addBinaryOp(int32, 'MOD_', '%', 'obj_int32');
418 addCompOp(int32, 'LT_', '<', 'obj_int32'); 419 addCompOp(int32, 'LT_', '<', 'obj_int32');
419 addCompOp(int32, 'GT_', '>', 'obj_int32'); 420 addCompOp(int32, 'GT_', '>', 'obj_int32');
420 addCompOp(int32, 'EQ_', '==', 'obj_int32'); 421 addCompOp(int32, 'EQ_', '==', 'obj_int32');
421 addCompOp(int32, 'NEQ_', '!=', 'obj_int32'); 422 addCompOp(int32, 'NEQ_', '!=', 'obj_int32');
422 addCompOp(int32, 'GEQ_', '>=', 'obj_int32'); 423 addCompOp(int32, 'GEQ_', '>=', 'obj_int32');