move all position setting into position

Position and subclasses handle the logic, external to
the classes, so it can be swapped out later
(at runtime positions can’t change)
This commit is contained in:
Torsten Ruger
2018-05-07 22:30:43 +03:00
parent 68fb9b1bdc
commit ce3cc72f9e
10 changed files with 52 additions and 123 deletions

View File

@ -24,23 +24,7 @@ module Arm
def insert(instruction)
super
my_pos = Risc::Position.get(self)
@next.set_position( my_pos + self.byte_length , 0 , my_pos.binary)
Risc::Position.set( my_pos + self.byte_length , 0 , my_pos.binary)
end
def set_position( position , count , extra = nil)
Risc::Position.set(self,position , extra)
position += byte_length
if self.next
count += 1 #assumes 4 byte instructions, as does the whole setup
if( 0 == count % 12) # 12 is the amount of instructions that fit into a BinaryCode
count = 0
position += 12 # 12=3*4 , 3 for marker,type,next words to jump over
end
self.next.set_position( position , count , extra)
else
position
end
end
end
end