2018-05-28 13:46:26 +02:00
|
|
|
require_relative "fake_memory"
|
|
|
|
|
|
|
|
module Parfait
|
|
|
|
class DataObject < Object
|
|
|
|
|
|
|
|
def self.allocate
|
|
|
|
r = super
|
2018-05-28 14:09:59 +02:00
|
|
|
r.instance_variable_set(:@memory , Risc::FakeMemory.new(self.type_length , self.memory_size))
|
2018-05-28 13:46:26 +02:00
|
|
|
r
|
|
|
|
end
|
|
|
|
|
|
|
|
# 0 -based index
|
|
|
|
def get_internal_word(index)
|
2018-05-28 14:45:29 +02:00
|
|
|
return super if index < self.class.type_length
|
2018-05-28 13:46:26 +02:00
|
|
|
@memory[index]
|
|
|
|
end
|
|
|
|
|
2018-05-28 17:20:09 +02:00
|
|
|
# 0 -based index
|
2018-05-28 13:46:26 +02:00
|
|
|
def set_internal_word(index , value)
|
2018-05-28 14:45:29 +02:00
|
|
|
return super if index < self.class.type_length
|
|
|
|
raise "Word[#{index}] = nil" if( value.nil? and self.class != List)
|
2018-05-28 13:46:26 +02:00
|
|
|
@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
|