rubyx/lib/virtual/positioned.rb

20 lines
514 B
Ruby
Raw Normal View History

require_relative "type"
module Positioned
def position
2015-05-30 11:20:39 +02:00
if @position == nil
raise "position accessed but not set at #{word_length} for #{self.inspect[0...500]}"
2015-05-30 11:20:39 +02:00
end
@position
end
def set_position pos
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}"
end
@position = pos
end
end