modulize return and list
This commit is contained in:
parent
99132a92b6
commit
da4a1af074
@ -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"
|
||||
|
@ -1,5 +1,5 @@
|
||||
module Typed
|
||||
Compiler.class_eval do
|
||||
module ReturnStatement
|
||||
|
||||
def on_ReturnStatement statement
|
||||
reg = process(statement.return_value)
|
||||
|
@ -1,7 +1,5 @@
|
||||
module Typed
|
||||
|
||||
Compiler.class_eval do
|
||||
|
||||
module StatementList
|
||||
def on_statements statement
|
||||
process_all( statement.children )
|
||||
end
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user