2018-05-10 19:56:12 +02:00
|
|
|
module Risc
|
|
|
|
module Position
|
|
|
|
|
2018-05-11 17:36:45 +02:00
|
|
|
# BinaryCodes form a linked list
|
|
|
|
#
|
|
|
|
# We want to keep all code for a method continous, so we propagate Positions
|
|
|
|
#
|
2018-05-10 19:56:12 +02:00
|
|
|
class CodePosition < ObjectPosition
|
2018-05-11 17:36:45 +02:00
|
|
|
|
2018-05-10 19:56:12 +02:00
|
|
|
attr_reader :code , :method
|
2018-05-11 17:36:45 +02:00
|
|
|
|
2018-05-10 19:56:12 +02:00
|
|
|
def initialize(code, pos , method)
|
2018-05-11 17:36:45 +02:00
|
|
|
super(pos,code)
|
2018-05-10 19:56:12 +02:00
|
|
|
@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
|