Class: Ikra::AST::ArrayNode

Inherits:
TreeNode show all
Defined in:
lib/ast/nodes.rb,
lib/ast/printer.rb,
lib/ast/visitor.rb

Constant Summary

Constants inherited from TreeNode

TreeNode::TYPE_INFO_VARS

Instance Attribute Summary collapse

Attributes inherited from Node

#parent

Instance Method Summary collapse

Methods inherited from TreeNode

#==, #enclosing_class, #find_behavior_node, #get_type, #is_begin_node?, #merge_union_type, #register_type_change, #replace, #replace_child, #symbol_table

Methods inherited from Node

#==, #eql?, #hash

Constructor Details

#initialize(values:) ⇒ ArrayNode

Returns a new instance of ArrayNode.



279
280
281
282
283
284
285
# File 'lib/ast/nodes.rb', line 279

def initialize(values:)
    @values = values

    for value in values
        value.parent = self
    end
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



277
278
279
# File 'lib/ast/nodes.rb', line 277

def values
  @values
end

Instance Method Details

#accept(visitor) ⇒ Object



50
51
52
# File 'lib/ast/visitor.rb', line 50

def accept(visitor)
    visitor.visit_array_node(self)
end

#cloneObject



287
288
289
290
# File 'lib/ast/nodes.rb', line 287

def clone
    return ArrayNode.new(
        values: @values.map do |v| v.clone end)
end

#to_sObject



46
47
48
# File 'lib/ast/printer.rb', line 46

def to_s
    return "[ArrayNode: [#{(values.map do |v| v.to_s end).join(', ')}]]"
end