Class: YARP::CallNode

Inherits:
YARPNode
  • Object
show all
Defined in:
lib/yarp/node.rb,
ext/yarp/api_node.c

Overview

Represents a method call, in all of the various forms that can take.

foo
^^^

foo()
^^^^^

+foo
^^^^

foo + bar
^^^^^^^^^

foo.bar
^^^^^^^

foo&.bar
^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(receiver, operator_loc, message_loc, opening_loc, arguments, closing_loc, block, flags, name, location) ⇒ CallNode

def initialize: (receiver: Node?, operator_loc: Location?, message_loc: Location?, opening_loc: Location?, arguments: Node?, closing_loc: Location?, block: Node?, flags: Integer, name: String, location: Location) -> void



805
806
807
808
809
810
811
812
813
814
815
816
# File 'lib/yarp/node.rb', line 805

def initialize(receiver, operator_loc, message_loc, opening_loc, arguments, closing_loc, block, flags, name, location)
  @receiver = receiver
  @operator_loc = operator_loc
  @message_loc = message_loc
  @opening_loc = opening_loc
  @arguments = arguments
  @closing_loc = closing_loc
  @block = block
  @flags = flags
  @name = name
  @location = location
end

Instance Attribute Details

#argumentsObject (readonly)

attr_reader arguments: Node?



790
791
792
# File 'lib/yarp/node.rb', line 790

def arguments
  @arguments
end

#blockObject (readonly)

attr_reader block: Node?



796
797
798
# File 'lib/yarp/node.rb', line 796

def block
  @block
end

#closing_locObject (readonly)

attr_reader closing_loc: Location?



793
794
795
# File 'lib/yarp/node.rb', line 793

def closing_loc
  @closing_loc
end

#flagsObject (readonly)

attr_reader flags: Integer



799
800
801
# File 'lib/yarp/node.rb', line 799

def flags
  @flags
end

#message_locObject (readonly)

attr_reader message_loc: Location?



784
785
786
# File 'lib/yarp/node.rb', line 784

def message_loc
  @message_loc
end

#nameObject (readonly)

attr_reader name: String



802
803
804
# File 'lib/yarp/node.rb', line 802

def name
  @name
end

#opening_locObject (readonly)

attr_reader opening_loc: Location?



787
788
789
# File 'lib/yarp/node.rb', line 787

def opening_loc
  @opening_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location?



781
782
783
# File 'lib/yarp/node.rb', line 781

def operator_loc
  @operator_loc
end

#receiverObject (readonly)

attr_reader receiver: Node?



778
779
780
# File 'lib/yarp/node.rb', line 778

def receiver
  @receiver
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



819
820
821
# File 'lib/yarp/node.rb', line 819

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



825
826
827
# File 'lib/yarp/node.rb', line 825

def child_nodes
  [receiver, arguments, block]
end

#closingObject

def closing: () -> String?



853
854
855
# File 'lib/yarp/node.rb', line 853

def closing
  closing_loc&.slice
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



833
834
835
# File 'lib/yarp/node.rb', line 833

def deconstruct_keys(keys)
  { receiver: receiver, operator_loc: operator_loc, message_loc: message_loc, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block, flags: flags, name: name, location: location }
end

#messageObject

def message: () -> String?



843
844
845
# File 'lib/yarp/node.rb', line 843

def message
  message_loc&.slice
end

#openingObject

def opening: () -> String?



848
849
850
# File 'lib/yarp/node.rb', line 848

def opening
  opening_loc&.slice
end

#operatorObject

def operator: () -> String?



838
839
840
# File 'lib/yarp/node.rb', line 838

def operator
  operator_loc&.slice
end