rename set_slot

set_slot was clear about the target, but not the source.
Better with reg_to_slot (and soon it’s inverse slot_to_reg)
This commit is contained in:
Torsten Ruger
2016-12-25 18:02:39 +02:00
parent 1b8d6149dd
commit 35adf9a5e6
31 changed files with 126 additions and 115 deletions

View File

@ -17,9 +17,9 @@ HERE
def test_chain
#show_ticks # get output of what is
check_chain ["Branch","Label","LoadConstant","GetSlot","SetSlot",
"LoadConstant","SetSlot","FunctionCall","Label","LoadConstant",
"LoadConstant","OperatorInstruction","SetSlot","Label","FunctionReturn",
check_chain ["Branch","Label","LoadConstant","GetSlot","RegToSlot",
"LoadConstant","RegToSlot","FunctionCall","Label","LoadConstant",
"LoadConstant","OperatorInstruction","RegToSlot","Label","FunctionReturn",
"RegisterTransfer","Syscall","NilClass"]
end

View File

@ -36,9 +36,9 @@ class AddChange < MiniTest::Test
def test_chain
#show_ticks # get output of what is
check_chain ["Branch","Label","LoadConstant","GetSlot","SetSlot",
"LoadConstant","SetSlot","FunctionCall","Label","LoadConstant",
"LoadConstant","OperatorInstruction","SetSlot","Label","FunctionReturn",
check_chain ["Branch","Label","LoadConstant","GetSlot","RegToSlot",
"LoadConstant","RegToSlot","FunctionCall","Label","LoadConstant",
"LoadConstant","OperatorInstruction","RegToSlot","Label","FunctionReturn",
"RegisterTransfer","Syscall","NilClass"]
end

View File

@ -20,11 +20,11 @@ HERE
def test_chain
#show_ticks # get output of what is
check_chain ["Branch","Label","LoadConstant","GetSlot","SetSlot",
"LoadConstant","SetSlot","FunctionCall","Label","GetSlot",
"LoadConstant","SetSlot","LoadConstant","SetSlot","LoadConstant",
"SetSlot","LoadConstant","SetSlot","LoadConstant","SetSlot",
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","Label",
check_chain ["Branch","Label","LoadConstant","GetSlot","RegToSlot",
"LoadConstant","RegToSlot","FunctionCall","Label","GetSlot",
"LoadConstant","RegToSlot","LoadConstant","RegToSlot","LoadConstant",
"RegToSlot","LoadConstant","RegToSlot","LoadConstant","RegToSlot",
"LoadConstant","RegToSlot","RegisterTransfer","FunctionCall","Label",
"GetSlot","GetSlot","GetSlot","SetByte","Label",
"FunctionReturn","RegisterTransfer","GetSlot","GetSlot","Label",
"FunctionReturn","RegisterTransfer","Syscall","NilClass"]

View File

@ -32,17 +32,17 @@ HERE
s(:false_statements, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "else"))))))
end
def test_if
show_ticks # get output of what is
check_chain ["Branch","Label","LoadConstant","GetSlot","SetSlot",
"LoadConstant","SetSlot","FunctionCall","Label","GetSlot",
"GetSlot","SetSlot","LoadConstant","SetSlot","LoadConstant",
"SetSlot","LoadConstant","SetSlot","LoadConstant","SetSlot",
#show_ticks # get output of what is
check_chain ["Branch","Label","LoadConstant","GetSlot","RegToSlot",
"LoadConstant","RegToSlot","FunctionCall","Label","GetSlot",
"GetSlot","RegToSlot","LoadConstant","RegToSlot","LoadConstant",
"RegToSlot","LoadConstant","RegToSlot","LoadConstant","RegToSlot",
"RegisterTransfer","FunctionCall","Label","GetSlot","LoadConstant",
"OperatorInstruction","IsZero","GetSlot","LoadConstant","SetSlot",
"LoadConstant","SetSlot","LoadConstant","SetSlot","LoadConstant",
"SetSlot","RegisterTransfer","FunctionCall","Label","GetSlot",
"OperatorInstruction","IsZero","GetSlot","LoadConstant","RegToSlot",
"LoadConstant","RegToSlot","LoadConstant","RegToSlot","LoadConstant",
"RegToSlot","RegisterTransfer","FunctionCall","Label","GetSlot",
"GetSlot","RegisterTransfer","Syscall","RegisterTransfer","RegisterTransfer",
"SetSlot","Label","FunctionReturn","RegisterTransfer","GetSlot",
"RegToSlot","Label","FunctionReturn","RegisterTransfer","GetSlot",
"GetSlot","Branch","Label","Label","FunctionReturn",
"RegisterTransfer","GetSlot","GetSlot","Label","FunctionReturn",
"RegisterTransfer","Syscall","NilClass"]

View File

@ -19,9 +19,9 @@ HERE
def test_mult
#show_ticks # get output of what is
check_chain ["Branch","Label","LoadConstant","GetSlot","SetSlot",
"LoadConstant","SetSlot","FunctionCall","Label","LoadConstant",
"LoadConstant","OperatorInstruction","SetSlot","Label","FunctionReturn",
check_chain ["Branch","Label","LoadConstant","GetSlot","RegToSlot",
"LoadConstant","RegToSlot","FunctionCall","Label","LoadConstant",
"LoadConstant","OperatorInstruction","RegToSlot","Label","FunctionReturn",
"RegisterTransfer","Syscall","NilClass"]
check_return 0
end

View File

@ -17,9 +17,9 @@ HERE
def test_add
#show_ticks # get output of what is
check_chain ["Branch","Label","LoadConstant","GetSlot","SetSlot",
"LoadConstant","SetSlot","FunctionCall","Label","LoadConstant",
"LoadConstant","OperatorInstruction","SetSlot","Label","FunctionReturn",
check_chain ["Branch","Label","LoadConstant","GetSlot","RegToSlot",
"LoadConstant","RegToSlot","FunctionCall","Label","LoadConstant",
"LoadConstant","OperatorInstruction","RegToSlot","Label","FunctionReturn",
"RegisterTransfer","Syscall","NilClass"]
check_return 0
end

View File

@ -17,12 +17,12 @@ HERE
def test_chain
#show_ticks # get output of what is
check_chain ["Branch","Label","LoadConstant","GetSlot","SetSlot",
"LoadConstant","SetSlot","FunctionCall","Label","GetSlot",
"LoadConstant","SetSlot","LoadConstant","SetSlot","LoadConstant",
"SetSlot","LoadConstant","SetSlot","RegisterTransfer","FunctionCall",
check_chain ["Branch","Label","LoadConstant","GetSlot","RegToSlot",
"LoadConstant","RegToSlot","FunctionCall","Label","GetSlot",
"LoadConstant","RegToSlot","LoadConstant","RegToSlot","LoadConstant",
"RegToSlot","LoadConstant","RegToSlot","RegisterTransfer","FunctionCall",
"Label","GetSlot","GetSlot","RegisterTransfer","Syscall",
"RegisterTransfer","RegisterTransfer","SetSlot","Label","FunctionReturn",
"RegisterTransfer","RegisterTransfer","RegToSlot","Label","FunctionReturn",
"RegisterTransfer","GetSlot","GetSlot","Label","FunctionReturn",
"RegisterTransfer","Syscall","NilClass"]
end

View File

@ -20,12 +20,12 @@ HERE
def test_chain
#show_ticks # get output of what is
check_chain ["Branch","Label","LoadConstant","GetSlot","SetSlot",
"LoadConstant","SetSlot","FunctionCall","Label","GetSlot",
"LoadConstant","SetSlot","LoadConstant","SetSlot","LoadConstant",
"SetSlot","LoadConstant","SetSlot","LoadConstant","SetSlot",
check_chain ["Branch","Label","LoadConstant","GetSlot","RegToSlot",
"LoadConstant","RegToSlot","FunctionCall","Label","GetSlot",
"LoadConstant","RegToSlot","LoadConstant","RegToSlot","LoadConstant",
"RegToSlot","LoadConstant","RegToSlot","LoadConstant","RegToSlot",
"RegisterTransfer","FunctionCall","Label","GetSlot","GetSlot",
"GetByte","SetSlot","Label","FunctionReturn","RegisterTransfer",
"GetByte","RegToSlot","Label","FunctionReturn","RegisterTransfer",
"GetSlot","GetSlot","Label","FunctionReturn","RegisterTransfer",
"Syscall","NilClass"]
end

View File

@ -9,6 +9,8 @@ class TestNamedLists < MiniTest::Test
def test_named_list_get_type
assert_equal Parfait::Type , @type.class
assert @type.instance_names
assert @named_list.get_instance_variables
end
def test_named_list_next_set
@ -16,4 +18,13 @@ class TestNamedLists < MiniTest::Test
assert_equal :next_list , @named_list.next_list
end
def test_new
list = Parfait::NamedList.new
assert list.get_type
end
def test_var_names
list = Parfait::NamedList.new
assert list.get_instance_variables
end
end

View File

@ -9,7 +9,7 @@ class TestAssignStatement < MiniTest::Test
@input = s(:statements, s(:assignment, s(:name, :r), s(:operator_value, :+, s(:int, 10), s(:int, 1))))
@expect = [Label, LoadConstant, LoadConstant, OperatorInstruction, GetSlot, SetSlot, Label ,
@expect = [Label, LoadConstant, LoadConstant, OperatorInstruction, GetSlot, RegToSlot, Label ,
FunctionReturn]
check
end
@ -18,7 +18,7 @@ class TestAssignStatement < MiniTest::Test
Register.machine.space.get_main.add_local(:r , :Integer)
@input =s(:statements, s(:assignment, s(:name, :r), s(:int, 5)))
@expect = [Label, LoadConstant, GetSlot, SetSlot, Label, FunctionReturn]
@expect = [Label, LoadConstant, GetSlot, RegToSlot, Label, FunctionReturn]
check
end
@ -27,23 +27,23 @@ class TestAssignStatement < MiniTest::Test
@input = s(:statements, s(:assignment, s(:name, :r), s(:int, 5)))
@expect = [Label, LoadConstant, GetSlot, SetSlot, Label, FunctionReturn]
@expect = [Label, LoadConstant, GetSlot, RegToSlot, Label, FunctionReturn]
check
end
def test_assign_call
Register.machine.space.get_main.add_local(:r , :Integer)
@input = s(:statements, s(:assignment, s(:name, :r), s(:call, s(:name, :main), s(:arguments))))
@expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant ,
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
GetSlot, GetSlot, GetSlot, SetSlot, Label, FunctionReturn]
@expect = [Label, GetSlot, GetSlot, RegToSlot, LoadConstant, RegToSlot, LoadConstant ,
RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
GetSlot, GetSlot, GetSlot, RegToSlot, Label, FunctionReturn]
check
end
def test_named_list_get
Register.machine.space.get_main.add_local(:r , :Integer)
@input = s(:statements, s(:assignment, s(:name, :r), s(:int, 5)), s(:return, s(:name, :r)))
@expect = [Label, LoadConstant, GetSlot, SetSlot, GetSlot, GetSlot, SetSlot ,
@expect = [Label, LoadConstant, GetSlot, RegToSlot, GetSlot, GetSlot, RegToSlot ,
Label, FunctionReturn]
was = check
get = was.next(5)
@ -54,20 +54,20 @@ class TestAssignStatement < MiniTest::Test
def test_assign_int
Register.machine.space.get_main.add_local(:r , :Integer)
@input = s(:statements, s(:assignment, s(:name, :r), s(:int, 5)) )
@expect = [Label, LoadConstant, GetSlot, SetSlot, Label, FunctionReturn]
@expect = [Label, LoadConstant, GetSlot, RegToSlot, Label, FunctionReturn]
was = check
set = was.next(3)
assert_equal SetSlot , set.class
assert_equal RegToSlot , set.class
assert_equal 1, set.index , "Set to named_list index must be offset, not #{set.index}"
end
def test_assign_arg
Register.machine.space.get_main.add_argument(:blar , :Integer)
@input = s(:statements, s(:assignment, s(:name, :blar), s(:int, 5)))
@expect = [Label, LoadConstant, SetSlot, Label, FunctionReturn]
@expect = [Label, LoadConstant, RegToSlot, Label, FunctionReturn]
was = check
set = was.next(2)
assert_equal SetSlot , set.class
assert_equal RegToSlot , set.class
assert_equal 10, set.index , "Set to args index must be offset, not #{set.index}"
end
@ -75,7 +75,7 @@ class TestAssignStatement < MiniTest::Test
# have to define bar externally, just because redefining main. Otherwise that would be automatic
Register.machine.space.get_main.add_argument(:balr , :Integer)
@input = s(:statements, s(:return, s(:name, :balr)))
@expect = [Label, GetSlot, SetSlot, Label, FunctionReturn]
@expect = [Label, GetSlot, RegToSlot, Label, FunctionReturn]
was = check
get = was.next(1)
assert_equal GetSlot , get.class

View File

@ -7,8 +7,8 @@ class TestCallStatement < MiniTest::Test
def test_call_constant_int
clean_compile :Integer, :puti, {}, s(:statements, s(:return, s(:int, 1)))
@input = s(:call, s(:name, :puti), s(:arguments), s(:receiver, s(:int, 42)))
@expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant ,
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
@expect = [Label, GetSlot, LoadConstant, RegToSlot, LoadConstant, RegToSlot, LoadConstant ,
RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
GetSlot, GetSlot, Label, FunctionReturn]
check
end
@ -18,8 +18,8 @@ class TestCallStatement < MiniTest::Test
clean_compile :Word, :putstr,{}, s(:statements, s(:return, s(:int, 1)))
@input =s(:call, s(:name, :putstr), s(:arguments), s(:receiver, s(:string, "Hello")))
@expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant ,
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
@expect = [Label, GetSlot, LoadConstant, RegToSlot, LoadConstant, RegToSlot, LoadConstant ,
RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
GetSlot, GetSlot, Label, FunctionReturn]
check
end
@ -29,8 +29,8 @@ class TestCallStatement < MiniTest::Test
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))))
@expect = [Label, LoadConstant, GetSlot, SetSlot, GetSlot, GetSlot, GetSlot ,
SetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot ,
@expect = [Label, LoadConstant, GetSlot, RegToSlot, GetSlot, GetSlot, GetSlot ,
RegToSlot, LoadConstant, RegToSlot, LoadConstant, RegToSlot, LoadConstant, RegToSlot ,
RegisterTransfer, FunctionCall, Label, RegisterTransfer, GetSlot, GetSlot, Label ,
FunctionReturn]
check
@ -41,8 +41,8 @@ class TestCallStatement < MiniTest::Test
clean_compile :List, :add, {}, s(:statements, s(:return, s(:int, 1)))
@input =s(:statements, s(:call, s(:name, :add), s(:arguments), s(:receiver, s(:name, :test_l))))
@expect = [Label, GetSlot, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot ,
LoadConstant, SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label ,
@expect = [Label, GetSlot, GetSlot, GetSlot, RegToSlot, LoadConstant, RegToSlot ,
LoadConstant, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall, Label ,
RegisterTransfer, GetSlot, GetSlot, Label, FunctionReturn]
check
end
@ -58,12 +58,12 @@ int main()
end
end
HERE
@expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant ,
SetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall ,
@expect = [Label, GetSlot, GetSlot, RegToSlot, LoadConstant, RegToSlot, LoadConstant ,
RegToSlot, LoadConstant, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall ,
Label, RegisterTransfer, GetSlot, GetSlot, Label, FunctionReturn]
was = check
set = was.next(7)
assert_equal SetSlot , set.class
assert_equal RegToSlot , set.class
assert_equal 9, set.index , "Set to message must be offset, not #{set.index}"
end
end

View File

@ -11,7 +11,7 @@ class TestClassStatements < MiniTest::Test
def test_class_defs
class_def
@input =s(:statements, s(:return, s(:int, 1)))
@expect = [Label, LoadConstant,SetSlot,Label,FunctionReturn]
@expect = [Label, LoadConstant,RegToSlot,Label,FunctionReturn]
check
end
@ -20,9 +20,9 @@ class TestClassStatements < MiniTest::Test
# class_def
# @input = s(:statements, s(:return, s(:call, s(:name, :buh), s(:arguments), s(:receiver, s(:class_name, :Bar)))))
#
# @expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant ,
# SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
# GetSlot, GetSlot, SetSlot, Label, FunctionReturn]
# @expect = [Label, GetSlot, LoadConstant, RegToSlot, LoadConstant, RegToSlot, LoadConstant ,
# RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
# GetSlot, GetSlot, RegToSlot, Label, FunctionReturn]
# check
end
@ -31,7 +31,7 @@ class TestClassStatements < MiniTest::Test
#FIXME class_field handling unclear at the moment
# @input =s(:statements, s(:return, s(:field_access, s(:receiver, s(:name, :self)),
# s(:field,s(:name, :boo2)))))
# @expect = [Label, GetSlot,GetSlot,SetSlot,Label,FunctionReturn]
# @expect = [Label, GetSlot,GetSlot,RegToSlot,Label,FunctionReturn]
# check
end
end

View File

@ -9,7 +9,7 @@ module Register
Register.machine.space.get_main.add_local( :m , :Message)
@input = s(:statements, s(:return, s(:field_access,
s(:receiver, s(:name, :m)), s(:field, s(:name, :name)))))
@expect = [Label, GetSlot, GetSlot, GetSlot, SetSlot, Label, FunctionReturn]
@expect = [Label, GetSlot, GetSlot, GetSlot, RegToSlot, Label, FunctionReturn]
check
end
@ -20,9 +20,9 @@ module Register
s(:receiver, s(:name, :main)), s(:field, s(:name, :name)))))
@input =s(:statements, s(:return, s(:call, s(:name, :get_name), s(:arguments, s(:name, :m)))))
@expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant ,
SetSlot, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, RegisterTransfer ,
FunctionCall, Label, RegisterTransfer, GetSlot, GetSlot, SetSlot, Label ,
@expect = [Label, GetSlot, GetSlot, RegToSlot, LoadConstant, RegToSlot, LoadConstant ,
RegToSlot, GetSlot, GetSlot, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer ,
FunctionCall, Label, RegisterTransfer, GetSlot, GetSlot, RegToSlot, Label ,
FunctionReturn]
check
end
@ -31,8 +31,8 @@ module Register
Register.machine.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)))
@expect = [Label, RegisterTransfer, GetSlot, GetSlot, SetSlot, GetSlot, GetSlot ,
SetSlot, Label, FunctionReturn]
@expect = [Label, RegisterTransfer, GetSlot, GetSlot, RegToSlot, GetSlot, GetSlot ,
RegToSlot, Label, FunctionReturn]
check
end
end

