Self-compiler can compile splats.

This commit is contained in:
Jeremy Ashkenas
2010-02-09 21:44:34 -05:00
parent ae4f6309e8
commit fd80d784f4
4 changed files with 41 additions and 4 deletions

View File

@@ -691,6 +691,25 @@ CodeNode: exports.CodeNode: inherit Node, {
}
# A splat, either as a parameter to a function, an argument to a call,
# or in a destructuring assignment.
SplatNode: exports.SplatNode: inherit Node, {
constructor: (name) ->
@children: [@name: name]
this
compile_node: (o) ->
if @index then @compile_param(o) else @name.compile(o)
compile_param: (o) ->
o.scope.find @name
@name + ' = Array.prototype.slice.call(arguments, ' + @index + ')'
compile_value: (o, name, index) ->
"Array.prototype.slice.call(" + @name + ', ' + @index + ')'
}