renames compiler to method_compiler

This commit is contained in:
Torsten Ruger 2016-12-18 14:15:19 +02:00
parent 272f99daf7
commit 756cb52a98
22 changed files with 15 additions and 15 deletions

View File

@ -7,7 +7,7 @@ end
require "register/padding" require "register/padding"
require "register/positioned" require "register/positioned"
require "typed/compiler" require "typed/method_compiler"
require "typed/parfait" require "typed/parfait"
require "register/machine" require "register/machine"

View File

@ -14,7 +14,7 @@ module Register
def compiler_for( type , method_name , extra_args = {}) def compiler_for( type , method_name , extra_args = {})
args = {:index => :Integer}.merge( extra_args ) args = {:index => :Integer}.merge( extra_args )
Typed::Compiler.new.create_method(type , method_name , args ).init_method Typed::MethodCompiler.new.create_method(type , method_name , args ).init_method
end end
# Load the value # Load the value

View File

@ -6,18 +6,18 @@ module Register
include AST::Sexp include AST::Sexp
def mod4 context def mod4 context
compiler = Typed::Compiler.new.create_method(:Integer,:mod4 ).init_method compiler = Typed::MethodCompiler.new.create_method(:Integer,:mod4 ).init_method
return compiler.method return compiler.method
end end
def putint context def putint context
compiler = Typed::Compiler.new.create_method(:Integer,:putint ).init_method compiler = Typed::MethodCompiler.new.create_method(:Integer,:putint ).init_method
return compiler.method return compiler.method
end end
def div10 context def div10 context
s = "div_10" s = "div_10"
compiler = Typed::Compiler.new.create_method(:Integer,:div10 ).init_method compiler = Typed::MethodCompiler.new.create_method(:Integer,:div10 ).init_method
me = compiler.process( Typed::Tree::NameExpression.new( :self) ) me = compiler.process( Typed::Tree::NameExpression.new( :self) )
tmp = compiler.process( Typed::Tree::NameExpression.new( :self) ) tmp = compiler.process( Typed::Tree::NameExpression.new( :self) )
q = compiler.process( Typed::Tree::NameExpression.new( :self) ) q = compiler.process( Typed::Tree::NameExpression.new( :self) )

View File

@ -7,7 +7,7 @@ module Register
# so it is responsible for initial setup # so it is responsible for initial setup
def __init__ context def __init__ context
source = "__init__" source = "__init__"
compiler = Typed::Compiler.new.create_method(:Kernel,:__init__ ) compiler = Typed::MethodCompiler.new.create_method(:Kernel,:__init__ )
# no method enter or return (automatically added), remove # no method enter or return (automatically added), remove
new_start = Label.new(source , source ) new_start = Label.new(source , source )
compiler.method.instructions = new_start compiler.method.instructions = new_start
@ -34,7 +34,7 @@ module Register
end end
def exit context def exit context
compiler = Typed::Compiler.new.create_method(:Kernel,:exit ).init_method compiler = Typed::MethodCompiler.new.create_method(:Kernel,:exit ).init_method
emit_syscall( compiler , :exit ) emit_syscall( compiler , :exit )
return compiler.method return compiler.method
end end

View File

@ -9,7 +9,7 @@ module Register
# main entry point, ie __init__ calls this # main entry point, ie __init__ calls this
# defined here as empty, to be redefined # defined here as empty, to be redefined
def main context def main context
compiler = Typed::Compiler.new.create_method(:Space , :main ).init_method compiler = Typed::MethodCompiler.new.create_method(:Space , :main ).init_method
return compiler.method return compiler.method
end end

View File

@ -7,7 +7,7 @@ module Register
include CompileHelper include CompileHelper
def putstring context def putstring context
compiler = Typed::Compiler.new.create_method(:Word , :putstring ).init_method compiler = Typed::MethodCompiler.new.create_method(:Word , :putstring ).init_method
compiler.add_code Register.get_slot( "putstring" , :message , :receiver , :new_message ) compiler.add_code Register.get_slot( "putstring" , :message , :receiver , :new_message )
index = Parfait::Word.get_length_index index = Parfait::Word.get_length_index
reg = RegisterValue.new(:r2 , :Integer) reg = RegisterValue.new(:r2 , :Integer)

View File

@ -9,7 +9,7 @@ module Typed
"while_statement"] "while_statement"]
CompilerModules.each do |mod| CompilerModules.each do |mod|
require_relative "compiler/" + mod require_relative "method_compiler/" + mod
end end
# Compiling is the conversion of the AST into 2 things: # Compiling is the conversion of the AST into 2 things:
@ -44,12 +44,12 @@ module Typed
# Helper function to create a new compiler and compie the statement(s) # Helper function to create a new compiler and compie the statement(s)
def self.compile statement def self.compile statement
compiler = Compiler.new compiler = MethodCompiler.new
code = Typed.ast_to_code statement code = Typed.ast_to_code statement
compiler.process code compiler.process code
end end
class Compiler class MethodCompiler
CompilerModules.each do |mod| CompilerModules.each do |mod|
include Typed.const_get( mod.camelize ) include Typed.const_get( mod.camelize )
end end

View File

@ -21,7 +21,7 @@ require 'salama'
module Compiling module Compiling
def clean_compile(clazz_name , method_name , args , statements) def clean_compile(clazz_name , method_name , args , statements)
compiler = Typed::Compiler.new.create_method(clazz_name,method_name,args ).init_method compiler = Typed::MethodCompiler.new.create_method(clazz_name,method_name,args ).init_method
compiler.process( Typed.ast_to_code( statements ) ) compiler.process( Typed.ast_to_code( statements ) )
end end

View File

@ -4,7 +4,7 @@ module ExpressionHelper
def check def check
Register.machine.boot unless Register.machine.booted Register.machine.boot unless Register.machine.booted
compiler = Typed::Compiler.new Register.machine.space.get_main compiler = Typed::MethodCompiler.new Register.machine.space.get_main
code = Typed.ast_to_code @input code = Typed.ast_to_code @input
produced = compiler.process( code ) produced = compiler.process( code )
assert @output , "No output given" assert @output , "No output given"

View File

@ -12,7 +12,7 @@ module Statements
def check def check
assert @expect , "No output given" assert @expect , "No output given"
compiler = Typed::Compiler.new compiler = Typed::MethodCompiler.new
produced = compiler.process( Typed.ast_to_code( @input) ) produced = compiler.process( Typed.ast_to_code( @input) )
produced = Register.machine.space.get_main.instructions produced = Register.machine.space.get_main.instructions
compare_instructions produced , @expect compare_instructions produced , @expect