modulize return and list

This commit is contained in:
Torsten Ruger 2016-12-09 14:19:22 +02:00
parent 99132a92b6
commit da4a1af074
5 changed files with 8 additions and 10 deletions

View File

@ -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"

View File

@ -1,5 +1,5 @@
module Typed
Compiler.class_eval do
module ReturnStatement
def on_ReturnStatement statement
reg = process(statement.return_value)

View File

@ -1,7 +1,5 @@
module Typed
Compiler.class_eval do
module StatementList
def on_statements statement
process_all( statement.children )
end

View File

@ -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

View File

@ -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