Class: Yadriggy::Return
- Includes:
- AstHelper
- Defined in:
- lib/yadriggy/ast.rb
Overview
Return.
Instance Attribute Summary collapse
-
#values ⇒ Array<ASTnode>
readonly
Gets the returned values.
Attributes inherited from ASTnode
Class Method Summary collapse
Instance Method Summary collapse
-
#accept(evaluator) ⇒ void
A method for Visitor pattern.
-
#initialize(sexp) ⇒ Return
constructor
A new instance of Return.
Methods included from AstHelper
#has_tag?, #to_node, #to_nodes
Methods inherited from ASTnode
#add_child, #add_children, #const_value, #const_value_in_class, #get_context_class, #get_receiver_object, #is_proc?, #pretty_print, #root, #source_location, #source_location_string, #value, #value_in_class
Constructor Details
#initialize(sexp) ⇒ Return
Returns a new instance of Return.
1256 1257 1258 1259 1260 1261 1262 1263 1264 |
# File 'lib/yadriggy/ast.rb', line 1256 def initialize(sexp) if sexp.length < 2 # return0 @values = [] else values = has_tag?(sexp[1], :args_add_block)[1] @values = to_nodes(values) add_children(@values) end end |
Instance Attribute Details
#values ⇒ Array<ASTnode> (readonly)
Gets the returned values.
1252 1253 1254 |
# File 'lib/yadriggy/ast.rb', line 1252 def values @values end |
Class Method Details
.tags ⇒ Object
1254 |
# File 'lib/yadriggy/ast.rb', line 1254 def self.() [:return, :return0] end |
Instance Method Details
#accept(evaluator) ⇒ void
This method returns an undefined value.
A method for Visitor pattern.
1269 1270 1271 |
# File 'lib/yadriggy/ast.rb', line 1269 def accept(evaluator) evaluator.return_values(self) end |