From bea10cc5603ec88c9e1b9ff722307ba1a8becb79 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sat, 30 May 2015 11:55:46 +0300 Subject: [PATCH] fix bug where layout wasn't initialized --- lib/parfait/module.rb | 1 + lib/parfait/object.rb | 5 +++++ lib/register/assembler.rb | 12 ++++++++---- lib/virtual/boot.rb | 11 +++++------ lib/virtual/parfait_adapter.rb | 5 ++++- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/parfait/module.rb b/lib/parfait/module.rb index d0684cb6..0fab35ac 100644 --- a/lib/parfait/module.rb +++ b/lib/parfait/module.rb @@ -14,6 +14,7 @@ module Parfait class Module < Object def initialize name , superclass + super() @name = name @instance_methods = [] @name = name diff --git a/lib/parfait/object.rb b/lib/parfait/object.rb index 2308eaee..2501b22d 100644 --- a/lib/parfait/object.rb +++ b/lib/parfait/object.rb @@ -43,6 +43,11 @@ module Parfait # private def set_layout(layout) + if( internal_object_get(LAYOUT_INDEX) ) + #TODO find out wat these objects are + # puts "Layout was set for #{self.class}" + return + end internal_object_set(LAYOUT_INDEX , layout) end diff --git a/lib/register/assembler.rb b/lib/register/assembler.rb index 08514dfc..31a44317 100644 --- a/lib/register/assembler.rb +++ b/lib/register/assembler.rb @@ -179,15 +179,19 @@ module Register pad_after( count ) end - def assemble_String( str ) - str = str.string if str.is_a? Parfait::Word - str = str.to_s if str.is_a? Symbol + def assemble_BinaryCode code + assemble_String code + end + + def assemble_String( string ) + str = string.to_s if string.is_a? Parfait::Word + str = string.to_s if str.is_a? Symbol word = (str.length + 7) / 32 # all object are multiple of 8 words (7 for header) raise "String too long (implement split string!) #{word}" if word > 15 # first line is integers, convention is that following lines are the same TYPE_LENGTH.times { word = ((word << TYPE_BITS) + TYPE_INT) } @stream.write_uint32( word ) - write_ref_for( str.layout[:names] ) #ref + write_ref_for( string.get_layout ) #ref @stream.write str pad_after(str.length) #puts "String (#{slot.mem_length}) stream #{@stream.mem_length.to_s(16)}" diff --git a/lib/virtual/boot.rb b/lib/virtual/boot.rb index 7373a807..5a8ed233 100644 --- a/lib/virtual/boot.rb +++ b/lib/virtual/boot.rb @@ -26,7 +26,7 @@ module Virtual layouts = { "Word" => [] , "List" => [] , "Message" => [], - "BinaryCode" => [], + "BinaryCode" => [], "Space" => ["classes","objects","frames","messages","next_message","next_frame"], "Frame" => ["locals" , "tmps" ], "Layout" => ["object_class"] , @@ -51,6 +51,7 @@ module Virtual clazz.object_layout.add_instance_variable Virtual.new_word(var_name) end end + # now store the classes so we can hand them out later during object creation # this can not be done earlier, as parfait objects are all the time created and would # lookup half created class info @@ -61,11 +62,9 @@ module Virtual class_mappings["Object"] = value_classes[3] #need for further booting # add space and instances which get created before the objects list - @space.add_object @space - @space.add_object @space.classes - @space.add_object @space.classes.keys - @space.add_object @space.classes.values - @space.add_object @space.objects + [@space,@space.classes,@space.classes.keys, @space.classes.values,@space.objects].each do |o| + @space.add_object o + end @space.late_init diff --git a/lib/virtual/parfait_adapter.rb b/lib/virtual/parfait_adapter.rb index bb4b7ea3..a364b223 100644 --- a/lib/virtual/parfait_adapter.rb +++ b/lib/virtual/parfait_adapter.rb @@ -11,7 +11,10 @@ module FakeMem @length = -1 if Parfait::Space.object_space and Parfait::Space.object_space.objects Parfait::Space.object_space.add_object self - end #Note: the else is handled in boot, by ading the space "by hand", as it slips though + else + #Note: the else is handled in boot, by ading the space "by hand", as it slips though + #puts "Got away #{self.class}" + end init_layout if Virtual::Machine.instance.class_mappings end def init_layout