aboutsummaryrefslogtreecommitdiff
path: root/lib/ast.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ast.js')
-rw-r--r--lib/ast.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/ast.js b/lib/ast.js
index 6e05a396..19d9fbcd 100644
--- a/lib/ast.js
+++ b/lib/ast.js
@@ -86,7 +86,7 @@ function DEFNODE(type, props, methods, base) {
return ctor;
};
-var AST_Token = DEFNODE("Token", "type value line col pos endpos nlb comments_before", {
+var AST_Token = DEFNODE("Token", "type value line col pos endpos nlb comments_before file", {
}, null);
var AST_Node = DEFNODE("Node", "start end", {
@@ -146,10 +146,12 @@ var AST_BlockStatement = DEFNODE("BlockStatement", null, {
}, AST_Statement);
function walk_body(node, visitor) {
- if (node.body instanceof Array) node.body.forEach(function(stat){
+ if (node.body instanceof AST_Statement) {
+ node.body._walk(visitor);
+ }
+ else node.body.forEach(function(stat){
stat._walk(visitor);
});
- else if (node.body instanceof AST_Statement) node.body._walk(visitor);
};
var AST_Block = DEFNODE("Block", null, {
@@ -239,7 +241,7 @@ var AST_Scope = DEFNODE("Scope", "directives variables functions uses_with uses_
$documentation: "Base class for all statements introducing a lexical scope",
}, AST_Block);
-var AST_Toplevel = DEFNODE("Toplevel", null, {
+var AST_Toplevel = DEFNODE("Toplevel", "globals", {
$documentation: "The toplevel scope"
}, AST_Scope);