diff options
author | Mihai Bazon <mihai@bazon.net> | 2012-08-28 15:29:58 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2012-08-28 15:29:58 +0300 |
commit | 7fcb6bcb1270d1688512e25704125edb5b35b3c5 (patch) | |
tree | 6c0b5b40cd2731d8f6f15eae6f816571ef05adcd /lib/ast.js | |
parent | ce8e8d57c0d346dba9527b7a11b03364ce9ad1bb (diff) | |
download | tracifyjs-7fcb6bcb1270d1688512e25704125edb5b35b3c5.tar.gz tracifyjs-7fcb6bcb1270d1688512e25704125edb5b35b3c5.zip |
fix code generator for this case:
if (foo) {
with (bar)
if (baz)
x();
} else y();
(the compressor removes the brackets since the consequent consists of a
single statement, but the codegen must include the brackets because
otherwise the `else` would refer to the inner `if`)
Diffstat (limited to 'lib/ast.js')
-rw-r--r-- | lib/ast.js | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -149,6 +149,9 @@ var AST_EmptyStatement = DEFNODE("EmptyStatement", null, { } }, AST_Statement); +var AST_StatementWithBody = DEFNODE("StatementWithBody", null, { +}, AST_Statement); + var AST_DWLoop = DEFNODE("DWLoop", "condition", { $documentation: "Base class for do/while statements.", _walk: function(visitor) { @@ -157,7 +160,7 @@ var AST_DWLoop = DEFNODE("DWLoop", "condition", { this.body._walk(visitor); }); } -}, AST_Statement); +}, AST_StatementWithBody); var AST_Do = DEFNODE("Do", null, { $documentation: "A `do` statement" @@ -177,7 +180,7 @@ var AST_For = DEFNODE("For", "init condition step", { this.body._walk(visitor); }); } -}, AST_Statement); +}, AST_StatementWithBody); var AST_ForIn = DEFNODE("ForIn", "init name object", { $documentation: "A `for ... in` statement", @@ -188,7 +191,7 @@ var AST_ForIn = DEFNODE("ForIn", "init name object", { this.body._walk(visitor); }); } -}, AST_Statement); +}, AST_StatementWithBody); var AST_With = DEFNODE("With", "expression", { $documentation: "A `with` statement", @@ -198,7 +201,7 @@ var AST_With = DEFNODE("With", "expression", { this.body._walk(visitor); }); } -}, AST_Statement); +}, AST_StatementWithBody); /* -----[ scope and functions ]----- */ |