comparison jsbackend.js @ 110:d715fb3c39ab

Implemented clicking on symbols inside inscope box to replace function name in funcall.
author Mike Pavone <pavone@retrodev.com>
date Sat, 13 Apr 2013 23:37:54 -0700
parents 648659961e0e
children a83989115028
comparison
equal deleted inserted replaced
109:a647cdad620b 110:d715fb3c39ab
32 } 32 }
33 return obj; 33 return obj;
34 } 34 }
35 35
36 op.prototype.toJS = function(isReceiver) { 36 op.prototype.toJS = function(isReceiver) {
37 var opmap = {'=': '==', '.': '+'}; 37 if (this.op == '&&') {
38 var ret = '(' + this.left.toJS() +' '+ (this.op in opmap ? opmap[this.op] : this.op) +' '+ this.right.toJS() + ')'; 38 var ret = 'toobj(' + this.left.toJS() + ').sif(' + this.right.toJS() + ')';
39 } else if(this.op == '||') {
40 var ret = 'toobj(' + this.left.toJS() + ').ifnot(' + this.right.toJS() + ')';
41 } else {
42 var opmap = {'=': '==', '.': '+'};
43 var ret = '(' + this.left.toJS() +' '+ (this.op in opmap ? opmap[this.op] : this.op) +' '+ this.right.toJS() + ')';
44 }
39 return ret; 45 return ret;
40 }; 46 };
41 47
42 function escapeJSName(name) 48 function escapeJSName(name)
43 { 49 {
313 { 319 {
314 return processUsedToplevelJS(toplevel) + 'main_module = ' + mainmodule.toJSModule() + '\n' + 320 return processUsedToplevelJS(toplevel) + 'main_module = ' + mainmodule.toJSModule() + '\n' +
315 'Number.prototype.__defineGetter__("string", function() { return "" + this; });\n' + 321 'Number.prototype.__defineGetter__("string", function() { return "" + this; });\n' +
316 'String.prototype.__defineGetter__("string", function() { return this; });\n' + 322 'String.prototype.__defineGetter__("string", function() { return this; });\n' +
317 'String.prototype.__defineGetter__("print", function() { write(this); });\n' + 323 'String.prototype.__defineGetter__("print", function() { write(this); });\n' +
318 'Array.prototype = function(action) { var ret = module_false; for (var i = 0; i < this.length; i++) { ret = action(i, this[i]) }; return ret; };\n' + 324 'Object.defineProperty(Array.prototype, "foreach", {value: function(action) { var ret = module_false; for (var i = 0; i < this.length; i++) { ret = action(i, this[i]) }; return ret; }});\n' +
319 'Function.prototype.whileCN_do = function(action) { var ret = module_false; while(toobj(this()) == module_true) { ret = action(); } return ret; };\n' + 325 'Function.prototype.whileCN_do = function(action) { var ret = module_false; while(toobj(this()) == module_true) { ret = action(); } return ret; };\n' +
326 'module_true.valueOf = function() { return true; }\n' +
327 'module_false.valueOf = function() { return false; }\n' +
320 'function toobj(val) {\n' + 328 'function toobj(val) {\n' +
321 ' return (typeof val == "boolean") ? (val ? module_true : module_false) : val;\n' + 329 ' return (typeof val == "boolean") ? (val ? module_true : module_false) : val;\n' +
322 '}\n' + 330 '}\n' +
323 'var m = main_module.main;\n' + 331 'var m = main_module.main;\n' +
324 'if (m instanceof Function) {\n' + 332 'if (m instanceof Function) {\n' +