diff --git a/lib/ast.js b/lib/ast.js index ffb9907f17c..70e36ed46fc 100644 --- a/lib/ast.js +++ b/lib/ast.js @@ -145,10 +145,9 @@ var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", { function walk_body(node, visitor) { if (node.body instanceof AST_Statement) { node.body._walk(visitor); + } else for (var i = 0, len = node.body.length; i < len; i++) { + node.body[i]._walk(visitor); } - else node.body.forEach(function(stat){ - stat._walk(visitor); - }); }; var AST_Block = DEFNODE("Block", "body", { @@ -302,12 +301,13 @@ var AST_Toplevel = DEFNODE("Toplevel", "globals", { var args = []; var parameters = []; - arg_parameter_pairs.forEach(function(pair) { + for (var i = 0, len = arg_parameter_pairs.length; i < len; i++) { + var pair = arg_parameter_pairs[i]; var splitAt = pair.lastIndexOf(":"); args.push(pair.substr(0, splitAt)); parameters.push(pair.substr(splitAt + 1)); - }); + } var wrapped_tl = "(function(" + parameters.join(",") + "){ '$ORIG'; })(" + args.join(",") + ")"; wrapped_tl = parse(wrapped_tl); @@ -339,7 +339,8 @@ var AST_Toplevel = DEFNODE("Toplevel", "globals", { return MAP.splice(self.body); case "$EXPORTS": var body = []; - to_export.forEach(function(sym){ + for (var i = 0, len = to_export.length; i < len; i++) { + var sym = to_export[i]; body.push(new AST_SimpleStatement({ body: new AST_Assign({ left: new AST_Sub({ @@ -350,7 +351,7 @@ var AST_Toplevel = DEFNODE("Toplevel", "globals", { right: new AST_SymbolRef(sym), }), })); - }); + } return MAP.splice(body); } } @@ -369,9 +370,9 @@ var AST_Lambda = DEFNODE("Lambda", "name argnames uses_arguments", { _walk: function(visitor) { return visitor._visit(this, function(){ if (this.name) this.name._walk(visitor); - this.argnames.forEach(function(arg){ - arg._walk(visitor); - }); + for (var i = 0, len = this.argnames.length; i < len; i++) { + this.argnames[i]._walk(visitor); + } walk_body(this, visitor); }); } @@ -531,9 +532,9 @@ var AST_Definitions = DEFNODE("Definitions", "definitions", { }, _walk: function(visitor) { return visitor._visit(this, function(){ - this.definitions.forEach(function(def){ - def._walk(visitor); - }); + for (var i = 0, len = this.definitions.length; i < len; i++) { + this.definitions[i]._walk(visitor); + } }); } }, AST_Statement); @@ -571,9 +572,9 @@ var AST_Call = DEFNODE("Call", "expression args", { _walk: function(visitor) { return visitor._visit(this, function(){ this.expression._walk(visitor); - this.args.forEach(function(arg){ - arg._walk(visitor); - }); + for (var i = 0, len = this.args.length; i < len; i++) { + this.args[i]._walk(visitor); + } }); } }); @@ -596,9 +597,9 @@ var AST_Sequence = DEFNODE("Sequence", "expressions", { }, _walk: function(visitor) { return visitor._visit(this, function(){ - this.expressions.forEach(function(expression) { - expression._walk(visitor); - }); + for (var i = 0, len = this.expressions.length; i < len; i++) { + this.expressions[i]._walk(visitor); + } }); } }); @@ -695,9 +696,9 @@ var AST_Array = DEFNODE("Array", "elements", { }, _walk: function(visitor) { return visitor._visit(this, function(){ - this.elements.forEach(function(el){ - el._walk(visitor); - }); + for (var i = 0, len = this.elements.length; i < len; i++) { + this.elements[i]._walk(visitor); + } }); } }); @@ -709,9 +710,9 @@ var AST_Object = DEFNODE("Object", "properties", { }, _walk: function(visitor) { return visitor._visit(this, function(){ - this.properties.forEach(function(prop){ - prop._walk(visitor); - }); + for (var i = 0, len = this.properties.length; i < len; i++) { + this.properties[i]._walk(visitor); + } }); } });