work on ObjectWriter

Back to the root! but lots of adjusting
ObjectWriter takes machine, machine has space
Virtual constants become Parfait::Objects etc
This commit is contained in:
Torsten Ruger
2015-05-16 12:53:10 +03:00
parent 9d8dc68bf4
commit 9376b8bc16
12 changed files with 65 additions and 50 deletions

View File

@ -22,5 +22,8 @@
module Parfait
class Layout < List
def get_object_class()
return internal_object_get(2)
end
end
end

View File

@ -42,6 +42,15 @@ module Parfait
self.length == 0
end
def each
index = 0
while index < self.length
item = get(index)
yield item
index = index + 1
end
self
end
def grow_to(len)
raise "negative length for grow #{len}" if len < 0
return unless len > self.length

View File

@ -16,10 +16,16 @@ module Parfait
# In Salama we store the class in the Layout, and so the Layout is the only fixed
# data that every object carries.
def get_class()
@layout.get_class()
l = get_layout()
puts "Layout #{l}"
l.get_object_class()
end
# class stores the "latest" layout for instances, ir the layout a new object will
def get_layout()
return internal_object_get(1)
end
# class stores the "latest" layout for instances, ie the layout a new object will
# be created with.
# inside parfait (and for now everywhere) these are constant.
@@EMPTY = { :names => [] , :types => []}
@ -27,12 +33,8 @@ module Parfait
@@EMPTY
end
def get_layout()
@layout
end
def instance_variables
@layout.instance_variables
get_layout().instance_variables
end
def instance_variable_get name
@ -48,7 +50,7 @@ module Parfait
end
def instance_variable_defined name
@layout.index_of(name)
layout().index_of(name)
end
# Object

View File

@ -33,7 +33,7 @@ module Parfait
@next_message = @messages.first
@next_frame = @frames.first
end
attr_reader :init , :main , :classes , :objects , :symbols,:messages, :next_message , :next_frame
attr_reader :classes , :objects , :symbols,:messages, :next_message , :next_frame
@@SPACE = { :names => [:classes,:objects,:symbols,:messages, :next_message , :next_frame] ,
:types => [Virtual::Reference,Virtual::Reference,Virtual::Reference,Virtual::Reference,Virtual::Reference]}
@ -50,7 +50,7 @@ module Parfait
end
end
# this is the way to instantiate classes (not BootClass.new)
# this is the way to instantiate classes (not Parfait::Class.new)
# so we get and keep exactly one per name
def get_or_create_class name
raise "uups #{name}.#{name.class}" unless name.is_a? Symbol

View File

@ -78,12 +78,6 @@ module Parfait
raise "called"
class_for(MoveInstruction).new(value , self , :opcode => :mov)
end
def clazz
Space.space.get_or_create_class(:Word)
end
def layout
Virtual::Object.layout
end
def mem_length
padded(1 + string.length)
end