aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2012-09-05 14:31:05 +0300
committerMihai Bazon <mihai@bazon.net>2012-09-05 14:31:05 +0300
commitc7b484b64fdce8ed922f18376b7edf3cb40112f1 (patch)
treeba096e7b888de9099901434916cf651a5271497b
parent0503513dcc9e4dc9f01ffc894245076de9f48cb0 (diff)
downloadtracifyjs-c7b484b64fdce8ed922f18376b7edf3cb40112f1.tar.gz
tracifyjs-c7b484b64fdce8ed922f18376b7edf3cb40112f1.zip
fix for variable names like `toString`
-rw-r--r--lib/scope.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/scope.js b/lib/scope.js
index 0518a49a..adf36493 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -258,9 +258,10 @@ AST_SymbolRef.DEFMETHOD("reference", function(symbol) {
AST_Scope.DEFMETHOD("find_variable", function(name){
if (name instanceof AST_Symbol) name = name.name;
- return this.variables[name] ||
- (this.name && this.name.name == name && this.name) ||
- (this.parent_scope && this.parent_scope.find_variable(name));
+ return HOP(this.variables, name)
+ ? this.variables[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){
@@ -270,11 +271,10 @@ AST_Scope.DEFMETHOD("def_function", function(symbol){
AST_Scope.DEFMETHOD("def_variable", function(symbol){
symbol.global = !this.parent_scope;
- var existing = this.variables[symbol.name];
- if (!existing) {
+ if (!HOP(this.variables, symbol.name)) {
this.variables[symbol.name] = symbol;
} else {
- symbol.uniq = existing;
+ symbol.uniq = this.variables[symbol.name];
}
symbol.scope = this;
});