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:
parent
a5189570c6
commit
696886cc94
@ -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
|
||||
|
@ -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
|
||||
|
@ -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: {},
|
||||
|
@ -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 )
|
||||
|
Loading…
Reference in New Issue
Block a user