1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

CoffeeScript 1.3.0

This commit is contained in:
Jeremy Ashkenas 2012-04-10 14:57:45 -04:00
parent 1b3af684cb
commit ed8d94f69c
74 changed files with 1587 additions and 698 deletions

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.2.1-pre
// Generated by CoffeeScript 1.3.0
(function() {
var Scope, extend, last, _ref;
@ -21,11 +21,15 @@
}
];
this.positions = {};
if (!this.parent) Scope.root = this;
if (!this.parent) {
Scope.root = this;
}
}
Scope.prototype.add = function(name, type, immediate) {
if (this.shared && !immediate) return this.parent.add(name, type, immediate);
if (this.shared && !immediate) {
return this.parent.add(name, type, immediate);
}
if (Object.prototype.hasOwnProperty.call(this.positions, name)) {
return this.variables[this.positions[name]].type = type;
} else {
@ -37,20 +41,26 @@
};
Scope.prototype.find = function(name, options) {
if (this.check(name, options)) return true;
if (this.check(name, options)) {
return true;
}
this.add(name, 'var');
return false;
};
Scope.prototype.parameter = function(name) {
if (this.shared && this.parent.check(name, true)) return;
if (this.shared && this.parent.check(name, true)) {
return;
}
return this.add(name, 'param');
};
Scope.prototype.check = function(name, immediate) {
var found, _ref1;
found = !!this.type(name);
if (found || immediate) return found;
if (found || immediate) {
return found;
}
return !!((_ref1 = this.parent) != null ? _ref1.check(name) : void 0);
};
@ -67,19 +77,25 @@
_ref1 = this.variables;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
v = _ref1[_i];
if (v.name === name) return v.type;
if (v.name === name) {
return v.type;
}
}
return null;
};
Scope.prototype.freeVariable = function(name, reserve) {
var index, temp;
if (reserve == null) reserve = true;
if (reserve == null) {
reserve = true;
}
index = 0;
while (this.check((temp = this.temporary(name, index)))) {
index++;
}
if (reserve) this.add(temp, 'var', true);
if (reserve) {
this.add(temp, 'var', true);
}
return temp;
};
@ -115,7 +131,9 @@
_results = [];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
v = _ref1[_i];
if (v.type.assigned) _results.push("" + v.name + " = " + v.type.value);
if (v.type.assigned) {
_results.push("" + v.name + " = " + v.type.value);
}
}
return _results;
};