aboutsummaryrefslogtreecommitdiff
path: root/lib/ast.js
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2013-09-02 19:36:16 +0300
committerMihai Bazon <mihai@bazon.net>2013-09-02 19:36:16 +0300
commit85b527ba3d609e87b5b5f758b429ef371dc3e459 (patch)
tree0a8e08c1645289e6ddda7e4ad48befc6c89c99f9 /lib/ast.js
parent1c6efdae34f308a8cd22c41f48adf96dd428f4ee (diff)
downloadtracifyjs-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.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/ast.js b/lib/ast.js
index b8e89f23..e51cdd02 100644
--- a/lib/ast.js
+++ b/lib/ast.js
@@ -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);