adding arg length to call sequence

and fix all the tests that affects
This commit is contained in:
Torsten Ruger 2015-10-27 16:21:11 +02:00
parent bd171d091a
commit bb908dcf76
13 changed files with 53 additions and 45 deletions

View File

@ -28,7 +28,12 @@ module Soml
name_tmp = use_reg(:Word)
add_code Register::LoadConstant.new(statement, name , name_tmp)
add_code Register.set_slot( statement , name_tmp , :new_message , :name)
# next arguments. reset tmp regs for each and load result into new_message
# next arguments. first length then args
len_tmp = use_reg(:Integer , arguments.to_a.length )
add_code Register::LoadConstant.new(statement, arguments.to_a.length , len_tmp)
add_code Register.set_slot( statement , len_tmp , :new_message , :indexed_length)
# reset tmp regs for each and load result into new_message
arguments.to_a.each_with_index do |arg , i|
reset_regs
# processing should return the register with the value

View File

@ -16,7 +16,7 @@ class Object
end
end
HERE
@length = 36
@length = 38
check
end

View File

@ -28,7 +28,7 @@ class Object
end
end
HERE
@length = 179
@length = 191
check
end

View File

@ -11,7 +11,7 @@ class Object
end
end
HERE
@length = 35
@length = 37
@stdout = "Hello Raisa, I am salama"
check
end

View File

@ -31,7 +31,7 @@ class Object
end
end
HERE
@length = 45
@length = 47
@stdout = "10"
check
end
@ -53,7 +53,7 @@ class Object
end
end
HERE
@length = 57
@length = 61
@stdout = "else"
check
end

View File

@ -16,7 +16,7 @@ class Object
end
end
HERE
@length = 30
@length = 32
check
end
end

View File

@ -27,7 +27,7 @@ class Object
end
end
HERE
@length = 71
@length = 77
check
end
end

View File

