From 07b98d684a533efb9f918d00db6d61ef9356a09c Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Tue, 24 Jun 2014 12:23:39 +0300 Subject: [PATCH] more on method lookup --- lib/boot/boot_class.rb | 2 +- lib/boot/meta_class.rb | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/boot/boot_class.rb b/lib/boot/boot_class.rb index a0cb72e9..c4f911fa 100644 --- a/lib/boot/boot_class.rb +++ b/lib/boot/boot_class.rb @@ -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 diff --git a/lib/boot/meta_class.rb b/lib/boot/meta_class.rb index d77a1553..e40149e4 100644 --- a/lib/boot/meta_class.rb +++ b/lib/boot/meta_class.rb @@ -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