From 756cb52a98fa81852414d4cc3b4c66e846a43d3c Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 18 Dec 2016 14:15:19 +0200 Subject: [PATCH] renames compiler to method_compiler --- lib/register.rb | 2 +- lib/register/builtin/compile_helper.rb | 2 +- lib/register/builtin/integer.rb | 6 +++--- lib/register/builtin/kernel.rb | 4 ++-- lib/register/builtin/space.rb | 2 +- lib/register/builtin/word.rb | 2 +- lib/typed/{compiler.rb => method_compiler.rb} | 6 +++--- lib/typed/{compiler => method_compiler}/README.md | 0 lib/typed/{compiler => method_compiler}/assignment.rb | 0 lib/typed/{compiler => method_compiler}/basic_values.rb | 0 lib/typed/{compiler => method_compiler}/call_site.rb | 0 lib/typed/{compiler => method_compiler}/collections.rb | 0 lib/typed/{compiler => method_compiler}/field_access.rb | 0 lib/typed/{compiler => method_compiler}/if_statement.rb | 0 lib/typed/{compiler => method_compiler}/name_expression.rb | 0 .../{compiler => method_compiler}/operator_expression.rb | 0 lib/typed/{compiler => method_compiler}/return_statement.rb | 0 lib/typed/{compiler => method_compiler}/statement_list.rb | 0 lib/typed/{compiler => method_compiler}/while_statement.rb | 0 test/helper.rb | 2 +- test/typed/expressions/helper.rb | 2 +- test/typed/statements/helper.rb | 2 +- 22 files changed, 15 insertions(+), 15 deletions(-) rename lib/typed/{compiler.rb => method_compiler.rb} (98%) rename lib/typed/{compiler => method_compiler}/README.md (100%) rename lib/typed/{compiler => method_compiler}/assignment.rb (100%) rename lib/typed/{compiler => method_compiler}/basic_values.rb (100%) rename lib/typed/{compiler => method_compiler}/call_site.rb (100%) rename lib/typed/{compiler => method_compiler}/collections.rb (100%) rename lib/typed/{compiler => method_compiler}/field_access.rb (100%) rename lib/typed/{compiler => method_compiler}/if_statement.rb (100%) rename lib/typed/{compiler => method_compiler}/name_expression.rb (100%) rename lib/typed/{compiler => method_compiler}/operator_expression.rb (100%) rename lib/typed/{compiler => method_compiler}/return_statement.rb (100%) rename lib/typed/{compiler => method_compiler}/statement_list.rb (100%) rename lib/typed/{compiler => method_compiler}/while_statement.rb (100%) diff --git a/lib/register.rb b/lib/register.rb index a18a58ee..d0dc789e 100644 --- a/lib/register.rb +++ b/lib/register.rb @@ -7,7 +7,7 @@ end require "register/padding" require "register/positioned" -require "typed/compiler" +require "typed/method_compiler" require "typed/parfait" require "register/machine" diff --git a/lib/register/builtin/compile_helper.rb b/lib/register/builtin/compile_helper.rb index 7b74407b..79819415 100644 --- a/lib/register/builtin/compile_helper.rb +++ b/lib/register/builtin/compile_helper.rb @@ -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 diff --git a/lib/register/builtin/integer.rb b/lib/register/builtin/integer.rb index 49fc7314..a3739e8d 100644 --- a/lib/register/builtin/integer.rb +++ b/lib/register/builtin/integer.rb @@ -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) ) diff --git a/lib/register/builtin/kernel.rb b/lib/register/builtin/kernel.rb index cfb43505..b4860c78 100644 --- a/lib/register/builtin/kernel.rb +++ b/lib/register/builtin/kernel.rb @@ -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 diff --git a/lib/register/builtin/space.rb b/lib/register/builtin/space.rb index 14ba16c8..ab55be16 100644 --- a/lib/register/builtin/space.rb +++ b/lib/register/builtin/space.rb @@ -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 diff --git a/lib/register/builtin/word.rb b/lib/register/builtin/word.rb index 3d9f5a41..544243e5 100644 --- a/lib/register/builtin/word.rb +++ b/lib/register/builtin/word.rb @@ -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) diff --git a/lib/typed/compiler.rb b/lib/typed/method_compiler.rb similarity index 98% rename from lib/typed/compiler.rb rename to lib/typed/method_compiler.rb index 2403332d..f9182aa6 100644 --- a/lib/typed/compiler.rb +++ b/lib/typed/method_compiler.rb @@ -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 diff --git a/lib/typed/compiler/README.md b/lib/typed/method_compiler/README.md similarity index 100% rename from lib/typed/compiler/README.md rename to lib/typed/method_compiler/README.md diff --git a/lib/typed/compiler/assignment.rb b/lib/typed/method_compiler/assignment.rb similarity index 100% rename from lib/typed/compiler/assignment.rb rename to lib/typed/method_compiler/assignment.rb diff --git a/lib/typed/compiler/basic_values.rb b/lib/typed/method_compiler/basic_values.rb similarity index 100% rename from lib/typed/compiler/basic_values.rb rename to lib/typed/method_compiler/basic_values.rb diff --git a/lib/typed/compiler/call_site.rb b/lib/typed/method_compiler/call_site.rb similarity index 100% rename from lib/typed/compiler/call_site.rb rename to lib/typed/method_compiler/call_site.rb diff --git a/lib/typed/compiler/collections.rb b/lib/typed/method_compiler/collections.rb similarity index 100% rename from lib/typed/compiler/collections.rb rename to lib/typed/method_compiler/collections.rb diff --git a/lib/typed/compiler/field_access.rb b/lib/typed/method_compiler/field_access.rb similarity index 100% rename from lib/typed/compiler/field_access.rb rename to lib/typed/method_compiler/field_access.rb diff --git a/lib/typed/compiler/if_statement.rb b/lib/typed/method_compiler/if_statement.rb similarity index 100% rename from lib/typed/compiler/if_statement.rb rename to lib/typed/method_compiler/if_statement.rb diff --git a/lib/typed/compiler/name_expression.rb b/lib/typed/method_compiler/name_expression.rb similarity index 100% rename from lib/typed/compiler/name_expression.rb rename to lib/typed/method_compiler/name_expression.rb diff --git a/lib/typed/compiler/operator_expression.rb b/lib/typed/method_compiler/operator_expression.rb similarity index 100% rename from lib/typed/compiler/operator_expression.rb rename to lib/typed/method_compiler/operator_expression.rb diff --git a/lib/typed/compiler/return_statement.rb b/lib/typed/method_compiler/return_statement.rb similarity index 100% rename from lib/typed/compiler/return_statement.rb rename to lib/typed/method_compiler/return_statement.rb diff --git a/lib/typed/compiler/statement_list.rb b/lib/typed/method_compiler/statement_list.rb similarity index 100% rename from lib/typed/compiler/statement_list.rb rename to lib/typed/method_compiler/statement_list.rb diff --git a/lib/typed/compiler/while_statement.rb b/lib/typed/method_compiler/while_statement.rb similarity index 100% rename from lib/typed/compiler/while_statement.rb rename to lib/typed/method_compiler/while_statement.rb diff --git a/test/helper.rb b/test/helper.rb index 9fdd961b..ca301f5d 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -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 diff --git a/test/typed/expressions/helper.rb b/test/typed/expressions/helper.rb index 3afba423..fcb12cee 100644 --- a/test/typed/expressions/helper.rb +++ b/test/typed/expressions/helper.rb @@ -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" diff --git a/test/typed/statements/helper.rb b/test/typed/statements/helper.rb index f2e59efd..4236cd60 100644 --- a/test/typed/statements/helper.rb +++ b/test/typed/statements/helper.rb @@ -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