renames compiler to method_compiler
This commit is contained in:
@ -7,7 +7,7 @@ end
|
||||
|
||||
require "register/padding"
|
||||
require "register/positioned"
|
||||
require "typed/compiler"
|
||||
require "typed/method_compiler"
|
||||
|
||||
require "typed/parfait"
|
||||
require "register/machine"
|
||||
|
@ -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
|
||||
|
@ -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) )
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
Reference in New Issue
Block a user