store method, not name, in message

changes the calling and thus too many test
This commit is contained in:
Torsten Ruger 2018-07-22 22:29:32 +03:00
parent b6c85cd4a4
commit d80ef4bf4e
41 changed files with 384 additions and 398 deletions

View File

@ -72,8 +72,7 @@ module Mom
named_list << next_message[:frame] named_list << next_message[:frame]
named_list[:type] << type named_list[:type] << type
name << callable_method[:name] next_message[:method] << callable_method
next_message[:name] << name
#store next.next back into space #store next.next back into space
#FIXME in a multithreaded future this should be done soon after getting #FIXME in a multithreaded future this should be done soon after getting

View File

@ -18,7 +18,7 @@ module Parfait
attr_accessor :next_message attr_accessor :next_message
attr_reader :receiver , :frame attr_reader :receiver , :frame
attr_reader :return_address, :return_value attr_reader :return_address, :return_value
attr_reader :caller , :name , :arguments attr_reader :caller , :method , :arguments
def initialize( next_m ) def initialize( next_m )
@next_message = next_m @next_message = next_m
@ -40,7 +40,7 @@ module Parfait
get_at(index) get_at(index)
end end
def to_s def to_s
"Message:#{name}(#{arguments.get_length})" "Message:#{method&.name}(#{arguments.get_length})"
end end
end end
end end

View File

@ -154,7 +154,7 @@ module Parfait
List: {indexed_length: :Integer , next_list: :List} , List: {indexed_length: :Integer , next_list: :List} ,
Message: { next_message: :Message, receiver: :Object, frame: :NamedList , Message: { next_message: :Message, receiver: :Object, frame: :NamedList ,
return_address: :Integer, return_value: :Object, return_address: :Integer, return_value: :Object,
caller: :Message , name: :Word , arguments: :NamedList }, caller: :Message , method: :TypedMethod , arguments: :NamedList },
NamedList: {}, NamedList: {},
NilClass: {}, NilClass: {},
Object: {}, Object: {},

View File

@ -9,10 +9,10 @@ module Risc
@input = "r = 5.div4" @input = "r = 5.div4"
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, @expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, RegToSlot, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, FunctionCall, Label, SlotToReg, SlotToReg, FunctionCall, Label, SlotToReg, SlotToReg,
SlotToReg, RegToSlot] RegToSlot]
end end
def test_local_assign_instructions def test_local_assign_instructions
assert_nil msg = check_nil , msg assert_nil msg = check_nil , msg
@ -20,7 +20,7 @@ module Risc
def test_constant_load def test_constant_load
produced = produce_body produced = produce_body
load = produced.next(15) load = produced.next(14)
assert_equal LoadConstant , load.class assert_equal LoadConstant , load.class
assert_equal 5 , load.constant.value assert_equal 5 , load.constant.value
end end

View File

@ -17,10 +17,10 @@ module Risc
RegToSlot, RegToSlot, Label, RegToSlot, Label, RegToSlot, RegToSlot, Label, RegToSlot, Label,
LoadConstant, SlotToReg, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant, SlotToReg,
SlotToReg, DynamicJump, Label] DynamicJump, Label]
end end
def test_send_instructions def test_send_instructions
@ -38,7 +38,7 @@ module Risc
end end
def test_function_call def test_function_call
produced = produce_body produced = produce_body
assert_equal DynamicJump , produced.next(66).class assert_equal DynamicJump , produced.next(65).class
end end
def test_cache_check def test_cache_check
produced = produce_body produced = produce_body

View File

@ -9,9 +9,9 @@ module Risc
@input = "5.div4" @input = "5.div4"
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, @expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, RegToSlot, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, FunctionCall, Label] SlotToReg, FunctionCall, Label]
end end
def test_send_instructions def test_send_instructions
@ -19,24 +19,24 @@ module Risc
end end
def test_load_5 def test_load_5
produced = produce_body produced = produce_body
assert_equal 5 , produced.next(15).constant.value assert_equal 5 , produced.next(14).constant.value
end end
def test_load_label def test_load_label
produced = produce_body produced = produce_body
assert_equal Label , produced.next(18).constant.class assert_equal Label , produced.next(17).constant.class
end end
def test_call_reg_setup def test_call_reg_setup
produced = produce_body produced = produce_body
assert_equal :div4 , produced.next(22).method.name assert_equal :div4 , produced.next(21).method.name
end end
def test_function_call def test_function_call
produced = produce_body produced = produce_body
assert_equal FunctionCall , produced.next(22).class assert_equal FunctionCall , produced.next(21).class
assert_equal :div4 , produced.next(22).method.name assert_equal :div4 , produced.next(21).method.name
end end
def test_check_continue def test_check_continue
produced = produce_body produced = produce_body
assert produced.next(23).name.start_with?("continue_") assert produced.next(22).name.start_with?("continue_")
end end
#TODO check the message setup, type and frame moves #TODO check the message setup, type and frame moves
end end

View File

@ -9,10 +9,10 @@ module Risc
@input = "5.get_internal_word(1)" @input = "5.get_internal_word(1)"
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, @expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, RegToSlot, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, FunctionCall, Label] FunctionCall, Label]
end end
def test_send_instructions def test_send_instructions
@ -20,16 +20,16 @@ module Risc
end end
def test_load_5 def test_load_5
produced = produce_body produced = produce_body
assert_equal 5 , produced.next(15).constant.value assert_equal 5 , produced.next(14).constant.value
end end
def base def base
18 17
end end
def test_load_arg_const def test_load_arg_const
produced = produce_body produced = produce_body
assert_equal LoadConstant , produced.next(base).class assert_equal LoadConstant , produced.next(base).class
assert_equal Parfait::Integer , produced.next(base).constant.class assert_equal Parfait::Integer , produced.next(base).constant.class
assert_equal 1 , produced.next(18).constant.value assert_equal 1 , produced.next(base).constant.value
end end
def test_load_next_m def test_load_next_m
produced = produce_body produced = produce_body

