adding arg length to call sequence
and fix all the tests that affects
This commit is contained in:
parent
bd171d091a
commit
bb908dcf76
@ -28,7 +28,12 @@ module Soml
|
|||||||
name_tmp = use_reg(:Word)
|
name_tmp = use_reg(:Word)
|
||||||
add_code Register::LoadConstant.new(statement, name , name_tmp)
|
add_code Register::LoadConstant.new(statement, name , name_tmp)
|
||||||
add_code Register.set_slot( statement , name_tmp , :new_message , :name)
|
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|
|
arguments.to_a.each_with_index do |arg , i|
|
||||||
reset_regs
|
reset_regs
|
||||||
# processing should return the register with the value
|
# processing should return the register with the value
|
||||||
|
@ -16,7 +16,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@length = 36
|
@length = 38
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@length = 179
|
@length = 191
|
||||||
check
|
check
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -11,7 +11,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@length = 35
|
@length = 37
|
||||||
@stdout = "Hello Raisa, I am salama"
|
@stdout = "Hello Raisa, I am salama"
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
@ -31,7 +31,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@length = 45
|
@length = 47
|
||||||
@stdout = "10"
|
@stdout = "10"
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
@ -53,7 +53,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@length = 57
|
@length = 61
|
||||||
@stdout = "else"
|
@stdout = "else"
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
@ -16,7 +16,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@length = 30
|
@length = 32
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -27,7 +27,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@length = 71
|
@length = 77
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -55,7 +55,7 @@ class Object
|
|||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@expect = [Label, SaveReturn,GetSlot,GetSlot,SetSlot, LoadConstant,SetSlot,
|
@expect = [Label, SaveReturn,GetSlot,GetSlot,SetSlot, LoadConstant,SetSlot,
|
||||||
RegisterTransfer,FunctionCall,GetSlot,GetSlot,SetSlot ,
|
LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot,GetSlot,SetSlot ,
|
||||||
Label,RegisterTransfer,GetSlot,FunctionReturn]
|
Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
@ -18,7 +18,7 @@ class Object
|
|||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@expect = [Label, SaveReturn,GetSlot,LoadConstant,
|
@expect = [Label, SaveReturn,GetSlot,LoadConstant,
|
||||||
SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot ,
|
SetSlot,LoadConstant,SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot ,
|
||||||
Label,RegisterTransfer,GetSlot,FunctionReturn]
|
Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
@ -38,7 +38,7 @@ class Object
|
|||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@expect = [Label, SaveReturn,GetSlot,LoadConstant,
|
@expect = [Label, SaveReturn,GetSlot,LoadConstant,
|
||||||
SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot ,
|
SetSlot,LoadConstant,SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot ,
|
||||||
Label,RegisterTransfer,GetSlot,FunctionReturn]
|
Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
@ -58,7 +58,7 @@ class Object
|
|||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@expect = [ Label, SaveReturn,LoadConstant,GetSlot,SetSlot,GetSlot,
|
@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]
|
GetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
@ -78,7 +78,7 @@ class Object
|
|||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@expect = [ Label, SaveReturn,GetSlot,GetSlot,GetSlot,SetSlot,
|
@expect = [ Label, SaveReturn,GetSlot,GetSlot,GetSlot,SetSlot,
|
||||||
LoadConstant,SetSlot,RegisterTransfer,FunctionCall,
|
LoadConstant,SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,
|
||||||
GetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
GetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
@ -95,12 +95,12 @@ end
|
|||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@expect = [ Label, SaveReturn , GetSlot,GetSlot,SetSlot,LoadConstant,SetSlot,LoadConstant,
|
@expect = [ Label, SaveReturn , GetSlot,GetSlot,SetSlot,LoadConstant,SetSlot,LoadConstant,
|
||||||
SetSlot,RegisterTransfer,FunctionCall,GetSlot,
|
SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot,
|
||||||
Label,RegisterTransfer,GetSlot,FunctionReturn]
|
Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||||
was = check
|
was = check
|
||||||
set = was.next(8)
|
set = was.next(8)
|
||||||
assert_equal SetSlot , set.class
|
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
|
end
|
||||||
end
|
end
|
||||||
|
@ -34,7 +34,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
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]
|
RegisterTransfer,FunctionCall,GetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
@ -66,7 +66,8 @@ class Object
|
|||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@expect = [Label, SaveReturn,GetSlot,GetSlot,SetSlot, LoadConstant,
|
@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
|
check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -61,29 +61,31 @@ HERE
|
|||||||
#show_ticks # get output of what is
|
#show_ticks # get output of what is
|
||||||
["Branch","Label","LoadConstant","GetSlot","SetSlot",
|
["Branch","Label","LoadConstant","GetSlot","SetSlot",
|
||||||
"RegisterTransfer","FunctionCall","Label","SaveReturn","GetSlot",
|
"RegisterTransfer","FunctionCall","Label","SaveReturn","GetSlot",
|
||||||
"LoadConstant","SetSlot","LoadConstant","SetSlot","RegisterTransfer",
|
"LoadConstant","SetSlot","LoadConstant","SetSlot","LoadConstant",
|
||||||
"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",
|
|
||||||
"SetSlot","RegisterTransfer","FunctionCall","Label","SaveReturn",
|
"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","GetSlot","LoadConstant","OperatorInstruction","IsZero",
|
||||||
"Label","LoadConstant","Label","GetSlot","LoadConstant",
|
"Label","LoadConstant","Label","GetSlot","LoadConstant",
|
||||||
"OperatorInstruction","IsZero","Label","LoadConstant","Label",
|
"OperatorInstruction","IsZero","Label","LoadConstant","Label",
|
||||||
"GetSlot","LoadConstant","OperatorInstruction","IsZero","Label",
|
"Label","RegisterTransfer","GetSlot","FunctionReturn","GetSlot",
|
||||||
"LoadConstant","Label","GetSlot","LoadConstant","OperatorInstruction",
|
"GetSlot","SetSlot","GetSlot","GetSlot","GetSlot",
|
||||||
"IsZero","Label","LoadConstant","Label","Label",
|
"OperatorInstruction","SetSlot","Label","GetSlot","Label",
|
||||||
"RegisterTransfer","GetSlot","FunctionReturn","GetSlot","GetSlot",
|
"RegisterTransfer","GetSlot","FunctionReturn","GetSlot","Label",
|
||||||
"SetSlot","GetSlot","GetSlot","GetSlot","OperatorInstruction",
|
"RegisterTransfer","GetSlot","FunctionReturn","GetSlot","Label",
|
||||||
"SetSlot","Label","GetSlot","Label","RegisterTransfer",
|
"RegisterTransfer","GetSlot","FunctionReturn","RegisterTransfer","Syscall",
|
||||||
"GetSlot","FunctionReturn","GetSlot","Label","RegisterTransfer",
|
"NilClass"].each_with_index do |name , index|
|
||||||
"GetSlot","FunctionReturn","GetSlot","Label","RegisterTransfer",
|
|
||||||
"GetSlot","FunctionReturn","RegisterTransfer","Syscall","NilClass"].each_with_index do |name , index|
|
|
||||||
got = ticks(1)
|
got = ticks(1)
|
||||||
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
|
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
|
||||||
end
|
end
|
||||||
|
@ -59,12 +59,12 @@ class TestPuts < MiniTest::Test
|
|||||||
#show_ticks # get output of what is
|
#show_ticks # get output of what is
|
||||||
[ "Branch","Label","LoadConstant","GetSlot","SetSlot",
|
[ "Branch","Label","LoadConstant","GetSlot","SetSlot",
|
||||||
"RegisterTransfer","FunctionCall","Label","SaveReturn","GetSlot",
|
"RegisterTransfer","FunctionCall","Label","SaveReturn","GetSlot",
|
||||||
"LoadConstant","SetSlot","LoadConstant","SetSlot","RegisterTransfer",
|
"LoadConstant","SetSlot","LoadConstant","SetSlot","LoadConstant",
|
||||||
"FunctionCall","Label","SaveReturn","GetSlot","RegisterTransfer",
|
"SetSlot","RegisterTransfer","FunctionCall","Label","SaveReturn",
|
||||||
"Syscall","RegisterTransfer","RegisterTransfer","SetSlot","Label",
|
"GetSlot","RegisterTransfer","Syscall","RegisterTransfer","RegisterTransfer",
|
||||||
"RegisterTransfer","GetSlot","FunctionReturn","GetSlot","Label",
|
"SetSlot","Label","RegisterTransfer","GetSlot","FunctionReturn",
|
||||||
"RegisterTransfer","GetSlot","FunctionReturn","RegisterTransfer","Syscall",
|
"GetSlot","Label","RegisterTransfer","GetSlot","FunctionReturn",
|
||||||
"NilClass"].each_with_index do |name , index|
|
"RegisterTransfer","Syscall","NilClass"].each_with_index do |name , index|
|
||||||
got = ticks(1)
|
got = ticks(1)
|
||||||
#puts "TICK #{index}"
|
#puts "TICK #{index}"
|
||||||
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
|
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
|
||||||
@ -72,20 +72,20 @@ class TestPuts < MiniTest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_putstring
|
def test_putstring
|
||||||
done = ticks(21)
|
done = ticks(23)
|
||||||
assert_equal Register::Syscall , done.class
|
assert_equal Register::Syscall , done.class
|
||||||
assert_equal "Hello again" , @interpreter.stdout
|
assert_equal "Hello again" , @interpreter.stdout
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_return
|
def test_return
|
||||||
done = ticks(28)
|
done = ticks(30)
|
||||||
assert_equal Register::FunctionReturn , done.class
|
assert_equal Register::FunctionReturn , done.class
|
||||||
assert Register::Label , @interpreter.instruction.class
|
assert Register::Label , @interpreter.instruction.class
|
||||||
assert @interpreter.instruction.is_a?(Register::Instruction) , "not instruction #{@interpreter.instruction}"
|
assert @interpreter.instruction.is_a?(Register::Instruction) , "not instruction #{@interpreter.instruction}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_exit
|
def test_exit
|
||||||
done = ticks(36)
|
done = ticks(38)
|
||||||
assert_equal NilClass , done.class
|
assert_equal NilClass , done.class
|
||||||
assert_equal "Hello again" , @interpreter.stdout
|
assert_equal "Hello again" , @interpreter.stdout
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user