rename position accessor
for future
This commit is contained in:
parent
c60949fe24
commit
80237e5033
@ -33,7 +33,7 @@ module Register
|
|||||||
@machine.objects.each do |id , objekt|
|
@machine.objects.each do |id , objekt|
|
||||||
next unless objekt.is_a? Parfait::TypedMethod
|
next unless objekt.is_a? Parfait::TypedMethod
|
||||||
binary = objekt.binary
|
binary = objekt.binary
|
||||||
binary.position = at
|
binary.set_position at
|
||||||
objekt.instructions.set_position at + 12 # BinaryCode header
|
objekt.instructions.set_position at + 12 # BinaryCode header
|
||||||
len = objekt.instructions.total_byte_length
|
len = objekt.instructions.total_byte_length
|
||||||
log.debug "CODE #{objekt.name} at #{binary.position} len: #{len}"
|
log.debug "CODE #{objekt.name} at #{binary.position} len: #{len}"
|
||||||
@ -50,7 +50,7 @@ module Register
|
|||||||
@machine.objects.each do | id , objekt|
|
@machine.objects.each do | id , objekt|
|
||||||
next if objekt.is_a? Register::Label # will get assembled as method.instructions
|
next if objekt.is_a? Register::Label # will get assembled as method.instructions
|
||||||
next if objekt.is_a? Parfait::BinaryCode
|
next if objekt.is_a? Parfait::BinaryCode
|
||||||
objekt.position = at
|
objekt.set_position at
|
||||||
at += objekt.padded_length
|
at += objekt.padded_length
|
||||||
end
|
end
|
||||||
at
|
at
|
||||||
|
@ -100,7 +100,7 @@ module Register
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_position position , labels = []
|
def set_position position , labels = []
|
||||||
self.position = position
|
super(position)
|
||||||
position += byte_length
|
position += byte_length
|
||||||
if self.next
|
if self.next
|
||||||
self.next.set_position(position , labels)
|
self.next.set_position(position , labels)
|
||||||
|
@ -35,7 +35,7 @@ module Register
|
|||||||
|
|
||||||
# labels have the same position as their next
|
# labels have the same position as their next
|
||||||
def set_position position , labels = []
|
def set_position position , labels = []
|
||||||
position = self.label.set_position( position , labels ) if self.label
|
set_position self.label.set_position( position , labels ) if self.label
|
||||||
super(position,labels)
|
super(position,labels)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ module Register
|
|||||||
def to_s
|
def to_s
|
||||||
"Label: #{@name} (#{self.next.class.name.split("::").last})"
|
"Label: #{@name} (#{self.next.class.name.split("::").last})"
|
||||||
end
|
end
|
||||||
|
|
||||||
def sof_reference_name
|
def sof_reference_name
|
||||||
@name
|
@name
|
||||||
end
|
end
|
||||||
@ -61,7 +62,7 @@ module Register
|
|||||||
def set_position position , labels = []
|
def set_position position , labels = []
|
||||||
return position if labels.include?(self)
|
return position if labels.include?(self)
|
||||||
labels << self
|
labels << self
|
||||||
self.position = position
|
super(position , labels)
|
||||||
self.next.set_position(position,labels)
|
self.next.set_position(position,labels)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ module Positioned
|
|||||||
end
|
end
|
||||||
pos
|
pos
|
||||||
end
|
end
|
||||||
def position= pos
|
def set_position( pos )
|
||||||
raise "Position must be number not :#{pos}:" unless pos.is_a?(Numeric)
|
raise "Position must be number not :#{pos}:" unless pos.is_a?(Numeric)
|
||||||
# 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)
|
||||||
|
@ -38,7 +38,6 @@ module Parfait
|
|||||||
|
|
||||||
def compile_time_init
|
def compile_time_init
|
||||||
@memory = Array.new(16)
|
@memory = Array.new(16)
|
||||||
@position = nil
|
|
||||||
self # for chaining
|
self # for chaining
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class TestLogic < MiniTest::Test
|
|||||||
|
|
||||||
def label pos = 0x22
|
def label pos = 0x22
|
||||||
l = Register.label("some" , "Label")
|
l = Register.label("some" , "Label")
|
||||||
l.position = pos
|
l.set_position pos
|
||||||
l
|
l
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,13 +32,13 @@ class TestPositioning < MiniTest::Test
|
|||||||
assert_raises { TestPosition.new.position}
|
assert_raises { TestPosition.new.position}
|
||||||
end
|
end
|
||||||
def test_raises_set_nil
|
def test_raises_set_nil
|
||||||
assert_raises { TestPosition.new.position = nil}
|
assert_raises { TestPosition.new.set_position nil}
|
||||||
end
|
end
|
||||||
def test_raises_reset_far
|
def test_raises_reset_far
|
||||||
assert_raises do
|
assert_raises do
|
||||||
test = TestPosition.new
|
test = TestPosition.new
|
||||||
test.position = 0
|
test.set_position 0
|
||||||
test.position = 12000
|
test.set_position 12000
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user