implement how send should work (but parfait doesn't parse yet, so it doesnt)

This commit is contained in:
Torsten Ruger 2014-09-23 20:16:05 +03:00
parent f5ec7f3bdb
commit 892f251d18
4 changed files with 11 additions and 2 deletions

View File

@ -34,6 +34,10 @@ module Builtin
function.set_return ret function.set_return ret
function function
end end
def __send__ context
function = Virtual::CompiledMethod.new(:__send__ , [] , Virtual::Integer)
return function
end
end end
extend ClassMethods extend ClassMethods
end end

View File

@ -8,7 +8,7 @@ class Message
get_at(index) get_at(index)
end end
def send def __send__
typ = get_type_for( :receiver ) typ = get_type_for( :receiver )
# TODO: this will obviously be recoded as case, once that is done :-) # TODO: this will obviously be recoded as case, once that is done :-)
# depending on value type get method # depending on value type get method

View File

@ -77,7 +77,7 @@ module Virtual
obj.add_instance_method Builtin::Object.send(f , @context) obj.add_instance_method Builtin::Object.send(f , @context)
end end
obj = get_or_create_class :Kernel obj = get_or_create_class :Kernel
[:main , :__init__,:putstring,:exit].each do |f| [:main , :__init__,:putstring,:exit,:__send__].each do |f|
obj.add_instance_method Builtin::Kernel.send(f , @context) obj.add_instance_method Builtin::Kernel.send(f , @context)
end end
obj = get_or_create_class :Integer obj = get_or_create_class :Integer

View File

@ -24,6 +24,11 @@ module Virtual
raise "Method not implemented #{clazz.name}.#{code.name}" unless method raise "Method not implemented #{clazz.name}.#{code.name}" unless method
new_codes << FunctionCall.new( method ) new_codes << FunctionCall.new( method )
else 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::BootSpace.space.get_or_create_class(:Kernel)
method = kernel.get_instance_method(:__send__)
new_codes << FunctionCall.new( method )
raise "unimplemented #{code}" raise "unimplemented #{code}"
end end
else else