Class: Prism::GlobalVariableWriteNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::GlobalVariableWriteNode
- Defined in:
- lib/prism/node.rb,
lib/prism/parse_result/newlines.rb,
sig/generated/prism/node.rbs,
sig/generated/prism/parse_result/newlines.rbs,
ext/prism/api_node.c
Overview
Class Method Summary collapse
-
.type ⇒ :global_variable_write_node
See
Node.type.
Instance Method Summary collapse
-
#===(other) ⇒ boolish
: (untyped other) -> boolish.
-
#accept(visitor) ⇒ Object
See Node.accept.
-
#child_nodes ⇒ Array[node?]
(also: #deconstruct)
See Node.child_nodes.
-
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, value: self.value, operator_loc: self.operator_loc) ⇒ GlobalVariableWriteNode
:call-seq: copy(**fields) -> GlobalVariableWriteNode.
-
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped].
-
#each_child_node {|arg0| ... } ⇒ Object
See Node.each_child_node.
-
#initialize(source, node_id, location, flags, name, name_loc, value, operator_loc) ⇒ GlobalVariableWriteNode
constructor
Initialize a new GlobalVariableWriteNode node.
-
#inspect ⇒ String
: () -> String.
-
#name ⇒ Symbol
:call-seq: name -> Symbol.
-
#name_loc ⇒ Location
:category: Locations :call-seq: name_loc -> Location.
-
#newline_flag!(lines) ⇒ void
: (Array lines) -> void.
-
#operator ⇒ String
:call-seq: operator -> String.
-
#operator_loc ⇒ Location
:category: Locations :call-seq: operator_loc -> Location.
-
#save_name_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the name_loc location using the given saved source so that it can be retrieved later.
-
#save_operator_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the operator_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ :global_variable_write_node
See
Node#type. -
#value ⇒ Prism::node
:call-seq: value -> Node.
Constructor Details
#initialize(source, node_id, location, flags, name, name_loc, value, operator_loc) ⇒ GlobalVariableWriteNode
Initialize a new GlobalVariableWriteNode node.
: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Prism::node value, Location operator_loc) -> void
14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 |
# File 'lib/prism/node.rb', line 14841 def initialize(source, node_id, location, flags, name, name_loc, value, operator_loc) @source = source @node_id = node_id @location = location @flags = flags @name = name @name_loc = name_loc @value = value @operator_loc = operator_loc end |
Class Method Details
.type ⇒ :global_variable_write_node
See Node.type.
: () -> :global_variable_write_node
14933 14934 14935 |
# File 'lib/prism/node.rb', line 14933 def self.type :global_variable_write_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
15055 15056 15057 15058 15059 15060 15061 |
# File 'lib/prism/node.rb', line 15055 def ===(other) # :nodoc: other.is_a?(GlobalVariableWriteNode) && (name === other.name) && (name_loc.nil? == other.name_loc.nil?) && (value === other.value) && (operator_loc.nil? == other.operator_loc.nil?) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
14866 14867 14868 |
# File 'lib/prism/node.rb', line 14866 def accept(visitor) visitor.visit_global_variable_write_node(self) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
14873 14874 14875 |
# File 'lib/prism/node.rb', line 14873 def child_nodes [value] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
14890 14891 14892 |
# File 'lib/prism/node.rb', line 14890 def compact_child_nodes [value] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, value: self.value, operator_loc: self.operator_loc) ⇒ GlobalVariableWriteNode
:call-seq:
copy(**fields) -> GlobalVariableWriteNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> GlobalVariableWriteNode
14900 14901 14902 |
# File 'lib/prism/node.rb', line 14900 def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, value: self.value, operator_loc: self.operator_loc) GlobalVariableWriteNode.new(source, node_id, location, flags, name, name_loc, value, operator_loc) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
14907 14908 14909 14910 14911 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 |
# File 'lib/prism/node.rb', line 14907 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location name name_loc value operator_loc operator]).each_with_object( {} #: Hash[Symbol, untyped] ) do |key, deconstructed| case key when :node_id then deconstructed[:node_id] = self.node_id when :location then deconstructed[:location] = self.location when :name then deconstructed[:name] = self.name when :name_loc then deconstructed[:name_loc] = self.name_loc when :value then deconstructed[:value] = self.value when :operator_loc then deconstructed[:operator_loc] = self.operator_loc when :operator then deconstructed[:operator] = self.operator end end end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
14881 14882 14883 14884 14885 |
# File 'lib/prism/node.rb', line 14881 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield value end |
#inspect ⇒ String
: () -> String
14938 14939 14940 |
# File 'lib/prism/node.rb', line 14938 def inspect # :nodoc: InspectVisitor.compose(self) end |
#name ⇒ Symbol
:call-seq:
name -> Symbol
The name of the global variable, which is a $ followed by an identifier. Alternatively, it can be one of the special global variables designated by a symbol.
$foo = :bar # name `:$foo`
$_Test = 123 # name `:$_Test`
: () -> Symbol
14958 14959 14960 |
# File 'lib/prism/node.rb', line 14958 def name @name end |
#name_loc ⇒ Location
:category: Locations :call-seq:
name_loc -> Location
The Location of the global variable's name.
$foo = :bar
^^^^
: () -> Location
14976 14977 14978 14979 14980 |
# File 'lib/prism/node.rb', line 14976 def name_loc location = @name_loc return location if location.is_a?(Location) @name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#newline_flag!(lines) ⇒ void
This method returns an undefined value.
: (Array lines) -> void
319 320 321 |
# File 'lib/prism/parse_result/newlines.rb', line 319 def newline_flag!(lines) # :nodoc: value.newline_flag!(lines) end |
#operator ⇒ String
:call-seq:
operator -> String
Slice the location of operator_loc from the source.
: () -> String
15048 15049 15050 |
# File 'lib/prism/node.rb', line 15048 def operator operator_loc.slice end |
#operator_loc ⇒ Location
:category: Locations :call-seq:
operator_loc -> Location
The Location of the = operator.
$foo = :bar
^
: () -> Location
15025 15026 15027 15028 15029 |
# File 'lib/prism/node.rb', line 15025 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#save_name_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the name_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
14987 14988 14989 |
# File 'lib/prism/node.rb', line 14987 def save_name_loc(repository) repository.enter(node_id, :name_loc) end |
#save_operator_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the operator_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
15036 15037 15038 |
# File 'lib/prism/node.rb', line 15036 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end |
#type ⇒ :global_variable_write_node
See Node#type.
: () -> :global_variable_write_node
14926 14927 14928 |
# File 'lib/prism/node.rb', line 14926 def type :global_variable_write_node end |
#value ⇒ Prism::node
:call-seq:
value -> Node
The value to write to the global variable. It can be any non-void expression.
$foo = :bar
^^^^
$-xyz = 123
^^^
: () -> Prism::node
15007 15008 15009 |
# File 'lib/prism/node.rb', line 15007 def value @value end |