more on method lookup

This commit is contained in:
Torsten Ruger 2014-06-24 12:23:39 +03:00
parent 98e25abf8e
commit 07b98d684a
2 changed files with 8 additions and 3 deletions

View File

@ -13,7 +13,7 @@ module Boot
@super_class = super_class
@meta_class = MetaClass.new(self)
end
attr_reader :name , :functions , :meta_class , :context
attr_reader :name , :functions , :meta_class , :context , :super_class
def add_function function
raise "not a function #{function}" unless function.is_a? Vm::Function

View File

@ -27,8 +27,13 @@ module Boot
def get_function name
name = name.to_sym
f = @functions.detect{ |f| f.name == name }
puts "no function for :#{name} in Meta #{@me_self.inspect}" unless f
f
return f if f
if( @me_self == :Object )
puts "no function for :#{name} in Meta #{@me_self.inspect}"
return nil
else #recurse up class hierachy unless we're at Object
return @me_self.context.object_space.get_or_create_class(@me_self.super_class).get_function name
end
end
# get the function and if not found, try superclasses. raise error if not found