2014-08-23 09:25:55 +02:00
|
|
|
module Virtual
|
2014-08-21 16:46:12 +02:00
|
|
|
# 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
|
2014-08-23 09:25:55 +02:00
|
|
|
class SendImplementation
|
2014-08-21 16:46:12 +02:00
|
|
|
def run block
|
|
|
|
block.codes.dup.each do |code|
|
2014-08-23 09:25:55 +02:00
|
|
|
next unless code.is_a? MessageSend
|
2014-08-22 09:21:12 +02:00
|
|
|
me = code.me
|
2014-08-23 09:25:55 +02:00
|
|
|
next unless ( me.type == Reference)
|
|
|
|
if( me.is_a? Constant)
|
2014-08-23 23:25:15 +02:00
|
|
|
if( me.is_a? BootClass )
|
2014-08-22 09:21:12 +02:00
|
|
|
raise "unimplemented"
|
2014-08-23 09:25:55 +02:00
|
|
|
elsif( me.is_a? ObjectConstant )
|
2014-08-22 09:21:12 +02:00
|
|
|
clazz = me.clazz
|
2014-08-23 22:57:47 +02:00
|
|
|
method = clazz.get_instance_method code.name
|
2014-08-22 09:21:12 +02:00
|
|
|
raise "Method not implemented #{clazz.name}.#{code.name}" unless method
|
2014-08-23 09:25:55 +02:00
|
|
|
call = FunctionCall.new( method )
|
2014-08-22 14:08:46 +02:00
|
|
|
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
|