From bb49f1be7899290695aa5445a2779305799c2780 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 1 Jul 2018 21:26:45 +0300 Subject: [PATCH] rename ClassCompiler to MomComplier ended up not even using the class, it just came from there It actually compiles methods, and it turns out is the point where builtin comes into the picture as it's boot process also returns method compilers --- lib/mom/mom.rb | 2 +- lib/mom/{class_compiler.rb => mom_compiler.rb} | 7 +++---- lib/vool/class_statement.rb | 2 +- .../{test_class_compiler.rb => test_method_compiler.rb} | 6 +++--- test/vool/test_class_statement.rb | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) rename lib/mom/{class_compiler.rb => mom_compiler.rb} (91%) rename test/mom/{test_class_compiler.rb => test_method_compiler.rb} (87%) diff --git a/lib/mom/mom.rb b/lib/mom/mom.rb index 54bb67ab..2fec938e 100644 --- a/lib/mom/mom.rb +++ b/lib/mom/mom.rb @@ -15,4 +15,4 @@ module Mom end require_relative "instruction/instruction.rb" -require_relative "class_compiler" +require_relative "mom_compiler" diff --git a/lib/mom/class_compiler.rb b/lib/mom/mom_compiler.rb similarity index 91% rename from lib/mom/class_compiler.rb rename to lib/mom/mom_compiler.rb index 75d4e9de..2c2e96d0 100644 --- a/lib/mom/class_compiler.rb +++ b/lib/mom/mom_compiler.rb @@ -1,10 +1,9 @@ module Mom - class ClassCompiler + class MomCompiler attr_reader :clazz , :method_compilers - def initialize(clazz , compilers) - @clazz = clazz - @method_compilers = compilers + def initialize(compilers = []) + @method_compilers = Builtin.boot_functions + compilers end # Translate code to whatever cpu is specified. diff --git a/lib/vool/class_statement.rb b/lib/vool/class_statement.rb index 23354e54..be80953c 100644 --- a/lib/vool/class_statement.rb +++ b/lib/vool/class_statement.rb @@ -29,7 +29,7 @@ module Vool raise "Only methods for now #{node}" unless node.is_a?(MethodStatement) method_compilers << node.to_mom(@clazz) end - Mom::ClassCompiler.new(@clazz , method_compilers) + Mom::MomCompiler.new(method_compilers) end def each(&block) diff --git a/test/mom/test_class_compiler.rb b/test/mom/test_method_compiler.rb similarity index 87% rename from test/mom/test_class_compiler.rb rename to test/mom/test_method_compiler.rb index 7cb01ccf..e6c2026e 100644 --- a/test/mom/test_class_compiler.rb +++ b/test/mom/test_method_compiler.rb @@ -1,7 +1,7 @@ require_relative "helper" module Mom - class TestClassCompiler < MiniTest::Test + class TestMomCompiler < MiniTest::Test include MomCompile def setup @@ -10,7 +10,7 @@ module Mom end def test_class - assert_equal ClassCompiler , @comp.class + assert_equal MomCompiler , @comp.class end def test_compilers assert_equal 1 , @comp.method_compilers.length @@ -19,7 +19,7 @@ module Mom assert @comp.translate(:interpreter) end end - class TestClassCompilerTranslate < MiniTest::Test + class TestMomCompilerTranslate < MiniTest::Test include MomCompile def setup diff --git a/test/vool/test_class_statement.rb b/test/vool/test_class_statement.rb index dadc755a..97caf29e 100644 --- a/test/vool/test_class_statement.rb +++ b/test/vool/test_class_statement.rb @@ -11,7 +11,7 @@ module Vool end def test_return_class - assert_equal Mom::ClassCompiler , @ret.class + assert_equal Mom::MomCompiler , @ret.class end def test_has_compilers assert_equal Risc::MethodCompiler , @ret.method_compilers.first.class