rename method_compiler
in line with other compiler XX_Compiler being the compiler for that layer remove type from compiler as it is in method available
This commit is contained in:
parent
114dc95b60
commit
6bd01fd55f
@ -18,7 +18,7 @@ module Mom
|
||||
# In other words Mom is the higher abstraction and so mom instructions convert
|
||||
# to many (1-10) risc instructions
|
||||
#
|
||||
# The argument that is passed is a MethodCompiler, which has the method and some
|
||||
# The argument that is passed is a RiscCompiler, which has the method and some
|
||||
# state about registers used. (also provides helpers to generate risc instructions)
|
||||
def to_risc(compiler)
|
||||
raise self.class.name + "_todo"
|
||||
|
@ -30,7 +30,7 @@ module Parfait
|
||||
def compile_to_risc(for_type)
|
||||
typed_method = create_typed_method(for_type)
|
||||
head = source.to_mom( typed_method )
|
||||
compiler = Risc::MethodCompiler.new( typed_method )
|
||||
compiler = Risc::RiscCompiler.new( typed_method )
|
||||
compiler.add_mom(head)
|
||||
head # return for testing
|
||||
end
|
||||
|
@ -25,7 +25,7 @@ require_relative "risc/platform"
|
||||
require "parfait"
|
||||
require_relative "risc/parfait_adapter"
|
||||
require_relative "risc/machine"
|
||||
require_relative "risc/method_compiler"
|
||||
require_relative "risc/risc_compiler"
|
||||
|
||||
class Fixnum
|
||||
def fits_u8?
|
||||
|
@ -135,7 +135,7 @@ module Risc
|
||||
def add_known(name)
|
||||
case name
|
||||
when :receiver
|
||||
ret = compiler.use_reg compiler.type
|
||||
ret = compiler.use_reg compiler.method.for_type
|
||||
add_slot_to_reg(" load self" , :message , :receiver , ret )
|
||||
return ret
|
||||
when :space
|
||||
@ -236,7 +236,7 @@ module Risc
|
||||
end
|
||||
end
|
||||
|
||||
# A CompilerBuilder adds the generated code to the MethodCompiler.
|
||||
# A CompilerBuilder adds the generated code to the RiscCompiler.
|
||||
#
|
||||
class CompilerBuilder < Builder
|
||||
# add code straight to the compiler
|
||||
|
@ -6,7 +6,7 @@ module Risc
|
||||
def compiler_for( clazz_name , method_name , arguments , locals = {})
|
||||
frame = Parfait::NamedList.type_for( locals )
|
||||
args = Parfait::NamedList.type_for( arguments )
|
||||
Risc::MethodCompiler.compiler_for_class(clazz_name , method_name , args, frame )
|
||||
Risc::RiscCompiler.compiler_for_class(clazz_name , method_name , args, frame )
|
||||
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
|
||||
# so it is responsible for initial setup
|
||||
def __init__ context
|
||||
compiler = MethodCompiler.compiler_for_class(:Object,:__init__ ,
|
||||
compiler = RiscCompiler.compiler_for_class(:Object,:__init__ ,
|
||||
Parfait::NamedList.type_for({}) , Parfait::NamedList.type_for({}))
|
||||
builder = compiler.compiler_builder(compiler.method)
|
||||
builder.build do
|
||||
@ -63,7 +63,7 @@ module Risc
|
||||
message[:receiver] << space
|
||||
end
|
||||
|
||||
exit_label = Risc.label(compiler.method , "#{compiler.type.object_class.name}.#{compiler.method.name}" )
|
||||
exit_label = Risc.label(compiler.method , "#{compiler.method.for_type.object_class.name}.#{compiler.method.name}" )
|
||||
ret_tmp = compiler.use_reg(:Label)
|
||||
builder.build do
|
||||
add_load_constant("__init__ load return", exit_label , ret_tmp)
|
||||
|
@ -1,19 +1,17 @@
|
||||
module Risc
|
||||
|
||||
# MethodCompiler (old name) is used to generate risc instructions for methods
|
||||
# RiscCompiler (old name) is used to generate risc instructions for methods
|
||||
# and to instantiate the methods correctly. Most of the init is typed layer stuff,
|
||||
# but there is some logic too.
|
||||
|
||||
class MethodCompiler
|
||||
class RiscCompiler
|
||||
|
||||
def initialize( method )
|
||||
@regs = []
|
||||
@method = method
|
||||
@type = method.for_type
|
||||
@current = @method.risc_instructions
|
||||
end
|
||||
attr_reader :type , :method
|
||||
|
||||
attr_reader :method
|
||||
|
||||
# helper method for builtin mainly
|
||||
# the class_name is a symbol, which is resolved to the instance_type of that class
|
@ -6,7 +6,7 @@ module Risc
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
init = Parfait.object_space.get_init
|
||||
@builder = Risc::MethodCompiler.new( init ).code_builder(init)
|
||||
@builder = Risc::RiscCompiler.new( init ).code_builder(init)
|
||||
@label = Risc.label("source","name")
|
||||
end
|
||||
def test_has_build
|
||||
@ -102,7 +102,7 @@ module Risc
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@init = Parfait.object_space.get_init
|
||||
@builder = Risc::MethodCompiler.new( @init ).compiler_builder(@init)
|
||||
@builder = Risc::RiscCompiler.new( @init ).compiler_builder(@init)
|
||||
end
|
||||
def test_inserts_built
|
||||
r1 = RegisterValue.new(:r1 , :Space)
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestMethodCompiler < MiniTest::Test
|
||||
class TestRiscCompiler < MiniTest::Test
|
||||
include CompilerHelper
|
||||
|
||||
def setup
|
@ -1 +0,0 @@
|
||||
require_relative "../helper"
|
Loading…
Reference in New Issue
Block a user