Class: Yadriggy::ForLoop
- Includes:
- AstHelper
- Defined in:
- lib/yadriggy/ast.rb
Overview
For statement.
Instance Attribute Summary collapse
-
#body ⇒ ASTnode
readonly
The loop body.
-
#set ⇒ ASTnode
readonly
The elements.
-
#vars ⇒ Array<ASTnode>
readonly
The variables.
Attributes inherited from ASTnode
Class Method Summary collapse
Instance Method Summary collapse
-
#accept(evaluator) ⇒ void
A method for Visitor pattern.
-
#initialize(sexp) ⇒ ForLoop
constructor
A new instance of ForLoop.
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) ⇒ ForLoop
Returns a new instance of ForLoop.
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 |
# File 'lib/yadriggy/ast.rb', line 1190 def initialize(sexp) if sexp[1][0] == :var_field @vars = [ to_node(sexp[1][1]) ] else @vars = to_nodes(sexp[1]) end @set = to_node(sexp[2]) @body = Exprs.make(sexp[3]) add_children(@vars) add_child(@set) add_child(@body) end |
Instance Attribute Details
#body ⇒ ASTnode (readonly)
Returns the loop body.
1186 1187 1188 |
# File 'lib/yadriggy/ast.rb', line 1186 def body @body end |
#set ⇒ ASTnode (readonly)
Returns the elements.
1183 1184 1185 |
# File 'lib/yadriggy/ast.rb', line 1183 def set @set end |
#vars ⇒ Array<ASTnode> (readonly)
Returns the variables.
1180 1181 1182 |
# File 'lib/yadriggy/ast.rb', line 1180 def vars @vars end |
Class Method Details
.tag ⇒ Object
1188 |
# File 'lib/yadriggy/ast.rb', line 1188 def self.tag() :for end |
Instance Method Details
#accept(evaluator) ⇒ void
This method returns an undefined value.
A method for Visitor pattern.
1206 1207 1208 |
# File 'lib/yadriggy/ast.rb', line 1206 def accept(evaluator) evaluator.for_loop(self) end |