Restoring garbage collection.

This commit is contained in:
Timothy Jones 2010-10-20 12:58:59 +13:00
parent 8c4a48d9d0
commit 15cfe8ebf1
3 changed files with 12 additions and 23 deletions

View File

@ -781,7 +781,7 @@
__extends(ObjectLiteral, Base);
ObjectLiteral.prototype.children = ['properties'];
ObjectLiteral.prototype.compileNode = function(o) {
var _i, _len, _len2, _ref2, _ref3, _result, _result2, i, indent, join, lastNoncom, nonComments, obj, prop, props, top;
var _i, _len, _ref2, _result, i, indent, join, lastNoncom, nonComments, obj, prop, props, top;
top = del(o, 'top');
o.indent = this.idt(1);
nonComments = (function() {
@ -796,10 +796,10 @@
}).call(this);
lastNoncom = last(nonComments);
props = (function() {
_result2 = [];
for (i = 0, _len2 = (_ref3 = this.properties).length; i < _len2; i++) {
prop = _ref3[i];
_result2.push((function() {
_result = [];
for (i = 0, _len = (_ref2 = this.properties).length; i < _len; i++) {
prop = _ref2[i];
_result.push((function() {
join = i === this.properties.length - 1 ? '' : (prop === lastNoncom || prop instanceof Comment ? '\n' : ',\n');
indent = prop instanceof Comment ? '' : this.idt(1);
if (prop instanceof Value && prop.tags["this"]) {
@ -810,7 +810,7 @@
return indent + prop.compile(o) + join;
}).call(this));
}
return _result2;
return _result;
}).call(this);
props = props.join('');
obj = ("{" + (props ? '\n' + props + '\n' + this.idt() : '') + "}");
@ -1123,7 +1123,7 @@
__extends(Code, Base);
Code.prototype.children = ['params', 'body'];
Code.prototype.compileNode = function(o) {
var _i, _j, _len, _len2, _len3, _ref2, _ref3, _result, close, code, comm, empty, func, i, open, param, params, sharedScope, splat, top, value;
var _i, _len, _len2, _ref2, _ref3, _result, close, code, comm, empty, func, i, open, param, params, sharedScope, splat, top, value;
sharedScope = del(o, 'sharedScope');
top = del(o, 'top');
o.scope = sharedScope || new Scope(o.scope, this.body, this);
@ -1171,8 +1171,8 @@
if (!(empty || this.noReturn)) {
this.body.makeReturn();
}
for (_j = 0, _len3 = params.length; _j < _len3; _j++) {
param = params[_j];
for (_i = 0, _len2 = params.length; _i < _len2; _i++) {
param = params[_i];
(o.scope.parameter(param));
}
comm = this.comment ? this.comment.compile(o) + '\n' : '';

View File

@ -43,22 +43,13 @@
return this.garbage.push([]);
};
Scope.prototype.endLevel = function() {
var _i, _len, _len2, _ref2, _result, garbage, i, v, vars;
var _i, _len, _ref2, _result, garbage, vars;
vars = this.variables;
_result = [];
for (_i = 0, _len = (_ref2 = this.garbage.pop()).length; _i < _len; _i++) {
garbage = _ref2[_i];
if (this.type(garbage) === 'var') {
for (i = 0, _len2 = vars.length; i < _len2; i++) {
v = vars[i];
if (v.name === garbage.name) {
vars.splice(i, 1, {
name: garbage.name,
type: 'reuse'
});
break;
}
}
_result.push(this.setVar(garbage, 'reuse'));
}
}
return _result;

View File

@ -43,9 +43,7 @@ exports.Scope = class Scope
endLevel: ->
vars = @variables
for garbage in @garbage.pop() when @type(garbage) is 'var'
for v, i in vars when v.name is garbage.name
vars.splice(i, 1, {name: garbage.name, type: 'reuse'})
break
@setVar garbage, 'reuse'
# Look up a variable name in lexical scope, and declare it if it does not
# already exist.