further minor cleanup to varargs

This commit is contained in:
Jeremy Ashkenas
2010-05-08 12:20:14 -04:00
parent c452c3a101
commit be72120311
3 changed files with 11 additions and 6 deletions

View File

@@ -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.