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" ,
|
CompilerModules = [ "assignment" , "basic_values" , "call_site", "class_field" ,
|
||||||
"class_statement" , "collections" , "field_def" , "field_access",
|
"class_statement" , "collections" , "field_def" , "field_access",
|
||||||
"function_statement" , "if_statement" , "name_expression" ,
|
"function_statement" , "if_statement" , "name_expression" ,
|
||||||
"operator_expression"]
|
"operator_expression" , "return_statement", "statement_list"]
|
||||||
|
|
||||||
CompilerModules.each do |mod|
|
CompilerModules.each do |mod|
|
||||||
require_relative "compiler/" + mod
|
require_relative "compiler/" + mod
|
||||||
@ -191,6 +191,4 @@ module Typed
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
require_relative "compiler/return_statement"
|
|
||||||
require_relative "compiler/statement_list"
|
|
||||||
require_relative "compiler/while_statement"
|
require_relative "compiler/while_statement"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
module Typed
|
module Typed
|
||||||
Compiler.class_eval do
|
module ReturnStatement
|
||||||
|
|
||||||
def on_ReturnStatement statement
|
def on_ReturnStatement statement
|
||||||
reg = process(statement.return_value)
|
reg = process(statement.return_value)
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
module Typed
|
module Typed
|
||||||
|
module StatementList
|
||||||
Compiler.class_eval do
|
|
||||||
|
|
||||||
def on_statements statement
|
def on_statements statement
|
||||||
process_all( statement.children )
|
process_all( statement.children )
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
module Typed
|
module Typed
|
||||||
class ReturnStatement < Statement
|
module Tree
|
||||||
attr_accessor :return_value
|
class ReturnStatement < Statement
|
||||||
|
attr_accessor :return_value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -89,7 +89,7 @@ module Typed
|
|||||||
alias :on_false_statements :on_statements
|
alias :on_false_statements :on_statements
|
||||||
|
|
||||||
def on_return statement
|
def on_return statement
|
||||||
w = ReturnStatement.new()
|
w = Tree::ReturnStatement.new()
|
||||||
w.return_value = process(statement.children.first)
|
w.return_value = process(statement.children.first)
|
||||||
w
|
w
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user