View File

@ -10,9 +10,9 @@ module Risc
@input = "5.div4" @input = "5.div4"
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, @expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, RegToSlot, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, FunctionCall, Label] SlotToReg, FunctionCall, Label]
@produced = produce_body @produced = produce_body
end end
@ -66,22 +66,16 @@ module Risc
sl = @produced.next( 10 ) sl = @produced.next( 10 )
assert_reg_to_slot( sl , :r4 , :r5 , 0 ) assert_reg_to_slot( sl , :r4 , :r5 , 0 )
end end
def test_store_method_in_message
def test_get_name
sl = @produced.next( 11 ) sl = @produced.next( 11 )
assert_slot_to_reg( sl , :r1 , 1 , :r6 ) assert_reg_to_slot( sl , :r1 , :r3 , 7 )
end end
def test_store_name_in_message
sl = @produced.next( 12 )
assert_reg_to_slot( sl , :r6 , :r3 , 7 )
end
def test_get_next_next #reduce onto itself def test_get_next_next #reduce onto itself
sl = @produced.next( 13 ) sl = @produced.next( 12 )
assert_slot_to_reg( sl , :r3 , 1 , :r3 ) assert_slot_to_reg( sl , :r3 , 1 , :r3 )
end end
def test_store_next_next_in_space def test_store_next_next_in_space
sl = @produced.next( 14 ) sl = @produced.next( 13 )
assert_reg_to_slot( sl , :r3 , :r2 , 3 ) assert_reg_to_slot( sl , :r3 , :r2 , 3 )
end end
end end

View File

@ -9,12 +9,12 @@ module Risc
@input = "return 5.div4" @input = "return 5.div4"
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, @expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, RegToSlot, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, FunctionCall, Label, SlotToReg, SlotToReg, FunctionCall, Label, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, FunctionReturn] FunctionReturn]
end end
def test_return_instructions def test_return_instructions
@ -22,12 +22,12 @@ module Risc
end end
def test_function_return def test_function_return
produced = produce_body produced = produce_body
assert_equal FunctionReturn , produced.next(36).class assert_equal FunctionReturn , produced.next(35).class
end end
def test_load_5 def test_load_5
produced = produce_body produced = produce_body
assert_equal LoadConstant , produced.next(15).class assert_equal LoadConstant , produced.next(14).class
assert_equal 5 , produced.next(15).constant.value assert_equal 5 , produced.next(14).constant.value
end end
end end
end end

View File

@ -17,13 +17,12 @@ module Risc
RegToSlot, RegToSlot, Label, RegToSlot, Label, RegToSlot, RegToSlot, Label, RegToSlot, Label,
LoadConstant, SlotToReg, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant, SlotToReg,
SlotToReg, DynamicJump, Label, SlotToReg, SlotToReg, DynamicJump, Label, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn]
FunctionReturn]
end end
def test_return_instructions def test_return_instructions
@ -31,7 +30,7 @@ module Risc
end end
def test_function_return def test_function_return
produced = produce_body produced = produce_body
assert_equal FunctionReturn , produced.next(80).class assert_equal FunctionReturn , produced.next(79).class
end end
def test_cache_check def test_cache_check
produced = produce_body produced = produce_body

View File

@ -9,13 +9,13 @@ module Risc
@input = "while(5 > 0) ; @a = true; end" @input = "while(5 > 0) ; @a = true; end"
@expect = [Label, LoadConstant, LoadConstant, SlotToReg, RegToSlot, @expect = [Label, LoadConstant, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, FunctionCall, Label, SlotToReg, SlotToReg, FunctionCall, Label, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, LoadConstant, RegToSlot, SlotToReg, SlotToReg, LoadConstant, OperatorInstruction,
OperatorInstruction, IsZero, LoadConstant, OperatorInstruction, IsZero, IsZero, LoadConstant, OperatorInstruction, IsZero, LoadConstant,
LoadConstant, SlotToReg, RegToSlot, Branch, Label] SlotToReg, RegToSlot, Branch, Label]
end end
def test_while_instructions def test_while_instructions
@ -26,33 +26,33 @@ module Risc
end end
def test_int_load_5 def test_int_load_5
produced = produce_body produced = produce_body
load = produced.next(16) load = produced.next(15)
assert_equal Risc::LoadConstant , load.class assert_equal Risc::LoadConstant , load.class
assert_equal Parfait::Integer , load.constant.class assert_equal Parfait::Integer , load.constant.class
assert_equal 5 , load.constant.value assert_equal 5 , load.constant.value
end end
def test_int_load_0 def test_int_load_0
produced = produce_body produced = produce_body
load = produced.next(19) load = produced.next(18)
assert_equal Risc::LoadConstant , load.class assert_equal Risc::LoadConstant , load.class
assert_equal Parfait::Integer , load.constant.class assert_equal Parfait::Integer , load.constant.class
assert_equal 0 , load.constant.value assert_equal 0 , load.constant.value
end end
def test_false_check def test_false_check
produced = produce_body produced = produce_body
assert_equal Risc::IsZero , produced.next(36).class assert_equal Risc::IsZero , produced.next(35).class
assert produced.next(36).label.name.start_with?("merge_label") , produced.next(36).label.name assert produced.next(35).label.name.start_with?("merge_label") , produced.next(35).label.name
end end
def test_nil_load def test_nil_load
produced = produce_body produced = produce_body
assert_equal Risc::LoadConstant , produced.next(37).class assert_equal Risc::LoadConstant , produced.next(36).class
assert_equal Parfait::NilClass , produced.next(37).constant.class assert_equal Parfait::NilClass , produced.next(36).constant.class
end end
def test_back_jump # should jump back to condition label def test_back_jump # should jump back to condition label
produced = produce_body produced = produce_body
assert_equal Risc::Branch , produced.next(43).class assert_equal Risc::Branch , produced.next(42).class
assert_equal produced , produced.next(43).label assert_equal produced , produced.next(42).label
end end
end end

