more booting
This commit is contained in:
@ -15,7 +15,7 @@ require_relative "meta_class"
|
||||
module Parfait
|
||||
class Class < Module
|
||||
|
||||
def initialize name , super_class = nil
|
||||
def initialize name , super_class
|
||||
super( name , super_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
|
||||
@ -34,16 +34,9 @@ module Parfait
|
||||
@object_layout.push name
|
||||
end
|
||||
|
||||
@@CLAZZ = { :names => [:name , :super_class_name , :instance_methods] , :types => [Virtual::Reference,Virtual::Reference,Virtual::Reference]}
|
||||
def old_layout
|
||||
@@CLAZZ
|
||||
end
|
||||
def mem_length
|
||||
padded_words(3)
|
||||
end
|
||||
def to_s
|
||||
inspect[0...300]
|
||||
end
|
||||
|
||||
# ruby 2.1 list (just for reference, keep at bottom)
|
||||
#:allocate, :new, :superclass
|
||||
|
@ -19,15 +19,16 @@ module Parfait
|
||||
|
||||
class Method < Object
|
||||
|
||||
def initialize name , arg_names
|
||||
def initialize clazz , name , arg_names
|
||||
super()
|
||||
raise "No class #{name}" unless clazz
|
||||
@for_class = clazz
|
||||
@name = name
|
||||
@arg_names = arg_names
|
||||
@locals = []
|
||||
@tmps = []
|
||||
end
|
||||
attr_reader :name , :arg_names
|
||||
attr_accessor :for_class
|
||||
attr_reader :name , :arg_names , :for_class
|
||||
|
||||
|
||||
# determine whether this method has a variable by the given name
|
||||
|
@ -28,16 +28,19 @@ module Parfait
|
||||
def instance_methods
|
||||
@instance_methods
|
||||
end
|
||||
|
||||
def add_instance_method method
|
||||
raise "not a method #{method.class} #{method.inspect}" unless method.is_a? Method
|
||||
raise "syserr #{method.name.class}" unless method.name.is_a? Word
|
||||
method.for_class = self
|
||||
@instance_methods << method
|
||||
puts "#{self.name} add #{method.name}"
|
||||
method
|
||||
end
|
||||
|
||||
def create_instance_method name , arg_names
|
||||
add_instance_method Method.new( name , arg_names )
|
||||
def create_instance_method name , arg_names
|
||||
clazz = Space.object_space.get_class_by_name(self.name)
|
||||
raise "??? #{self.name}" unless clazz
|
||||
Method.new( clazz , name , arg_names )
|
||||
end
|
||||
|
||||
# this needs to be done during booting as we can't have all the classes and superclassses
|
||||
@ -56,12 +59,11 @@ module Parfait
|
||||
def resolve_method m_name
|
||||
raise "uups #{m_name}.#{m_name.class}" unless m_name.is_a? Word
|
||||
method = get_instance_method(m_name)
|
||||
unless method
|
||||
unless( @name == "Object" )
|
||||
method = @super_class.resolve_method(m_name)
|
||||
end
|
||||
return method if method
|
||||
if( @super_class )
|
||||
method = @super_class.resolve_method(m_name)
|
||||
raise "Method not found #{m_name}, for \n#{self}" unless method
|
||||
end
|
||||
raise "Method not found #{m_name}, for #{@name}" unless method
|
||||
method
|
||||
end
|
||||
|
||||
|
@ -69,8 +69,8 @@ module Parfait
|
||||
c
|
||||
end
|
||||
|
||||
def create_class name
|
||||
c = Class.new_object(name)
|
||||
def create_class name , superclass
|
||||
c = Class.new_object(name , superclass)
|
||||
raise "uups " if name.is_a? String
|
||||
@classes[name] = c
|
||||
end
|
||||
|
@ -109,7 +109,7 @@ module Parfait
|
||||
|
||||
# as we answered is_value? with true, sof will create a basic node with this string
|
||||
def to_sof
|
||||
"Parfait::Word('#{to_s}')"
|
||||
"\"#{to_s}\""
|
||||
end
|
||||
|
||||
#below here is OLD, DUBIOUS and needs to be checked TODO
|
||||
|
Reference in New Issue
Block a user