diff --git a/test/vm/method_compiler/test_assignment.rb b/test/vm/method_compiler/test_assignment.rb index d7635525..fb20df8a 100644 --- a/test/vm/method_compiler/test_assignment.rb +++ b/test/vm/method_compiler/test_assignment.rb @@ -7,7 +7,7 @@ module Register def test_assign_op Parfait.object_space.get_main.add_local(:r , :Integer) - @input = s(:statements, s(:assignment, s(:name, :r), s(:operator_value, :+, s(:int, 10), s(:int, 1)))) + @input = s(:statements, s(:l_assignment, s(:name, :r), s(:operator_value, :+, s(:int, 10), s(:int, 1)))) @expect = [Label, LoadConstant, LoadConstant, OperatorInstruction, SlotToReg, RegToSlot , LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn] @@ -16,7 +16,7 @@ module Register def test_assign_local Parfait.object_space.get_main.add_local(:r , :Integer) - @input =s(:statements, s(:assignment, s(:name, :r), s(:int, 5))) + @input =s(:statements, s(:l_assignment, s(:name, :r), s(:int, 5))) @expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg , RegToSlot, Label, FunctionReturn] @@ -26,7 +26,7 @@ module Register def test_assign_local_assign Parfait.object_space.get_main.add_local(:r , :Integer) - @input = s(:statements, s(:assignment, s(:name, :r), s(:int, 5))) + @input = s(:statements, s(:l_assignment, s(:name, :r), s(:int, 5))) @expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg , RegToSlot, Label, FunctionReturn] @@ -35,7 +35,7 @@ module Register def test_assign_call Parfait.object_space.get_main.add_local(:r , :Integer) - @input = s(:statements, s(:assignment, s(:name, :r), s(:call, s(:name, :main), s(:arguments)))) + @input = s(:statements, s(:l_assignment, s(:name, :r), s(:call, s(:name, :main), s(:arguments)))) @expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot , LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer , FunctionCall, Label, RegisterTransfer, SlotToReg, SlotToReg, SlotToReg , @@ -45,7 +45,7 @@ module Register def test_named_list_get Parfait.object_space.get_main.add_local(:r , :Integer) - @input = s(:statements, s(:assignment, s(:name, :r), s(:int, 5)), s(:return, s(:name, :r))) + @input = s(:statements, s(:l_assignment, s(:name, :r), s(:int, 5)), s(:return, s(:name, :r))) @expect = [Label, LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg , RegToSlot, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn] was = check_return @@ -56,7 +56,7 @@ module Register def test_assign_local_int Parfait.object_space.get_main.add_local(:r , :Integer) - @input = s(:statements, s(:assignment, s(:name, :r), s(:int, 5)) ) + @input = s(:statements, s(:l_assignment, s(:name, :r), s(:int, 5)) ) @expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg , RegToSlot, Label, FunctionReturn] was = check_return @@ -67,14 +67,14 @@ module Register def test_misassign_local Parfait.object_space.get_main.add_local(:r , :Integer) - @input = s(:statements, s(:assignment, s(:name, :r), s(:string, "5")) ) + @input = s(:statements, s(:l_assignment, s(:name, :r), s(:string, "5")) ) @expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn] assert_raises {check } end def test_assign_arg Parfait.object_space.get_main.add_argument(:blar , :Integer) - @input = s(:statements, s(:assignment, s(:name, :blar), s(:int, 5))) + @input = s(:statements, s(:a_assignment, s(:name, :blar), s(:int, 5))) @expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg , RegToSlot, Label, FunctionReturn] was = check_return @@ -85,7 +85,7 @@ module Register def test_misassign_arg Parfait.object_space.get_main.add_argument(:blar , :Integer) - @input = s(:statements, s(:assignment, s(:name, :blar), s(:string, "5"))) + @input = s(:statements, s(:a_assignment, s(:name, :blar), s(:string, "5"))) @expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn] assert_raises {check } end diff --git a/test/vm/method_compiler/test_call_site.rb b/test/vm/method_compiler/test_call_site.rb index e0881465..38cee5d6 100644 --- a/test/vm/method_compiler/test_call_site.rb +++ b/test/vm/method_compiler/test_call_site.rb @@ -30,7 +30,7 @@ module Register def test_call_local_int Parfait.object_space.get_main.add_local(:testi , :Integer) clean_compile :Integer, :putint, {}, s(:statements, s(:return, s(:int, 1))) - @input = s(:statements, s(:assignment, s(:name, :testi), s(:int, 20)), s(:call, s(:name, :putint), s(:arguments), s(:receiver, s(:name, :testi)))) + @input = s(:statements, s(:l_assignment, s(:name, :testi), s(:int, 20)), s(:call, s(:name, :putint), s(:arguments), s(:receiver, s(:name, :testi)))) @expect = [Label, LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg , RegToSlot, LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant , diff --git a/test/vm/method_compiler/test_fields.rb b/test/vm/method_compiler/test_fields.rb index 382c7475..afea1bd6 100644 --- a/test/vm/method_compiler/test_fields.rb +++ b/test/vm/method_compiler/test_fields.rb @@ -31,7 +31,7 @@ module Register def test_message_field Parfait.object_space.get_main.add_local(:name , :Word) - @input = s(:statements, s(:assignment, s(:name, :name), s(:field_access, s(:receiver, s(:name, :message)), s(:field, s(:name, :name)))), s(:return, s(:name, :name))) + @input = s(:statements, s(:l_assignment, s(:name, :name), s(:field_access, s(:receiver, s(:name, :message)), s(:field, s(:name, :name)))), s(:return, s(:name, :name))) @expect = [Label, RegisterTransfer, SlotToReg, SlotToReg, RegToSlot, SlotToReg , SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, Label , diff --git a/test/vm/method_compiler/test_return_statement.rb b/test/vm/method_compiler/test_return_statement.rb index eb8ea88f..5d81a2af 100644 --- a/test/vm/method_compiler/test_return_statement.rb +++ b/test/vm/method_compiler/test_return_statement.rb @@ -21,7 +21,7 @@ module Register def test_return_local_assign Parfait.object_space.get_main.add_local(:runner , :Integer) - @input = s(:statements, s(:assignment, s(:name, :runner), s(:int, 5)), s(:return, s(:name, :runner))) + @input = s(:statements, s(:l_assignment, s(:name, :runner), s(:int, 5)), s(:return, s(:name, :runner))) @expect = [Label, LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg , RegToSlot, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn] assert_nil msg = check_nil , msg @@ -38,7 +38,7 @@ module Register def pest_return_space_length # need to add runtime first Parfait.object_space.get_main.add_local(:l , :Type) - @input = s(:statements, s(:assignment, s(:name, :l), s(:call, s(:name, :get_type), s(:arguments), s(:receiver, s(:name, :space)))), s(:return, s(:field_access, s(:receiver, s(:name, :self)), s(:field, s(:name, :runner))))) + @input = s(:statements, s(:l_assignment, s(:name, :l), s(:call, s(:name, :get_type), s(:arguments), s(:receiver, s(:name, :space)))), s(:return, s(:field_access, s(:receiver, s(:name, :self)), s(:field, s(:name, :runner))))) @expect = [Label, SlotToReg,SlotToReg ,RegToSlot,Label,FunctionReturn] assert_nil msg = check_nil , msg end diff --git a/test/vm/method_compiler/test_while_statement.rb b/test/vm/method_compiler/test_while_statement.rb index 96ff2077..887e5ac0 100644 --- a/test/vm/method_compiler/test_while_statement.rb +++ b/test/vm/method_compiler/test_while_statement.rb @@ -17,7 +17,7 @@ module Register def test_while_assign Parfait.object_space.get_main.add_local(:n , :Integer) - @input = s(:statements, s(:assignment, s(:name, :n), s(:int, 5)), s(:while_statement, :plus, s(:conditional, s(:name, :n)), s(:statements, s(:assignment, s(:name, :n), s(:operator_value, :-, s(:name, :n), s(:int, 1))))), s(:return, s(:name, :n))) + @input = s(:statements, s(:l_assignment, s(:name, :n), s(:int, 5)), s(:while_statement, :plus, s(:conditional, s(:name, :n)), s(:statements, s(:l_assignment, s(:name, :n), s(:operator_value, :-, s(:name, :n), s(:int, 1))))), s(:return, s(:name, :n))) @expect = [Label, LoadConstant, SlotToReg, RegToSlot, Branch, Label , SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, SlotToReg, RegToSlot , @@ -30,7 +30,7 @@ module Register def test_while_return Parfait.object_space.get_main.add_local(:n , :Integer) - @input = s(:statements, s(:assignment, s(:name, :n), s(:int, 10)), s(:while_statement, :plus, s(:conditional, s(:operator_value, :-, s(:name, :n), s(:int, 5))), s(:statements, s(:assignment, s(:name, :n), s(:operator_value, :+, s(:name, :n), s(:int, 1))), s(:return, s(:name, :n))))) + @input = s(:statements, s(:l_assignment, s(:name, :n), s(:int, 10)), s(:while_statement, :plus, s(:conditional, s(:operator_value, :-, s(:name, :n), s(:int, 5))), s(:statements, s(:l_assignment, s(:name, :n), s(:operator_value, :+, s(:name, :n), s(:int, 1))), s(:return, s(:name, :n))))) @expect = [Label, LoadConstant, SlotToReg, RegToSlot, Branch, Label , SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, SlotToReg, RegToSlot , diff --git a/test/vm/test_to_code.rb b/test/vm/test_to_code.rb index 860e69f2..e3860b52 100644 --- a/test/vm/test_to_code.rb +++ b/test/vm/test_to_code.rb @@ -16,9 +16,17 @@ class ToCodeTest < MiniTest::Test @statement = s(:while_statement, :false, s(:conditional,s(:int, 1)), s(:statements)) check "WhileStatement" end - def test_assignment - @statement = s(:assignment, s(:name, :i), s(:int, 0)) - check "Assignment" + def test_l_assignment + @statement = s(:l_assignment, s(:name, :i), s(:int, 0)) + check "LocalAssignment" + end + def test_a_assignment + @statement = s(:a_assignment, s(:name, :i), s(:int, 0)) + check "ArgAssignment" + end + def test_i_assignment + @statement = s(:i_assignment, s(:name, :i), s(:int, 0)) + check "IvarAssignment" end def test_nil @statement = s(:nil)