start on fake memory

get index checks on the array access of parfait
This commit is contained in:
Torsten Ruger
2018-05-28 14:46:26 +03:00
parent be1bc63ff2
commit 6c06f61ab8
7 changed files with 143 additions and 33 deletions

View File

@ -0,0 +1,43 @@
require_relative "fake_memory"
module Parfait
class DataObject < Object
def self.allocate
r = super
puts "#{self.memory_size}"
r.instance_variable_set(:@memory , [])
r
end
# 0 -based index
def get_internal_word(index)
return super if index < data_start
@memory[index]
end
# 1 -based index
def set_internal_word(index , value)
return super if index < data_start
raise "Word[#{index}] = nil" if( value.nil? )
@memory[index] = value
value
end
end
end
class Symbol
def has_type?
true
end
def get_type
l = Parfait.object_space.classes[:Word].instance_type
#puts "LL #{l.class}"
l
end
def padded_length
Padding.padded( to_s.length + 4)
end
end