refactor send code
This commit is contained in:
parent
eb7cfb47d6
commit
0ccb7df0ab
@ -34,35 +34,32 @@ module Vool
|
|||||||
# in a not so distant future, temporary variables will have to be created
|
# in a not so distant future, temporary variables will have to be created
|
||||||
# and complex statements hoisted to assign to them. pps: same as in conditions
|
# and complex statements hoisted to assign to them. pps: same as in conditions
|
||||||
def to_mom( method )
|
def to_mom( method )
|
||||||
Mom::Statements.new( message_setup + call_instruction )
|
if(@receiver.ct_type)
|
||||||
|
simple_call(method)
|
||||||
|
else
|
||||||
|
cached_call(method)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def message_setup
|
def message_setup(method)
|
||||||
pops = [@receiver.slot_class.new([:message , :next_message , :receiver] , @receiver) ]
|
pops = [@receiver.slot_class.new([:message , :next_message , :receiver] , @receiver) ]
|
||||||
@arguments.each_with_index do |arg , index|
|
|
||||||
arg_target = [:message , :next_message , :arguments]
|
arg_target = [:message , :next_message , :arguments]
|
||||||
|
@arguments.each_with_index do |arg , index|
|
||||||
pops << arg.slot_class.new( arg_target + [index] , arg)
|
pops << arg.slot_class.new( arg_target + [index] , arg)
|
||||||
end
|
end
|
||||||
pops
|
pops
|
||||||
end
|
end
|
||||||
|
|
||||||
def call_instruction
|
def simple_call(method)
|
||||||
if(@receiver.ct_type)
|
|
||||||
simple_call
|
|
||||||
else
|
|
||||||
cached_call
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def simple_call
|
|
||||||
type = @receiver.ct_type
|
type = @receiver.ct_type
|
||||||
method = type.resolve_method(@name)
|
method = type.resolve_method(@name)
|
||||||
raise "No method #{@name} for #{type}" unless method
|
raise "No method #{@name} for #{type}" unless method
|
||||||
[Mom::SimpleCall.new( method) ]
|
Mom::Statements.new( message_setup(method) << Mom::SimpleCall.new( method) )
|
||||||
end
|
end
|
||||||
|
|
||||||
def cached_call
|
def cached_call(method)
|
||||||
raise "Not implemented"
|
raise "Not implemented"
|
||||||
|
Mom::Statements.new( message_setup + call_instruction )
|
||||||
[@receiver.slot_class.new([:message , :next_message , :receiver] , @receiver) ]
|
[@receiver.slot_class.new([:message , :next_message , :receiver] , @receiver) ]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user