Mercurial > repos > tabletprog
diff 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 |
line wrap: on
line diff
--- a/compiler.js Thu Jul 26 18:54:42 2012 -0700 +++ b/compiler.js Thu Jul 26 23:40:56 2012 -0700 @@ -296,6 +296,12 @@ op.prototype.populateSymbols = function(symbols, isReceiver) { this.left.populateSymbols(symbols); + if (this.op == '&&' || this.op == '||') { + //&& and || are syntactic sugar for if and ifnot with + //the second argument transformed into a lambda to + //achieve short-circuit evalutation + this.right = new lambda([], [this.right]); + } this.right.populateSymbols(symbols); };