View File

@ -16,7 +16,7 @@ module Parfait
def test_message_name_nil def test_message_name_nil
last = @type.names.last last = @type.names.last
assert_equal :arguments , last , @type.names.inspect assert_equal :arguments , last , @type.names.inspect
assert_nil @mess.name assert_nil @mess.method
end end
def test_message_next_set def test_message_next_set
@mess.next_message = :next_message @mess.next_message = :next_message

View File

@ -35,8 +35,8 @@ module Parfait
def test_caller def test_caller
assert_nil @mess.caller assert_nil @mess.caller
end end
def test_name def test_method
assert_nil @mess.name assert_nil @mess.method
end end
end end
end end

View File

@ -14,7 +14,7 @@ module Risc
check_main_chain [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, check_main_chain [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg,
Branch, SlotToReg, Syscall, NilClass] SlotToReg, Branch, Syscall, NilClass]
assert_equal 15 , get_return assert_equal 15 , get_return
end end

View File

@ -13,18 +13,18 @@ module Risc
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, RegToSlot,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, Branch, FunctionCall, SlotToReg, SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, SlotToReg, SlotToReg, OperatorInstruction, LoadConstant, SlotToReg,
LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot, RegToSlot, RegToSlot, SlotToReg,
RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, Branch, FunctionReturn, Transfer, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
Branch, SlotToReg, Syscall, NilClass] Transfer, SlotToReg, SlotToReg, Branch, Syscall,
NilClass]
assert_equal 10 , get_return assert_equal 10 , get_return
end end
end end

View File

@ -14,30 +14,30 @@ module Risc
check_main_chain [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, check_main_chain [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg,
RegToSlot, RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, RegToSlot,
RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, Branch, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, Branch, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, OperatorInstruction, LoadConstant, SlotToReg,
SlotToReg, RegToSlot, RegToSlot, RegToSlot, SlotToReg,
Branch, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, Branch, SlotToReg, SlotToReg, RegToSlot,
LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
Branch, RegToSlot, SlotToReg, RegToSlot, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, RegToSlot, Branch, FunctionCall, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall, SlotToReg, OperatorInstruction, LoadConstant, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, SlotToReg, Branch,
OperatorInstruction, LoadConstant, SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
RegToSlot, RegToSlot, SlotToReg, Branch, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, Branch, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, Branch, RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer, Branch, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, Branch, SlotToReg, Syscall, NilClass] SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, Branch,
RegToSlot, SlotToReg, FunctionCall, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, LoadConstant,
SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot,
SlotToReg, Branch, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, Branch, SlotToReg,
SlotToReg, FunctionReturn, Transfer, SlotToReg, SlotToReg,
Branch, Syscall, NilClass]
assert_equal 15 , get_return assert_equal 15 , get_return
end end

View File

@ -14,19 +14,19 @@ module Risc
check_main_chain [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, check_main_chain [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg,
RegToSlot, RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, RegToSlot,
RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, Branch, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, Branch, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, OperatorInstruction, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, RegToSlot, RegToSlot, SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
Branch, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, LoadConstant, SlotToReg, SlotToReg,
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, RegToSlot, SlotToReg, Branch,
SlotToReg, Branch, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
FunctionReturn, Transfer, SlotToReg, Branch, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
Syscall, NilClass] SlotToReg, Branch, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
Transfer, SlotToReg, SlotToReg, Branch, Syscall,
NilClass]
assert_equal 10 , get_return assert_equal 10 , get_return
end end
end end

View File

@ -13,39 +13,39 @@ module Risc
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, RegToSlot,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, FunctionCall, SlotToReg, RegToSlot, SlotToReg, FunctionCall, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, LoadData,
OperatorInstruction, LoadData, OperatorInstruction, OperatorInstruction, LoadData,
Transfer, Branch, OperatorInstruction, OperatorInstruction, LoadData,
Transfer, OperatorInstruction, OperatorInstruction, LoadData, Transfer,
OperatorInstruction, OperatorInstruction, LoadData, OperatorInstruction, LoadData,
Branch, Transfer, OperatorInstruction, OperatorInstruction, Transfer,
LoadData, OperatorInstruction, LoadData, OperatorInstruction, OperatorInstruction, LoadData, OperatorInstruction, LoadData, OperatorInstruction, OperatorInstruction,
LoadData, Transfer, Branch, OperatorInstruction, OperatorInstruction, LoadConstant, SlotToReg, SlotToReg, RegToSlot, Branch,
LoadData, Transfer, OperatorInstruction, OperatorInstruction, LoadData, RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
Transfer, OperatorInstruction, OperatorInstruction, LoadData, OperatorInstruction, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
LoadData, Branch, Transfer, OperatorInstruction, OperatorInstruction, SlotToReg, RegToSlot, SlotToReg, Branch, SlotToReg,
Transfer, LoadData, OperatorInstruction, LoadData, OperatorInstruction, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
OperatorInstruction, LoadConstant, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg,
Branch, RegToSlot, RegToSlot, SlotToReg, SlotToReg, SlotToReg, Branch, Syscall, NilClass]
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
SlotToReg, SlotToReg, RegToSlot, Branch, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer,
SlotToReg, Branch, SlotToReg, Syscall, NilClass]
assert_equal 2 , get_return assert_equal 2 , get_return
end end
def test_load_25 def test_load_25
load_ins = main_ticks 17 load_ins = main_ticks 16
assert_equal LoadConstant , load_ins.class assert_equal LoadConstant , load_ins.class
assert_equal 25 , @interpreter.get_register(load_ins.register).value assert_equal 25 , @interpreter.get_register(load_ins.register).value
end end
def test_return_class def test_return_class
ret = main_ticks(75) ret = main_ticks(74)
assert_equal FunctionReturn , ret.class assert_equal FunctionReturn , ret.class
link = @interpreter.get_register( ret.register ) link = @interpreter.get_register( ret.register )
assert_equal Fixnum , link.class assert_equal Fixnum , link.class
end end
def test_sys def test_sys
sys = main_ticks(94) sys = main_ticks(93)
assert_equal Syscall , sys.class assert_equal Syscall , sys.class
assert_equal :exit , sys.name assert_equal :exit , sys.name
end end

