Fixing new parfait boot process

mostly about setting the types to existing objects. 
Then after space is in place, it is set automatically

also a fair bit of misc in the commit
This commit is contained in:
2019-09-23 00:07:30 +03:00
parent e61c5d4a55
commit 7b40bb9106
16 changed files with 70 additions and 73 deletions

View File

@ -24,7 +24,6 @@ module Risc
collection = []
mark_1k( object , 0 , collection)
collection.each do |obj|
#puts "obj #{obj.object_id}"
keep(obj)
end
end
@ -49,7 +48,6 @@ module Risc
type.names.each do |name|
mark_1k(name , depth + 1, collection)
inst = object.get_instance_variable name
#puts "getting name #{name}, val=#{inst} #{inst.object_id}"
mark_1k(inst , depth + 1, collection)
end
if object.is_a? Parfait::List

View File

@ -19,6 +19,8 @@ module Parfait
def self.set_type_for(object)
return unless(Parfait.object_space)
return if(object.is_a?(Symbol))
return if(object.is_a?(::Integer))
name = object.class.name.split("::").last.to_sym
# have to grab the class, because we are in the ruby class not the parfait one
cl = Parfait.object_space.get_class_by_name( name )
@ -40,11 +42,11 @@ module Parfait
end
def init_mem(pages)
[:Integer , :ReturnAddress , :Message].each do |fact_name|
for_type = classes[fact_name].instance_type
for_type = @classes[fact_name].instance_type
page_size = pages[fact_name] || 1024
factory = Factory.new( for_type , page_size )
factory.get_more
factories[ fact_name ] = factory
@factories[ fact_name ] = factory
end
init_message_chain( factories[ :Message ].reserve )
init_message_chain( factories[ :Message ].next_object )
@ -96,24 +98,16 @@ module Parfait
value
end
def self.variable_index( name)
if(name == :type)
return Parfait::TYPE_INDEX
end
clazz = self.name.split("::").last.to_sym
type = Parfait.type_names[clazz]
i = type.keys.index(name)
raise "no #{name} for #{clazz}:#{type.keys}" unless i
i + 1
end
end
def self.cattr( *names )
names.each do |ca|
class_eval "@@#{ca} = 0"
class_eval "def self.#{ca}; return @#{ca};end"
class_eval "def self.#{ca}=(val); @#{ca} = val;end"
end
end
def self.name_for_index(object , index)
return :type if index == 0
clazz = object.class.name.split("::").last.to_sym
cl = self.type_names[clazz]
keys = cl.keys
keys[index - 1] # -1 because type is excluded in the lists (FIX)
# FIXME Now that we use instance variables in parfait, they should be parsed
# and the type_names generated automatically
end
# new list from ruby array to be precise

View File

@ -25,6 +25,7 @@ module Parfait
end
def self.boot!(options)
Parfait::Object.set_object_space( nil ) #case of reboot
space = Space.new( )
type_names.each do |name , ivars |
ivars[:type] = :Type
@ -41,18 +42,36 @@ module Parfait
# Types are hollow shells before this, so we need to set the object_class
# and initialize the list variables (which we now can with .new)
def self.fix_types
ObjectSpace.each_object(Parfait::Object) { |o| Parfait.set_type_for(o) }
fix_object_type(Parfait.object_space)
classes = Parfait.object_space.classes
class_type = Parfait.object_space.get_type_by_class_name(:Class)
raise "nil type" unless class_type
types = Parfait.object_space.types
super_names = super_class_names
classes.each do |name , cl|
object_type = Parfait.object_space.get_type_by_class_name(name)
cl.meta_class.set_instance_variable(:@instance_type, class_type)
cl.set_instance_variable( :@instance_type , object_type)
object_type.set_object_class(cl)
raise "nil type" unless object_type
cl.meta_class.instance_eval{ @instance_type = class_type}
cl.instance_eval{ @instance_type = object_type}
cl.instance_eval{ @super_class_name = super_names[name] || :Object}
object_type.instance_eval{ @object_class = cl }
end
end
def self.fix_object_type(object)
return unless object
return if object.is_a?(::Integer)
return if object.is_a?(::Symbol)
return if object.type
Parfait.set_type_for(object)
object.type.names.each do |name|
value = object.get_instance_variable(name)
fix_object_type(value)
end
return unless object.is_a?(List)
object.each {|obj| fix_object_type(obj)}
end
# superclasses other than default object
def self.super_class_names
{ Data4: :DataObject ,
@ -123,14 +142,5 @@ module Parfait
Word: {char_length: :Integer , next_word: :Word} ,
}
end
def self.name_for_index(object , index)
return :type if index == 0
clazz = object.class.name.split("::").last.to_sym
cl = self.type_names[clazz]
keys = cl.keys
keys[index - 1] # -1 because type is excluded in the lists (FIX)
# FIXME Now that we use instance variables in parfait, they should be parsed
# and the type_names generated automatically
end
end