rename super_clsas to super_class_name
as it should have been
This commit is contained in:
parent
f22eca053d
commit
0d001ec0fc
@ -20,14 +20,14 @@ require_relative "meta_class"
|
|||||||
|
|
||||||
module Parfait
|
module Parfait
|
||||||
class Class < Object
|
class Class < Object
|
||||||
attributes [:object_layout , :name , :instance_methods , :super_class , :meta_class]
|
attributes [:object_layout , :name , :instance_methods , :super_class_name , :meta_class]
|
||||||
|
|
||||||
def initialize name , superclass
|
def initialize name , superclass
|
||||||
super()
|
super()
|
||||||
self.name = name
|
self.name = name
|
||||||
self.instance_methods = List.new
|
self.instance_methods = List.new
|
||||||
self.super_class = superclass
|
self.super_class_name = superclass
|
||||||
self.meta_class = nil#MetaClass.new(self)
|
self.meta_class = MetaClass.new(self)
|
||||||
# the layout for this class (class = object of type Class) carries the class
|
# the layout for this class (class = object of type Class) carries the class
|
||||||
# as an instance. The relation is from an object through the Layout to it's class
|
# as an instance. The relation is from an object through the Layout to it's class
|
||||||
self.object_layout = Layout.new(self)
|
self.object_layout = Layout.new(self)
|
||||||
@ -37,6 +37,11 @@ module Parfait
|
|||||||
#space, and ruby allocate
|
#space, and ruby allocate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def meta
|
||||||
|
m = self.meta_class
|
||||||
|
return m if m
|
||||||
|
self.meta_class = MetaClass.new(self)
|
||||||
|
end
|
||||||
def add_instance_name name
|
def add_instance_name name
|
||||||
self.object_layout.push name
|
self.object_layout.push name
|
||||||
end
|
end
|
||||||
@ -92,8 +97,12 @@ module Parfait
|
|||||||
# this needs to be done during booting as we can't have all the classes and superclassses
|
# this needs to be done during booting as we can't have all the classes and superclassses
|
||||||
# instantiated. By that logic it should maybe be part of vm rather.
|
# instantiated. By that logic it should maybe be part of vm rather.
|
||||||
# On the other hand vague plans to load the hierachy from sof exist, so for now...
|
# On the other hand vague plans to load the hierachy from sof exist, so for now...
|
||||||
def set_super_class sup
|
def set_super_class_name sup
|
||||||
self.super_class = sup
|
self.super_class_name = sup
|
||||||
|
end
|
||||||
|
|
||||||
|
def super_class
|
||||||
|
Parfait::Space.object_space.get_class_by_name(self.super_class_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_instance_method fname
|
def get_instance_method fname
|
||||||
@ -110,8 +119,8 @@ module Parfait
|
|||||||
raise "resolve_method #{m_name}.#{m_name.class}" unless m_name.is_a?(Symbol)
|
raise "resolve_method #{m_name}.#{m_name.class}" unless m_name.is_a?(Symbol)
|
||||||
method = get_instance_method(m_name)
|
method = get_instance_method(m_name)
|
||||||
return method if method
|
return method if method
|
||||||
if( self.super_class )
|
if( self.super_class_name )
|
||||||
method = Parfait::Space.object_space.get_class_by_name(self.super_class).resolve_method(m_name)
|
method = self.super_class.resolve_method(m_name)
|
||||||
raise "Method not found #{m_name}, for \n#{self}" unless method
|
raise "Method not found #{m_name}, for \n#{self}" unless method
|
||||||
end
|
end
|
||||||
method
|
method
|
||||||
|
@ -84,9 +84,9 @@ module Register
|
|||||||
clazz = classes[classname]
|
clazz = classes[classname]
|
||||||
super_name = supers[classname]
|
super_name = supers[classname]
|
||||||
if super_name
|
if super_name
|
||||||
clazz.set_super_class classes[super_name]
|
clazz.set_super_class_name classes[super_name]
|
||||||
else
|
else
|
||||||
clazz.set_super_class object_class
|
clazz.set_super_class_name object_class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -118,7 +118,7 @@ module Register
|
|||||||
# Assumtion is that name is the last of message
|
# Assumtion is that name is the last of message
|
||||||
:Message => [:next_message , :receiver , :frame , :return_address , :return_value,
|
:Message => [:next_message , :receiver , :frame , :return_address , :return_value,
|
||||||
:caller , :name ],
|
:caller , :name ],
|
||||||
:MetaClass => [],
|
:MetaClass => [:me],
|
||||||
:Integer => [],
|
:Integer => [],
|
||||||
:Object => [],
|
:Object => [],
|
||||||
:Kernel => [], #fix, kernel is a class, but should be a module
|
:Kernel => [], #fix, kernel is a class, but should be a module
|
||||||
@ -128,7 +128,7 @@ module Register
|
|||||||
:Layout => [:object_class] ,
|
:Layout => [:object_class] ,
|
||||||
# TODO fix layouts for inherited classes. Currently only :Class and the
|
# TODO fix layouts for inherited classes. Currently only :Class and the
|
||||||
# instances are copied (shame on you)
|
# instances are copied (shame on you)
|
||||||
:Class => [:object_layout , :name , :instance_methods , :super_class , :meta_class],
|
:Class => [:object_layout , :name , :instance_methods , :super_class_name , :meta_class],
|
||||||
:Dictionary => [:keys , :values ] ,
|
:Dictionary => [:keys , :values ] ,
|
||||||
:Method => [:name , :source , :instructions , :binary ,:arguments , :for_class, :locals ] ,
|
:Method => [:name , :source , :instructions , :binary ,:arguments , :for_class, :locals ] ,
|
||||||
:Variable => [:type , :name , :value ]
|
:Variable => [:type , :name , :value ]
|
||||||
|
@ -16,8 +16,11 @@ class TestClass < MiniTest::Test
|
|||||||
assert_equal "Class(Space)" , @space.get_layout.object_class.inspect
|
assert_equal "Class(Space)" , @space.get_layout.object_class.inspect
|
||||||
assert_equal :Space , @space.get_layout.object_class.name
|
assert_equal :Space , @space.get_layout.object_class.name
|
||||||
end
|
end
|
||||||
|
def test_new_superclass_name
|
||||||
|
assert_equal :Object , @try.super_class_name
|
||||||
|
end
|
||||||
def test_new_superclass
|
def test_new_superclass
|
||||||
assert_equal :Object , @try.super_class
|
assert_equal "Class(Object)" , @try.super_class.inspect
|
||||||
end
|
end
|
||||||
def test_new_methods
|
def test_new_methods
|
||||||
assert_equal @try.method_names.class, @try.instance_methods.class
|
assert_equal @try.method_names.class, @try.instance_methods.class
|
||||||
|
Loading…
Reference in New Issue
Block a user