View File

@ -8,7 +8,7 @@ class TestIfStatement < MiniTest::Test
@input = s(:statements, s(:if_statement, :plus, s(:condition, s(:operator_value, :-, s(:int, 10), s(:int, 12))), s(:true_statements, s(:return, s(:int, 3))), s(:false_statements, s(:return, s(:int, 4)))))
@expect = [Label, LoadConstant,LoadConstant, OperatorInstruction,IsPlus ,
LoadConstant,SetSlot,Branch , Label , LoadConstant ,SetSlot,
LoadConstant,RegToSlot,Branch , Label , LoadConstant ,RegToSlot,
Label,Label,FunctionReturn]
check
end
@ -18,7 +18,7 @@ class TestIfStatement < MiniTest::Test
@input = s(:statements, s(:if_statement, :minus, s(:condition, s(:operator_value, :-, s(:int, 10), s(:int, 12))), s(:true_statements, s(:return, s(:int, 3))), s(:false_statements, nil)))
@expect = [Label, LoadConstant, LoadConstant, OperatorInstruction, IsMinus, Branch, Label ,
LoadConstant, SetSlot, Label, Label, FunctionReturn]
LoadConstant, RegToSlot, Label, Label, FunctionReturn]
check
end
@ -27,7 +27,7 @@ class TestIfStatement < MiniTest::Test
@input = s(:statements, s(:if_statement, :zero, s(:condition, s(:operator_value, :-, s(:int, 10), s(:int, 12))), s(:true_statements, s(:return, s(:int, 3))), s(:false_statements, nil)))
@expect = [Label, LoadConstant,LoadConstant,OperatorInstruction,IsZero ,
Branch , Label , LoadConstant ,SetSlot,
Branch , Label , LoadConstant ,RegToSlot,
Label,Label, FunctionReturn]
check
end

