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
This commit is contained in:
Torsten Ruger 2018-03-31 19:12:06 +03:00
parent a5189570c6
commit 696886cc94
4 changed files with 19 additions and 16 deletions

View File

@ -13,8 +13,8 @@
# logical and math operation that are bundled into the OperatorInstruction. # 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 # 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 # encoded in the class/type name. Ie An Integer derives from Data4, which is 4 long
# (minus one for the type, so exactly the one word for the integer) # ( 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 # DataObjects still have a type, and so can have objects before the data starts
# #
@ -44,9 +44,9 @@ module Parfait
end end
end end
class Data2 < DataObject class Data4 < DataObject
def data_length def data_length
1 3
end end
def padded_length def padded_length
2 * 4 2 * 4

View File

@ -7,15 +7,18 @@
# Ie it would be possible to change the value, we just don't support that) # Ie it would be possible to change the value, we just don't support that)
module Parfait module Parfait
class Integer < Data2 class Integer < Data4
#FIXME: this is "just" for compilation def initialize(value , next_i = nil)
def initialize(value)
super() super()
@value = value @value = value
@next_i = next_i
end 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, # :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, # :ceil, :truncate, :round, :gcd, :lcm, :gcdlcm, :numerator, :denominator, :to_r, :rationalize,
# :singleton_method_added, :coerce, :i, :+@, :-@, :fdiv, :div, :divmod, :%, :modulo, :remainder, :abs, :magnitude, # :singleton_method_added, :coerce, :i, :+@, :-@, :fdiv, :div, :divmod, :%, :modulo, :remainder, :abs, :magnitude,
@ -30,19 +33,19 @@ module Parfait
end end
# adding other base classes in here for now: # adding other base classes in here for now:
class FalseClass < Data2 class FalseClass < Data4
#FIXME: this is "just" for compilation #FIXME: this is "just" for compilation
def initialize def initialize
super super
end end
end end
class TrueClass < Data2 class TrueClass < Data4
#FIXME: this is "just" for compilation #FIXME: this is "just" for compilation
def initialize def initialize
super super
end end
end end
class NilClass < Data2 class NilClass < Data4
#FIXME: this is "just" for compilation #FIXME: this is "just" for compilation
def initialize def initialize
super super

View File

@ -117,7 +117,7 @@ module Risc
# superclasses other than default object # superclasses other than default object
def super_class_names def super_class_names
{ Object: :Kernel , Kernel: :Value , BinaryCode: :Word , { Object: :Kernel , Kernel: :Value , BinaryCode: :Word ,
Data2: :DataObject ,Data8: :DataObject , Integer: :Data2, Word: :Data8} Data4: :DataObject ,Data8: :DataObject , Integer: :Data4, Word: :Data8}
end end
# the function really just returns a constant (just avoiding the constant) # 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 , Message: { next_message: :Message, receiver: :Object, frame: :NamedList ,
return_address: :Integer, return_value: :Integer, return_address: :Integer, return_value: :Integer,
caller: :Message , name: :Word , arguments: :NamedList }, caller: :Message , name: :Word , arguments: :NamedList },
Integer: {}, Integer: {next_i: :Integer},
DataObject: {}, DataObject: {},
Data2: {}, Data4: {},
Data8: {}, Data8: {},
TrueClass: {}, TrueClass: {},
FalseClass: {}, FalseClass: {},

View File

@ -87,7 +87,7 @@ module Risc
write_String obj write_String obj
when Parfait::BinaryCode when Parfait::BinaryCode
write_BinaryCode obj write_BinaryCode obj
when Parfait::Data2 when Parfait::Data4
write_data2 obj write_data2 obj
else else
write_object obj write_object obj
@ -143,7 +143,7 @@ module Risc
def write_data2( code ) def write_data2( code )
@stream.write_signed_int_32( MARKER ) @stream.write_signed_int_32( MARKER )
write_ref_for( code.get_type ) 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 end
def write_BinaryCode( code ) def write_BinaryCode( code )