first risc level block test working

assign was not executing yield
baecause it was just testing for send, instead of callable
This commit is contained in:
Torsten Ruger 2018-07-30 20:11:52 +03:00
parent 1d2ec8e8ac
commit 4fe0edd1e3
6 changed files with 77 additions and 25 deletions

View File

@ -23,7 +23,7 @@ module Ruby
end
def normalize_arg(arg , arguments , statements)
if arg.is_a?(Constant) and !arg.is_a?(SendStatement)
if arg.is_a?(Constant) and !arg.is_a?(CallStatement)
arguments << arg.to_vool
return
end

View File

@ -16,7 +16,7 @@ module Vool
end
def chain_assign(assign , compiler)
return assign unless @value.is_a?(SendStatement)
return assign unless @value.is_a?(CallStatement)
@value.to_mom(compiler) << assign
end
end

View File

@ -19,8 +19,21 @@ module Risc
RegToSlot, LoadConstant, Branch, SlotToReg, RegToSlot,
SlotToReg, FunctionCall, LoadConstant, SlotToReg, OperatorInstruction,
IsZero, SlotToReg, SlotToReg, LoadConstant, SlotToReg,
RegToSlot, RegToSlot, SlotToReg, SlotToReg]
assert_equal 15 , get_return.class
RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
Branch, SlotToReg, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, RegToSlot, SlotToReg, Branch,
SlotToReg, SlotToReg, DynamicJump, LoadConstant, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, Branch, SlotToReg, SlotToReg,
FunctionReturn, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
Branch, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
Transfer, SlotToReg, SlotToReg, Branch, Syscall,
NilClass]
assert_equal 15 , get_return
end
def est_call_main

View File

@ -42,7 +42,7 @@ module Risc
end
def get_return
#assert_equal Parfait::Message , @interpreter.get_register(:r8).class
assert_equal Parfait::Message , @interpreter.get_register(:r8).class
@interpreter.get_register(:r0)
end

View File

@ -1,19 +1,8 @@
require_relative "helper"
module Vool
class TestYieldArgsSendMom < MiniTest::Test
include MomCompile
module YieldBasics
include Mom
def setup
Parfait.boot!
@ins = compile_first_method( "yield(1)" )
end
def test_array
check_array [NotSameCheck, Label, MessageSetup, ArgumentTransfer, BlockYield] ,
@ins
end
def test_check_label
assert_equal NotSameCheck, @ins.class
assert @ins.false_jump.name.start_with?("method_ok_")
@ -37,23 +26,73 @@ module Vool
assert_equal MessageSetup, @ins.next(2).class
assert_equal 2, @ins.next(2).method_source
end
def test_transfer
assert_equal ArgumentTransfer, @ins.next(3).class
assert_equal 1, @ins.next(3).arguments.length
end
def test_receiver
assert_equal :message , @ins.next(3).receiver.known_object
assert_equal [:receiver] , @ins.next(3).receiver.slots
end
def test_yield
assert_equal BlockYield, @ins.next(4).class
assert_equal 2, @ins.next(4).arg_index
end
def test_return_load
assert_equal SlotLoad, @ins.next(5).class
assert_equal :message, @ins.next(5).left.known_object
assert_equal :message, @ins.next(5).right.known_object
assert_equal :frame, @ins.next(5).left.slots.first
assert @ins.next(5).left.slots.last.to_s.start_with?("tmp_")
assert_equal [:return_value], @ins.next(5).right.slots
end
def test_return_load2
assert_equal SlotLoad, @ins.next(6).class
assert_equal :message, @ins.next(6).left.known_object
assert_equal :message, @ins.next(6).right.known_object
assert_equal :return_value, @ins.next(6).left.slots.first
assert_equal :frame, @ins.next(6).right.slots.first
assert @ins.next(6).right.slots.last.to_s.start_with?("tmp_")
end
def test_return
assert_equal ReturnSequence, @ins.next(7).class
end
end
class TestYieldArgsSendMom < MiniTest::Test
include MomCompile
include YieldBasics
def setup
Parfait.boot!
@ins = compile_first_method( "return yield(1)" )
end
def test_array
check_array [NotSameCheck, Label, MessageSetup, ArgumentTransfer, BlockYield ,
SlotLoad, SlotLoad, ReturnSequence] , @ins
end
def test_transfer
assert_equal ArgumentTransfer, @ins.next(3).class
assert_equal 1, @ins.next(3).arguments.length
end
def test_args_one_l
left = @ins.next(3).arguments[0].left
assert_equal Symbol, left.known_object.class
assert_equal :message, left.known_object
assert_equal [:next_message, :arguments, 1], left.slots
end
def test_yield
assert_equal BlockYield, @ins.next(4).class
assert_equal 2, @ins.next(4).arg_index
end
class TestYieldNoArgsSendMom < MiniTest::Test
include MomCompile
include Mom
include YieldBasics
def setup
Parfait.boot!
@ins = compile_first_method( "return yield" )
end
def test_array
check_array [NotSameCheck, Label, MessageSetup, ArgumentTransfer, BlockYield ,
SlotLoad, SlotLoad, ReturnSequence] , @ins
end
def test_transfer
assert_equal ArgumentTransfer, @ins.next(3).class
assert_equal 0, @ins.next(3).arguments.length
end
end
end