diff --git a/lib/typed/compiler.rb b/lib/typed/compiler.rb index 40ffebb9..34a13ca6 100644 --- a/lib/typed/compiler.rb +++ b/lib/typed/compiler.rb @@ -5,7 +5,7 @@ module Typed CompilerModules = [ "assignment" , "basic_values" , "call_site", "class_field" , "class_statement" , "collections" , "field_def" , "field_access", "function_statement" , "if_statement" , "name_expression" , - "operator_expression"] + "operator_expression" , "return_statement", "statement_list"] CompilerModules.each do |mod| require_relative "compiler/" + mod @@ -191,6 +191,4 @@ module Typed end end -require_relative "compiler/return_statement" -require_relative "compiler/statement_list" require_relative "compiler/while_statement" diff --git a/lib/typed/compiler/return_statement.rb b/lib/typed/compiler/return_statement.rb index 95f8021c..791c32a1 100644 --- a/lib/typed/compiler/return_statement.rb +++ b/lib/typed/compiler/return_statement.rb @@ -1,5 +1,5 @@ module Typed - Compiler.class_eval do + module ReturnStatement def on_ReturnStatement statement reg = process(statement.return_value) diff --git a/lib/typed/compiler/statement_list.rb b/lib/typed/compiler/statement_list.rb index a9dd1ccf..addb4952 100644 --- a/lib/typed/compiler/statement_list.rb +++ b/lib/typed/compiler/statement_list.rb @@ -1,7 +1,5 @@ module Typed - - Compiler.class_eval do - + module StatementList def on_statements statement process_all( statement.children ) end diff --git a/lib/typed/tree/return_statement.rb b/lib/typed/tree/return_statement.rb index e50b3cc8..703202b1 100644 --- a/lib/typed/tree/return_statement.rb +++ b/lib/typed/tree/return_statement.rb @@ -1,5 +1,7 @@ module Typed - class ReturnStatement < Statement - attr_accessor :return_value + module Tree + class ReturnStatement < Statement + attr_accessor :return_value + end end end diff --git a/lib/typed/tree/to_code.rb b/lib/typed/tree/to_code.rb index c8af3dfe..9d03d578 100644 --- a/lib/typed/tree/to_code.rb +++ b/lib/typed/tree/to_code.rb @@ -89,7 +89,7 @@ module Typed alias :on_false_statements :on_statements def on_return statement - w = ReturnStatement.new() + w = Tree::ReturnStatement.new() w.return_value = process(statement.children.first) w end