fix for variable names like toString
This commit is contained in:
12
lib/scope.js
12
lib/scope.js
@@ -258,9 +258,10 @@ AST_SymbolRef.DEFMETHOD("reference", function(symbol) {
|
|||||||
|
|
||||||
AST_Scope.DEFMETHOD("find_variable", function(name){
|
AST_Scope.DEFMETHOD("find_variable", function(name){
|
||||||
if (name instanceof AST_Symbol) name = name.name;
|
if (name instanceof AST_Symbol) name = name.name;
|
||||||
return this.variables[name] ||
|
return HOP(this.variables, name)
|
||||||
(this.name && this.name.name == name && this.name) ||
|
? this.variables[name]
|
||||||
(this.parent_scope && this.parent_scope.find_variable(name));
|
: ((this.name && this.name.name == name && this.name)
|
||||||
|
|| (this.parent_scope && this.parent_scope.find_variable(name)));
|
||||||
});
|
});
|
||||||
|
|
||||||
AST_Scope.DEFMETHOD("def_function", function(symbol){
|
AST_Scope.DEFMETHOD("def_function", function(symbol){
|
||||||
@@ -270,11 +271,10 @@ AST_Scope.DEFMETHOD("def_function", function(symbol){
|
|||||||
|
|
||||||
AST_Scope.DEFMETHOD("def_variable", function(symbol){
|
AST_Scope.DEFMETHOD("def_variable", function(symbol){
|
||||||
symbol.global = !this.parent_scope;
|
symbol.global = !this.parent_scope;
|
||||||
var existing = this.variables[symbol.name];
|
if (!HOP(this.variables, symbol.name)) {
|
||||||
if (!existing) {
|
|
||||||
this.variables[symbol.name] = symbol;
|
this.variables[symbol.name] = symbol;
|
||||||
} else {
|
} else {
|
||||||
symbol.uniq = existing;
|
symbol.uniq = this.variables[symbol.name];
|
||||||
}
|
}
|
||||||
symbol.scope = this;
|
symbol.scope = this;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user