From 03979156dbc647a98424d12022694db95636166b Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 2 Nov 2015 20:12:01 +0200 Subject: [PATCH] fix statements as they go --- test/compiler/statements/test_assign.rb | 30 +++++++++++------------ test/compiler/statements/test_call.rb | 32 ++++++++++++------------- test/compiler/statements/test_class.rb | 11 +++++---- test/compiler/statements/test_if.rb | 6 ++--- test/compiler/statements/test_return.rb | 18 +++++++------- test/compiler/statements/test_while.rb | 6 ++--- 6 files changed, 52 insertions(+), 51 deletions(-) diff --git a/test/compiler/statements/test_assign.rb b/test/compiler/statements/test_assign.rb index 352bd11c..f7610d98 100644 --- a/test/compiler/statements/test_assign.rb +++ b/test/compiler/statements/test_assign.rb @@ -16,7 +16,7 @@ int main() end end HERE - @expect = [Label, SaveReturn,LoadConstant,LoadConstant,OperatorInstruction,GetSlot,SetSlot, + @expect = [Label, LoadConstant,LoadConstant,OperatorInstruction,GetSlot,SetSlot, Label,RegisterTransfer,GetSlot,FunctionReturn] check end @@ -30,7 +30,7 @@ class Object end end HERE - @expect = [Label, SaveReturn,LoadConstant,GetSlot,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, LoadConstant,GetSlot,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn] check end @@ -42,7 +42,7 @@ class Object end end HERE - @expect = [Label, SaveReturn,LoadConstant, GetSlot,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, LoadConstant, GetSlot,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn] check end @@ -54,10 +54,10 @@ class Object end end HERE - @expect = [Label, SaveReturn,GetSlot,GetSlot,SetSlot, LoadConstant,SetSlot, - LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot,GetSlot,SetSlot , - Label,RegisterTransfer,GetSlot,FunctionReturn] - check + @expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant , + SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, GetSlot, GetSlot , + SetSlot, Label, RegisterTransfer, GetSlot, FunctionReturn] + check end def test_frame_get @@ -69,10 +69,10 @@ class Object end end HERE - @expect = [Label, SaveReturn,LoadConstant,GetSlot,SetSlot,GetSlot,GetSlot ,SetSlot, + @expect = [Label, LoadConstant,GetSlot,SetSlot,GetSlot,GetSlot ,SetSlot, Label,RegisterTransfer,GetSlot,FunctionReturn] was = check - get = was.next(6) + get = was.next(5) assert_equal GetSlot , get.class assert_equal 4, get.index , "Get to frame index must be offset, not #{get.index}" end @@ -86,9 +86,9 @@ class Object end end HERE - @expect = [Label, SaveReturn,LoadConstant,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, LoadConstant,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn] was = check - set = was.next(3) + set = was.next(2) assert_equal SetSlot , set.class assert_equal 10, set.index , "Set to args index must be offset, not #{set.index}" end @@ -101,9 +101,9 @@ class Object end end HERE - @expect = [Label, SaveReturn,LoadConstant,GetSlot,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, LoadConstant,GetSlot,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn] was = check - set = was.next(4) + set = was.next(3) assert_equal SetSlot , set.class assert_equal 4, set.index , "Set to frame index must be offset, not #{set.index}" end @@ -118,9 +118,9 @@ class Object end end HERE - @expect = [Label, SaveReturn,GetSlot , SetSlot,Label , RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, GetSlot , SetSlot,Label , RegisterTransfer,GetSlot,FunctionReturn] was = check - get = was.next(2) + get = was.next(1) assert_equal GetSlot , get.class assert_equal 10, get.index , "Get to frame index must be offset, not #{get.index}" end diff --git a/test/compiler/statements/test_call.rb b/test/compiler/statements/test_call.rb index a770a654..48cb6cb2 100644 --- a/test/compiler/statements/test_call.rb +++ b/test/compiler/statements/test_call.rb @@ -17,9 +17,9 @@ class Object end end HERE - @expect = [Label, SaveReturn,GetSlot,LoadConstant, - SetSlot,LoadConstant,SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot , - Label,RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant , + SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, GetSlot, Label , + RegisterTransfer, GetSlot, FunctionReturn] check end @@ -37,9 +37,9 @@ class Object end end HERE - @expect = [Label, SaveReturn,GetSlot,LoadConstant, - SetSlot,LoadConstant,SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot , - Label,RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant , + SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, GetSlot, Label , + RegisterTransfer, GetSlot, FunctionReturn] check end @@ -57,9 +57,9 @@ class Object end end HERE - @expect = [ Label, SaveReturn,LoadConstant,GetSlot,SetSlot,GetSlot, - GetSlot,GetSlot,SetSlot,LoadConstant,SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall, - GetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, LoadConstant, GetSlot, SetSlot, GetSlot, GetSlot, GetSlot , + SetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot , + RegisterTransfer, FunctionCall, GetSlot, Label, RegisterTransfer, GetSlot, FunctionReturn] check end @@ -77,9 +77,9 @@ class Object end end HERE - @expect = [ Label, SaveReturn,GetSlot,GetSlot,GetSlot,SetSlot, - LoadConstant,SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall, - GetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, GetSlot, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot , + LoadConstant, SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, GetSlot , + Label, RegisterTransfer, GetSlot, FunctionReturn] check end @@ -94,11 +94,11 @@ int main() end end HERE - @expect = [ Label, SaveReturn , GetSlot,GetSlot,SetSlot,LoadConstant,SetSlot,LoadConstant, - SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot, - Label,RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant , + SetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall , + GetSlot, Label, RegisterTransfer, GetSlot, FunctionReturn] was = check - set = was.next(8) + set = was.next(7) assert_equal SetSlot , set.class assert_equal 9, set.index , "Set to message must be offset, not #{set.index}" end diff --git a/test/compiler/statements/test_class.rb b/test/compiler/statements/test_class.rb index e28f0375..34e05102 100644 --- a/test/compiler/statements/test_class.rb +++ b/test/compiler/statements/test_class.rb @@ -17,7 +17,7 @@ class Object end end HERE - @expect = [Label, SaveReturn,LoadConstant,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, LoadConstant,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] check end @@ -34,8 +34,9 @@ class Object end end HERE - @expect = [Label, SaveReturn,GetSlot,LoadConstant,SetSlot,LoadConstant,SetSlot,LoadConstant,SetSlot, - RegisterTransfer,FunctionCall,GetSlot,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant , + SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, GetSlot, SetSlot , + Label, RegisterTransfer, GetSlot, FunctionReturn] check end @@ -48,7 +49,7 @@ class Object end end HERE - @expect = [Label, SaveReturn,LoadConstant,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, LoadConstant,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] assert_raises{check} end @@ -61,7 +62,7 @@ class Object end end HERE - @expect = [Label, SaveReturn,GetSlot,GetSlot,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, GetSlot,GetSlot,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] check end end diff --git a/test/compiler/statements/test_if.rb b/test/compiler/statements/test_if.rb index 086f777e..5f4c7fa7 100644 --- a/test/compiler/statements/test_if.rb +++ b/test/compiler/statements/test_if.rb @@ -16,7 +16,7 @@ class Object end end HERE - @expect = [Label, SaveReturn,LoadConstant,LoadConstant, OperatorInstruction,IsPlus , + @expect = [Label, LoadConstant,LoadConstant, OperatorInstruction,IsPlus , LoadConstant,SetSlot,Branch , Label , LoadConstant ,SetSlot, Label,Label,RegisterTransfer,GetSlot,FunctionReturn] check @@ -33,7 +33,7 @@ class Object end end HERE - @expect = [Label, SaveReturn,LoadConstant,LoadConstant, OperatorInstruction,IsMinus , + @expect = [Label,LoadConstant,LoadConstant, OperatorInstruction,IsMinus , Branch ,Label , LoadConstant ,SetSlot, Label,Label , RegisterTransfer,GetSlot,FunctionReturn] check @@ -50,7 +50,7 @@ class Object end end HERE - @expect = [Label, SaveReturn,LoadConstant,LoadConstant,OperatorInstruction,IsZero , + @expect = [Label, LoadConstant,LoadConstant,OperatorInstruction,IsZero , Branch , Label , LoadConstant ,SetSlot, Label,Label, RegisterTransfer,GetSlot,FunctionReturn] check diff --git a/test/compiler/statements/test_return.rb b/test/compiler/statements/test_return.rb index 1abed688..2f207d65 100644 --- a/test/compiler/statements/test_return.rb +++ b/test/compiler/statements/test_return.rb @@ -13,9 +13,9 @@ class Object end end HERE - @expect = [Label, SaveReturn,LoadConstant ,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, LoadConstant ,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] was = check - set = was.next(3) + set = was.next(2) assert_equal SetSlot , set.class should = Register.machine.space.first_message.get_layout.variable_index(:return_value) assert_equal should, set.index , "Set to message must got to return_value(#{should}), not #{set.index}" @@ -30,7 +30,7 @@ class Object end end HERE - @expect = [Label, SaveReturn,GetSlot,GetSlot ,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, GetSlot,GetSlot ,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] check end @@ -43,7 +43,7 @@ class Object end end HERE - @expect = [Label, SaveReturn,LoadConstant,GetSlot,SetSlot,GetSlot,GetSlot ,SetSlot, + @expect = [Label, LoadConstant,GetSlot,SetSlot,GetSlot,GetSlot ,SetSlot, Label,RegisterTransfer,GetSlot,FunctionReturn] check end @@ -57,7 +57,7 @@ class Object end end HERE - @expect = [Label, SaveReturn,GetSlot,GetSlot ,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] + @expect = [Label, GetSlot,GetSlot ,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] check end @@ -69,10 +69,10 @@ class Object end end HERE - @expect = [Label, SaveReturn,GetSlot,GetSlot,SetSlot, LoadConstant, - SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot ,SetSlot,Label, - RegisterTransfer,GetSlot,FunctionReturn] - check + @expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant , + SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, GetSlot, SetSlot , + Label, RegisterTransfer, GetSlot, FunctionReturn] + check end end end diff --git a/test/compiler/statements/test_while.rb b/test/compiler/statements/test_while.rb index b2b6ff5a..d7963b11 100644 --- a/test/compiler/statements/test_while.rb +++ b/test/compiler/statements/test_while.rb @@ -15,7 +15,7 @@ class Object end end HERE - @expect = [Label, SaveReturn,Label,LoadConstant,IsPlus,LoadConstant,SetSlot,Branch, + @expect = [Label, Label,LoadConstant,IsPlus,LoadConstant,SetSlot,Branch, Label,Label,RegisterTransfer,GetSlot,FunctionReturn] check end @@ -32,7 +32,7 @@ class Object end end HERE - @expect = [Label, SaveReturn,LoadConstant,GetSlot,SetSlot,Label,GetSlot,GetSlot, IsPlus,GetSlot, + @expect = [Label, LoadConstant,GetSlot,SetSlot,Label,GetSlot,GetSlot, IsPlus,GetSlot, GetSlot,LoadConstant,OperatorInstruction,GetSlot,SetSlot,Branch, Label,GetSlot,GetSlot,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] check @@ -51,7 +51,7 @@ class Object end end HERE - @expect = [Label, SaveReturn,LoadConstant,GetSlot,SetSlot,Label, + @expect = [Label, LoadConstant,GetSlot,SetSlot,Label, GetSlot,GetSlot,LoadConstant,OperatorInstruction,IsPlus, GetSlot, GetSlot,LoadConstant,OperatorInstruction, GetSlot, SetSlot,GetSlot, GetSlot,SetSlot,Branch , Label ,