mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 11:31:20 -05:00
self-compiling pattern matching correctly
This commit is contained in:
@@ -600,6 +600,7 @@ AssignNode: exports.AssignNode: inherit Node, {
|
||||
if obj instanceof SplatNode
|
||||
val: new LiteralNode(obj.compile_value(o, val_var, @variable.base.objects.indexOf(obj)))
|
||||
else
|
||||
idx: new LiteralNode(idx) unless typeof idx is 'object'
|
||||
val: new ValueNode(new LiteralNode(val_var), [new access_class(idx)])
|
||||
assigns.push(new AssignNode(obj, val).compile(o))
|
||||
assigns.join("\n")
|
||||
@@ -664,11 +665,12 @@ SplatNode: exports.SplatNode: inherit Node, {
|
||||
if @index then @compile_param(o) else @name.compile(o)
|
||||
|
||||
compile_param: (o) ->
|
||||
o.scope.find @name
|
||||
@name + ' = Array.prototype.slice.call(arguments, ' + @index + ')'
|
||||
name: @name.compile(o)
|
||||
o.scope.find name
|
||||
name + ' = Array.prototype.slice.call(arguments, ' + @index + ')'
|
||||
|
||||
compile_value: (o, name, index) ->
|
||||
"Array.prototype.slice.call(" + @name + ', ' + @index + ')'
|
||||
"Array.prototype.slice.call(" + name + ', ' + index + ')'
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user