2014-08-21 16:46:12 +02:00
|
|
|
module Trickle
|
|
|
|
# This implements the send logic
|
|
|
|
# Send is so complicated that we actually code it in ruby and stick it in
|
|
|
|
# That off course opens up an endless loop possibility that we stop by reducing to Class and Module methods
|
|
|
|
class Send
|
|
|
|
def run block
|
|
|
|
block.codes.dup.each do |code|
|
2014-08-22 08:21:59 +02:00
|
|
|
next unless code.is_a? Virtual::MessageSend
|
2014-08-22 09:21:12 +02:00
|
|
|
me = code.me
|
|
|
|
next unless ( me.type == Virtual::Reference)
|
|
|
|
if( me.is_a? Virtual::Constant)
|
|
|
|
Boot::BootClass
|
|
|
|
if( me.is_a? Boot::BootClass )
|
|
|
|
raise "unimplemented"
|
|
|
|
elsif( me.is_a? Virtual::ObjectConstant )
|
|
|
|
clazz = me.clazz
|
|
|
|
method = clazz.get_method_definition code.name
|
|
|
|
raise "Method not implemented #{clazz.name}.#{code.name}" unless method
|
2014-08-22 14:08:46 +02:00
|
|
|
call = Virtual::FunctionCall.new( method )
|
|
|
|
block.replace(code , [call] )
|
2014-08-22 09:21:12 +02:00
|
|
|
else
|
|
|
|
raise "unimplemented"
|
|
|
|
end
|
2014-08-21 21:57:20 +02:00
|
|
|
end
|
2014-08-21 16:46:12 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|