some renames before main fixes commences
This commit is contained in:
parent
dced6b12e6
commit
e33b9f565d
@ -7,7 +7,7 @@ module Risc
|
||||
def setup
|
||||
super
|
||||
@input = as_block("return 5")
|
||||
@mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(as_test_main)
|
||||
@mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(as_main)
|
||||
end
|
||||
def main_risc
|
||||
@mom.to_risc.method_compilers.find{|c| c.callable.name == :main }
|
||||
|
@ -22,13 +22,13 @@ module Risc
|
||||
def as_block( block_input , method_input = "main_local = 5")
|
||||
"#{method_input} ; self.main{|val| #{block_input}}"
|
||||
end
|
||||
def as_test_main
|
||||
"class Test; #{@class_input if @class_input};def main(arg);#{@input};end;end"
|
||||
def as_main
|
||||
"class Space; #{@class_input if @class_input};def main(arg);#{@input};end;end"
|
||||
end
|
||||
def to_target
|
||||
assert @expect , "No output given"
|
||||
compiler = RubyX::RubyXCompiler.new(RubyX.default_test_options)
|
||||
vool = compiler.ruby_to_vool(as_test_main)
|
||||
vool = compiler.ruby_to_vool(as_main)
|
||||
compiler.to_target(:interpreter)
|
||||
end
|
||||
def produce_main
|
||||
|
@ -5,7 +5,7 @@ module Mom
|
||||
class BootTest < MiniTest::Test
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
Builtin.compiler_for( Parfait.object_space.get_class.instance_type , Space , :main)
|
||||
MomCollection.compiler_for( Parfait.object_space.get_class.instance_type , Parfait::Space , :main)
|
||||
end
|
||||
def get_int_compiler(name)
|
||||
obj_type = Parfait.object_space.get_type_by_class_name(:Integer)
|
||||
|
@ -5,7 +5,7 @@ module Mom
|
||||
include ScopeHelper
|
||||
|
||||
def setup
|
||||
code = as_test_main_block("return 5" , "a = 1")
|
||||
code = as_main_block("return 5" , "a = 1")
|
||||
@risc = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_risc(code)
|
||||
end
|
||||
|
||||
@ -24,7 +24,7 @@ module Mom
|
||||
include ScopeHelper
|
||||
|
||||
def setup
|
||||
code = as_test_main_block("return arg" , "arg = 1")
|
||||
code = as_main_block("return arg" , "arg = 1")
|
||||
@risc = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_risc(code)
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,7 @@ module Vool
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
@ret = compile_mom( as_test_main("self.main {|elem| elem = 5 } "))
|
||||
@ret = compile_mom( as_main("self.main {|elem| elem = 5 } "))
|
||||
end
|
||||
def test_is_compiler
|
||||
assert_equal Mom::MomCollection , @ret.class
|
||||
@ -21,7 +21,7 @@ module Vool
|
||||
class TestBlockLocal < MiniTest::Test
|
||||
include MomCompile
|
||||
def setup
|
||||
@ret = compile_mom( as_test_main("self.main {|elem| local = 5 } "))
|
||||
@ret = compile_mom( as_main("self.main {|elem| local = 5 } "))
|
||||
@block = @ret.method_compilers.first.get_method.blocks
|
||||
end
|
||||
def test_block_arg_type
|
||||
@ -43,11 +43,11 @@ module Vool
|
||||
def setup
|
||||
end
|
||||
def test_method_arg_compiles
|
||||
ret = compile_mom( as_test_main("self.main {|elem| arg = 5 } "))
|
||||
ret = compile_mom( as_main("self.main {|elem| arg = 5 } "))
|
||||
assert ret
|
||||
end
|
||||
def test_method_local_compiles
|
||||
ret = compile_mom( as_test_main("local = 5 ; self.main {|elem| local = 10 } "))
|
||||
ret = compile_mom( as_main("local = 5 ; self.main {|elem| local = 10 } "))
|
||||
assert ret
|
||||
end
|
||||
end
|
||||
|
@ -1,23 +0,0 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TestBuiltinFunction < MiniTest::Test
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@functions = Builtin.boot_functions({})
|
||||
end
|
||||
def test_has_boot_function
|
||||
assert @functions
|
||||
end
|
||||
def test_boot_function_type
|
||||
assert_equal Array, @functions.class
|
||||
end
|
||||
def test_boot_function_length
|
||||
assert_equal 21, @functions.length
|
||||
end
|
||||
def test_boot_function_first
|
||||
assert_equal Mom::MethodCompiler, @functions.first.class
|
||||
end
|
||||
end
|
||||
end
|
@ -6,7 +6,7 @@ module Vool
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
@ret = compile_mom( as_test_main("return 1"))
|
||||
@ret = compile_mom( as_main("return 1"))
|
||||
end
|
||||
|
||||
def test_return_class
|
||||
|
@ -12,13 +12,13 @@ module Mom
|
||||
assert_equal MomCollection , @comp.class
|
||||
end
|
||||
def test_compilers
|
||||
assert_equal 23 , @comp.compilers.length
|
||||
assert_equal 2 , @comp.compilers.length
|
||||
end
|
||||
def test_boot_compilers
|
||||
assert_equal 22 , @comp.boot_compilers.length
|
||||
def test_init_compiler
|
||||
assert_equal Mom::MethodCompiler , @comp.init_compiler.class
|
||||
end
|
||||
def test_compilers_bare
|
||||
assert_equal 22 , MomCollection.new.compilers.length
|
||||
assert_equal 1 , MomCollection.new.compilers.length
|
||||
end
|
||||
def test_append_class
|
||||
assert_equal MomCollection, (@comp.append @comp).class
|
||||
@ -31,7 +31,7 @@ module Mom
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
@comp = compile_mom( "class Test ; def main(); return 'Hi'; end; end;")
|
||||
@comp = compile_mom( "class Space ; def main(); return 'Hi'; end; end;")
|
||||
@collection = @comp.to_risc()
|
||||
end
|
||||
def compiler
|
||||
@ -42,7 +42,7 @@ module Mom
|
||||
end
|
||||
def test_has_risc_compiler
|
||||
assert_equal Risc::MethodCompiler, compiler.class
|
||||
assert_equal 23, @collection.method_compilers.length
|
||||
assert_equal 2, @collection.method_compilers.length
|
||||
end
|
||||
def test_has_risc_instructions
|
||||
assert_equal Risc::Label, compiler.risc_instructions.class
|
||||
|
@ -6,7 +6,7 @@ module Vool
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
ruby_tree = Ruby::RubyCompiler.compile( as_test_main("a = 5") )
|
||||
ruby_tree = Ruby::RubyCompiler.compile( as_main("a = 5") )
|
||||
@clazz = ruby_tree.to_vool
|
||||
end
|
||||
def method
|
||||
|
@ -49,11 +49,11 @@ module Ruby
|
||||
include RubyTests
|
||||
|
||||
def test_compile_one_method
|
||||
lst = compile( as_test_main("@ivar = 4") )
|
||||
lst = compile( as_main("@ivar = 4") )
|
||||
assert_equal IvarAssignment , lst.body.first.body.class
|
||||
end
|
||||
def test_compile_two_stats
|
||||
lst = compile( as_test_main("false; true;") )
|
||||
lst = compile( as_main("false; true;") )
|
||||
assert_equal ScopeStatement , lst.body.first.body.class
|
||||
assert_equal TrueConstant , lst.body.first.body.statements[1].class
|
||||
end
|
||||
|
@ -1,10 +1,6 @@
|
||||
|
||||
module ScopeHelper
|
||||
|
||||
def in_Test(statements)
|
||||
"class Test ; #{statements} ; end"
|
||||
end
|
||||
|
||||
def in_Space(statements)
|
||||
"class Space ; #{statements} ; end"
|
||||
end
|
||||
@ -13,12 +9,8 @@ module ScopeHelper
|
||||
in_Space("def main(arg) ; #{statements}; end")
|
||||
end
|
||||
|
||||
def as_test_main( statements )
|
||||
in_Test("def main(arg) ; #{statements}; end")
|
||||
end
|
||||
|
||||
def as_test_main_block( block_input = "return 5", method_input = "main_local = 5")
|
||||
as_test_main("#{method_input} ; self.main{|val| #{block_input}}")
|
||||
def as_main_block( block_input = "return 5", method_input = "main_local = 5")
|
||||
as_main("#{method_input} ; self.main{|val| #{block_input}}")
|
||||
end
|
||||
|
||||
end
|
||||
@ -26,8 +18,8 @@ module VoolCompile
|
||||
include ScopeHelper
|
||||
include Mom
|
||||
|
||||
def compile_first_method( input )
|
||||
input = as_test_main( input )
|
||||
def compile_main( input )
|
||||
input = 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.first
|
||||
@ -35,8 +27,8 @@ module VoolCompile
|
||||
assert_equal Mom::MethodCompiler , compiler.class
|
||||
compiler
|
||||
end
|
||||
def compile_first_block( block_input , method_input = "main_local = 5")
|
||||
source = as_test_main("#{method_input} ; self.main{|val| #{block_input}}")
|
||||
def compile_main_block( block_input , method_input = "main_local = 5")
|
||||
source = 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") }
|
||||
block = compiler.block_compilers.first
|
||||
|
@ -7,7 +7,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( send_method )
|
||||
@compiler = compile_main( send_method )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,7 @@ module VoolBlocks
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@ins = compile_first_block( "local = 5" )
|
||||
@ins = compile_main_block( "local = 5" )
|
||||
end
|
||||
def test_block_compiles
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
@ -30,7 +30,7 @@ module VoolBlocks
|
||||
class TestAssignMomInstanceToLocal < MiniTest::Test
|
||||
include VoolCompile
|
||||
def setup
|
||||
@ins = compile_first_block( "local = @a" , "@a = 5") #second arg in method scope
|
||||
@ins = compile_main_block( "local = @a" , "@a = 5") #second arg in method scope
|
||||
end
|
||||
def test_class_compiles
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
@ -47,7 +47,7 @@ module VoolBlocks
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@ins = compile_first_block( "arg = 5")
|
||||
@ins = compile_main_block( "arg = 5")
|
||||
end
|
||||
|
||||
def test_class_compiles
|
||||
@ -66,12 +66,12 @@ module VoolBlocks
|
||||
def setup
|
||||
end
|
||||
def test_assigns_const
|
||||
@ins = compile_first_block( "@a = 5")
|
||||
@ins = compile_main_block( "@a = 5")
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins
|
||||
end
|
||||
def test_assigns_move
|
||||
@ins = compile_first_block( "@a = arg")
|
||||
@ins = compile_main_block( "@a = arg")
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal Mom::SlotDefinition , @ins.right.class , @ins
|
||||
end
|
||||
|
@ -5,7 +5,7 @@ module VoolBlocks
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@ins = compile_first_block( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end")
|
||||
@ins = compile_main_block( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end")
|
||||
end
|
||||
|
||||
def test_condition
|
||||
|
@ -5,7 +5,7 @@ module VoolBlocks
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@ins = compile_first_block( "while(@a) ; @a = 5 ; end")
|
||||
@ins = compile_main_block( "while(@a) ; @a = 5 ; end")
|
||||
end
|
||||
|
||||
def test_compiles_as_while
|
||||
|
@ -7,7 +7,7 @@ module Vool
|
||||
include Mom
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( send_method )
|
||||
@compiler = compile_main( send_method )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "5.div8")
|
||||
@compiler = compile_main( "5.div8")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
def test_check_type
|
||||
|
@ -5,7 +5,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "a = main(1 + 2);return a" )
|
||||
@compiler = compile_main( "a = main(1 + 2);return a" )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "a = 5; a.div4;return ")
|
||||
@compiler = compile_main( "a = 5; a.div4;return ")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
def test_check_type
|
||||
|
@ -5,7 +5,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "local = 5;return")
|
||||
@compiler = compile_main( "local = 5;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
@ -33,7 +33,7 @@ module Vool
|
||||
class TestAssignMomInstanceToLocal < MiniTest::Test
|
||||
include VoolCompile
|
||||
def setup
|
||||
@compiler = compile_first_method( "@a = 5 ; local = @a;return")
|
||||
@compiler = compile_main( "@a = 5 ; local = @a;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
def test_class_compiles
|
||||
@ -46,7 +46,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "arg = 5;return")
|
||||
@compiler = compile_main( "arg = 5;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
@ -70,13 +70,13 @@ module Vool
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
end
|
||||
def test_assigns_const
|
||||
@compiler = compile_first_method( "@a = 5;return")
|
||||
@compiler = compile_main( "@a = 5;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins
|
||||
end
|
||||
def test_assigns_move
|
||||
@compiler = compile_first_method( "@a = arg;return")
|
||||
@compiler = compile_main( "@a = arg;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal Mom::SlotDefinition , @ins.right.class , @ins
|
||||
|
@ -6,7 +6,7 @@ module Vool
|
||||
include ScopeHelper
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
ruby_tree = Ruby::RubyCompiler.compile( as_test_main("@a = 5") )
|
||||
ruby_tree = Ruby::RubyCompiler.compile( as_main("@a = 5") )
|
||||
@vool = ruby_tree.to_vool
|
||||
end
|
||||
def test_class
|
||||
@ -31,7 +31,7 @@ module Vool
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
end
|
||||
def assert_type_for(input)
|
||||
ruby_tree = Ruby::RubyCompiler.compile( as_test_main(input) )
|
||||
ruby_tree = Ruby::RubyCompiler.compile( as_main(input) )
|
||||
vool = ruby_tree.to_vool
|
||||
assert_equal ClassExpression , vool.class
|
||||
clazz = vool.create_class_object
|
||||
@ -67,7 +67,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "if(@a) ; @a = 5 ; else; @a = 6 ; end; return")
|
||||
@compiler = compile_main( "if(@a) ; @a = 5 ; else; @a = 6 ; end; return")
|
||||
@ins = @compiler.mom_instructions
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "if(@a) ; @a = 5 ; end;return")
|
||||
@compiler = compile_main( "if(@a) ; @a = 5 ; end;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "unless(@a) ; @a = 5 ; end;return")
|
||||
@compiler = compile_main( "unless(@a) ; @a = 5 ; end;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "if(@a) ; @a = 5 ; else; @a = 6 ; end;return")
|
||||
@compiler = compile_main( "if(@a) ; @a = 5 ; else; @a = 6 ; end;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end;return")
|
||||
@compiler = compile_main( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "@a = 5")
|
||||
@compiler = compile_main( "@a = 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "a = 5")
|
||||
@compiler = compile_main( "a = 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
@ -37,7 +37,7 @@ module Vool
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "arg = 5")
|
||||
@compiler = compile_main( "arg = 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
|
@ -15,7 +15,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "X.plus_equals(arg,1)")
|
||||
@compiler = compile_main( "X.plus_equals(arg,1)")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,7 @@ module Vool
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
ruby_tree = Ruby::RubyCompiler.compile( as_test_main("a = 5") )
|
||||
ruby_tree = Ruby::RubyCompiler.compile( as_main("a = 5") )
|
||||
@clazz = ruby_tree.to_vool
|
||||
end
|
||||
def method
|
||||
|
@ -1,11 +1,11 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestReturnMom < MiniTest::Test
|
||||
class TestReturnMom #< MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "return 5")
|
||||
@compiler = compile_main( "return 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
@ -41,7 +41,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "return 5.div4")
|
||||
@compiler = compile_main( "return 5.div4")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "while(@a) ; @a = 5 ; end;return")
|
||||
@compiler = compile_main( "while(@a) ; @a = 5 ; end;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "while(5.div4) ; 5.div4 ; end;return")
|
||||
@compiler = compile_main( "while(5.div4) ; 5.div4 ; end;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "return yield(1)" )
|
||||
@compiler = compile_main( "return yield(1)" )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
@ -69,7 +69,7 @@ module Vool
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_first_method( "return yield(some.extra.calls)" )
|
||||
@compiler = compile_main( "return yield(some.extra.calls)" )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
def test_check_label
|
||||
|
Loading…
Reference in New Issue
Block a user