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

@ -14,9 +14,7 @@ module Parfait
end
def methods
m = @instance_methods
return m if m
@instance_methods = List.new
@instance_methods
end
def method_names

View File

@ -29,7 +29,7 @@ module Parfait
@for_type = type
@attribute_name = type.names.find {|name| name.to_s.start_with?("next")}
@page_size = page
raise "No next found for #{type.class_name}" unless attribute_name
raise "No next found for #{type.class_name}" unless @attribute_name
end
# get the next free object, advancing the list.
@ -37,7 +37,7 @@ module Parfait
# This function is not realy used, as it is hard-coded in risc, but the get_more is
# used, as it get's called from risc (or will)
def get_next_object
unless( next_object )
unless( @next_object )
@next_object = reserve
get_more
end
@ -46,7 +46,7 @@ module Parfait
# this gets the head of the freelist, swaps it out agains the next and returns it
def get_head
nekst = next_object
nekst = @next_object
@next_object = get_next_for(nekst)
return nekst
end
@ -117,7 +117,6 @@ module Parfait
r_class = eval( "Parfait::#{type.object_class.name}" )
obj = r_class.allocate
obj.set_type(type)
#puts "Factory #{type.object_class.name} at 0x#{obj.object_id.to_s(16)}"
obj
end
end

View File

@ -10,7 +10,7 @@ module Parfait
attr_reader :indexed_length , :next_list
def self.type_length
3 # 0 type , 1 length , 2 - next_list
3 # 0 type , 1 indexed_length , 2 - next_list
end
def self.data_length
self.memory_size - self.type_length - 1
@ -19,6 +19,7 @@ module Parfait
def initialize
super
@indexed_length = 0
@next_list = nil
end
def data_length

View File

@ -64,7 +64,7 @@ module Parfait
end
def get_type()
raise "No type " + self.object_id.to_s(16) + ":" + self.class.name unless has_type?
raise "No type " + self.object_id.to_s(16) + " : " + self.class.name+" : " + self.to_s unless @type
@type
end

View File

@ -57,13 +57,7 @@ module Parfait
# type to the global list
def initialize( object_class , hash )
super()
set_object_class( object_class)
init_lists( hash )
end
# this part of the init is seperate because at boot time we can not use normal new
# new is overloaded to grab the type from space, and before boot, that is not set up
def init_lists(hash)
@object_class = object_class
@methods = nil
@names = List.new
@types = List.new
@ -75,13 +69,13 @@ module Parfait
end
def class_name
@object_class.name
@object_class&.name
end
def to_s
str = "#{class_name}-["
first = false
names.each do |name|
@names.each do |name|
unless(first)
first = true
str += ":#{name}"
@ -196,13 +190,6 @@ module Parfait
return Type.for_hash( hash , object_class)
end
def set_object_class(oc)
unless oc.is_a?(Class) #but during boot a symbol is ok
raise "object class should be a class, not #{oc.class}" unless oc.is_a?(Symbol)
end
@object_class = oc
end
def instance_length
@names.get_length()
end

View File

@ -13,13 +13,13 @@ module Parfait
# Object length is measured in non-type cells though
class Word < Data8
attr_reader :char_length
attr_reader :char_length , :next_word
def self.type_length
2 # 0 type , 1 char_length
3 # 0 type , 1 char_length , next_word
end
def self.get_length_index
type_length - 1
type_length - 2
end
# initialize with length. For now we try to keep all non-parfait (including String) out
# String will contain spaces for non-zero length