mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Using a typeof check in scope.
This commit is contained in:
15
lib/scope.js
15
lib/scope.js
@@ -13,6 +13,7 @@
|
||||
type: 'arguments'
|
||||
}
|
||||
];
|
||||
this.positions = {};
|
||||
if (this.parent) {
|
||||
this.garbage = this.parent.garbage;
|
||||
} else {
|
||||
@@ -25,19 +26,11 @@
|
||||
})();
|
||||
Scope.root = null;
|
||||
Scope.prototype.add = function(name, type) {
|
||||
var _len, _ref2, i, variable;
|
||||
_ref2 = this.variables;
|
||||
for (i = 0, _len = _ref2.length; i < _len; i++) {
|
||||
variable = _ref2[i];
|
||||
if (variable.name === name) {
|
||||
this.variables[i].type = type;
|
||||
return;
|
||||
}
|
||||
}
|
||||
return this.variables.push({
|
||||
var pos;
|
||||
return typeof (pos = this.positions[name]) === 'number' ? this.variables[pos].type = type : this.positions[name] = this.variables.push({
|
||||
name: name,
|
||||
type: type
|
||||
});
|
||||
}) - 1;
|
||||
};
|
||||
Scope.prototype.startLevel = function() {
|
||||
this.garbage.push([]);
|
||||
|
||||
Reference in New Issue
Block a user