fix mom and vool after cc changes

This commit is contained in:
Torsten Rüger 2019-08-23 10:21:22 +03:00
parent ec1e8c8f3a
commit 5e44e9caaf
16 changed files with 50 additions and 64 deletions

View File

@ -7,9 +7,7 @@ module Risc
def setup def setup
super super
@input = "local = arg; return local" @input = "local = arg; return local"
@expect =[ SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #4 @expect = [SlotToReg, RegToSlot, SlotToReg, RegToSlot, Branch] #4
RegToSlot, Branch] #9
end end
def test_local_assign_instructions def test_local_assign_instructions
assert_nil msg = check_nil , msg assert_nil msg = check_nil , msg
@ -26,8 +24,8 @@ module Risc
end end
def test_load_frame_from_message def test_load_frame_from_message
produced = produce_body produced = produce_body
assert_equal :r3 , produced.next(2).array.symbol , produced.next.to_rxf[0..200] assert_equal 16 , produced.next.index , produced.next.to_rxf[0..200]
assert_equal 3 , produced.next.index , produced.next.to_rxf[0..200] assert_equal :r0 , produced.next(2).array.symbol
end end
end end
end end

View File

@ -7,7 +7,7 @@ module Risc
def setup def setup
super super
@input = "r = false;return" @input = "r = false;return"
@expect = [LoadConstant,SlotToReg, RegToSlot,LoadConstant, RegToSlot, Branch] @expect = [LoadConstant, RegToSlot,LoadConstant, RegToSlot, Branch]
end end
def test_local_assign_instructions def test_local_assign_instructions
assert_nil msg = check_nil , msg assert_nil msg = check_nil , msg
@ -21,12 +21,12 @@ module Risc
def test_frame_load def test_frame_load
produced = produce_body produced = produce_body
assert_equal :Message , produced.next(1).array.type.class_name assert_equal :Message , produced.next(1).array.type.class_name
assert_equal 3 , produced.next(1).index # 3 is frame assert_equal 16 , produced.next(1).index # 3 is frame
end end
def test_value_load def test_value_load
produced = produce_body produced = produce_body
assert_equal produced.next(2).register , produced.register assert_equal produced.next(2).register , produced.register
assert_equal 1 , produced.next(2).index #type == 0 , r == 1 assert_equal 16 , produced.next(1).index #type == 0 , r == 16
end end
end end

View File

@ -7,7 +7,7 @@ module Risc
def setup def setup
super super
@input = "r = 5;return" @input = "r = 5;return"
@expect = [LoadConstant,SlotToReg, RegToSlot, LoadConstant, RegToSlot, Branch] @expect = [LoadConstant, RegToSlot, LoadConstant, RegToSlot, Branch]
end end
def test_local_assign_instructions def test_local_assign_instructions
assert_nil msg = check_nil , msg assert_nil msg = check_nil , msg
@ -21,12 +21,11 @@ module Risc
def test_frame_load def test_frame_load
produced = produce_body produced = produce_body
assert_equal :Message , produced.next(1).array.type.class_name assert_equal :Message , produced.next(1).array.type.class_name
assert_equal 3 , produced.next(1).index # 4 is frame assert_equal 16 , produced.next(1).index # 4 is frame
end end
def test_value_load def test_value_load
produced = produce_body produced = produce_body
assert_equal produced.next(2).register , produced.register assert_equal produced.next(1).register , produced.register
assert_equal 1 , produced.next(2).index #type == 1 , r == 2
end end
end end

View File

@ -7,8 +7,8 @@ module Risc
def setup def setup
super super
@input = "@ivar = 5 ; r = @ivar;return" @input = "@ivar = 5 ; r = @ivar;return"
@expect = [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg , @expect = [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #4
RegToSlot, LoadConstant, RegToSlot, Branch] RegToSlot, LoadConstant, RegToSlot, Branch] #9
end end
def test_local_assign_instructions def test_local_assign_instructions
assert_nil msg = check_nil , msg assert_nil msg = check_nil , msg

View File

@ -7,11 +7,11 @@ module Risc
def setup def setup
super super
@input = "r = 5.div4;return" @input = "r = 5.div4;return"
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot, @expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot, #4
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg, #9
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, #14
FunctionCall, Label, SlotToReg, SlotToReg, RegToSlot, FunctionCall, Label, SlotToReg, RegToSlot, LoadConstant, #19
LoadConstant, RegToSlot, Branch] RegToSlot, Branch] #2
end end
def test_local_assign_instructions def test_local_assign_instructions
assert_nil msg = check_nil , msg assert_nil msg = check_nil , msg

View File