View File

@ -6,37 +6,37 @@ class TestReturnStatement < MiniTest::Test
def test_return_int
@input = s(:statements, s(:return, s(:int, 5)))
@expect = [Label, LoadConstant ,SetSlot,Label,FunctionReturn]
@expect = [Label, LoadConstant ,RegToSlot,Label,FunctionReturn]
check
end
def test_return_local
Register.machine.space.get_main.add_local(:runner , :Integer)
@input = s(:statements, s(:return, s(:name, :runner)))
@expect = [Label, GetSlot,GetSlot ,SetSlot,Label,FunctionReturn]
@expect = [Label, GetSlot,GetSlot ,RegToSlot,Label,FunctionReturn]
check
end
def test_return_local_assign
Register.machine.space.get_main.add_local(:runner , :Integer)
@input = s(:statements, s(:assignment, s(:name, :runner), s(:int, 5)), s(:return, s(:name, :runner)))
@expect = [Label, LoadConstant,GetSlot,SetSlot,GetSlot,GetSlot ,SetSlot,
@expect = [Label, LoadConstant,GetSlot,RegToSlot,GetSlot,GetSlot ,RegToSlot,
Label,FunctionReturn]
check
end
def test_return_call
@input =s(:statements, s(:return, s(:call, s(:name, :main), s(:arguments))))
@expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant ,
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
GetSlot, GetSlot, SetSlot, Label, FunctionReturn]
@expect = [Label, GetSlot, GetSlot, RegToSlot, LoadConstant, RegToSlot, LoadConstant ,
RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
GetSlot, GetSlot, RegToSlot, Label, FunctionReturn]
check
end
def pest_return_space_length # need to add runtime first
Register.machine.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)))))
@expect = [Label, GetSlot,GetSlot ,SetSlot,Label,FunctionReturn]
@expect = [Label, GetSlot,GetSlot ,RegToSlot,Label,FunctionReturn]
check
end

