Updating Vars to allow scoped anonymous functions

This commit is contained in:
Bryce Watson 2015-12-21 18:55:28 -08:00
parent 90fb80b71f
commit 9d5a7429c5
3 changed files with 18 additions and 2 deletions

View File

@ -15,6 +15,14 @@ class Vars extends Node {
var declarations = this.declarations;
var kind = this.kind;
var isStatement = this.statement;
var body = this.body;
var selfInvoking = this.isFlagSet('selfInvoking');
var hasBody = (body && body.array && body.array.length > 0);
if(!selfInvoking && hasBody) {
this.setFlag('selfInvoking');
return generator.builder.selfInvokingFunction([ this ]);
}
if (declarations && !Array.isArray(declarations) && typeof declarations === 'object') {
// Convert the object into an array of variables
@ -77,6 +85,9 @@ class Vars extends Node {
}
}
}
if(hasBody) {
generator.generateCode(body);
}
}
}

View File

@ -1 +1 @@
FRANK 3650
FRANK 36501711

View File

@ -1,3 +1,8 @@
<var name='Frank' age=10/>
${name.toUpperCase()} ${age*365}
${name.toUpperCase()} ${age*365}
<var x=1 y=7 z=x+10 unusedVar>
${x}
${y}
${z}
</var>