bc1e29e4f6
also tests and have Position module keep all positions (singletons should be at module, not class level)
23 lines
487 B
Ruby
23 lines
487 B
Ruby
module Risc
|
|
module Position
|
|
|
|
class CodePosition < ObjectPosition
|
|
attr_reader :code , :method
|
|
def initialize(code, pos , method)
|
|
super(pos)
|
|
@code = code
|
|
@method = method
|
|
end
|
|
def init(at)
|
|
return unless code.next
|
|
Position.set(code.next , at + code.padded_length, method)
|
|
end
|
|
def reset_to(pos)
|
|
super(pos)
|
|
#puts "Reset (#{changed}) #{instruction}"
|
|
init(pos)
|
|
end
|
|
end
|
|
end
|
|
end
|