View File

@ -8,7 +8,7 @@ module Register
def test_while_mini
@input = s(:statements, s(:while_statement, :plus, s(:conditional, s(:int, 1)), s(:statements, s(:return, s(:int, 3)))))
@expect = [Label, Branch, Label, LoadConstant, SetSlot, Label, LoadConstant ,
@expect = [Label, Branch, Label, LoadConstant, RegToSlot, Label, LoadConstant ,
IsPlus, Label, FunctionReturn]
check
end
@ -18,9 +18,9 @@ module Register
@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)))
@expect = [Label, LoadConstant, GetSlot, SetSlot, Branch, Label, GetSlot ,
GetSlot, LoadConstant, OperatorInstruction, GetSlot, SetSlot, Label, GetSlot ,
GetSlot, IsPlus, GetSlot, GetSlot, SetSlot, Label, FunctionReturn]
@expect = [Label, LoadConstant, GetSlot, RegToSlot, Branch, Label, GetSlot ,
GetSlot, LoadConstant, OperatorInstruction, GetSlot, RegToSlot, Label, GetSlot ,
GetSlot, IsPlus, GetSlot, GetSlot, RegToSlot, Label, FunctionReturn]
check
end
@ -30,9 +30,9 @@ module Register
@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)))))
@expect = [Label, LoadConstant, GetSlot, SetSlot, Branch, Label, GetSlot ,
GetSlot, LoadConstant, OperatorInstruction, GetSlot, SetSlot, GetSlot, GetSlot ,
SetSlot, Label, GetSlot, GetSlot, LoadConstant, OperatorInstruction, IsPlus ,
@expect = [Label, LoadConstant, GetSlot, RegToSlot, Branch, Label, GetSlot ,
GetSlot, LoadConstant, OperatorInstruction, GetSlot, RegToSlot, GetSlot, GetSlot ,
RegToSlot, Label, GetSlot, GetSlot, LoadConstant, OperatorInstruction, IsPlus ,
Label, FunctionReturn]
check
end