block creation and insertion with correct types
This commit is contained in:
parent
1913848910
commit
0d900de695
@ -38,7 +38,10 @@ module Parfait
|
||||
end
|
||||
|
||||
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
|
||||
bl.next = block if(block)
|
||||
@blocks = bl
|
||||
|
@ -45,7 +45,7 @@ module Risc
|
||||
method = type.create_method( method_name , args , frame)
|
||||
self.new(method)
|
||||
end
|
||||
|
||||
|
||||
# convert the given mom instruction to_risc and then add it (see add_code)
|
||||
# continue down the instruction chain unti depleted
|
||||
# (adding moves the insertion point so the whole mom chain is added as a risc chain)
|
||||
|
@ -15,7 +15,6 @@ module Vool
|
||||
# fact never called)
|
||||
def slot_definition(compiler)
|
||||
@parfait_block = to_parfait(compiler)
|
||||
compiler.add_constant(@parfait_block)
|
||||
return Mom::SlotDefinition.new(Mom::IntegerConstant.new(1) , [])
|
||||
end
|
||||
|
||||
@ -34,7 +33,7 @@ module Vool
|
||||
|
||||
private
|
||||
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
|
||||
def make_arg_type( )
|
||||
type_hash = {}
|
||||
|
@ -9,14 +9,34 @@ module Vool
|
||||
Parfait.boot!
|
||||
@ret = compile_mom( as_test_main("self.main {|elem| elem } "))
|
||||
end
|
||||
|
||||
def test_is_compiler
|
||||
# assert_equal Mom::MomCompiler , @ret.class
|
||||
assert_equal Mom::MomCompiler , @ret.class
|
||||
end
|
||||
|
||||
def est_has_compilers
|
||||
assert_equal Risc::MethodCompiler , @ret.method_compilers.first.class
|
||||
def test_has_method
|
||||
assert_equal Parfait::CallableMethod , @ret.method_compilers.first.method.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
|
||||
|
Loading…
x
Reference in New Issue
Block a user