diff --git a/lib/builtin/kernel.rb b/lib/builtin/kernel.rb index 965d8143..3a4ac0dd 100644 --- a/lib/builtin/kernel.rb +++ b/lib/builtin/kernel.rb @@ -12,6 +12,12 @@ module Builtin # so it is responsible for initial setup (and relocation) def __init__ context function = Virtual::CompiledMethod.new(:__init__ , [] , Virtual::Integer) + clazz = Virtual::BootSpace.space.get_or_create_class :Kernel + method = clazz.resolve_method :main + me = Virtual::Self.new(Virtual::Reference) + code = Virtual::Set.new(Virtual::NewSelf.new(me.type), me) + function.add_code(code) + function.add_code Virtual::FunctionCall.new(method) return function end def putstring context diff --git a/lib/virtual/boot_class.rb b/lib/virtual/boot_class.rb index 8a76b40e..4415bc93 100644 --- a/lib/virtual/boot_class.rb +++ b/lib/virtual/boot_class.rb @@ -27,15 +27,16 @@ module Virtual end # get the method and if not found, try superclasses. raise error if not found - def resolve_method name - fun = get_instance_method name - unless fun or name == :Object - supr = @context.object_space.get_or_create_class(@super_class_name) - fun = supr.get_method name - puts "#{supr.methods.collect(&:name)} for #{name} GOT #{fun.class}" if name == :index_of + def resolve_method m_name + method = get_instance_method(m_name) + unless method + unless( @name == :Object) + supr = BootSpace.space.get_or_create_class(@super_class_name) + method = supr.resolve_method(m_name) + end end - raise "Method not found :#{name}, for #{inspect}" unless fun - fun + raise "Method not found #{m_name}, for #{@name}" unless method + method end def to_s