better name for cool compile
This commit is contained in:
parent
5fe0ba06ab
commit
d910c02b4a
@ -3,7 +3,7 @@ require_relative "ruby_compiler"
|
|||||||
module Vool
|
module Vool
|
||||||
class VoolCompiler
|
class VoolCompiler
|
||||||
|
|
||||||
def self.compile( ruby_source )
|
def self.ruby_to_vool( ruby_source )
|
||||||
statements = RubyCompiler.compile( ruby_source )
|
statements = RubyCompiler.compile( ruby_source )
|
||||||
statements.create_objects
|
statements.create_objects
|
||||||
statements
|
statements
|
||||||
|
@ -22,7 +22,7 @@ module MomCompile
|
|||||||
include CompilerHelper
|
include CompilerHelper
|
||||||
|
|
||||||
def compile_first_method input
|
def compile_first_method input
|
||||||
lst = Vool::VoolCompiler.compile as_test_main( input )
|
lst = Vool::VoolCompiler.ruby_to_vool as_test_main( input )
|
||||||
assert_equal Parfait::Class , lst.clazz.class , input
|
assert_equal Parfait::Class , lst.clazz.class , input
|
||||||
@method = lst.clazz.get_method(:main)
|
@method = lst.clazz.get_method(:main)
|
||||||
assert_equal Parfait::VoolMethod , @method.class
|
assert_equal Parfait::VoolMethod , @method.class
|
||||||
|
@ -9,7 +9,7 @@ module Vool
|
|||||||
end
|
end
|
||||||
|
|
||||||
def compile_in_test input
|
def compile_in_test input
|
||||||
VoolCompiler.compile in_Test(input)
|
VoolCompiler.ruby_to_vool in_Test(input)
|
||||||
itest = Parfait.object_space.get_class_by_name(:Test)
|
itest = Parfait.object_space.get_class_by_name(:Test)
|
||||||
assert itest
|
assert itest
|
||||||
itest
|
itest
|
||||||
@ -27,25 +27,25 @@ module Vool
|
|||||||
|
|
||||||
def test_doesnt_create_existing_clas
|
def test_doesnt_create_existing_clas
|
||||||
space_class = Parfait.object_space.get_class_by_name(:Space)
|
space_class = Parfait.object_space.get_class_by_name(:Space)
|
||||||
VoolCompiler.compile "class Space ; end"
|
VoolCompiler.ruby_to_vool "class Space ; end"
|
||||||
clazz = Parfait.object_space.get_class_by_name(:Space)
|
clazz = Parfait.object_space.get_class_by_name(:Space)
|
||||||
assert_equal clazz , space_class
|
assert_equal clazz , space_class
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_body_is_scope
|
def test_class_body_is_scope
|
||||||
clazz = VoolCompiler.compile in_Test("def meth; @ivar ;end")
|
clazz = VoolCompiler.ruby_to_vool in_Test("def meth; @ivar ;end")
|
||||||
assert_equal ScopeStatement , clazz.body.class
|
assert_equal ScopeStatement , clazz.body.class
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_creates_class_without_deriviation
|
def test_creates_class_without_deriviation
|
||||||
VoolCompiler.compile "class Testing ; end"
|
VoolCompiler.ruby_to_vool "class Testing ; end"
|
||||||
clazz = Parfait.object_space.get_class_by_name(:Testing)
|
clazz = Parfait.object_space.get_class_by_name(:Testing)
|
||||||
assert clazz , "No classes created"
|
assert clazz , "No classes created"
|
||||||
assert_equal :Object , clazz.super_class_name
|
assert_equal :Object , clazz.super_class_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_creates_class_with_deriviation
|
def test_creates_class_with_deriviation
|
||||||
VoolCompiler.compile "class Test2 < List ;end"
|
VoolCompiler.ruby_to_vool "class Test2 < List ;end"
|
||||||
clazz = Parfait.object_space.get_class_by_name(:Test2)
|
clazz = Parfait.object_space.get_class_by_name(:Test2)
|
||||||
assert clazz, "No classes created"
|
assert clazz, "No classes created"
|
||||||
assert_equal :List , clazz.super_class_name
|
assert_equal :List , clazz.super_class_name
|
||||||
@ -53,14 +53,14 @@ module Vool
|
|||||||
|
|
||||||
def test_space_is_unchanged_by_compile
|
def test_space_is_unchanged_by_compile
|
||||||
space1 = Parfait.object_space.get_class_by_name(:Space)
|
space1 = Parfait.object_space.get_class_by_name(:Space)
|
||||||
VoolCompiler.compile "class Space ;end"
|
VoolCompiler.ruby_to_vool "class Space ;end"
|
||||||
space2 = Parfait.object_space.get_class_by_name(:Space)
|
space2 = Parfait.object_space.get_class_by_name(:Space)
|
||||||
assert_equal space1 , space2
|
assert_equal space1 , space2
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_space_type_is_unchanged_by_compile
|
def test_space_type_is_unchanged_by_compile
|
||||||
space1 = Parfait.object_space.get_class_by_name(:Space).instance_type
|
space1 = Parfait.object_space.get_class_by_name(:Space).instance_type
|
||||||
VoolCompiler.compile "class Space ;end"
|
VoolCompiler.ruby_to_vool "class Space ;end"
|
||||||
space2 = Parfait.object_space.get_class_by_name(:Space).instance_type
|
space2 = Parfait.object_space.get_class_by_name(:Space).instance_type
|
||||||
assert_equal space1 , space2
|
assert_equal space1 , space2
|
||||||
end
|
end
|
||||||
|
@ -5,7 +5,7 @@ module Vool
|
|||||||
class TestIvarCollect < MiniTest::Test
|
class TestIvarCollect < MiniTest::Test
|
||||||
|
|
||||||
def compile(input)
|
def compile(input)
|
||||||
lst = VoolCompiler.compile( input )
|
lst = VoolCompiler.ruby_to_vool( input )
|
||||||
vars = []
|
vars = []
|
||||||
lst.collect([]).each do |node|
|
lst.collect([]).each do |node|
|
||||||
node.add_ivar(vars)
|
node.add_ivar(vars)
|
||||||
|
@ -5,7 +5,7 @@ module Vool
|
|||||||
class TestLocalCollect < MiniTest::Test
|
class TestLocalCollect < MiniTest::Test
|
||||||
|
|
||||||
def compile(input)
|
def compile(input)
|
||||||
lst = VoolCompiler.compile( input )
|
lst = VoolCompiler.ruby_to_vool( input )
|
||||||
vars = []
|
vars = []
|
||||||
lst.collect([]).each do |node|
|
lst.collect([]).each do |node|
|
||||||
node.add_local(vars)
|
node.add_local(vars)
|
||||||
|
@ -9,7 +9,7 @@ module Vool
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_method
|
def create_method
|
||||||
VoolCompiler.compile in_Test("def meth; @ivar ;end")
|
VoolCompiler.ruby_to_vool in_Test("def meth; @ivar ;end")
|
||||||
test = Parfait.object_space.get_class_by_name(:Test)
|
test = Parfait.object_space.get_class_by_name(:Test)
|
||||||
test.get_method(:meth)
|
test.get_method(:meth)
|
||||||
end
|
end
|
||||||
@ -38,27 +38,27 @@ module Vool
|
|||||||
|
|
||||||
|
|
||||||
def test_creates_method_statement_in_class
|
def test_creates_method_statement_in_class
|
||||||
clazz = VoolCompiler.compile in_Test("def meth; @ivar ;end")
|
clazz = VoolCompiler.ruby_to_vool in_Test("def meth; @ivar ;end")
|
||||||
assert_equal MethodStatement , clazz.body.statements.first.class
|
assert_equal MethodStatement , clazz.body.statements.first.class
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parfait_class_creation
|
def test_parfait_class_creation
|
||||||
clazz = VoolCompiler.compile in_Test("def meth; @ivar ;end")
|
clazz = VoolCompiler.ruby_to_vool in_Test("def meth; @ivar ;end")
|
||||||
assert_equal Parfait::Class , clazz.body.statements.first.clazz.class
|
assert_equal Parfait::Class , clazz.body.statements.first.clazz.class
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_method_statement_has_class
|
def test_method_statement_has_class
|
||||||
clazz = VoolCompiler.compile in_Test("def meth; @ivar ;end")
|
clazz = VoolCompiler.ruby_to_vool in_Test("def meth; @ivar ;end")
|
||||||
assert clazz.body.statements.first.clazz
|
assert clazz.body.statements.first.clazz
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_method_statement_has_class_in_main
|
def test_method_statement_has_class_in_main
|
||||||
clazz = VoolCompiler.compile as_main("def meth; @ivar ;end")
|
clazz = VoolCompiler.ruby_to_vool as_main("def meth; @ivar ;end")
|
||||||
assert clazz.body.statements.first.clazz
|
assert clazz.body.statements.first.clazz
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_method_has_one_local
|
def test_method_has_one_local
|
||||||
VoolCompiler.compile in_Test("def meth; local = 5 ;end")
|
VoolCompiler.ruby_to_vool in_Test("def meth; local = 5 ;end")
|
||||||
test = Parfait.object_space.get_class_by_name(:Test)
|
test = Parfait.object_space.get_class_by_name(:Test)
|
||||||
method = test.get_method(:meth)
|
method = test.get_method(:meth)
|
||||||
assert_equal 2 , method.locals_type.instance_length
|
assert_equal 2 , method.locals_type.instance_length
|
||||||
|
Loading…
Reference in New Issue
Block a user