2015-10-10 11:39:09 +02:00
|
|
|
#require_relative "type"
|
2014-09-16 15:06:56 +02:00
|
|
|
|
2014-09-25 19:30:02 +02:00
|
|
|
module Positioned
|
|
|
|
def position
|
2015-06-08 11:37:20 +02:00
|
|
|
if @position.nil?
|
2015-10-22 17:16:29 +02:00
|
|
|
str = "IN machine #{Register.machine.objects.has_key?(self.object_id)}, at #{self.object_id.to_s(16)}\n"
|
2015-06-08 11:52:56 +02:00
|
|
|
raise str + "position not set for #{self.class} len #{word_length} for #{self.inspect[0...100]}"
|
2015-05-30 11:20:39 +02:00
|
|
|
end
|
2014-09-25 19:30:02 +02:00
|
|
|
@position
|
|
|
|
end
|
2015-10-24 16:12:36 +02:00
|
|
|
def position= pos
|
2015-06-08 11:37:20 +02:00
|
|
|
raise "Setting of nil not allowed" if pos.nil?
|
2015-05-13 15:06:38 +02:00
|
|
|
# resetting of position used to be error, but since relink and dynamic instruction size it is ok.
|
|
|
|
# in measures (of 32)
|
2014-09-28 10:18:24 +02:00
|
|
|
if @position != nil and ((@position - pos).abs > 32)
|
2015-05-04 10:10:40 +02:00
|
|
|
raise "position set again #{pos}!=#{@position} for #{self}"
|
2014-09-25 19:30:02 +02:00
|
|
|
end
|
|
|
|
@position = pos
|
|
|
|
end
|
2014-06-26 17:39:02 +02:00
|
|
|
end
|