fixing tests for shifting constants into slots
This commit is contained in:
parent
3fecdf54a5
commit
cddc25a595
@ -15,6 +15,7 @@ module Risc
|
||||
|
||||
# Produce a RegToSlot instruction.
|
||||
# From and to are registers or symbols that can be transformed to a register by resolve_to_register
|
||||
# (which are precisely the symbols :message or :new_message. or a register)
|
||||
# index resolves with resolve_to_index.
|
||||
def self.reg_to_slot( source , from_reg , to , index )
|
||||
from = resolve_to_register from_reg
|
||||
|
@ -86,7 +86,7 @@ module Risc
|
||||
return instance_name unless instance_name.is_a? Symbol
|
||||
real_name = clazz_name.to_s.split('_').last.capitalize.to_sym
|
||||
clazz = Parfait.object_space.get_class_by_name(real_name)
|
||||
raise "Class name not given #{real_name}" unless clazz
|
||||
raise "Class name not given #{real_name} #{clazz_name} #{instance_name}" unless clazz
|
||||
index = clazz.instance_type.variable_index( instance_name )
|
||||
raise "Instance name=#{instance_name} not found on #{real_name}:#{clazz.instance_type}" unless index.is_a?(Numeric)
|
||||
return index # the type word is at index 0, but type is a list and starts at 1 == type
|
||||
|
@ -15,7 +15,7 @@ module Risc
|
||||
|
||||
def test_constant_load
|
||||
produced = produce_body
|
||||
assert_equal 5 , produced.constant.value
|
||||
assert_equal 5 , produced.constant.known_object.value
|
||||
end
|
||||
|
||||
def test_slot_move
|
||||
|
@ -18,8 +18,8 @@ module Vool
|
||||
end
|
||||
def test_receiver
|
||||
type , value = receiver
|
||||
assert_equal type, @ins.next.right.class
|
||||
assert_equal value, @ins.next.right.value
|
||||
assert_equal type, @ins.next.right.known_object.class
|
||||
assert_equal value, @ins.next.right.known_object.value
|
||||
end
|
||||
def test_call_is
|
||||
assert_equal Mom::SimpleCall, @ins.next(3).class
|
||||
|
@ -19,8 +19,8 @@ module Vool
|
||||
assert_equal :arguments, @ins.next(2).arguments[1].left.slots[1]
|
||||
end
|
||||
def test_args_two_str
|
||||
assert_equal Mom::IntegerConstant, @ins.next(2).arguments[1].right.class
|
||||
assert_equal 2, @ins.next(2).arguments[1].right.value
|
||||
assert_equal Mom::IntegerConstant, @ins.next(2).arguments[1].right.known_object.class
|
||||
assert_equal 2, @ins.next(2).arguments[1].right.known_object.value
|
||||
end
|
||||
def test_array
|
||||
check_array [Mom::MessageSetup,Mom::SlotLoad,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins
|
||||
|
@ -19,8 +19,8 @@ module Vool
|
||||
assert_equal :arguments, @ins.next.next.arguments[0].left.slots[1]
|
||||
end
|
||||
def test_args_one_str
|
||||
assert_equal Mom::IntegerConstant, @ins.next.next.arguments[0].right.class
|
||||
assert_equal 1, @ins.next.next.arguments[0].right.value
|
||||
assert_equal Mom::IntegerConstant, @ins.next.next.arguments[0].right.known_object.class
|
||||
assert_equal 1, @ins.next.next.arguments[0].right.known_object.value
|
||||
end
|
||||
def test_array
|
||||
check_array [Mom::MessageSetup,Mom::SlotLoad,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins
|
||||
|
@ -28,7 +28,7 @@ module Vool
|
||||
assert @stats.right
|
||||
end
|
||||
def test_slot_assigns_int
|
||||
assert_equal Mom::IntegerConstant , @stats.right.class
|
||||
assert_equal Mom::IntegerConstant , @stats.right.known_object.class
|
||||
end
|
||||
end
|
||||
|
||||
@ -78,7 +78,7 @@ module Vool
|
||||
def test_assigns_const
|
||||
@stats = compile_first_method( "@a = 5")
|
||||
assert_equal Mom::SlotLoad , @stats.class , @stats
|
||||
assert_equal Mom::IntegerConstant , @stats.right.class , @stats
|
||||
assert_equal Mom::IntegerConstant , @stats.right.known_object.class , @stats
|
||||
end
|
||||
def test_assigns_move
|
||||
@stats = compile_first_method( "@a = arg")
|
||||
|
@ -31,7 +31,7 @@ module Vool
|
||||
assert @ins.right
|
||||
end
|
||||
def test_slot_assigns_int
|
||||
assert_equal Mom::IntegerConstant , @ins.right.class
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -31,7 +31,7 @@ module Vool
|
||||
assert @ins.right
|
||||
end
|
||||
def test_slot_assigns_int
|
||||
assert_equal Mom::IntegerConstant , @ins.right.class
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -32,7 +32,7 @@ module Vool
|
||||
assert @inst.right
|
||||
end
|
||||
def test_slot_assigns_int
|
||||
assert_equal Mom::IntegerConstant , @inst.right.class
|
||||
assert_equal Mom::IntegerConstant , @inst.right.known_object.class
|
||||
end
|
||||
def test_array
|
||||
check_array [SlotLoad,ReturnSequence] , @ins
|
||||
|
Loading…
Reference in New Issue
Block a user