remove send , move into call_site (resolve to calls)

This commit is contained in:
Torsten Ruger
2015-09-27 19:07:12 +03:00
parent 252c0ccdca
commit bb8a57f5a5
3 changed files with 30 additions and 72 deletions

View File

@ -27,7 +27,36 @@ module Bosl
method.source.add_code Virtual::Set.new( val , to )
compiled_args << to
end
method.source.add_code Virtual::MessageSend.new(name , me , compiled_args) #and pass control
#method.source.add_code Virtual::MessageSend.new(name , me , compiled_args) #and pass control
method = nil
if(me.value)
me = me.value
if( me.is_a? Parfait::Class )
raise "unimplemented #{code} me is #{me}"
elsif( me.is_a? Symbol )
# get the function from my class. easy peasy
method = Virtual.machine.space.get_class_by_name(:Word).get_instance_method(name)
raise "Method not implemented #{me.class}.#{code.name}" unless method
@method.source.add_code Virtual::MethodCall.new( method )
elsif( me.is_a? Fixnum )
name = :plus if name == :+
method = Virtual.machine.space.get_class_by_name(:Integer).get_instance_method(name)
#puts Virtual.machine.space.get_class_by_name(:Integer).method_names.to_a
raise "Method not implemented Integer.#{name}" unless method
@method.source.add_code Virtual::MethodCall.new( method )
else
# note: this is the current view: call internal send, even the method name says else
# but send is "special" and accesses the internal method name and resolves.
kernel = Virtual.machine.space.get_class_by_name(:Kernel)
method = kernel.get_instance_method(:__send)
@method.source.add_code Virtual::MethodCall.new( method )
raise "unimplemented: \n#{code} \nfor #{ref.inspect}"
end
else
method = @method
@method.source.add_code Virtual::MethodCall.new( @method )
end
raise "Method not implemented #{me.value}.#{name}" unless method
# the effect of the method is that the NewMessage Return slot will be filled, return it
# (this is what is moved _inside_ above loop for such expressions that are calls (or constants))
Virtual::Return.new( method.source.return_type )