more on method lookup
This commit is contained in:
parent
98e25abf8e
commit
07b98d684a
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user