Fix instruction resetting
which happens on insert of a new instruction
This commit is contained in:
parent
7ca7e92dda
commit
6a1528e75a
@ -24,7 +24,8 @@ module Arm
|
|||||||
def insert(instruction)
|
def insert(instruction)
|
||||||
super
|
super
|
||||||
my_pos = Risc::Position.get(self)
|
my_pos = Risc::Position.get(self)
|
||||||
Risc::Position.set( my_pos + self.byte_length , 0 , my_pos.binary)
|
# set my position to set next according to rules
|
||||||
|
Risc::Position.set( self , my_pos.at , my_pos.binary)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -114,11 +114,9 @@ module Risc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def reset_to(pos)
|
def reset_to(pos)
|
||||||
changed = super(pos)
|
super(pos)
|
||||||
#puts "Reset (#{changed}) #{instruction}"
|
#puts "Reset (#{changed}) #{instruction}"
|
||||||
return unless changed
|
init(pos)
|
||||||
return unless instruction.next
|
|
||||||
instruction.next.set_position( pos + instruction.byte_length , 0)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -21,6 +21,14 @@ module Risc
|
|||||||
Position.set( @label , 0 , @binary)
|
Position.set( @label , 0 , @binary)
|
||||||
assert_equal 0 , Position.get(@label.next).at
|
assert_equal 0 , Position.get(@label.next).at
|
||||||
end
|
end
|
||||||
|
def test_ins_propagates_again
|
||||||
|
second = Arm::ArmMachine.b( @label)
|
||||||
|
@label.set_next(second)
|
||||||
|
Position.set( @label , 0 , @binary)
|
||||||
|
Position.set(second , 2 , @binary)
|
||||||
|
Position.set( @label , 0 , @binary)
|
||||||
|
assert_equal 0 , Position.get(@label.next).at
|
||||||
|
end
|
||||||
def test_bin_propagates
|
def test_bin_propagates
|
||||||
@binary.extend_to(16)
|
@binary.extend_to(16)
|
||||||
Position.set( @binary , 0 , Parfait.object_space.get_main)
|
Position.set( @binary , 0 , Parfait.object_space.get_main)
|
||||||
|
Loading…
Reference in New Issue
Block a user