change platform to return register names
not just the number of them also adds protocol to map registers (like message to r0 , or syscalls)
This commit is contained in:
@ -13,8 +13,24 @@ module Risc
|
||||
assert_raises{ Platform.for("NotArm")}
|
||||
end
|
||||
def test_allocate
|
||||
allocator = Platform.new.allocator(FakeCompiler.new)
|
||||
allocator = Platform.for("Interpreter").allocator(FakeCompiler.new)
|
||||
assert_equal FakeCompiler , allocator.compiler.class
|
||||
end
|
||||
def test_map_message
|
||||
assert_equal :r0 , Platform.new.assign_reg?(:message)
|
||||
end
|
||||
def test_map_sys
|
||||
assert_equal :r0 , Platform.new.assign_reg?(:syscall_1)
|
||||
end
|
||||
def test_map_id
|
||||
assert_nil Platform.new.assign_reg?(:id_some_id)
|
||||
end
|
||||
def test_names_len
|
||||
assert_equal 15 , Platform.new.register_names.length
|
||||
end
|
||||
def test_names_r
|
||||
assert_equal "r" , Platform.new.register_names.first.to_s[0]
|
||||
assert_equal "r" , Platform.new.register_names.last.to_s[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user