@ -7,7 +7,7 @@ module Risc
def setup def setup
super super
@input = as_block("a = 5") @input = as_block("a = 5")
@expect = [LoadConstant, SlotToReg, RegToSlot] @expect = [LoadConstant, RegToSlot]
end end
def test_send_instructions def test_send_instructions
assert_nil msg = check_nil(:main_block) , msg assert_nil msg = check_nil(:main_block) , msg

View File

@ -7,11 +7,11 @@ module Risc
def setup def setup
super super
@input = as_block("return 5") @input = as_block("return 5")
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, #4 @expect = [LoadConstant, RegToSlot, LoadConstant, LoadConstant, SlotToReg, #4
SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, #9 SlotToReg, RegToSlot, RegToSlot, RegToSlot, RegToSlot, #9
RegToSlot, SlotToReg, SlotToReg, RegToSlot, LoadConstant, #14 SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #14
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #19 RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, #19
SlotToReg, FunctionCall, Label] #24 FunctionCall, Label] #24
end end
def test_send_instructions def test_send_instructions
@ -28,12 +28,12 @@ module Risc
assert_equal 5 , produced.constant.value assert_equal 5 , produced.constant.value
end end
def test_load_next_message def test_load_next_message
produced = produce_body.next(4) produced = produce_body.next(3)
assert_load( produced , Parfait::Factory) assert_load( produced , Parfait::Factory)
assert_equal "Message_Type" , produced.constant.for_type.name assert_equal "Message_Type" , produced.constant.for_type.name
end end
def test_load_block def test_load_block
produced = produce_body.next(14) produced = produce_body.next(13)
assert_load( produced , Parfait::Block) assert_load( produced , Parfait::Block)
assert_equal :main_block , produced.constant.name assert_equal :main_block , produced.constant.name
end end
@ -43,12 +43,12 @@ module Risc
assert produced.constant.name.start_with?("continue_") assert produced.constant.name.start_with?("continue_")
end end
def test_function_call def test_function_call
produced = produce_body.next(21) produced = produce_body.next(20)
assert_equal FunctionCall , produced.class assert_equal FunctionCall , produced.class
assert_equal :main , produced.method.name assert_equal :main , produced.method.name
end end
def test_check_continue def test_check_continue
produced = produce_body.next(23) produced = produce_body.next(22)
assert_equal Label , produced.class assert_equal Label , produced.class
# assert produced.name.start_with?("continue_") , produced.name # assert produced.name.start_with?("continue_") , produced.name
end end

View File

@ -15,7 +15,7 @@ module Parfait
def test_message_name_nil def test_message_name_nil
last = @type.names.last last = @type.names.last
assert_equal :arg6 , last , @type.names.inspect assert_equal :local15 , last , @type.names.inspect
assert_nil @mess.method assert_nil @mess.method
end end
def test_message_next_set def test_message_next_set

View File

@ -10,23 +10,31 @@ module Parfait
def test_args_start def test_args_start
assert_equal 8 , Message.args_start_at assert_equal 8 , Message.args_start_at
end end
def test_locals_start
assert_equal 15 , Message.locals_start_at
end
def test_length def test_length
assert_equal 15 , @mess.get_type.instance_length , @mess.get_type.inspect assert_equal 31 , @mess.get_type.instance_length , @mess.get_type.inspect
end end
def test_attribute_set def test_attribute_set
@mess.set_receiver( 55 ) # 55 is not parfait, hance not actually allowed @mess.set_receiver( 55 ) # 55 is not parfait, hance not actually allowed
assert_equal 55 , @mess.receiver assert_equal 55 , @mess.receiver
end end
def test_indexed def test_indexed_arg
assert_equal 8 , @mess.get_type.variable_index(:arguments_given) assert_equal 8 , @mess.get_type.variable_index(:arguments_given)
assert_equal 9 , @mess.get_type.variable_index(:arg1) assert_equal 9 , @mess.get_type.variable_index(:arg1)
assert_equal 13 , @mess.get_type.variable_index(:arg5) assert_equal 13 , @mess.get_type.variable_index(:arg5)
end end
def test_indexed_local
assert_equal 15 , @mess.get_type.variable_index(:locals_used)
assert_equal 16 , @mess.get_type.variable_index(:local1)
assert_equal 30 , @mess.get_type.variable_index(:local15)
end
def test_next_message def test_next_message
assert_equal Message , @mess.next_message.class assert_equal Message , @mess.next_message.class
end end
def test_locals def test_locals
assert_equal NamedList , @mess.frame.class assert_equal Integer , @mess.locals_used.class
end end
def test_arguments def test_arguments
assert_equal Integer , @mess.arguments_given.class assert_equal Integer , @mess.arguments_given.class

