make mom:method_compiler a list
Compilers forms alist by Util::CompilerList Change Collection to use the list instead of array
This commit is contained in:
@ -8,7 +8,7 @@ module Mom
|
||||
def get_compiler(clazz , name)
|
||||
compiler = RubyX::RubyXCompiler.new(RubyX.default_test_options)
|
||||
coll = compiler.ruby_to_mom( get_preload("Space.main;#{clazz}.#{name}") )
|
||||
@method = coll.method_compilers.last
|
||||
@method = coll.method_compilers.last_compiler
|
||||
@method
|
||||
end
|
||||
|
||||
|
@ -12,17 +12,17 @@ module Vool
|
||||
assert_equal Mom::MomCollection , @ret.class
|
||||
end
|
||||
def test_has_method
|
||||
assert_equal Parfait::CallableMethod , @ret.method_compilers.first.get_method.class
|
||||
assert_equal Parfait::CallableMethod , @ret.method_compilers.get_method.class
|
||||
end
|
||||
def test_method_has_block
|
||||
assert @ret.method_compilers.first.get_method.blocks , "No block created"
|
||||
assert @ret.method_compilers.get_method.blocks , "No block created"
|
||||
end
|
||||
end
|
||||
class TestBlockLocal < MiniTest::Test
|
||||
include MomCompile
|
||||
def setup
|
||||
@ret = compile_mom( as_main("self.main {|elem| local = 5 } "))
|
||||
@block = @ret.method_compilers.first.get_method.blocks
|
||||
@block = @ret.method_compilers.get_method.blocks
|
||||
end
|
||||
def test_block_arg_type
|
||||
assert_equal Parfait::Type, @block.arguments_type.class
|
||||
|
@ -13,11 +13,11 @@ module Vool
|
||||
assert_equal Mom::MomCollection , @ret.class
|
||||
end
|
||||
def test_has_compilers
|
||||
assert_equal Mom::MethodCompiler , @ret.method_compilers.first.class
|
||||
assert_equal Mom::MethodCompiler , @ret.method_compilers.class
|
||||
end
|
||||
|
||||
def test_constant
|
||||
assert @ret.method_compilers.first.add_constant( Parfait::Integer.new(5) )
|
||||
assert @ret.method_compilers.add_constant( Parfait::Integer.new(5) )
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -20,15 +20,15 @@ module Mom
|
||||
def test_method_mom_col
|
||||
mom = in_test_vool()
|
||||
assert_equal Mom::MomCollection , mom.class
|
||||
assert_equal Mom::MethodCompiler , mom.compilers.first.class
|
||||
assert_equal Mom::MethodCompiler , mom.compilers.class
|
||||
end
|
||||
def test_compiles_risc
|
||||
compiler = in_test_vool().compilers.first.to_risc
|
||||
compiler = in_test_vool().compilers.to_risc
|
||||
assert_equal Risc::MethodCompiler , compiler.class
|
||||
assert_equal Risc::Label , compiler.risc_instructions.class
|
||||
end
|
||||
def test_compiles_all_risc
|
||||
compiler = in_test_vool().compilers.first.to_risc
|
||||
compiler = in_test_vool().compilers.to_risc
|
||||
assert_equal Risc::LoadConstant , compiler.risc_instructions.next.class
|
||||
assert_equal 16 , compiler.risc_instructions.length
|
||||
end
|
||||
|
@ -12,23 +12,17 @@ module Mom
|
||||
assert_equal MomCollection , @comp.class
|
||||
end
|
||||
def test_compilers
|
||||
assert_equal 3 , @comp.compilers.length
|
||||
assert_equal 3 , @comp.compilers.num_compilers
|
||||
end
|
||||
def test_init_compilers
|
||||
assert_equal Array , @comp.init_compiler.class
|
||||
end
|
||||
def test_init_compiler
|
||||
assert_equal Mom::MethodCompiler , @comp.init_compiler.first.class
|
||||
assert_equal MomCollection , @comp.init_compilers.class
|
||||
end
|
||||
def test_compilers_bare
|
||||
assert_equal 2 , MomCollection.new.compilers.length
|
||||
assert_equal 2 , MomCollection.new.compilers.num_compilers
|
||||
end
|
||||
def test_append_class
|
||||
assert_equal MomCollection, (@comp.append @comp).class
|
||||
end
|
||||
def test_append_length
|
||||
assert_equal 2 , @comp.append(@comp).method_compilers.length
|
||||
end
|
||||
end
|
||||
class TestMomCollectionToRisc < MiniTest::Test
|
||||
include MomCompile
|
||||
|
@ -64,7 +64,7 @@ module Risc
|
||||
def constant_setup(input)
|
||||
mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(in_Test(input))
|
||||
assert_equal Mom::MomCollection , mom.class
|
||||
compiler = mom.method_compilers.first
|
||||
compiler = mom.method_compilers
|
||||
assert_equal Mom::MethodCompiler , compiler.class
|
||||
compiler
|
||||
end
|
||||
|
@ -5,12 +5,12 @@ module RubyX
|
||||
def setup
|
||||
whole ="class Space;def main(arg);return;end;end;" + source
|
||||
@mom = RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(whole)
|
||||
@mom.method_compilers.first
|
||||
@mom.method_compilers
|
||||
assert_equal Mom::MomCollection , @mom.class
|
||||
assert_equal Mom::MethodCompiler , compiler.class
|
||||
end
|
||||
def compiler
|
||||
@mom.method_compilers.last
|
||||
@mom.method_compilers.last_compiler
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -37,15 +37,14 @@ module VoolCompile
|
||||
input = get_preload(preload) + as_main( input )
|
||||
collection = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(input)
|
||||
assert collection.is_a?(Mom::MomCollection) , collection.class.name
|
||||
compiler = collection.compilers.find{|comp| comp.callable.name == :main}
|
||||
assert compiler.is_a?(Mom::MethodCompiler)
|
||||
compiler = collection.compilers.find_compiler{|comp| comp.callable.name == :main}
|
||||
assert_equal Mom::MethodCompiler , compiler.class
|
||||
compiler
|
||||
end
|
||||
def compile_main_block( block_input , method_input = "main_local = 5" , preload = nil)
|
||||
source = get_preload(preload) + as_main("#{method_input} ; self.main{|val| #{block_input}}")
|
||||
mom_col = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom( source )
|
||||
compiler = mom_col.method_compilers.find{|c| c.get_method.name.to_s.start_with?("main") }
|
||||
compiler = mom_col.method_compilers.find_compiler{|c| c.get_method.name.to_s.start_with?("main") }
|
||||
block = compiler.block_compilers.first
|
||||
assert block
|
||||
block.mom_instructions.next
|
||||
|
@ -24,7 +24,7 @@ module Util
|
||||
assert_equal :one , @compiler.last_compiler.name
|
||||
end
|
||||
def test_find_one
|
||||
assert_equal :one , @compiler.find_compiler{|c| c.name == :one}.name
|
||||
assert_equal :one , @compiler.find_compiler{|c| c.name == :one}.name
|
||||
end
|
||||
end
|
||||
class TestComplierListTwo < Minitest::Test
|
||||
@ -42,23 +42,10 @@ module Util
|
||||
def test_find_two
|
||||
assert_equal :two , @compiler.find_compiler{|c| c.name == :two}.name
|
||||
end
|
||||
def test_each
|
||||
all = []
|
||||
@compiler.each_compiler{|c| all << c.name}
|
||||
assert_equal [:one, :two] , all
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
@ -21,7 +21,7 @@ module Vool
|
||||
def setup
|
||||
source = "class Integer<Data4;def +(other);X.int_operator(:+);end;end;" + class_main
|
||||
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(source)
|
||||
@ins = ret.compilers.find{|c|c.callable.name==:main}.mom_instructions.next
|
||||
@ins = ret.compilers.find_compiler{|c|c.callable.name==:main}.mom_instructions.next
|
||||
end
|
||||
def test_array
|
||||
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,
|
||||
|
@ -20,8 +20,8 @@ module Vool
|
||||
|
||||
def setup
|
||||
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(class_main)
|
||||
@compiler = ret.compilers.find{|c|c.callable.name==:some_inst}
|
||||
@main = ret.compilers.find{|c|c.callable.name==:main}
|
||||
@compiler = ret.compilers.find_compiler{|c|c.callable.name==:some_inst}
|
||||
@main = ret.compilers.find_compiler{|c|c.callable.name==:main}
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
def test_class_inst
|
||||
|
@ -23,7 +23,7 @@ module Vool
|
||||
def setup
|
||||
source = "class Integer < Data4;def +(other);X.int_operator(:+);end;end;" + class_main
|
||||
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(source)
|
||||
@ins = ret.compilers.find{|c|c.callable.name==:main}.mom_instructions.next
|
||||
@ins = ret.compilers.find_compiler{|c|c.callable.name==:main}.mom_instructions.next
|
||||
end
|
||||
def test_array
|
||||
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,
|
||||
|
@ -39,10 +39,10 @@ module Vool
|
||||
def test_mom_basic
|
||||
mom = as_mom
|
||||
assert_equal Mom::MomCollection , mom.class
|
||||
assert_equal Mom::MethodCompiler , mom.method_compilers.first.class
|
||||
assert_equal Mom::MethodCompiler , mom.method_compilers.class
|
||||
end
|
||||
def test_mom_instructions
|
||||
mom_compiler = as_mom.method_compilers.first
|
||||
mom_compiler = as_mom.method_compilers
|
||||
assert_equal Mom::Label , mom_compiler.mom_instructions.class
|
||||
assert_equal Mom::IntOperator , mom_compiler.mom_instructions.next.class
|
||||
assert_equal Mom::SlotLoad , mom_compiler.mom_instructions.next(2).class
|
||||
|
Reference in New Issue
Block a user