diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ast.js | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -104,16 +104,11 @@ AST_Node.warn = function(txt, props) { AST_Node.warn_function(string_template(txt, props)); }; -var AST_Debugger = DEFNODE("Debugger", null, { - $documentation: "Represents a debugger statement" -}); +/* -----[ statements ]----- */ -var AST_Directive = DEFNODE("Directive", "value", { - $documentation: "Represents a directive, like \"use strict\";" +var AST_StatementBase = DEFNODE("StatementBase", null, { }); -/* -----[ loops ]----- */ - var AST_Statement = DEFNODE("Statement", "body", { $documentation: "Base class of all statements", _walk: function(visitor) { @@ -121,7 +116,15 @@ var AST_Statement = DEFNODE("Statement", "body", { this.body._walk(visitor); }); } -}); +}, AST_StatementBase); + +var AST_Debugger = DEFNODE("Debugger", null, { + $documentation: "Represents a debugger statement" +}, AST_StatementBase); + +var AST_Directive = DEFNODE("Directive", "value", { + $documentation: "Represents a directive, like \"use strict\";" +}, AST_StatementBase); var AST_SimpleStatement = DEFNODE("SimpleStatement", null, { $documentation: "A statement consisting of an expression, i.e. a = 1 + 2." @@ -141,7 +144,8 @@ var AST_BlockStatement = DEFNODE("BlockStatement", null, { function walk_body(node, visitor) { if (node.body instanceof Array) node.body.forEach(function(stat){ stat._walk(visitor); - }); else node.body._walk(visitor); + }); + else if (node.body instanceof AST_Statement) node.body._walk(visitor); }; var AST_Block = DEFNODE("Block", null, { |