some reorganization
(moved pretty much everything that relates to scope in scope.js, added a module for NodeJS that can be used with require() and exports everything.)
This commit is contained in:
20
lib/ast.js
20
lib/ast.js
@@ -156,16 +156,7 @@ var AST_With = DEFNODE("With", "expression", {
|
||||
/* -----[ scope and functions ]----- */
|
||||
|
||||
var AST_Scope = DEFNODE("Scope", null, {
|
||||
$documentation: "Base class for all statements introducing a lexical scope",
|
||||
initialize: function() {
|
||||
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 from this or outer scope(s) that are referenced from this or inner scopes
|
||||
this.cname = -1; // the current index for mangling functions/variables
|
||||
}
|
||||
$documentation: "Base class for all statements introducing a lexical scope"
|
||||
}, AST_BlockStatement);
|
||||
|
||||
var AST_Toplevel = DEFNODE("Toplevel", null, {
|
||||
@@ -174,10 +165,6 @@ var AST_Toplevel = DEFNODE("Toplevel", null, {
|
||||
|
||||
var AST_Lambda = DEFNODE("Lambda", "name argnames", {
|
||||
$documentation: "Base class for functions",
|
||||
initialize: function() {
|
||||
AST_Scope.prototype.initialize.call(this);
|
||||
this.uses_arguments = false;
|
||||
},
|
||||
_walk: function(visitor) {
|
||||
return visitor._visit(this, function(){
|
||||
if (this.name) this.name._walk(visitor);
|
||||
@@ -479,10 +466,7 @@ var AST_ObjectGetter = DEFNODE("ObjectGetter", null, {
|
||||
var AST_Symbol = DEFNODE("Symbol", "scope name", {
|
||||
});
|
||||
|
||||
var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "references", {
|
||||
initialize: function() {
|
||||
this.references = [];
|
||||
}
|
||||
var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", null, {
|
||||
}, AST_Symbol);
|
||||
|
||||
var AST_SymbolVar = DEFNODE("SymbolVar", null, {
|
||||
|
||||
Reference in New Issue
Block a user