compile from mom compiler to risc
This commit is contained in:
@ -7,20 +7,30 @@ module Mom
|
||||
def setup
|
||||
end
|
||||
|
||||
def in_test_vool(str)
|
||||
vool = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_vool(in_Test(str))
|
||||
vool.to_mom(nil)
|
||||
vool
|
||||
end
|
||||
def create_method(body = "@ivar = 5")
|
||||
in_test_vool("def meth; #{body};end")
|
||||
test = Parfait.object_space.get_class_by_name(:Test)
|
||||
test.get_method(:meth)
|
||||
def in_test_vool(body = "@ivar = 5")
|
||||
code = in_Test("def meth; #{body};end")
|
||||
RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(code)
|
||||
end
|
||||
|
||||
def test_method_has_source
|
||||
method = create_method
|
||||
assert_equal Vool::IvarAssignment , method.source.class
|
||||
def test_method
|
||||
in_test_vool()
|
||||
method = Parfait.object_space.get_class_by_name(:Test).get_method(:meth)
|
||||
assert_equal Parfait::VoolMethod , method.class
|
||||
end
|
||||
def test_method_mom_col
|
||||
mom = in_test_vool()
|
||||
assert_equal Mom::MomCollection , mom.class
|
||||
assert_equal Mom::MethodCompiler , mom.compilers.first.class
|
||||
end
|
||||
def test_compiles_risc
|
||||
compiler = in_test_vool().compilers.first.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
|
||||
assert_equal Risc::LoadConstant , compiler.risc_instructions.next.class
|
||||
assert_equal 17 , compiler.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,8 +3,8 @@ module Risc
|
||||
class FakeCallable
|
||||
end
|
||||
class FakeCallableCompiler < CallableCompiler
|
||||
def initialize(a,b,c)
|
||||
super(a,b,c)
|
||||
def initialize(a,c)
|
||||
super(a,c)
|
||||
end
|
||||
def source_name
|
||||
"luke"
|
||||
@ -14,8 +14,8 @@ module Risc
|
||||
|
||||
def setup
|
||||
Parfait.boot!({})
|
||||
label = Risc.label("hi","ho")
|
||||
@compiler = FakeCallableCompiler.new(FakeCallable.new , [] , label)
|
||||
label = Mom::Label.new("hi","ho")
|
||||
@compiler = FakeCallableCompiler.new(FakeCallable.new , label)
|
||||
end
|
||||
def test_ok
|
||||
assert @compiler
|
||||
|
@ -67,14 +67,6 @@ module Risc
|
||||
assert_equal Mom::MethodCompiler , compiler.class
|
||||
compiler
|
||||
end
|
||||
def test_has_method_constant
|
||||
compiler = constant_setup("def meth; return 'Hi';end")
|
||||
assert compiler.constants.include?("Hi")
|
||||
end
|
||||
def test_has_block_constant
|
||||
compiler = constant_setup("def meth; meth{return 'Ho'};return 'Hi';end")
|
||||
assert compiler.constants.include?("Ho")
|
||||
end
|
||||
def test_return_label
|
||||
compiler = constant_setup("def meth; return 'Hi';end")
|
||||
assert_equal "return_label", compiler.return_label.name
|
||||
|
Reference in New Issue
Block a user