Steamline objectPosition init

check for resetting on the same position with different class, which
should not happen
Ie it’s ok for an object to push another object up,
but not for an instruction to land on code
This commit is contained in:
Torsten Ruger
2018-05-23 21:34:49 +03:00
parent f5d1090c39
commit 8ca70a6835
6 changed files with 39 additions and 31 deletions

View File

@ -18,26 +18,26 @@ module Risc
attr_reader :instruction , :binary
def initialize(instruction, pos , binary)
raise "not set " unless binary
super(pos, instruction)
super(instruction,pos)
@instruction = instruction
@binary = binary
end
def init(at)
diff = at - Position.get(@binary).at
if( diff % 60 == 12*4)
if( diff % 60 == 13*4)
@binary.extend_one unless @binary.next
@binary = @binary.next
raise "end of line " unless @binary
at = Position.get(@binary).at + 3*4
at = Position.get(@binary).at + Parfait::BinaryCode.offset
end
return unless instruction.next
at += instruction.byte_length
Position.set(instruction.next, at , binary)
return unless @instruction.next
at += @instruction.byte_length
Position.set(@instruction.next, at , @binary)
end
def reset_to(pos)
super(pos)
#puts "Reset (#{changed}) #{instruction}"
Position.log.debug "Reset (#{pos}) #{instruction}"
init(pos)
end
end