move return address generation to factory

removes the list from space
adds a ReturnAddress factory instead
and uses these throughout
This commit is contained in:
Torsten Ruger
2018-08-29 21:02:49 +03:00
parent f993ccefe3
commit c983dcf0eb
7 changed files with 25 additions and 35 deletions

View File

@ -11,7 +11,7 @@ module Parfait
end
def test_space_length
assert_equal 11 , @space.get_type.instance_length , @space.get_type.inspect
assert_equal 9 , @space.get_type.instance_length , @space.get_type.inspect
end
def test_singletons
assert @space.true_object , "No truth"
@ -92,7 +92,7 @@ module Parfait
assert_equal Dictionary , @space.factories.class
end
def test_factory_length
assert_equal 1 , @space.factories.length
assert_equal 2 , @space.factories.length
end
def test_has_integer_factory
ints = @space.get_factory_for(:Integer)
@ -110,20 +110,21 @@ module Parfait
assert_equal Parfait::Integer , nekst.class
end
def test_has_addresses
assert_equal Parfait::ReturnAddress , @space.next_address.class
assert_equal 0 , @space.next_address.value
ret = @space.get_next_for(:ReturnAddress)
assert_equal Parfait::ReturnAddress , ret.class
assert_nil ret.value
end
def test_has_next_address
assert_equal Parfait::ReturnAddress , @space.next_address.next_integer.class
assert_equal Parfait::ReturnAddress , @space.get_next_for(:ReturnAddress).class
end
def test_address_count
addr = @space.addresses
addr = @space.get_next_for(:ReturnAddress)
count = 0
while(addr)
count += 1
addr = addr.next_integer
end
assert_equal 400, count
assert_equal 1014, count
end
def test_messages
mess = @space.messages

View File

@ -27,7 +27,7 @@ module Parfait
assert_equal Parfait::Space , space.class
type = space.get_type
assert_equal Parfait::Type , type.class
assert_equal 11 , type.names.get_length
assert_equal 9 , type.names.get_length
assert_equal type.object_class.class , Parfait::Class
assert_equal type.object_class.name , :Space
end

View File

@ -54,7 +54,7 @@ module Risc
end
def test_pc1
@interpreter.tick
assert_equal 41592 , @interpreter.pc
assert_equal 49992 , @interpreter.pc
end
def test_tick2
@interpreter.tick
@ -68,7 +68,7 @@ module Risc
def test_pc2
@interpreter.tick
@interpreter.tick
assert_equal 41596 , @interpreter.pc
assert_equal 49996 , @interpreter.pc
end
def test_tick_14_jump
14.times {@interpreter.tick}

View File

@ -25,7 +25,7 @@ module Risc
assert_equal 0 , Position.get(@linker.cpu_init).at
end
def test_cpu_at
assert_equal "0xb12c" , Position.get(@linker.cpu_init.first).to_s
assert_equal "0xd1fc" , Position.get(@linker.cpu_init.first).to_s
end
def test_cpu_label
assert_equal Position , Position.get(@linker.cpu_init.first).class