back to method_compiler
it is what it is
This commit is contained in:
parent
91a99b1239
commit
05669065ca
@ -18,7 +18,7 @@ module Mom
|
|||||||
# In other words Mom is the higher abstraction and so mom instructions convert
|
# In other words Mom is the higher abstraction and so mom instructions convert
|
||||||
# to many (1-10) risc instructions
|
# to many (1-10) risc instructions
|
||||||
#
|
#
|
||||||
# The argument that is passed is a RiscCompiler, which has the method and some
|
# The argument that is passed is a MethodCompiler, which has the method and some
|
||||||
# state about registers used. (also provides helpers to generate risc instructions)
|
# state about registers used. (also provides helpers to generate risc instructions)
|
||||||
def to_risc(compiler)
|
def to_risc(compiler)
|
||||||
raise self.class.name + "_todo"
|
raise self.class.name + "_todo"
|
||||||
|
@ -36,7 +36,7 @@ module Parfait
|
|||||||
def compile_to_risc(for_type)
|
def compile_to_risc(for_type)
|
||||||
typed_method = create_typed_method(for_type)
|
typed_method = create_typed_method(for_type)
|
||||||
head = source.to_mom( typed_method )
|
head = source.to_mom( typed_method )
|
||||||
compiler = Risc::RiscCompiler.new( typed_method )
|
compiler = Risc::MethodCompiler.new( typed_method )
|
||||||
compiler.add_mom(head)
|
compiler.add_mom(head)
|
||||||
head # return for testing
|
head # return for testing
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ require_relative "risc/platform"
|
|||||||
require "parfait"
|
require "parfait"
|
||||||
require_relative "risc/parfait_adapter"
|
require_relative "risc/parfait_adapter"
|
||||||
require_relative "risc/machine"
|
require_relative "risc/machine"
|
||||||
require_relative "risc/risc_compiler"
|
require_relative "risc/method_compiler"
|
||||||
|
|
||||||
class Fixnum
|
class Fixnum
|
||||||
def fits_u8?
|
def fits_u8?
|
||||||
|
@ -236,7 +236,7 @@ module Risc
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# A CompilerBuilder adds the generated code to the RiscCompiler.
|
# A CompilerBuilder adds the generated code to the MethodCompiler.
|
||||||
#
|
#
|
||||||
class CompilerBuilder < Builder
|
class CompilerBuilder < Builder
|
||||||
# add code straight to the compiler
|
# add code straight to the compiler
|
||||||
|
@ -6,7 +6,7 @@ module Risc
|
|||||||
def compiler_for( clazz_name , method_name , arguments , locals = {})
|
def compiler_for( clazz_name , method_name , arguments , locals = {})
|
||||||
frame = Parfait::NamedList.type_for( locals )
|
frame = Parfait::NamedList.type_for( locals )
|
||||||
args = Parfait::NamedList.type_for( arguments )
|
args = Parfait::NamedList.type_for( arguments )
|
||||||
RiscCompiler.compiler_for_class(clazz_name , method_name , args, frame )
|
MethodCompiler.compiler_for_class(clazz_name , method_name , args, frame )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -46,7 +46,7 @@ module Risc
|
|||||||
# it isn't really a function, ie it is jumped to (not called), exits and may not return
|
# it isn't really a function, ie it is jumped to (not called), exits and may not return
|
||||||
# so it is responsible for initial setup
|
# so it is responsible for initial setup
|
||||||
def __init__ context
|
def __init__ context
|
||||||
compiler = RiscCompiler.compiler_for_class(:Object,:__init__ ,
|
compiler = MethodCompiler.compiler_for_class(:Object,:__init__ ,
|
||||||
Parfait::NamedList.type_for({}) , Parfait::NamedList.type_for({}))
|
Parfait::NamedList.type_for({}) , Parfait::NamedList.type_for({}))
|
||||||
builder = compiler.compiler_builder(compiler.method)
|
builder = compiler.compiler_builder(compiler.method)
|
||||||
builder.build do
|
builder.build do
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
module Risc
|
module Risc
|
||||||
|
|
||||||
# RiscCompiler (old name) is used to generate risc instructions for methods
|
# MethodCompiler (old name) is used to generate risc instructions for methods
|
||||||
# and to instantiate the methods correctly. Most of the init is typed layer stuff,
|
# and to instantiate the methods correctly. Most of the init is typed layer stuff,
|
||||||
# but there is some logic too.
|
# but there is some logic too.
|
||||||
|
|
||||||
class RiscCompiler
|
class MethodCompiler
|
||||||
|
|
||||||
def initialize( method )
|
def initialize( method )
|
||||||
@regs = []
|
@regs = []
|
@ -7,7 +7,7 @@ module Risc
|
|||||||
Parfait.boot!
|
Parfait.boot!
|
||||||
Risc.machine.boot
|
Risc.machine.boot
|
||||||
init = Parfait.object_space.get_init
|
init = Parfait.object_space.get_init
|
||||||
@builder = Risc::RiscCompiler.new( init ).code_builder(init)
|
@builder = Risc::MethodCompiler.new( init ).code_builder(init)
|
||||||
@label = Risc.label("source","name")
|
@label = Risc.label("source","name")
|
||||||
end
|
end
|
||||||
def test_has_build
|
def test_has_build
|
||||||
@ -104,7 +104,7 @@ module Risc
|
|||||||
Parfait.boot!
|
Parfait.boot!
|
||||||
Risc.machine.boot
|
Risc.machine.boot
|
||||||
@init = Parfait.object_space.get_init
|
@init = Parfait.object_space.get_init
|
||||||
@builder = Risc::RiscCompiler.new( @init ).compiler_builder(@init)
|
@builder = Risc::MethodCompiler.new( @init ).compiler_builder(@init)
|
||||||
end
|
end
|
||||||
def test_inserts_built
|
def test_inserts_built
|
||||||
r1 = RegisterValue.new(:r1 , :Space)
|
r1 = RegisterValue.new(:r1 , :Space)
|
||||||
|
@ -16,7 +16,7 @@ module Risc
|
|||||||
assert_equal 23, Builtin.boot_functions.length
|
assert_equal 23, Builtin.boot_functions.length
|
||||||
end
|
end
|
||||||
def test_boot_function_first
|
def test_boot_function_first
|
||||||
assert_equal RiscCompiler, Builtin.boot_functions.first.class
|
assert_equal MethodCompiler, Builtin.boot_functions.first.class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Risc
|
module Risc
|
||||||
class TestRiscCompiler < MiniTest::Test
|
class TestMethodCompiler < MiniTest::Test
|
||||||
include ScopeHelper
|
include ScopeHelper
|
||||||
|
|
||||||
def setup
|
def setup
|
Loading…
Reference in New Issue
Block a user