seperate different Position classes into own files

also tests
and have Position module keep all positions
(singletons should be at module, not class level)
This commit is contained in:
Torsten Ruger
2018-05-10 20:56:12 +03:00
parent 1169fa7220
commit bc1e29e4f6
9 changed files with 192 additions and 145 deletions

View File

@ -0,0 +1,31 @@
module Risc
module Position
class InstructionPosition < ObjectPosition
attr_reader :instruction , :binary
def initialize(instruction, pos , binary)
raise "not set " unless binary
super(pos)
@instruction = instruction
@binary = binary
end
def init(at)
return unless instruction.next
at += instruction.byte_length
bin = binary
if( 12 == at % 60)
at = 12
bin = binary.next
end
Position.set(instruction.next, at , binary)
end
def reset_to(pos)
super(pos)
#puts "Reset (#{changed}) #{instruction}"
init(pos)
end
end
end
end