Class: Yadriggy::ArrayRef

Inherits:
ASTnode
  • Object
show all
Includes:
AstHelper
Defined in:
lib/yadriggy/ast.rb

Overview

Array reference.

Direct Known Subclasses

ArrayRefField

Instance Attribute Summary collapse

Attributes inherited from ASTnode

#parent, #usertype

Class Method Summary collapse

Instance Method Summary collapse

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) ⇒ ArrayRef



1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
# File 'lib/yadriggy/ast.rb', line 1004

def initialize(sexp)
  @array = to_node(sexp[1])
  args_block = sexp[2]
  if args_block.nil?
    @indexes = []
  else
    args = has_tag?(args_block, :args_add_block)[1]
    @indexes = to_nodes(args)
  end

  add_child(@array)
  add_children(@indexes)
end

Instance Attribute Details

#arrayASTnode (readonly)



996
997
998
# File 'lib/yadriggy/ast.rb', line 996

def array
  @array
end

#indexesArray<ASTnode> (readonly)



1000
1001
1002
# File 'lib/yadriggy/ast.rb', line 1000

def indexes
  @indexes
end

Class Method Details

.tagObject



1002
# File 'lib/yadriggy/ast.rb', line 1002

def self.tag() :aref end

Instance Method Details

#accept(evaluator) ⇒ void

This method returns an undefined value.

A method for Visitor pattern.



1021
1022
1023
# File 'lib/yadriggy/ast.rb', line 1021

def accept(evaluator)
  evaluator.array_ref(self)
end