View File

@ -3,18 +3,6 @@ require_relative "helper"
module Parfait module Parfait
class TestNamedLists < ParfaitTest class TestNamedLists < ParfaitTest
def setup
super
@named_list = @space.get_next_for(:Message).frame
@type = @named_list.get_type
end
def test_named_list_get_type
assert_equal Type , @type.class
assert @type.names
assert @named_list.get_instance_variables
end
def test_new def test_new
list = NamedList.new list = NamedList.new
assert list.get_type assert list.get_type

View File

@ -198,7 +198,7 @@ module Parfait
count = 0 count = 0
while(mess) while(mess)
count += 1 count += 1
assert mess.frame assert mess.locals_used
mess = mess.next_message mess = mess.next_message
end end
assert_equal 1014, count assert_equal 1014, count

View File

@ -22,7 +22,7 @@ module Parfait
def test_length def test_length
assert @mess assert @mess
assert @mess.get_type assert @mess.get_type
assert_equal 15 , @mess.get_type.instance_length , @mess.get_type.inspect assert_equal 31 , @mess.get_type.instance_length , @mess.get_type.inspect
end end
def test_names def test_names
@ -33,7 +33,7 @@ module Parfait
end end
def test_type_length def test_type_length
assert_equal 15 , @mess.get_type.instance_length , @mess.get_type.inspect assert_equal 31 , @mess.get_type.instance_length , @mess.get_type.inspect
end end
def test_type_length_index def test_type_length_index
@ -45,7 +45,7 @@ module Parfait
def test_no_index_below_0 def test_no_index_below_0
type = @mess.get_type type = @mess.get_type
names = type.names names = type.names
assert_equal 15 , names.get_length , names.inspect assert_equal 31 , names.get_length , names.inspect
names.each do |n| names.each do |n|
assert type.variable_index(n) >= 0 assert type.variable_index(n) >= 0
end end

View File

@ -18,7 +18,7 @@ module VoolBlocks
assert_equal :message , @ins.left.known_object assert_equal :message , @ins.left.known_object
end end
def test_slots_left def test_slots_left
assert_equal [:frame , :local] , @ins.left.slots assert_equal [:local1] , @ins.left.slots
end end
def test_slot_assigns_something def test_slot_assigns_something
assert @ins.right assert @ins.right
@ -38,7 +38,7 @@ module VoolBlocks
assert_equal Mom::SlotLoad , @ins.class , @ins assert_equal Mom::SlotLoad , @ins.class , @ins
end end
def test_slots_left def test_slots_left
assert_equal [:frame, :local] , @ins.left.slots assert_equal [:local1] , @ins.left.slots
end end
def test_slots_right def test_slots_right
assert_equal [:receiver, :a] , @ins.right.slots assert_equal [:receiver, :a] , @ins.right.slots

View File

@ -14,9 +14,8 @@ module Vool
def test_type_update def test_type_update
load = @ins.next(2) load = @ins.next(2)
assert_equal :message , load.right.known_object , load assert_equal :message , load.right.known_object , load
assert_equal :frame , load.right.slots[0] , load assert_equal :local1 , load.right.slots[0] , load
assert_equal :a , load.right.slots[1] , load assert_equal :type , load.right.slots[1] , load
assert_equal :type , load.right.slots[2] , load
end end
def test_check_resolve_call def test_check_resolve_call
assert_equal ResolveMethod , @ins.next(3).class , @ins assert_equal ResolveMethod , @ins.next(3).class , @ins

View File

@ -19,11 +19,8 @@ module Vool
def test_slot_starts_at_message def test_slot_starts_at_message
assert_equal :message , @ins.left.known_object assert_equal :message , @ins.left.known_object
end end
def test_slot_gets_self def test_slot_gets_local
assert_equal :frame , @ins.left.slots[0] assert_equal :local1 , @ins.left.slots[0]
end
def test_slot_assigns_to_local
assert_equal :local , @ins.left.slots[-1]
end end
def test_slot_assigns_something def test_slot_assigns_something
assert @ins.right assert @ins.right

View File

@ -22,11 +22,8 @@ module Vool
def test_slot_starts_at_message def test_slot_starts_at_message
assert_equal :message , @ins.left.known_object assert_equal :message , @ins.left.known_object
end end
def test_slot_gets_frame def test_slot_gets_local
assert_equal :frame , @ins.left.slots[0] assert_equal :local1 , @ins.left.slots[0]
end
def test_slot_assigns_to_local
assert_equal :a , @ins.left.slots[-1]
end end
def test_slot_assigns_something def test_slot_assigns_something
assert @ins.right assert @ins.right