Block/Lambda rework done
recovered from all renames and redoing the block compilation all green
This commit is contained in:
parent
a722a4c285
commit
d5d1df951c
@ -14,7 +14,7 @@ end
|
|||||||
|
|
||||||
require "minitest/color"
|
require "minitest/color"
|
||||||
require "minitest/autorun"
|
require "minitest/autorun"
|
||||||
#require "minitest/fail_fast" unless ENV["TEST_ALL"]
|
require "minitest/fail_fast" unless ENV["TEST_ALL"]
|
||||||
require 'minitest/profile'
|
require 'minitest/profile'
|
||||||
#require "minitest/reporters"
|
#require "minitest/reporters"
|
||||||
#Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
|
#Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
|
||||||
|
@ -7,55 +7,48 @@ module Risc
|
|||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@input = as_block("return 5")
|
@input = as_block("return 5")
|
||||||
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #4
|
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, #4
|
||||||
RegToSlot, LoadConstant, LoadConstant, SlotToReg, SlotToReg, #9
|
SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, #9
|
||||||
RegToSlot, RegToSlot, RegToSlot, RegToSlot, SlotToReg, #14
|
RegToSlot, SlotToReg, SlotToReg, RegToSlot, LoadConstant, #14
|
||||||
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #19
|
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #19
|
||||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #24
|
RegToSlot, SlotToReg, FunctionCall, Label] #24
|
||||||
SlotToReg, FunctionCall, Label] #29
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_send_instructions
|
def test_send_instructions
|
||||||
assert_nil msg = check_nil(:main) , msg
|
assert_nil msg = check_nil(:main) , msg
|
||||||
end
|
end
|
||||||
def test_load_5
|
def test_load_5_block
|
||||||
produced = produce_block.next
|
produced = produce_block.next
|
||||||
assert_load( produced , Parfait::Integer)
|
assert_load( produced , Parfait::Integer)
|
||||||
assert_equal 5 , produced.constant.value
|
assert_equal 5 , produced.constant.value
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_load_5
|
def test_load_5
|
||||||
produced = produce_body
|
produced = produce_body
|
||||||
assert_load( produced , Parfait::Integer)
|
assert_load( produced , Parfait::Integer)
|
||||||
assert_equal 5 , produced.constant.value
|
assert_equal 5 , produced.constant.value
|
||||||
end
|
end
|
||||||
def test_load_block
|
|
||||||
produced = produce_body.next(3)
|
|
||||||
assert_load( produced , Parfait::Block)
|
|
||||||
assert_equal :main_block , produced.constant.name
|
|
||||||
end
|
|
||||||
def test_load_method_to_call
|
|
||||||
produced = produce_body.next(6)
|
|
||||||
assert_load( produced , Parfait::CallableMethod)
|
|
||||||
assert_equal :main , produced.constant.name
|
|
||||||
end
|
|
||||||
def test_load_next_message
|
def test_load_next_message
|
||||||
produced = produce_body.next(7)
|
produced = produce_body.next(4)
|
||||||
assert_load( produced , Parfait::Factory)
|
assert_load( produced , Parfait::Factory)
|
||||||
assert_equal "Message_Type" , produced.constant.for_type.name
|
assert_equal "Message_Type" , produced.constant.for_type.name
|
||||||
end
|
end
|
||||||
|
def test_load_block
|
||||||
|
produced = produce_body.next(14)
|
||||||
|
assert_load( produced , Parfait::Block)
|
||||||
|
assert_equal :main_block , produced.constant.name
|
||||||
|
end
|
||||||
def test_load_return
|
def test_load_return
|
||||||
produced = produce_body.next(22)
|
produced = produce_body.next(18)
|
||||||
assert_load( produced , Label)
|
assert_load( produced , Label)
|
||||||
assert produced.constant.name.start_with?("continue_")
|
assert produced.constant.name.start_with?("continue_")
|
||||||
end
|
end
|
||||||
def test_function_call
|
def test_function_call
|
||||||
produced = produce_body.next(26)
|
produced = produce_body.next(22)
|
||||||
assert_equal FunctionCall , produced.class
|
assert_equal FunctionCall , produced.class
|
||||||
assert_equal :main , produced.method.name
|
assert_equal :main , produced.method.name
|
||||||
end
|
end
|
||||||
def test_check_continue
|
def test_check_continue
|
||||||
produced = produce_body.next(27)
|
produced = produce_body.next(23)
|
||||||
assert_equal Label , produced.class
|
assert_equal Label , produced.class
|
||||||
assert produced.name.start_with?("continue_")
|
assert produced.name.start_with?("continue_")
|
||||||
end
|
end
|
||||||
|
@ -13,9 +13,9 @@ module Vool
|
|||||||
@clazz.body.first
|
@clazz.body.first
|
||||||
end
|
end
|
||||||
def test_setup
|
def test_setup
|
||||||
assert_equal ClassStatement , @clazz.class
|
assert_equal ClassExpression , @clazz.class
|
||||||
assert_equal Statements , @clazz.body.class
|
assert_equal Statements , @clazz.body.class
|
||||||
assert_equal MethodStatement , method.class
|
assert_equal MethodExpression , method.class
|
||||||
end
|
end
|
||||||
def test_class
|
def test_class
|
||||||
assert_equal Parfait::Class , @clazz.create_class_object.class
|
assert_equal Parfait::Class , @clazz.create_class_object.class
|
||||||
@ -24,9 +24,5 @@ module Vool
|
|||||||
clazz = @clazz.create_class_object
|
clazz = @clazz.create_class_object
|
||||||
assert_equal Parfait::VoolMethod , method.make_method(clazz).class
|
assert_equal Parfait::VoolMethod , method.make_method(clazz).class
|
||||||
end
|
end
|
||||||
|
|
||||||
#create CallableMethod
|
|
||||||
|
|
||||||
#create Compiler
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,52 +11,56 @@ module Risc
|
|||||||
|
|
||||||
def test_chain
|
def test_chain
|
||||||
# show_main_ticks # get output of what is
|
# show_main_ticks # get output of what is
|
||||||
check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant,
|
||||||
RegToSlot, LoadConstant, LoadConstant, SlotToReg, SlotToReg, # 10
|
SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, # 10
|
||||||
RegToSlot, RegToSlot, RegToSlot, Branch, RegToSlot,
|
RegToSlot, SlotToReg, SlotToReg, Branch, RegToSlot,
|
||||||
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, # 20
|
LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, # 20
|
||||||
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
SlotToReg, RegToSlot, SlotToReg, FunctionCall, LoadConstant,
|
||||||
RegToSlot, SlotToReg, Branch, FunctionCall, LoadConstant, # 30
|
SlotToReg, OperatorInstruction, IsZero, SlotToReg, SlotToReg, # 30
|
||||||
SlotToReg, OperatorInstruction, IsZero, SlotToReg, SlotToReg,
|
LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot,
|
||||||
LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot, # 40
|
RegToSlot, RegToSlot, Branch, SlotToReg, SlotToReg, # 40
|
||||||
RegToSlot, RegToSlot, Branch, SlotToReg, SlotToReg,
|
RegToSlot, SlotToReg, LoadConstant, RegToSlot, SlotToReg,
|
||||||
RegToSlot, SlotToReg, LoadConstant, RegToSlot, SlotToReg, # 50
|
SlotToReg, SlotToReg, DynamicJump, LoadConstant, SlotToReg, # 50
|
||||||
SlotToReg, SlotToReg, DynamicJump, LoadConstant, SlotToReg,
|
SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot,
|
||||||
SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot, # 60
|
Branch, SlotToReg, SlotToReg, RegToSlot, LoadConstant, # 60
|
||||||
|
SlotToReg, Branch, RegToSlot, RegToSlot, SlotToReg,
|
||||||
|
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, RegToSlot, # 70
|
||||||
Branch, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
|
Branch, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
|
||||||
SlotToReg, Branch, RegToSlot, RegToSlot, SlotToReg, # 70
|
SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg, # 80
|
||||||
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, RegToSlot,
|
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
|
||||||
Branch, SlotToReg, SlotToReg, RegToSlot, LoadConstant, # 80
|
Branch, Branch, SlotToReg, SlotToReg, RegToSlot, # 90
|
||||||
SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg,
|
LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg,
|
||||||
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot, # 90
|
SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, # 100
|
||||||
Branch, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
|
|
||||||
SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, # 100
|
|
||||||
SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg,
|
|
||||||
SlotToReg, Syscall, NilClass, ]
|
SlotToReg, Syscall, NilClass, ]
|
||||||
assert_equal 10 , get_return
|
assert_equal 10 , get_return
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_block_jump
|
def test_block_jump
|
||||||
load_ins = main_ticks(53)
|
load_ins = main_ticks(48)
|
||||||
assert_equal DynamicJump , load_ins.class
|
assert_equal DynamicJump , load_ins.class
|
||||||
assert_equal Parfait::Block , @interpreter.get_register(load_ins.register).class
|
assert_equal Parfait::Block , @interpreter.get_register(load_ins.register).class
|
||||||
end
|
end
|
||||||
def test_block_load
|
def test_block_load
|
||||||
load_ins = main_ticks(54)
|
load_ins = main_ticks(49)
|
||||||
assert_load load_ins , Parfait::Integer , :r1
|
assert_load load_ins , Parfait::Integer , :r1
|
||||||
assert_equal 10 , @interpreter.get_register(load_ins.register).value
|
assert_equal 10 , @interpreter.get_register(load_ins.register).value
|
||||||
end
|
end
|
||||||
|
def test_ret_load
|
||||||
|
load_ins = main_ticks(54)
|
||||||
|
assert_load load_ins , Parfait::Integer , :r1
|
||||||
|
assert_equal 15 , @interpreter.get_register(load_ins.register).value
|
||||||
|
end
|
||||||
def test_block_slot1
|
def test_block_slot1
|
||||||
assert_slot_to_reg main_ticks(55) ,:r0 , 6 , :r2
|
assert_slot_to_reg main_ticks(50) ,:r0 , 6 , :r2
|
||||||
end
|
end
|
||||||
def test_block_slot2
|
def test_block_slot2
|
||||||
assert_slot_to_reg main_ticks(56) ,:r2 , 6 , :r2
|
assert_slot_to_reg main_ticks(51) ,:r2 , 6 , :r2
|
||||||
end
|
end
|
||||||
def test_block_slot3
|
def test_block_slot3
|
||||||
assert_slot_to_reg main_ticks(57) ,:r2 , 3 , :r2
|
assert_slot_to_reg main_ticks(52) ,:r2 , 3 , :r2
|
||||||
end
|
end
|
||||||
def test_block_reg
|
def test_block_reg
|
||||||
assert_reg_to_slot main_ticks(58) ,:r1 , :r2 , 1
|
assert_reg_to_slot main_ticks(53) ,:r1 , :r2 , 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,38 +11,38 @@ module Risc
|
|||||||
|
|
||||||
def test_chain
|
def test_chain
|
||||||
#show_main_ticks # get output of what is
|
#show_main_ticks # get output of what is
|
||||||
check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant,
|
check_main_chain [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
|
||||||
SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, # 10
|
RegToSlot, RegToSlot, RegToSlot, SlotToReg, SlotToReg, # 10
|
||||||
RegToSlot, SlotToReg, SlotToReg, Branch, RegToSlot,
|
RegToSlot, LoadConstant, SlotToReg, Branch, SlotToReg,
|
||||||
SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, # 20
|
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, # 20
|
||||||
LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall,
|
FunctionCall, LoadConstant, SlotToReg, OperatorInstruction, IsZero,
|
||||||
LoadConstant, SlotToReg, OperatorInstruction, IsZero, SlotToReg, # 30
|
SlotToReg, SlotToReg, LoadConstant, SlotToReg, SlotToReg, # 30
|
||||||
SlotToReg, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
|
RegToSlot, RegToSlot, RegToSlot, RegToSlot, Branch,
|
||||||
RegToSlot, RegToSlot, RegToSlot, Branch, SlotToReg, # 40
|
SlotToReg, SlotToReg, RegToSlot, SlotToReg, LoadConstant, # 40
|
||||||
SlotToReg, RegToSlot, SlotToReg, LoadConstant, RegToSlot,
|
RegToSlot, SlotToReg, SlotToReg, SlotToReg, DynamicJump,
|
||||||
SlotToReg, SlotToReg, SlotToReg, DynamicJump, LoadConstant, # 50
|
LoadConstant, RegToSlot, Branch, SlotToReg, SlotToReg, # 50
|
||||||
RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot,
|
RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
|
||||||
LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg, # 60
|
SlotToReg, SlotToReg, SlotToReg, Branch, FunctionReturn, # 60
|
||||||
SlotToReg, SlotToReg, Branch, FunctionReturn, SlotToReg,
|
SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg,
|
||||||
RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot, # 70
|
RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot, # 70
|
||||||
LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg,
|
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
|
||||||
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, # 80
|
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, # 80
|
||||||
Branch, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
|
Branch, Branch, SlotToReg, SlotToReg, RegToSlot,
|
||||||
Branch, SlotToReg, SlotToReg, RegToSlot, LoadConstant, # 90
|
LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg, # 90
|
||||||
SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch,
|
SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg,
|
||||||
SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, # 100
|
|
||||||
SlotToReg, Syscall, NilClass, ]
|
SlotToReg, Syscall, NilClass, ]
|
||||||
|
|
||||||
assert_equal 15 , get_return
|
assert_equal 15 , get_return
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_load_return
|
def test_load_return
|
||||||
load_ins = main_ticks(44)
|
load_ins = main_ticks(40)
|
||||||
assert_equal LoadConstant , load_ins.class
|
assert_equal LoadConstant , load_ins.class
|
||||||
assert_equal Parfait::ReturnAddress , @interpreter.get_register(load_ins.register).class
|
assert_equal Parfait::ReturnAddress , @interpreter.get_register(load_ins.register).class
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_load_block
|
def test_load_block
|
||||||
load_ins = main_ticks(49)
|
load_ins = main_ticks(45)
|
||||||
assert_equal DynamicJump , load_ins.class
|
assert_equal DynamicJump , load_ins.class
|
||||||
assert_equal Parfait::Block , @interpreter.get_register(load_ins.register).class
|
assert_equal Parfait::Block , @interpreter.get_register(load_ins.register).class
|
||||||
assert_equal :main_block , @interpreter.get_register(load_ins.register).name
|
assert_equal :main_block , @interpreter.get_register(load_ins.register).name
|
||||||
|
@ -42,7 +42,7 @@ module Risc
|
|||||||
def test_creates_method_statement_in_class
|
def test_creates_method_statement_in_class
|
||||||
clazz = in_test_vool("def meth; @ivar = 5 ;return;end")
|
clazz = in_test_vool("def meth; @ivar = 5 ;return;end")
|
||||||
assert_equal Vool::Statements , clazz.body.class
|
assert_equal Vool::Statements , clazz.body.class
|
||||||
assert_equal Vool::MethodStatement , clazz.body.first.class
|
assert_equal Vool::MethodExpression , clazz.body.first.class
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_callable_method_instance_type
|
def test_callable_method_instance_type
|
||||||
|
@ -13,7 +13,7 @@ module RubyX
|
|||||||
end
|
end
|
||||||
def test_vool
|
def test_vool
|
||||||
vool = compiler.ruby_to_vool source
|
vool = compiler.ruby_to_vool source
|
||||||
assert_equal Vool::ClassStatement , vool.class
|
assert_equal Vool::ClassExpression , vool.class
|
||||||
assert_equal :Object , vool.name
|
assert_equal :Object , vool.name
|
||||||
end
|
end
|
||||||
def test_mom
|
def test_mom
|
||||||
|
@ -18,7 +18,7 @@ module RubyX
|
|||||||
def test_class_body_is_scope
|
def test_class_body_is_scope
|
||||||
clazz = ruby_to_vool in_Test("def meth; @ivar = 5 ;end")
|
clazz = ruby_to_vool in_Test("def meth; @ivar = 5 ;end")
|
||||||
assert_equal Vool::Statements , clazz.body.class
|
assert_equal Vool::Statements , clazz.body.class
|
||||||
assert_equal Vool::MethodStatement , clazz.body.first.class
|
assert_equal Vool::MethodExpression , clazz.body.first.class
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_space_is_unchanged_by_compile
|
def test_space_is_unchanged_by_compile
|
||||||
|
@ -20,7 +20,7 @@ module RubyX
|
|||||||
def test_one_vool_call
|
def test_one_vool_call
|
||||||
compiler = RubyXCompiler.new(RubyX.default_test_options)
|
compiler = RubyXCompiler.new(RubyX.default_test_options)
|
||||||
compiler.ruby_to_vool(space_source_for("main"))
|
compiler.ruby_to_vool(space_source_for("main"))
|
||||||
assert_equal Vool::ClassStatement , compiler.vool.class
|
assert_equal Vool::ClassExpression , compiler.vool.class
|
||||||
end
|
end
|
||||||
def test_two_vool_calls
|
def test_two_vool_calls
|
||||||
compiler = RubyXCompiler.new(RubyX.default_test_options)
|
compiler = RubyXCompiler.new(RubyX.default_test_options)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user