Removing code added during the migration. `freeVariable(..)` is called with
a `type` at all times.
This commit is contained in:
parent
bb35b3e3b2
commit
408833daef
19
lib/scope.js
19
lib/scope.js
|
@ -12,9 +12,7 @@
|
|||
this.expressions = _cache[1];
|
||||
this.method = _cache[2];
|
||||
this.variables = {};
|
||||
this.tempVars = {
|
||||
general: '_a'
|
||||
};
|
||||
this.tempVars = {};
|
||||
if (this.parent) {
|
||||
_cache2 = this.parent.tempVars;
|
||||
for (k in _cache2) {
|
||||
|
@ -60,18 +58,9 @@
|
|||
};
|
||||
Scope.prototype.freeVariable = function(type) {
|
||||
var next;
|
||||
if (type) {
|
||||
next = function(prev) {
|
||||
return '_' + type + ((prev && Number(prev.match(/\d+$/) || 1) + 1) || '');
|
||||
};
|
||||
} else {
|
||||
type = 'general';
|
||||
next = function(prev) {
|
||||
var ordinal;
|
||||
ordinal = 1 + parseInt(prev.substr(1), 36);
|
||||
return '_' + ordinal.toString(36).replace(/\d/g, 'a');
|
||||
};
|
||||
}
|
||||
next = function(prev) {
|
||||
return '_' + type + ((prev && Number(prev.match(/\d+$/) || 1) + 1) || '');
|
||||
};
|
||||
while (this.check(this.tempVars[type] || (this.tempVars[type] = next()))) {
|
||||
this.tempVars[type] = next(this.tempVars[type]);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@ exports.Scope = class Scope
|
|||
constructor: (parent, expressions, method) ->
|
||||
[@parent, @expressions, @method] = [parent, expressions, method]
|
||||
@variables = {}
|
||||
@tempVars =
|
||||
general: '_a'
|
||||
@tempVars = {}
|
||||
if @parent
|
||||
(@tempVars[k] = val) for k, val of @parent.tempVars
|
||||
else
|
||||
|
@ -53,16 +52,10 @@ exports.Scope = class Scope
|
|||
!!(@parent and @parent.check(name))
|
||||
|
||||
# If we need to store an intermediate result, find an available name for a
|
||||
# compiler-generated variable. `_a`, `_b`, and so on...
|
||||
# compiler-generated variable. `_var`, `_var2`, and so on...
|
||||
freeVariable: (type) ->
|
||||
if type
|
||||
next = (prev) ->
|
||||
'_' + type + ((prev and Number(prev.match(/\d+$/) or 1) + 1) or '')
|
||||
else
|
||||
type = 'general'
|
||||
next = (prev) ->
|
||||
ordinal = 1 + parseInt prev.substr(1), 36
|
||||
'_' + ordinal.toString(36).replace /\d/g, 'a'
|
||||
next = (prev) ->
|
||||
'_' + type + ((prev and Number(prev.match(/\d+$/) or 1) + 1) or '')
|
||||
while @check @tempVars[type] or= next()
|
||||
@tempVars[type] = next @tempVars[type]
|
||||
@variables[@tempVars[type]] = 'var'
|
||||
|
|
Loading…
Reference in New Issue