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
This commit is contained in:
parent
c947c27a14
commit
bb49f1be78
@ -15,4 +15,4 @@ module Mom
|
|||||||
end
|
end
|
||||||
|
|
||||||
require_relative "instruction/instruction.rb"
|
require_relative "instruction/instruction.rb"
|
||||||
require_relative "class_compiler"
|
require_relative "mom_compiler"
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
module Mom
|
module Mom
|
||||||
class ClassCompiler
|
class MomCompiler
|
||||||
attr_reader :clazz , :method_compilers
|
attr_reader :clazz , :method_compilers
|
||||||
|
|
||||||
def initialize(clazz , compilers)
|
def initialize(compilers = [])
|
||||||
@clazz = clazz
|
@method_compilers = Builtin.boot_functions + compilers
|
||||||
@method_compilers = compilers
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Translate code to whatever cpu is specified.
|
# Translate code to whatever cpu is specified.
|
@ -29,7 +29,7 @@ module Vool
|
|||||||
raise "Only methods for now #{node}" unless node.is_a?(MethodStatement)
|
raise "Only methods for now #{node}" unless node.is_a?(MethodStatement)
|
||||||
method_compilers << node.to_mom(@clazz)
|
method_compilers << node.to_mom(@clazz)
|
||||||
end
|
end
|
||||||
Mom::ClassCompiler.new(@clazz , method_compilers)
|
Mom::MomCompiler.new(method_compilers)
|
||||||
end
|
end
|
||||||
|
|
||||||
def each(&block)
|
def each(&block)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module Mom
|
||||||
class TestClassCompiler < MiniTest::Test
|
class TestMomCompiler < MiniTest::Test
|
||||||
include MomCompile
|
include MomCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@ -10,7 +10,7 @@ module Mom
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_class
|
def test_class
|
||||||
assert_equal ClassCompiler , @comp.class
|
assert_equal MomCompiler , @comp.class
|
||||||
end
|
end
|
||||||
def test_compilers
|
def test_compilers
|
||||||
assert_equal 1 , @comp.method_compilers.length
|
assert_equal 1 , @comp.method_compilers.length
|
||||||
@ -19,7 +19,7 @@ module Mom
|
|||||||
assert @comp.translate(:interpreter)
|
assert @comp.translate(:interpreter)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class TestClassCompilerTranslate < MiniTest::Test
|
class TestMomCompilerTranslate < MiniTest::Test
|
||||||
include MomCompile
|
include MomCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
@ -11,7 +11,7 @@ module Vool
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_return_class
|
def test_return_class
|
||||||
assert_equal Mom::ClassCompiler , @ret.class
|
assert_equal Mom::MomCompiler , @ret.class
|
||||||
end
|
end
|
||||||
def test_has_compilers
|
def test_has_compilers
|
||||||
assert_equal Risc::MethodCompiler , @ret.method_compilers.first.class
|
assert_equal Risc::MethodCompiler , @ret.method_compilers.first.class
|
||||||
|
Loading…
Reference in New Issue
Block a user