aboutsummaryrefslogtreecommitdiff
path: root/lib/ast.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ast.js')
-rw-r--r--lib/ast.js34
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/ast.js b/lib/ast.js
index c170b629..ac5010bb 100644
--- a/lib/ast.js
+++ b/lib/ast.js
@@ -44,6 +44,11 @@ var AST_Node = DEFNODE("Node", "start end", {
}
}, null);
+AST_Node.warn_function = noop;
+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"
});
@@ -121,6 +126,7 @@ var AST_For = DEFNODE("For", "init condition step", {
if (this.init) this.init._walk(visitor);
if (this.condition) this.condition._walk(visitor);
if (this.step) this.step._walk(visitor);
+ this.body._walk(visitor);
});
}
}, AST_Statement);
@@ -132,6 +138,7 @@ var AST_ForIn = DEFNODE("ForIn", "init name object", {
if (this.init) this.init._walk(visitor);
if (this.name) this.name._walk(visitor);
if (this.object) this.object._walk(visitor);
+ this.body._walk(visitor);
});
}
}, AST_Statement);
@@ -151,12 +158,15 @@ var AST_With = DEFNODE("With", "expression", {
var AST_Scope = DEFNODE("Scope", null, {
$documentation: "Base class for all statements introducing a lexical scope",
initialize: function() {
- this.labels = {};
- this.variables = {};
- this.functions = {};
- this.uses_with = false;
- this.uses_eval = false;
- this.parent_scope = null;
+ this.labels = {}; // map name to AST_Label (labels defined in this scope)
+ this.variables = {}; // map name to AST_SymbolVar (variables defined in this scope; includes functions)
+ this.functions = {}; // map name to AST_SymbolDefun (functions defined in this scope)
+ this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
+ this.uses_eval = false; // will be set to true if this or nested scope uses the global `eval`
+ this.parent_scope = null; // the parent scope
+ this.enclosed = []; // a list of variables this or from outer scope(s) that are accessed from this or inner scopes
+ this.cname = -1; // the current index for mangling functions/variables
+ this.lname = -1; // the current index for mangling labels
}
}, AST_BlockStatement);
@@ -496,17 +506,7 @@ var AST_Label = DEFNODE("Label", null, {
}, AST_SymbolDeclaration);
var AST_SymbolRef = DEFNODE("SymbolRef", "symbol", {
- $documentation: "Reference to some symbol (not definition/declaration)",
- reference: function(symbol) {
- if (symbol) {
- this.symbol = symbol;
- symbol.references.push(this);
- this.global = symbol.scope.parent_scope == null;
- } else {
- this.undeclared = true;
- this.global = true;
- }
- }
+ $documentation: "Reference to some symbol (not definition/declaration)"
}, AST_Symbol);
var AST_LabelRef = DEFNODE("LabelRef", null, {