View File

@ -12,27 +12,26 @@ module Risc
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, RegToSlot,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, Branch, FunctionCall, SlotToReg, SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, ByteToReg, LoadConstant, SlotToReg, ByteToReg, LoadConstant, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, RegToSlot, RegToSlot, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, Branch, RegToSlot, SlotToReg, Branch, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer,
Branch, FunctionReturn, Transfer, SlotToReg, Branch, SlotToReg, SlotToReg, Branch, Syscall, NilClass]
SlotToReg, Syscall, NilClass]
assert_equal "H".ord , get_return assert_equal "H".ord , get_return
end end
def test_byte_to_reg def test_byte_to_reg
done = main_ticks(34) done = main_ticks(32)
assert_equal ByteToReg , done.class assert_equal ByteToReg , done.class
assert_equal "H".ord , @interpreter.get_register(done.register) assert_equal "H".ord , @interpreter.get_register(done.register)
end end
def test_exit def test_exit
done = main_ticks(67) done = main_ticks(64)
assert_equal Syscall , done.class assert_equal Syscall , done.class
end end
end end

View File

@ -13,28 +13,28 @@ module Risc
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, RegToSlot,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, Branch, FunctionCall, SlotToReg, SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, SlotToReg, SlotToReg, OperatorInstruction, LoadConstant, SlotToReg,
LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot, RegToSlot, RegToSlot, SlotToReg,
RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, Branch, FunctionReturn, Transfer, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
Branch, SlotToReg, Syscall, NilClass] Transfer, SlotToReg, SlotToReg, Branch, Syscall,
NilClass]
assert_equal 1 , get_return assert_equal 1 , get_return
end end
def test_load_5 def test_load_5
lod = main_ticks( 20 ) lod = main_ticks( 19 )
assert_equal LoadConstant , lod.class assert_equal LoadConstant , lod.class
assert_equal Parfait::Integer , lod.constant.class assert_equal Parfait::Integer , lod.constant.class
assert_equal 5 , lod.constant.value assert_equal 5 , lod.constant.value
end end
def test_op def test_op
op = main_ticks(35) op = main_ticks(33)
assert_equal OperatorInstruction , op.class assert_equal OperatorInstruction , op.class
assert_equal :r1 , op.left.symbol assert_equal :r1 , op.left.symbol
assert_equal :r2 , op.right.symbol assert_equal :r2 , op.right.symbol
@ -42,13 +42,13 @@ module Risc
assert_equal 1 , @interpreter.get_register(:r1) assert_equal 1 , @interpreter.get_register(:r1)
end end
def test_return def test_return
ret = main_ticks(63) ret = main_ticks(60)
assert_equal FunctionReturn , ret.class assert_equal FunctionReturn , ret.class
assert_equal :r1 , ret.register.symbol assert_equal :r1 , ret.register.symbol
assert_equal 23332 , @interpreter.get_register(ret.register) assert_equal 23392 , @interpreter.get_register(ret.register)
end end
def test_sys def test_sys
sys = main_ticks(68) sys = main_ticks(65)
assert_equal Syscall , sys.class assert_equal Syscall , sys.class
assert_equal :exit , sys.name assert_equal :exit , sys.name
end end

View File

@ -13,27 +13,27 @@ module Risc
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, RegToSlot,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, FunctionCall, SlotToReg, RegToSlot, SlotToReg, FunctionCall, SlotToReg, SlotToReg,
SlotToReg, LoadData, OperatorInstruction, LoadConstant, SlotToReg, LoadData, OperatorInstruction, LoadConstant, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, RegToSlot, RegToSlot, SlotToReg, RegToSlot, RegToSlot, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot, FunctionReturn, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
Branch, SlotToReg, SlotToReg, RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
FunctionReturn, Transfer, SlotToReg, Branch, SlotToReg, Transfer, SlotToReg, SlotToReg, Branch, Syscall,
Syscall, NilClass] NilClass]
assert_equal 2 , get_return assert_equal 2 , get_return
end end
def test_load def test_load
lod = main_ticks(17) lod = main_ticks(16)
assert_equal LoadConstant , lod.class assert_equal LoadConstant , lod.class
assert_equal 9 , lod.constant.value assert_equal 9 , lod.constant.value
end end
def test_fix # reduce self to fix def test_fix # reduce self to fix
sl = main_ticks(26) sl = main_ticks(25)
assert_equal SlotToReg , sl.class assert_equal SlotToReg , sl.class
assert_equal :r1 , sl.array.symbol assert_equal :r1 , sl.array.symbol
assert_equal 2 , sl.index assert_equal 2 , sl.index
@ -42,7 +42,7 @@ module Risc
end end
def test_sys def test_sys
sys = main_ticks(61) sys = main_ticks(60)
assert_equal Syscall , sys.class assert_equal Syscall , sys.class
assert_equal :exit , sys.name assert_equal :exit , sys.name
end end

View File

