Skip to content

Commit

Permalink
Better way to use an object as a dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Crane committed Jun 26, 2012
1 parent a3f0dc4 commit d2488fe
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/compiler.js
Expand Up @@ -273,7 +273,7 @@
this.name = name; this.name = name;
this.parent = parent; this.parent = parent;
this.root = parent.root; this.root = parent.root;
this.variables = {}; this.variables = Object.create(null);
this.frame = parent.frame; this.frame = parent.frame;
assert(this.frame instanceof Frame); assert(this.frame instanceof Frame);
} }
Expand Down Expand Up @@ -339,7 +339,7 @@
Scope.prototype.addVariable = function addVariable(variable, external) { Scope.prototype.addVariable = function addVariable(variable, external) {
assert(variable); assert(variable);
assert(!variable.frame); assert(!variable.frame);
assert(!this.variables.hasOwnProperty(variable.name)); assert(!this.variables[variable.name]);
variable.frame = this.frame; variable.frame = this.frame;


var variables = this.variables; var variables = this.variables;
Expand Down Expand Up @@ -385,10 +385,10 @@
this.name = name; this.name = name;
this.parent = parent; this.parent = parent;
this.root = parent ? parent.root : this; this.root = parent ? parent.root : this;
this.variables = {}; this.variables = Object.create(null);
this.cachedLocals = {}; this.cachedLocals = Object.create(null);
this.frame = this; this.frame = this;
this.mangles = {}; this.mangles = Object.create(null);
} }


Frame.prototype = Object.create(Scope.prototype); Frame.prototype = Object.create(Scope.prototype);
Expand Down

0 comments on commit d2488fe

Please sign in to comment.