mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -04:00
got compile_pattern_match about as small as its going to get
This commit is contained in:
@@ -472,13 +472,13 @@ module CoffeeScript
|
|||||||
def compile_pattern_match(o)
|
def compile_pattern_match(o)
|
||||||
val_var = o[:scope].free_variable
|
val_var = o[:scope].free_variable
|
||||||
assigns = ["#{idt}#{val_var} = #{@value.compile(o)};"]
|
assigns = ["#{idt}#{val_var} = #{@value.compile(o)};"]
|
||||||
|
o.merge!(:top => true, :as_statement => true)
|
||||||
@variable.base.objects.each_with_index do |obj, i|
|
@variable.base.objects.each_with_index do |obj, i|
|
||||||
obj, i = obj.value, obj.variable.base if @variable.object?
|
obj, i = obj.value, obj.variable.base if @variable.object?
|
||||||
access_class = @variable.array? ? IndexNode : AccessorNode
|
access_class = @variable.array? ? IndexNode : AccessorNode
|
||||||
assigns << AssignNode.new(
|
assigns << AssignNode.new(
|
||||||
obj,
|
obj, ValueNode.new(Value.new(val_var), [access_class.new(Value.new(i.to_s))])
|
||||||
ValueNode.new(Value.new(val_var), [access_class.new(Value.new(i.to_s))])
|
).compile(o)
|
||||||
).compile(o.merge(:top => true, :as_statement => true))
|
|
||||||
end
|
end
|
||||||
write(assigns.join("\n"))
|
write(assigns.join("\n"))
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user