@ -13,18 +13,18 @@ module Risc
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, RegToSlot,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, Branch, FunctionCall, SlotToReg, SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, SlotToReg, SlotToReg, OperatorInstruction, LoadConstant, SlotToReg,
LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot, RegToSlot, RegToSlot, SlotToReg,
RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, Branch, FunctionReturn, Transfer, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
Branch, SlotToReg, Syscall, NilClass] Transfer, SlotToReg, SlotToReg, Branch, Syscall,
NilClass]
assert_equal 0 , get_return assert_equal 0 , get_return
end end
def test_zero def test_zero
@ -32,7 +32,7 @@ module Risc
assert @interpreter.flags[:zero] assert @interpreter.flags[:zero]
end end
def test_op def test_op
op = main_ticks(35) op = main_ticks(33)
assert_equal OperatorInstruction , op.class assert_equal OperatorInstruction , op.class
assert_equal :r1 , op.left.symbol assert_equal :r1 , op.left.symbol
assert_equal :r2 , op.right.symbol assert_equal :r2 , op.right.symbol
@ -40,7 +40,7 @@ module Risc
assert_equal 0 , @interpreter.get_register(:r1) assert_equal 0 , @interpreter.get_register(:r1)
end end
def test_overflow def test_overflow
main_ticks( 37 ) main_ticks( 34 )
assert @interpreter.flags[:overflow] assert @interpreter.flags[:overflow]
end end
end end

View File

@ -13,28 +13,28 @@ module Risc
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, RegToSlot,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, Branch, FunctionCall, SlotToReg, SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, SlotToReg, SlotToReg, OperatorInstruction, LoadConstant, SlotToReg,
LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot, RegToSlot, RegToSlot, SlotToReg,
RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, Branch, FunctionReturn, Transfer, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
Branch, SlotToReg, Syscall, NilClass] Transfer, SlotToReg, SlotToReg, Branch, Syscall,
NilClass]
assert_equal 10 , get_return assert_equal 10 , get_return
end end
def test_load_5 def test_load_5
lod = main_ticks( 20 ) lod = main_ticks( 19 )
assert_equal LoadConstant , lod.class assert_equal LoadConstant , lod.class
assert_equal Parfait::Integer , lod.constant.class assert_equal Parfait::Integer , lod.constant.class
assert_equal 5 , lod.constant.value assert_equal 5 , lod.constant.value
end end
def base def base
30 28
end end
def test_slot_receiver #load receiver from message def test_slot_receiver #load receiver from message
sl = main_ticks( base ) sl = main_ticks( base )
@ -102,7 +102,7 @@ module Risc
assert_equal :r4 , sl.register.symbol assert_equal :r4 , sl.register.symbol
end end
def test_sys def test_sys
sys = main_ticks(68) sys = main_ticks(65)
assert_equal Syscall , sys.class assert_equal Syscall , sys.class
assert_equal :exit , sys.name assert_equal :exit , sys.name
end end

View File

@ -13,28 +13,28 @@ module Risc
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, RegToSlot,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, FunctionCall, SlotToReg, RegToSlot, SlotToReg, FunctionCall, SlotToReg, SlotToReg,
SlotToReg, Transfer, Syscall, Transfer, Transfer, Transfer, Syscall, Transfer, Transfer, LoadConstant,
LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot,
SlotToReg, Branch, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, Branch, Syscall, NilClass]
SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg,
Branch, SlotToReg, Syscall, NilClass]
assert_equal "Hello again" , @interpreter.stdout assert_equal "Hello again" , @interpreter.stdout
assert_equal 11 , get_return #bytes written assert_equal 11 , get_return #bytes written
end end
def test_call def test_call
cal = main_ticks(24) cal = main_ticks(23)
assert_equal FunctionCall , cal.class assert_equal FunctionCall , cal.class
assert_equal :putstring , cal.method.name assert_equal :putstring , cal.method.name
end end
def test_putstring_sys def test_putstring_sys
done = main_ticks(28) done = main_ticks(27)
assert_equal Syscall , done.class assert_equal Syscall , done.class
assert_equal "Hello again" , @interpreter.stdout assert_equal "Hello again" , @interpreter.stdout
assert_equal 11 , @interpreter.get_register(:r0) assert_equal 11 , @interpreter.get_register(:r0)
@ -42,28 +42,28 @@ module Risc
assert_equal "Hello again" , @interpreter.get_register(:r1).to_string assert_equal "Hello again" , @interpreter.get_register(:r1).to_string
end end
def test_move_sys_return def test_move_sys_return
sl = main_ticks(29) sl = main_ticks(28)
assert_equal Transfer , sl.class assert_equal Transfer , sl.class
assert_equal :r0 , sl.from.symbol assert_equal :r0 , sl.from.symbol
assert_equal :r2 , sl.to.symbol assert_equal :r2 , sl.to.symbol
assert_equal 11 , @interpreter.get_register(:r2) assert_equal 11 , @interpreter.get_register(:r2)
end end
def test_restore_message def test_restore_message
sl = main_ticks(30) sl = main_ticks(29)
assert_equal Transfer , sl.class assert_equal Transfer , sl.class
assert_equal :r8 , sl.from.symbol assert_equal :r8 , sl.from.symbol
assert_equal :r0 , sl.to.symbol assert_equal :r0 , sl.to.symbol
assert_equal Parfait::Message , @interpreter.get_register(:r0).class assert_equal Parfait::Message , @interpreter.get_register(:r0).class
end end
def test_save_sys_return def test_save_sys_return
sl = main_ticks(35) sl = main_ticks(34)
assert_equal RegToSlot , sl.class assert_equal RegToSlot , sl.class
assert_equal :r2 , sl.register.symbol #return assert_equal :r2 , sl.register.symbol #return
assert_equal :r3 , sl.array.symbol #parfait integer assert_equal :r3 , sl.array.symbol #parfait integer
assert_equal 2 , sl.index assert_equal 2 , sl.index
end end
def test_return def test_return
done = main_ticks(44) done = main_ticks(43)
assert_equal FunctionReturn , done.class assert_equal FunctionReturn , done.class
end end

View File

