diff options
author | Mihai Bazon <mihai@bazon.net> | 2013-09-02 19:36:16 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2013-09-02 19:36:16 +0300 |
commit | 85b527ba3d609e87b5b5f758b429ef371dc3e459 (patch) | |
tree | 0a8e08c1645289e6ddda7e4ad48befc6c89c99f9 /lib/ast.js | |
parent | 1c6efdae34f308a8cd22c41f48adf96dd428f4ee (diff) | |
download | tracifyjs-85b527ba3d609e87b5b5f758b429ef371dc3e459.tar.gz tracifyjs-85b527ba3d609e87b5b5f758b429ef371dc3e459.zip |
Disallow `continue` referring to a non-IterationStatement. Fix #287
Simplifies handling of labels (their definition/references can be easily
figured out at parse time, no need to do it in `figure_out_scope`).
Diffstat (limited to 'lib/ast.js')
-rw-r--r-- | lib/ast.js | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -197,6 +197,10 @@ var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", { } }, AST_StatementWithBody); +var AST_IterationStatement = DEFNODE("Loop", null, { + $documentation: "Internal class. All loops inherit from it." +}, AST_StatementWithBody); + var AST_DWLoop = DEFNODE("DWLoop", "condition", { $documentation: "Base class for do/while statements", $propdoc: { @@ -208,7 +212,7 @@ var AST_DWLoop = DEFNODE("DWLoop", "condition", { this.body._walk(visitor); }); } -}, AST_StatementWithBody); +}, AST_IterationStatement); var AST_Do = DEFNODE("Do", null, { $documentation: "A `do` statement", @@ -233,7 +237,7 @@ var AST_For = DEFNODE("For", "init condition step", { this.body._walk(visitor); }); } -}, AST_StatementWithBody); +}, AST_IterationStatement); var AST_ForIn = DEFNODE("ForIn", "init name object", { $documentation: "A `for ... in` statement", @@ -249,7 +253,7 @@ var AST_ForIn = DEFNODE("ForIn", "init name object", { this.body._walk(visitor); }); } -}, AST_StatementWithBody); +}, AST_IterationStatement); var AST_With = DEFNODE("With", "expression", { $documentation: "A `with` statement", @@ -821,7 +825,11 @@ var AST_SymbolCatch = DEFNODE("SymbolCatch", null, { var AST_Label = DEFNODE("Label", "references", { $documentation: "Symbol naming a label (declaration)", $propdoc: { - references: "[AST_LabelRef*] a list of nodes referring to this label" + references: "[AST_LoopControl*] a list of nodes referring to this label" + }, + initialize: function() { + this.references = []; + this.thedef = this; } }, AST_Symbol); |