Class: Ikra::AST::BlockDefNode
- Inherits:
-
BehaviorNode
- Object
- Node
- BehaviorNode
- Ikra::AST::BlockDefNode
- Defined in:
- lib/ast/nodes.rb,
lib/ast/printer.rb,
lib/ast/visitor.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#ruby_block ⇒ Object
readonly
Returns the value of attribute ruby_block.
Attributes inherited from Node
Instance Method Summary collapse
- #==(other) ⇒ Object
- #accept(visitor) ⇒ Object
- #binding ⇒ Object
- #clone ⇒ Object
-
#initialize(body:, ruby_block:, parameters: nil) ⇒ BlockDefNode
constructor
A new instance of BlockDefNode.
- #to_s ⇒ Object
Methods inherited from BehaviorNode
#find_behavior_node, #get_type, #lexical_variables_names_and_types, #local_variables_names_and_types, #local_variables_names_and_types=, #merge_union_type, #parameters_names_and_types, #parameters_names_and_types=, #register_type_change, #reset_types_changed, #symbol_table, #types_changed?
Methods inherited from Node
Constructor Details
#initialize(body:, ruby_block:, parameters: nil) ⇒ BlockDefNode
Returns a new instance of BlockDefNode.
184 185 186 187 188 189 190 |
# File 'lib/ast/nodes.rb', line 184 def initialize(body:, ruby_block:, parameters: nil) @body = body @ruby_block = ruby_block @parameters = parameters body.parent = self end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
180 181 182 |
# File 'lib/ast/nodes.rb', line 180 def body @body end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
182 183 184 |
# File 'lib/ast/nodes.rb', line 182 def parameters @parameters end |
#ruby_block ⇒ Object (readonly)
Returns the value of attribute ruby_block.
181 182 183 |
# File 'lib/ast/nodes.rb', line 181 def ruby_block @ruby_block end |
Instance Method Details
#==(other) ⇒ Object
203 204 205 |
# File 'lib/ast/nodes.rb', line 203 def ==(other) return super(other) && body == other.body && parameters == other.parameters end |
#accept(visitor) ⇒ Object
38 39 40 |
# File 'lib/ast/visitor.rb', line 38 def accept(visitor) return visitor.visit_block_def_node(self) end |
#binding ⇒ Object
199 200 201 |
# File 'lib/ast/nodes.rb', line 199 def binding return ruby_block.binding end |
#clone ⇒ Object
192 193 194 195 196 197 |
# File 'lib/ast/nodes.rb', line 192 def clone return BlockDefNode.new( body: @body.clone, ruby_block: @ruby_block, parameters: @parameters == nil ? nil : @parameters.dup) end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/ast/printer.rb', line 34 def to_s return "[BlockDefNode: #{body.to_s}]" end |