@ -13,28 +13,28 @@ module Risc
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, RegToSlot,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, Branch, LoadConstant, SlotToReg, RegToSlot, LoadConstant, Branch, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToByte,
RegToByte, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, Branch, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
Branch, RegToSlot, SlotToReg, SlotToReg, SlotToReg, Branch, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
FunctionReturn, Transfer, SlotToReg, Branch, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
Syscall, NilClass] SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
Branch, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
Transfer, SlotToReg, SlotToReg, Branch, Syscall,
NilClass]
assert_equal "K".ord , get_return assert_equal "K".ord , get_return
end end
def test_reg_to_byte def test_reg_to_byte
done = main_ticks(41) done = main_ticks(40)
assert_equal RegToByte , done.class assert_equal RegToByte , done.class
assert_equal "K".ord , @interpreter.get_register(done.register) assert_equal "K".ord , @interpreter.get_register(done.register)
end end
def test_exit def test_exit
done = main_ticks(71) done = main_ticks(70)
assert_equal Syscall , done.class assert_equal Syscall , done.class
end end

View File

@ -14,8 +14,8 @@ module Risc
check_main_chain [LoadConstant, LoadConstant, OperatorInstruction, IsZero, LoadConstant, check_main_chain [LoadConstant, LoadConstant, OperatorInstruction, IsZero, LoadConstant,
OperatorInstruction, IsZero, LoadConstant, RegToSlot, SlotToReg, OperatorInstruction, IsZero, LoadConstant, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, Branch, SlotToReg, SlotToReg, RegToSlot, SlotToReg, Branch, SlotToReg,
SlotToReg, FunctionReturn, Transfer, SlotToReg, Branch, SlotToReg, FunctionReturn, Transfer, SlotToReg, SlotToReg,
SlotToReg, Syscall, NilClass] Branch, Syscall, NilClass]
assert_equal 1 , get_return assert_equal 1 , get_return
end end
def test_load_10 def test_load_10

View File

@ -13,23 +13,22 @@ module Risc
#show_main_ticks # get output of what is in main #show_main_ticks # get output of what is in main
check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, RegToSlot,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, Branch, FunctionCall, SlotToReg, SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, SlotToReg, SlotToReg, OperatorInstruction, IsMinus, IsZero,
IsMinus, IsZero, LoadConstant, RegToSlot, SlotToReg, LoadConstant, RegToSlot, SlotToReg, Branch, SlotToReg,
Branch, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero,
LoadConstant, RegToSlot, SlotToReg, SlotToReg, Branch,
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
Transfer, SlotToReg, Branch, SlotToReg, Syscall, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
NilClass] LoadConstant, OperatorInstruction, IsZero, LoadConstant, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, Branch, SlotToReg,
SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg,
SlotToReg, Branch, Syscall, NilClass]
assert_equal 2 , get_return assert_equal 2 , get_return
end end
def test_exit def test_exit
done = main_ticks(70) done = main_ticks(68)
assert_equal Syscall , done.class assert_equal Syscall , done.class
end end
end end

View File

@ -13,23 +13,23 @@ module Risc
#show_main_ticks # get output of what is in main #show_main_ticks # get output of what is in main
check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, RegToSlot,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, Branch, FunctionCall, SlotToReg, SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, SlotToReg, SlotToReg, OperatorInstruction, IsMinus, LoadConstant,
IsMinus, LoadConstant, Branch, RegToSlot, SlotToReg, Branch, RegToSlot, SlotToReg, SlotToReg, Branch,
SlotToReg, Branch, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero, LoadConstant, OperatorInstruction, IsZero, LoadConstant, OperatorInstruction,
LoadConstant, OperatorInstruction, IsZero, LoadConstant, Branch, IsZero, LoadConstant, RegToSlot, Branch, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, FunctionReturn, Transfer, SlotToReg, SlotToReg, Branch,
Branch, SlotToReg, Syscall, NilClass] Syscall, NilClass]
assert_equal 1 , get_return assert_equal 1 , get_return
end end
def test_exit def test_exit
done = main_ticks(73) done = main_ticks(71)
assert_equal Syscall , done.class assert_equal Syscall , done.class
end end
end end

View File

@ -11,25 +11,24 @@ module Risc
def test_if def test_if
#show_main_ticks # get output of what is in main #show_main_ticks # get output of what is in main
check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, RegToSlot,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, Branch, FunctionCall, SlotToReg, SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, SlotToReg, SlotToReg, OperatorInstruction, IsMinus, IsZero,
IsMinus, IsZero, LoadConstant, RegToSlot, SlotToReg, LoadConstant, RegToSlot, SlotToReg, Branch, SlotToReg,
Branch, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero,
LoadConstant, RegToSlot, SlotToReg, SlotToReg, Branch,
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
Transfer, SlotToReg, Branch, SlotToReg, Syscall, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
NilClass] LoadConstant, OperatorInstruction, IsZero, LoadConstant, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, Branch, SlotToReg,
SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg,
SlotToReg, Branch, Syscall, NilClass]
assert_equal 2 , get_return assert_equal 2 , get_return
end end
def test_exit def test_exit
done = main_ticks(70) done = main_ticks(68)
assert_equal Syscall , done.class assert_equal Syscall , done.class
end end
end end

View File

@ -13,23 +13,23 @@ module Risc
#show_main_ticks # get output of what is in main #show_main_ticks # get output of what is in main
check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, RegToSlot,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, Branch, FunctionCall, SlotToReg, SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, SlotToReg, SlotToReg, OperatorInstruction, IsMinus, LoadConstant,
IsMinus, LoadConstant, Branch, RegToSlot, SlotToReg, Branch, RegToSlot, SlotToReg, SlotToReg, Branch,
SlotToReg, Branch, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero, LoadConstant, OperatorInstruction, IsZero, LoadConstant, OperatorInstruction,
LoadConstant, OperatorInstruction, IsZero, LoadConstant, Branch, IsZero, LoadConstant, RegToSlot, Branch, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, FunctionReturn, Transfer, SlotToReg, SlotToReg, Branch,
Branch, SlotToReg, Syscall, NilClass] Syscall, NilClass]
assert_equal 1 , get_return assert_equal 1 , get_return
end end
def test_exit def test_exit
done = main_ticks(73) done = main_ticks(71)
assert_equal Syscall , done.class assert_equal Syscall , done.class
end end
end end