@ -55,7 +55,7 @@ class Object
end
HERE
@expect = [Label, SaveReturn,GetSlot,GetSlot,SetSlot, LoadConstant,SetSlot,
RegisterTransfer,FunctionCall,GetSlot,GetSlot,SetSlot ,
LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot,GetSlot,SetSlot ,
Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end

View File

@ -18,7 +18,7 @@ class Object
end
HERE
@expect = [Label, SaveReturn,GetSlot,LoadConstant,
SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot ,
SetSlot,LoadConstant,SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot ,
Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -38,7 +38,7 @@ class Object
end
HERE
@expect = [Label, SaveReturn,GetSlot,LoadConstant,
SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot ,
SetSlot,LoadConstant,SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot ,
Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -58,7 +58,7 @@ class Object
end
HERE
@expect = [ Label, SaveReturn,LoadConstant,GetSlot,SetSlot,GetSlot,
GetSlot,GetSlot,SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,
GetSlot,GetSlot,SetSlot,LoadConstant,SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,
GetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -78,7 +78,7 @@ class Object
end
HERE
@expect = [ Label, SaveReturn,GetSlot,GetSlot,GetSlot,SetSlot,
LoadConstant,SetSlot,RegisterTransfer,FunctionCall,
LoadConstant,SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,
GetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -95,12 +95,12 @@ end
end
HERE
@expect = [ Label, SaveReturn , GetSlot,GetSlot,SetSlot,LoadConstant,SetSlot,LoadConstant,
SetSlot,RegisterTransfer,FunctionCall,GetSlot,
SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot,
Label,RegisterTransfer,GetSlot,FunctionReturn]
was = check
set = was.next(8)
assert_equal SetSlot , set.class
assert_equal 10, set.index , "Set to message must be offset, not #{set.index}"
assert_equal 9, set.index , "Set to message must be offset, not #{set.index}"
end
end
end

View File

@ -34,7 +34,7 @@ class Object
end
end
HERE
@expect = [Label, SaveReturn,GetSlot,LoadConstant,SetSlot,LoadConstant,SetSlot,
@expect = [Label, SaveReturn,GetSlot,LoadConstant,SetSlot,LoadConstant,SetSlot,LoadConstant,SetSlot,
RegisterTransfer,FunctionCall,GetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end

View File

@ -66,7 +66,8 @@ class Object
end
HERE
@expect = [Label, SaveReturn,GetSlot,GetSlot,SetSlot, LoadConstant,
SetSlot,RegisterTransfer,FunctionCall,GetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot ,Label,
RegisterTransfer,GetSlot,FunctionReturn]
check
end
end

View File

@ -61,29 +61,31 @@ HERE
#show_ticks # get output of what is
["Branch","Label","LoadConstant","GetSlot","SetSlot",
"RegisterTransfer","FunctionCall","Label","SaveReturn","GetSlot",
"LoadConstant","SetSlot","LoadConstant","SetSlot","RegisterTransfer",
"FunctionCall","Label","SaveReturn","LoadConstant","GetSlot",
"SetSlot","GetSlot","GetSlot","SetSlot","LoadConstant",
"SetSlot","GetSlot","GetSlot","SetSlot","RegisterTransfer",
"FunctionCall","Label","SaveReturn","GetSlot","LoadConstant",
"OperatorInstruction","GetSlot","SetSlot","GetSlot","GetSlot",
"GetSlot","OperatorInstruction","GetSlot","SetSlot","GetSlot",
"GetSlot","IsNotzero","Label","GetSlot","GetSlot",
"SetSlot","LoadConstant","SetSlot","GetSlot","GetSlot",
"LoadConstant","SetSlot","LoadConstant","SetSlot","LoadConstant",
"SetSlot","RegisterTransfer","FunctionCall","Label","SaveReturn",
"GetSlot","LoadConstant","OperatorInstruction","IsZero","Branch",
"LoadConstant","GetSlot","SetSlot","GetSlot","GetSlot",
"SetSlot","LoadConstant","SetSlot","LoadConstant","SetSlot",
"GetSlot","GetSlot","SetSlot","RegisterTransfer","FunctionCall",
"Label","SaveReturn","GetSlot","LoadConstant","OperatorInstruction",
"GetSlot","SetSlot","GetSlot","GetSlot","GetSlot",
"OperatorInstruction","GetSlot","SetSlot","GetSlot","GetSlot",
"IsNotzero","Label","GetSlot","GetSlot","SetSlot",
"LoadConstant","SetSlot","LoadConstant","SetSlot","GetSlot",
"GetSlot","SetSlot","RegisterTransfer","FunctionCall","Label",
"SaveReturn","GetSlot","LoadConstant","OperatorInstruction","IsZero",
"Branch","Label","GetSlot","LoadConstant","OperatorInstruction",
"IsZero","Label","LoadConstant","Label","GetSlot",
"LoadConstant","OperatorInstruction","IsZero","Label","LoadConstant",
"Label","GetSlot","LoadConstant","OperatorInstruction","IsZero",
"Label","LoadConstant","Label","GetSlot","LoadConstant",
"OperatorInstruction","IsZero","Label","LoadConstant","Label",
"GetSlot","LoadConstant","OperatorInstruction","IsZero","Label",
"LoadConstant","Label","GetSlot","LoadConstant","OperatorInstruction",
"IsZero","Label","LoadConstant","Label","Label",
"RegisterTransfer","GetSlot","FunctionReturn","GetSlot","GetSlot",
"SetSlot","GetSlot","GetSlot","GetSlot","OperatorInstruction",
"SetSlot","Label","GetSlot","Label","RegisterTransfer",
"GetSlot","FunctionReturn","GetSlot","Label","RegisterTransfer",
"GetSlot","FunctionReturn","GetSlot","Label","RegisterTransfer",
"GetSlot","FunctionReturn","RegisterTransfer","Syscall","NilClass"].each_with_index do |name , index|
"Label","RegisterTransfer","GetSlot","FunctionReturn","GetSlot",
"GetSlot","SetSlot","GetSlot","GetSlot","GetSlot",
"OperatorInstruction","SetSlot","Label","GetSlot","Label",
"RegisterTransfer","GetSlot","FunctionReturn","GetSlot","Label",
"RegisterTransfer","GetSlot","FunctionReturn","GetSlot","Label",
"RegisterTransfer","GetSlot","FunctionReturn","RegisterTransfer","Syscall",
"NilClass"].each_with_index do |name , index|
got = ticks(1)
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
end

View File

@ -59,12 +59,12 @@ class TestPuts < MiniTest::Test
#show_ticks # get output of what is
[ "Branch","Label","LoadConstant","GetSlot","SetSlot",
"RegisterTransfer","FunctionCall","Label","SaveReturn","GetSlot",
"LoadConstant","SetSlot","LoadConstant","SetSlot","RegisterTransfer",
"FunctionCall","Label","SaveReturn","GetSlot","RegisterTransfer",
"Syscall","RegisterTransfer","RegisterTransfer","SetSlot","Label",
"RegisterTransfer","GetSlot","FunctionReturn","GetSlot","Label",
"RegisterTransfer","GetSlot","FunctionReturn","RegisterTransfer","Syscall",
"NilClass"].each_with_index do |name , index|
"LoadConstant","SetSlot","LoadConstant","SetSlot","LoadConstant",
"SetSlot","RegisterTransfer","FunctionCall","Label","SaveReturn",
"GetSlot","RegisterTransfer","Syscall","RegisterTransfer","RegisterTransfer",
"SetSlot","Label","RegisterTransfer","GetSlot","FunctionReturn",
"GetSlot","Label","RegisterTransfer","GetSlot","FunctionReturn",
"RegisterTransfer","Syscall","NilClass"].each_with_index do |name , index|
got = ticks(1)
#puts "TICK #{index}"
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
@ -72,20 +72,20 @@ class TestPuts < MiniTest::Test
end
def test_putstring
done = ticks(21)
done = ticks(23)
assert_equal Register::Syscall , done.class
assert_equal "Hello again" , @interpreter.stdout
end
def test_return
done = ticks(28)
done = ticks(30)
assert_equal Register::FunctionReturn , done.class
assert Register::Label , @interpreter.instruction.class
assert @interpreter.instruction.is_a?(Register::Instruction) , "not instruction #{@interpreter.instruction}"
end
def test_exit
done = ticks(36)
done = ticks(38)
assert_equal NilClass , done.class
assert_equal "Hello again" , @interpreter.stdout
end