From 696886cc94f614ce44758af1523e5e488e3447a0 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sat, 31 Mar 2018 19:12:06 +0300 Subject: [PATCH] remove Data2 in favour of Data4 as we write a Marker, type and marker make up 2 so data2 is just the type, not useful --- lib/parfait/data_object.rb | 8 ++++---- lib/parfait/integer.rb | 17 ++++++++++------- lib/risc/boot.rb | 6 +++--- lib/risc/text_writer.rb | 4 ++-- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/parfait/data_object.rb b/lib/parfait/data_object.rb index 61f0d3ef..136ab8aa 100644 --- a/lib/parfait/data_object.rb +++ b/lib/parfait/data_object.rb @@ -13,8 +13,8 @@ # logical and math operation that are bundled into the OperatorInstruction. # # For safe access the access code needs to know the length of the data, which is -# encoded in the class/type name. Ie An Integer derives from Data2, which is 2 long -# (minus one for the type, so exactly the one word for the integer) +# encoded in the class/type name. Ie An Integer derives from Data4, which is 4 long +# ( one for the type, one for the next, one word for the integer and currently still a marker) # # DataObjects still have a type, and so can have objects before the data starts # @@ -44,9 +44,9 @@ module Parfait end end - class Data2 < DataObject + class Data4 < DataObject def data_length - 1 + 3 end def padded_length 2 * 4 diff --git a/lib/parfait/integer.rb b/lib/parfait/integer.rb index 3db59623..3a566437 100644 --- a/lib/parfait/integer.rb +++ b/lib/parfait/integer.rb @@ -7,15 +7,18 @@ # Ie it would be possible to change the value, we just don't support that) module Parfait - class Integer < Data2 + class Integer < Data4 - #FIXME: this is "just" for compilation - def initialize(value) + def initialize(value , next_i = nil) super() @value = value + @next_i = next_i end - attr_reader :value + attr_reader :next_i, :value + def self.integer_index + 3 # 1 type, 2 next_i + end # :integer?, :odd?, :even?, :upto, :downto, :times, :succ, :next, :pred, :chr, :ord, :to_i, :to_int, :floor, # :ceil, :truncate, :round, :gcd, :lcm, :gcdlcm, :numerator, :denominator, :to_r, :rationalize, # :singleton_method_added, :coerce, :i, :+@, :-@, :fdiv, :div, :divmod, :%, :modulo, :remainder, :abs, :magnitude, @@ -30,19 +33,19 @@ module Parfait end # adding other base classes in here for now: - class FalseClass < Data2 + class FalseClass < Data4 #FIXME: this is "just" for compilation def initialize super end end - class TrueClass < Data2 + class TrueClass < Data4 #FIXME: this is "just" for compilation def initialize super end end - class NilClass < Data2 + class NilClass < Data4 #FIXME: this is "just" for compilation def initialize super diff --git a/lib/risc/boot.rb b/lib/risc/boot.rb index a5bb0195..8838ad07 100644 --- a/lib/risc/boot.rb +++ b/lib/risc/boot.rb @@ -117,7 +117,7 @@ module Risc # superclasses other than default object def super_class_names { Object: :Kernel , Kernel: :Value , BinaryCode: :Word , - Data2: :DataObject ,Data8: :DataObject , Integer: :Data2, Word: :Data8} + Data4: :DataObject ,Data8: :DataObject , Integer: :Data4, Word: :Data8} end # the function really just returns a constant (just avoiding the constant) @@ -129,9 +129,9 @@ module Risc Message: { next_message: :Message, receiver: :Object, frame: :NamedList , return_address: :Integer, return_value: :Integer, caller: :Message , name: :Word , arguments: :NamedList }, - Integer: {}, + Integer: {next_i: :Integer}, DataObject: {}, - Data2: {}, + Data4: {}, Data8: {}, TrueClass: {}, FalseClass: {}, diff --git a/lib/risc/text_writer.rb b/lib/risc/text_writer.rb index 8143b9d7..0098c0af 100644 --- a/lib/risc/text_writer.rb +++ b/lib/risc/text_writer.rb @@ -87,7 +87,7 @@ module Risc write_String obj when Parfait::BinaryCode write_BinaryCode obj - when Parfait::Data2 + when Parfait::Data4 write_data2 obj else write_object obj @@ -143,7 +143,7 @@ module Risc def write_data2( code ) @stream.write_signed_int_32( MARKER ) write_ref_for( code.get_type ) - log.debug "Data2 witten stream 0x#{@stream.length.to_s(16)}" + log.debug "Data4 witten stream 0x#{@stream.length.to_s(16)}" end def write_BinaryCode( code )