View File

@ -29,24 +29,23 @@ module Risc
OperatorInstruction, IsZero, RegToSlot, Branch, LoadConstant, OperatorInstruction, IsZero, RegToSlot, Branch, LoadConstant,
SlotToReg, LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, Branch, RegToSlot, SlotToReg, RegToSlot, RegToSlot, Branch, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant, SlotToReg,
SlotToReg, Branch, DynamicJump, SlotToReg, SlotToReg, DynamicJump, SlotToReg, SlotToReg, LoadData, OperatorInstruction,
LoadData, OperatorInstruction, LoadConstant, SlotToReg, SlotToReg, LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot,
RegToSlot, RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, Branch,
RegToSlot, Branch, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
FunctionReturn, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, SlotToReg, Branch, FunctionReturn, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
Transfer, SlotToReg, Branch, SlotToReg, Syscall, SlotToReg, FunctionReturn, Transfer, SlotToReg, SlotToReg,
NilClass] Branch, Syscall, NilClass]
assert_equal Fixnum , get_return.class assert_equal Fixnum , get_return.class
assert_equal 1 , get_return assert_equal 1 , get_return
end end
def test_call_main def test_call_main
call_ins = ticks(26) call_ins = ticks(25)
assert_equal FunctionCall , call_ins.class assert_equal FunctionCall , call_ins.class
assert_equal :main , call_ins.method.name assert_equal :main , call_ins.method.name
end end
@ -57,17 +56,17 @@ module Risc
end end
def test_dyn def test_dyn
cal = main_ticks(108) cal = main_ticks(106)
assert_equal DynamicJump , cal.class assert_equal DynamicJump , cal.class
end end
def test_return def test_return
ret = main_ticks(140) ret = main_ticks(137)
assert_equal FunctionReturn , ret.class assert_equal FunctionReturn , ret.class
link = @interpreter.get_register( ret.register ) link = @interpreter.get_register( ret.register )
assert_equal Fixnum , link.class assert_equal Fixnum , link.class
end end
def test_sys def test_sys
sys = main_ticks(145) sys = main_ticks(142)
assert_equal Syscall , sys.class assert_equal Syscall , sys.class
end end
end end

View File

@ -19,7 +19,7 @@ module Risc
@instruction_events << was @instruction_events << was
end end
def length def length
40 39
end end
def test_state_change def test_state_change
@interpreter.register_event :state_changed , self @interpreter.register_event :state_changed , self
@ -42,12 +42,11 @@ module Risc
check_chain [Branch, LoadConstant, SlotToReg, SlotToReg, RegToSlot, check_chain [Branch, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, Branch, SlotToReg, SlotToReg, RegToSlot, SlotToReg, Branch,
SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, RegToSlot, LoadConstant, RegToSlot, SlotToReg, RegToSlot, LoadConstant, RegToSlot, FunctionCall,
FunctionCall, LoadConstant, RegToSlot, SlotToReg, SlotToReg, LoadConstant, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer,
Transfer, SlotToReg, Branch, SlotToReg, Syscall, SlotToReg, SlotToReg, Branch, Syscall, NilClass]
NilClass]
assert_equal Fixnum , get_return.class assert_equal Fixnum , get_return.class
assert_equal 5 , get_return assert_equal 5 , get_return
end end

View File

@ -13,7 +13,7 @@ module Risc
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, RegToSlot, SlotToReg, SlotToReg, RegToSlot, check_main_chain [LoadConstant, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer,
SlotToReg, Branch, SlotToReg, Syscall, NilClass] SlotToReg, SlotToReg, Branch, Syscall, NilClass]
assert_equal 5 , get_return assert_equal 5 , get_return
end end
@ -44,7 +44,7 @@ module Risc
assert_equal 5 , save.index assert_equal 5 , save.index
end end
def test_return_reduce def test_return_reduce
save = main_ticks(13) save = main_ticks(12)
assert_equal SlotToReg , save.class assert_equal SlotToReg , save.class
assert_equal :r0 , save.register.symbol assert_equal :r0 , save.register.symbol
assert_equal 2 , save.index assert_equal 2 , save.index

View File

@ -11,51 +11,50 @@ module Risc
def test_if def test_if
#show_main_ticks # get output of what is in main #show_main_ticks # get output of what is in main
check_main_chain [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, check_main_chain [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg,
RegToSlot, RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, RegToSlot,
RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, Branch, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, Branch, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, OperatorInstruction, IsMinus, LoadConstant,
Branch, RegToSlot, SlotToReg, SlotToReg, Branch,
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, Branch,
SlotToReg, LoadConstant, OperatorInstruction, IsZero, LoadConstant,
OperatorInstruction, IsZero, SlotToReg, SlotToReg, SlotToReg,
RegToSlot, LoadConstant, LoadConstant, Branch, SlotToReg,
RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot,
SlotToReg, RegToSlot, Branch, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, SlotToReg, SlotToReg, SlotToReg, SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, OperatorInstruction, LoadConstant, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, IsMinus, LoadConstant, Branch,
RegToSlot, RegToSlot, RegToSlot, SlotToReg, Branch, RegToSlot, SlotToReg, SlotToReg, Branch, RegToSlot,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
FunctionReturn, SlotToReg, SlotToReg, RegToSlot, Branch, SlotToReg, RegToSlot, SlotToReg, SlotToReg, Branch,
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, LoadConstant, OperatorInstruction, IsZero, LoadConstant, OperatorInstruction,
LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg, IsZero, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
Branch, SlotToReg, RegToSlot, SlotToReg, SlotToReg, LoadConstant, LoadConstant, SlotToReg, Branch, RegToSlot,
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
LoadConstant, SlotToReg, RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, Branch, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, RegToSlot, SlotToReg, FunctionCall, SlotToReg, SlotToReg, RegToSlot, SlotToReg, FunctionCall, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction,
IsMinus, LoadConstant, RegToSlot, SlotToReg, SlotToReg, LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot,
Branch, RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot,
FunctionReturn, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
Branch, SlotToReg, LoadConstant, OperatorInstruction, IsZero, SlotToReg, Branch, RegToSlot, Branch, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, LoadConstant,
RegToSlot, SlotToReg, SlotToReg, SlotToReg, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch,
FunctionReturn, Transfer, SlotToReg, Branch, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
Syscall, NilClass] RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, Branch, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, OperatorInstruction, IsMinus, LoadConstant,
RegToSlot, SlotToReg, SlotToReg, Branch, RegToSlot,
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, Branch,
LoadConstant, OperatorInstruction, IsZero, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg,
SlotToReg, Branch, Syscall, NilClass]
assert_equal 1 , get_return assert_equal 1 , get_return
end end
def test_exit def test_exit
done = main_ticks(201) done = main_ticks(198)
assert_equal Syscall , done.class assert_equal Syscall , done.class
end end
end end

