propagating binary code position on extend
This commit is contained in:
parent
6a1528e75a
commit
1169fa7220
@ -17,13 +17,18 @@ module Parfait
|
|||||||
end
|
end
|
||||||
def extend_to(total_size)
|
def extend_to(total_size)
|
||||||
if total_size > self.data_length
|
if total_size > self.data_length
|
||||||
@next = BinaryCode.new(1) unless @next
|
unless @next
|
||||||
|
@next = BinaryCode.new(1)
|
||||||
|
#puts "extending #{total_size - data_length} in #{self}"
|
||||||
|
Risc::Position.reset(self) if Risc::Position.set?(self)
|
||||||
|
end
|
||||||
@next.extend_to(total_size - data_length)
|
@next.extend_to(total_size - data_length)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def to_s
|
def to_s
|
||||||
"BinaryCode #{}"
|
"BinaryCode #{Risc::Position.set?(self) ? Risc::Position.get(self): self.object_id.to_s(16)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def each_word
|
def each_word
|
||||||
index = 1
|
index = 1
|
||||||
while( index <= data_length)
|
while( index <= data_length)
|
||||||
|
@ -66,6 +66,13 @@ module Risc
|
|||||||
pos
|
pos
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# set to the same position as before, thus triggering whatever code that propagates
|
||||||
|
# position _must have been set, otherwise raises
|
||||||
|
def self.reset(obj)
|
||||||
|
old = self.get(obj)
|
||||||
|
old.reset_to( old.at )
|
||||||
|
end
|
||||||
|
|
||||||
def self.set( object , pos , extra = nil)
|
def self.set( object , pos , extra = nil)
|
||||||
# resetting of position used to be error, but since relink and dynamic instruction size it is ok.
|
# resetting of position used to be error, but since relink and dynamic instruction size it is ok.
|
||||||
# in measures (of 32)
|
# in measures (of 32)
|
||||||
@ -92,6 +99,7 @@ module Risc
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# handle event propagation
|
# handle event propagation
|
||||||
class IPosition < Position
|
class IPosition < Position
|
||||||
attr_reader :instruction , :binary
|
attr_reader :instruction , :binary
|
||||||
@ -131,5 +139,10 @@ module Risc
|
|||||||
return unless code.next
|
return unless code.next
|
||||||
Position.set(code.next , at + code.padded_length, method)
|
Position.set(code.next , at + code.padded_length, method)
|
||||||
end
|
end
|
||||||
|
def reset_to(pos)
|
||||||
|
super(pos)
|
||||||
|
#puts "Reset (#{changed}) #{instruction}"
|
||||||
|
init(pos)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -29,10 +29,15 @@ 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_bin_propagates
|
def test_bin_propagates_existing
|
||||||
@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)
|
||||||
assert_equal @binary.padded_length , Position.get(@binary.next).at
|
assert_equal @binary.padded_length , Position.get(@binary.next).at
|
||||||
end
|
end
|
||||||
|
def test_bin_propagates_after
|
||||||
|
Position.set( @binary , 0 , Parfait.object_space.get_main)
|
||||||
|
@binary.extend_to(16)
|
||||||
|
assert_equal @binary.padded_length , Position.get(@binary.next).at
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user