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/positioned"
require "typed/compiler"
require "typed/method_compiler"
require "typed/parfait"
require "register/machine"

View File

@ -14,7 +14,7 @@ module Register
def compiler_for( type , method_name , 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
# Load the value

View File

@ -6,18 +6,18 @@ module Register
include AST::Sexp
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
end
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
end
def div10 context
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) )
tmp = 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
def __init__ context
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
new_start = Label.new(source , source )
compiler.method.instructions = new_start
@ -34,7 +34,7 @@ module Register
end
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 )
return compiler.method
end

View File

@ -9,7 +9,7 @@ module Register
# main entry point, ie __init__ calls this
# defined here as empty, to be redefined
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
end

View File

@ -7,7 +7,7 @@ module Register
include CompileHelper
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 )
index = Parfait::Word.get_length_index
reg = RegisterValue.new(:r2 , :Integer)

View File

@ -9,7 +9,7 @@ module Typed
"while_statement"]
CompilerModules.each do |mod|
require_relative "compiler/" + mod
require_relative "method_compiler/" + mod
end
# 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)
def self.compile statement
compiler = Compiler.new
compiler = MethodCompiler.new
code = Typed.ast_to_code statement
compiler.process code
end
class Compiler
class MethodCompiler
CompilerModules.each do |mod|
include Typed.const_get( mod.camelize )
end

View File

@ -21,7 +21,7 @@ require 'salama'
module Compiling
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 ) )
end

View File

@ -4,7 +4,7 @@ module ExpressionHelper
def check
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
produced = compiler.process( code )
assert @output , "No output given"

View File

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