diff options
Diffstat (limited to 'lib/ast.js')
-rw-r--r-- | lib/ast.js | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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); |