use fake memory

fix integer offset bug
(which only didn’t cause errors as fixnums are still an order too big
and the famous +1 error hit the empty space)
This commit is contained in:
Torsten Ruger
2018-05-28 15:09:59 +03:00
parent 6c06f61ab8
commit f9a89db10c
14 changed files with 42 additions and 20 deletions

View File

@ -8,10 +8,13 @@ module Parfait
#
class BinaryCode < Data16
attr_reader :next
def self.offset
2 * 4 # size of type (2, type+next) * word_size (4)
end
def self.type_length
2 #type + next (could get from space, maybe later)
end
def self.byte_offset
self.type_length * 4 # size of type * word_size (4)
end
#16 - 2 -1 , two instance variables and one for the jump
def self.data_length
13
@ -45,7 +48,7 @@ module Parfait
def each_block( &block )
block.call( self )
@next.each( &block ) if @next
@next.each_block( &block ) if @next
end
def to_s
@ -68,8 +71,9 @@ module Parfait
#raise "invalid index #{index}" unless @next
extend_to( index )
@next.set_word( index - data_length , word)
else
set_internal_word(index + 2 , word)
end
set_internal_word(index + 2 , word)
end
def set_last(word)
set_word( data_length , word)

View File

@ -24,6 +24,9 @@ module Parfait
def initialize
super
end
def self.integer_index
type_length
end
def data_length
raise "called #{self}"
end

View File

@ -19,8 +19,12 @@ module Parfait
def value
get_internal_word(Integer.integer_index)
end
def self.type_length
2 # 0 type, 1 next_i
end
def self.integer_index
3 # 1 type, 2 next_i
type_length
end
# :integer?, :odd?, :even?, :upto, :downto, :times, :succ, :next, :pred, :chr, :ord, :to_i, :to_int, :floor,
@ -42,17 +46,26 @@ module Parfait
def initialize
super
end
def self.type_length
1 # 0 type
end
end
class TrueClass < Data4
#FIXME: this is "just" for compilation
def initialize
super
end
def self.type_length
1 # 0 type
end
end
class NilClass < Data4
#FIXME: this is "just" for compilation
def initialize
super
end
def self.type_length
1 # 0 type
end
end
end

View File

@ -19,6 +19,9 @@ module Parfait
def self.get_length_index
2 # 2 is the amount of attributes, type and char_length. the offset after which chars start
end
def self.type_length
2 # 0 type , 1 char_length
end
def self.get_indexed( i )
i + get_length_index * 4
end