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:
31
lib/risc/position/instruction_position.rb
Normal file
31
lib/risc/position/instruction_position.rb
Normal 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
|
Reference in New Issue
Block a user