block creation and insertion with correct types
This commit is contained in:
parent
1913848910
commit
0d900de695
@ -38,7 +38,10 @@ module Parfait
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_block(args , frame)
|
def create_block(args , frame)
|
||||||
bl = Block.new(self_type , args , frame)
|
add_block( Block.new(self_type , args , frame))
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_block(bl)
|
||||||
block = self.blocks
|
block = self.blocks
|
||||||
bl.next = block if(block)
|
bl.next = block if(block)
|
||||||
@blocks = bl
|
@blocks = bl
|
||||||
|
@ -15,7 +15,6 @@ module Vool
|
|||||||
# fact never called)
|
# fact never called)
|
||||||
def slot_definition(compiler)
|
def slot_definition(compiler)
|
||||||
@parfait_block = to_parfait(compiler)
|
@parfait_block = to_parfait(compiler)
|
||||||
compiler.add_constant(@parfait_block)
|
|
||||||
return Mom::SlotDefinition.new(Mom::IntegerConstant.new(1) , [])
|
return Mom::SlotDefinition.new(Mom::IntegerConstant.new(1) , [])
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -34,7 +33,7 @@ module Vool
|
|||||||
|
|
||||||
private
|
private
|
||||||
def to_parfait(compiler)
|
def to_parfait(compiler)
|
||||||
Parfait::Block.new(compiler.method.self_type , make_arg_type , make_frame)
|
compiler.method.create_block( make_arg_type , make_frame)
|
||||||
end
|
end
|
||||||
def make_arg_type( )
|
def make_arg_type( )
|
||||||
type_hash = {}
|
type_hash = {}
|
||||||
|
@ -9,14 +9,34 @@ module Vool
|
|||||||
Parfait.boot!
|
Parfait.boot!
|
||||||
@ret = compile_mom( as_test_main("self.main {|elem| elem } "))
|
@ret = compile_mom( as_test_main("self.main {|elem| elem } "))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_is_compiler
|
def test_is_compiler
|
||||||
# assert_equal Mom::MomCompiler , @ret.class
|
assert_equal Mom::MomCompiler , @ret.class
|
||||||
end
|
end
|
||||||
|
def test_has_method
|
||||||
def est_has_compilers
|
assert_equal Parfait::CallableMethod , @ret.method_compilers.first.method.class
|
||||||
assert_equal Risc::MethodCompiler , @ret.method_compilers.first.class
|
end
|
||||||
|
def test_method_has_block
|
||||||
|
assert @ret.method_compilers.first.method.blocks , "No block created"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
class TestBlockCreated < MiniTest::Test
|
||||||
|
include MomCompile
|
||||||
|
def setup
|
||||||
|
Parfait.boot!
|
||||||
|
@ret = compile_mom( as_test_main("self.main {|elem| local = 5 } "))
|
||||||
|
@block = @ret.method_compilers.first.method.blocks
|
||||||
|
end
|
||||||
|
def test_block_arg_type
|
||||||
|
assert_equal Parfait::Type, @block.arguments_type.class
|
||||||
|
end
|
||||||
|
def test_block_arg_type_name
|
||||||
|
assert_equal 1, @block.arguments_type.variable_index(:elem)
|
||||||
|
end
|
||||||
|
def test_block_local_type
|
||||||
|
assert_equal Parfait::Type, @block.frame_type.class
|
||||||
|
end
|
||||||
|
def test_block_frame_type_name
|
||||||
|
assert_equal 1, @block.frame_type.variable_index(:local)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user