rename position accessor

for future
This commit is contained in:
Torsten Ruger 2016-12-28 21:40:06 +02:00
parent c60949fe24
commit 80237e5033
8 changed files with 11 additions and 11 deletions

View File

@ -33,7 +33,7 @@ module Register
@machine.objects.each do |id , objekt|
next unless objekt.is_a? Parfait::TypedMethod
binary = objekt.binary
binary.position = at
binary.set_position at
objekt.instructions.set_position at + 12 # BinaryCode header
len = objekt.instructions.total_byte_length
log.debug "CODE #{objekt.name} at #{binary.position} len: #{len}"
@ -50,7 +50,7 @@ module Register
@machine.objects.each do | id , objekt|
next if objekt.is_a? Register::Label # will get assembled as method.instructions
next if objekt.is_a? Parfait::BinaryCode
objekt.position = at
objekt.set_position at
at += objekt.padded_length
end
at

View File

@ -100,7 +100,7 @@ module Register
end
def set_position position , labels = []
self.position = position
super(position)
position += byte_length
if self.next
self.next.set_position(position , labels)

View File

@ -35,7 +35,7 @@ module Register
# labels have the same position as their next
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)
end

View File

@ -17,6 +17,7 @@ module Register
def to_s
"Label: #{@name} (#{self.next.class.name.split("::").last})"
end
def sof_reference_name
@name
end
@ -61,7 +62,7 @@ module Register
def set_position position , labels = []
return position if labels.include?(self)
labels << self
self.position = position
super(position , labels)
self.next.set_position(position,labels)
end

View File

@ -15,7 +15,7 @@ module Positioned
end
pos
end
def position= pos
def set_position( pos )
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.
# in measures (of 32)

View File

@ -38,7 +38,6 @@ module Parfait
def compile_time_init
@memory = Array.new(16)
@position = nil
self # for chaining
end

View File

@ -82,7 +82,7 @@ class TestLogic < MiniTest::Test
def label pos = 0x22
l = Register.label("some" , "Label")
l.position = pos
l.set_position pos
l
end

View File

@ -32,13 +32,13 @@ class TestPositioning < MiniTest::Test
assert_raises { TestPosition.new.position}
end
def test_raises_set_nil
assert_raises { TestPosition.new.position = nil}
assert_raises { TestPosition.new.set_position nil}
end
def test_raises_reset_far
assert_raises do
test = TestPosition.new
test.position = 0
test.position = 12000
test.set_position 0
test.set_position 12000
end
end
end