further minor cleanup to varargs
This commit is contained in:
parent
c452c3a101
commit
be72120311
|
@ -240,7 +240,8 @@
|
|||
// balanced (ie. strings, JS literals).
|
||||
Lexer.prototype.balanced_token = function balanced_token() {
|
||||
var delimited;
|
||||
delimited = __slice.call(arguments, 0, arguments.length - 0);
|
||||
var _d = arguments.length;
|
||||
delimited = __slice.call(arguments, 0, _d - 0);
|
||||
return balanced_string(this.chunk, delimited);
|
||||
};
|
||||
// Matches and conumes comments. We pass through comments into JavaScript,
|
||||
|
|
|
@ -1153,15 +1153,17 @@
|
|||
// Compiling a parameter splat means recovering the parameters that succeed
|
||||
// the splat in the parameter list, by slicing the arguments object.
|
||||
SplatNode.prototype.compile_param = function compile_param(o) {
|
||||
var _b, _c, name, pos, trailing;
|
||||
var _b, _c, len, name, pos, trailing;
|
||||
name = this.name.compile(o);
|
||||
o.scope.find(name);
|
||||
len = o.scope.free_variable();
|
||||
o.scope.assign(len, "arguments.length");
|
||||
_b = this.trailings;
|
||||
for (pos = 0, _c = _b.length; pos < _c; pos++) {
|
||||
trailing = _b[pos];
|
||||
o.scope.assign(trailing.compile(o), ("arguments[arguments.length - " + (this.trailings.length + pos) + "]"));
|
||||
o.scope.assign(trailing.compile(o), ("arguments[" + len + " - " + (this.trailings.length + pos) + "]"));
|
||||
}
|
||||
return "" + name + " = " + (utility('slice')) + ".call(arguments, " + this.index + ", arguments.length - " + (this.trailings.length) + ")";
|
||||
return "" + name + " = " + (utility('slice')) + ".call(arguments, " + this.index + ", " + len + " - " + (this.trailings.length) + ")";
|
||||
};
|
||||
// A compiling a splat as a destructuring assignment means slicing arguments
|
||||
// from the right-hand-side's corresponding array.
|
||||
|
|
|
@ -828,9 +828,11 @@ exports.SplatNode: class SplatNode extends BaseNode
|
|||
compile_param: (o) ->
|
||||
name: @name.compile(o)
|
||||
o.scope.find name
|
||||
len: o.scope.free_variable()
|
||||
o.scope.assign len, "arguments.length"
|
||||
for trailing, pos in @trailings
|
||||
o.scope.assign(trailing.compile(o), "arguments[arguments.length - ${@trailings.length + pos}]")
|
||||
"$name = ${utility('slice')}.call(arguments, $@index, arguments.length - ${@trailings.length})"
|
||||
o.scope.assign(trailing.compile(o), "arguments[$len - ${@trailings.length + pos}]")
|
||||
"$name = ${utility('slice')}.call(arguments, $@index, $len - ${@trailings.length})"
|
||||
|
||||
# A compiling a splat as a destructuring assignment means slicing arguments
|
||||
# from the right-hand-side's corresponding array.
|
||||
|
|
Loading…
Reference in New Issue