remove call_site value dependency

Revisit for optimization, now irrelevant
This commit is contained in:
Torsten Ruger 2015-10-16 13:13:56 +03:00
parent 349352faa9
commit 0cf0b35853

View File

@ -2,6 +2,7 @@ module Phisol
Compiler.class_eval do Compiler.class_eval do
def on_call statement def on_call statement
#puts statement
name , arguments , receiver = *statement name , arguments , receiver = *statement
name = name.to_a.first name = name.to_a.first
raise "not inside method " unless @method raise "not inside method " unless @method
@ -31,34 +32,12 @@ module Phisol
end end
# now we have to resolve the method name (+ receiver) into a callable method # now we have to resolve the method name (+ receiver) into a callable method
method = nil clazz = Virtual.machine.space.get_class_by_name(me.type)
if(me.value) raise "No such class #{me.type}" unless clazz
raise "branch should only be optiisation, revit" method = clazz.get_instance_method(name)
me = me.value #puts Virtual.machine.space.get_class_by_name(:Integer).method_names.to_a
if( me.is_a? Parfait::Class ) raise "Method not implemented #{me.type}.#{name}" unless method
raise "unimplemented #{code} me is #{me}" @method.source.add_code Virtual::MethodCall.new( method )
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 )
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
raise "unimplemented: \n#{code} \nfor #{ref.inspect}"
end
else
clazz = Virtual.machine.space.get_class_by_name(me.type)
raise "No such class #{me.type}" unless clazz
method = clazz.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 )
end
raise "Method not implemented #{me.value}.#{name}" unless method
ret = use_reg( method.source.return_type ) ret = use_reg( method.source.return_type )
# the effect of the method is that the NewMessage Return slot will be filled, return it # the effect of the method is that the NewMessage Return slot will be filled, return it
# but move it into a register too # but move it into a register too