View File

@ -14,48 +14,48 @@ module Risc
check_main_chain [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, check_main_chain [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, LoadConstant, SlotToReg,
RegToSlot, RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, RegToSlot,
RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, Branch, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, Branch, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, OperatorInstruction, IsMinus, IsZero,
LoadConstant, Branch, RegToSlot, SlotToReg, Branch,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
FunctionReturn, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
Branch, SlotToReg, LoadConstant, OperatorInstruction, IsZero,
LoadConstant, OperatorInstruction, IsZero, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, LoadConstant, Branch,
SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, Branch, LoadConstant,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, OperatorInstruction, LoadConstant, SlotToReg,
SlotToReg, RegToSlot, RegToSlot, RegToSlot, SlotToReg,
Branch, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
Branch, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, Branch, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
Branch, SlotToReg, SlotToReg, SlotToReg, RegToSlot, FunctionCall, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, OperatorInstruction, IsMinus, IsZero, LoadConstant,
Branch, RegToSlot, SlotToReg, Branch, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
Branch, LoadConstant, OperatorInstruction, IsZero, LoadConstant,
OperatorInstruction, IsZero, SlotToReg, SlotToReg, SlotToReg,
RegToSlot, LoadConstant, LoadConstant, SlotToReg, Branch,
RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, RegToSlot, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, Branch, RegToSlot,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall, LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
OperatorInstruction, IsMinus, IsZero, LoadConstant, RegToSlot, OperatorInstruction, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, Branch, SlotToReg, RegToSlot, SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, SlotToReg,
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
RegToSlot, SlotToReg, Branch, SlotToReg, LoadConstant, SlotToReg, SlotToReg, Branch, RegToSlot, Branch,
OperatorInstruction, IsZero, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg,
Branch, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, Branch,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, FunctionCall, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, IsMinus,
IsZero, LoadConstant, RegToSlot, SlotToReg, Branch,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
FunctionReturn, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, Branch, LoadConstant, OperatorInstruction, IsZero,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, Branch, FunctionReturn, Transfer, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
Branch, SlotToReg, Syscall, NilClass] Transfer, SlotToReg, SlotToReg, Branch, Syscall,
NilClass]
assert_equal 0 , get_return assert_equal 0 , get_return
end end
def test_exit def test_exit
done = main_ticks(203) done = main_ticks(200)
assert_equal Syscall , done.class assert_equal Syscall , done.class
end end
end end

View File

@ -17,7 +17,7 @@ module Risc
Branch, SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, Branch, SlotToReg, SlotToReg, LoadConstant, OperatorInstruction,
IsZero, SlotToReg, SlotToReg, RegToSlot, SlotToReg, IsZero, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
FunctionReturn, Transfer, SlotToReg, Branch, SlotToReg, FunctionReturn, Transfer, SlotToReg, SlotToReg, Branch,
Syscall, NilClass] Syscall, NilClass]
assert_kind_of Parfait::NilClass , get_return assert_kind_of Parfait::NilClass , get_return
end end

View File

@ -54,7 +54,7 @@ module Risc
end end
def test_pc1 def test_pc1
@interpreter.tick @interpreter.tick
assert_equal 22904 , @interpreter.pc assert_equal 22968 , @interpreter.pc
end end
def test_tick2 def test_tick2
@interpreter.tick @interpreter.tick
@ -68,7 +68,7 @@ module Risc
def test_pc2 def test_pc2
@interpreter.tick @interpreter.tick
@interpreter.tick @interpreter.tick
assert_equal 22908 , @interpreter.pc assert_equal 22972 , @interpreter.pc
end end
def test_tick_14_jump def test_tick_14_jump
14.times {@interpreter.tick} 14.times {@interpreter.tick}

View File

@ -25,7 +25,7 @@ module Risc
assert_equal 0 , Position.get(@linker.cpu_init).at assert_equal 0 , Position.get(@linker.cpu_init).at
end end
def test_cpu_at def test_cpu_at
assert_equal "0x682c" , Position.get(@linker.cpu_init.first).to_s assert_equal "0x686c" , Position.get(@linker.cpu_init.first).to_s
end end
def test_cpu_label def test_cpu_label
assert_equal Position , Position.get(@linker.cpu_init.first).class assert_equal Position , Position.get(@linker.cpu_init.first).class

View File

View File

@ -30,7 +30,7 @@ module Risc
# how many instruction up until the main starts, ie # how many instruction up until the main starts, ie
# ticks(main_at) will be the label for main # ticks(main_at) will be the label for main
def main_at def main_at
26 25
end end
def get_return def get_return

View File

@ -1,7 +1,7 @@
require_relative "helper" require_relative "helper"
module Vool module Vool
class TestYieldArgsSendMom < MiniTest::Test class TestYieldArgsSendMom #< MiniTest::Test
include MomCompile include MomCompile
include Mom include Mom