comparison compiler.js @ 97:59a94f3ad56f

Added short-circuit && and || operators
author Mike Pavone <pavone@retrodev.com>
date Thu, 26 Jul 2012 23:40:56 -0700
parents 84b65ee8b78b
children b58b19c455ec
comparison
equal deleted inserted replaced
96:84b65ee8b78b 97:59a94f3ad56f
294 throw new Error("can't make val into object"); 294 throw new Error("can't make val into object");
295 } 295 }
296 296
297 op.prototype.populateSymbols = function(symbols, isReceiver) { 297 op.prototype.populateSymbols = function(symbols, isReceiver) {
298 this.left.populateSymbols(symbols); 298 this.left.populateSymbols(symbols);
299 if (this.op == '&&' || this.op == '||') {
300 //&& and || are syntactic sugar for if and ifnot with
301 //the second argument transformed into a lambda to
302 //achieve short-circuit evalutation
303 this.right = new lambda([], [this.right]);
304 }
299 this.right.populateSymbols(symbols); 305 this.right.populateSymbols(symbols);
300 }; 306 };
301 307
302 symbol.prototype.populateSymbols = function(symbols) { 308 symbol.prototype.populateSymbols = function(symbols) {
303 this.symbols = symbols; 309 this.symbols = symbols;