prism 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -1
- data/README.md +2 -1
- data/config.yml +188 -55
- data/docs/building.md +9 -2
- data/docs/configuration.md +10 -9
- data/docs/encoding.md +24 -56
- data/docs/local_variable_depth.md +229 -0
- data/docs/ruby_api.md +2 -0
- data/docs/serialization.md +18 -13
- data/ext/prism/api_node.c +337 -195
- data/ext/prism/extconf.rb +13 -7
- data/ext/prism/extension.c +96 -32
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +340 -137
- data/include/prism/defines.h +17 -0
- data/include/prism/diagnostic.h +11 -5
- data/include/prism/encoding.h +248 -0
- data/include/prism/options.h +2 -2
- data/include/prism/parser.h +62 -42
- data/include/prism/regexp.h +2 -2
- data/include/prism/util/pm_buffer.h +9 -1
- data/include/prism/util/pm_memchr.h +2 -2
- data/include/prism/util/pm_strpbrk.h +3 -3
- data/include/prism/version.h +2 -2
- data/include/prism.h +13 -15
- data/lib/prism/compiler.rb +12 -0
- data/lib/prism/debug.rb +9 -4
- data/lib/prism/desugar_compiler.rb +3 -3
- data/lib/prism/dispatcher.rb +56 -0
- data/lib/prism/dot_visitor.rb +476 -198
- data/lib/prism/dsl.rb +66 -46
- data/lib/prism/ffi.rb +16 -3
- data/lib/prism/lex_compat.rb +19 -9
- data/lib/prism/mutation_compiler.rb +20 -0
- data/lib/prism/node.rb +1173 -450
- data/lib/prism/node_ext.rb +41 -16
- data/lib/prism/parse_result.rb +12 -15
- data/lib/prism/ripper_compat.rb +49 -34
- data/lib/prism/serialize.rb +242 -212
- data/lib/prism/visitor.rb +12 -0
- data/lib/prism.rb +20 -4
- data/prism.gemspec +4 -10
- data/rbi/prism.rbi +605 -230
- data/rbi/prism_static.rbi +3 -0
- data/sig/prism.rbs +379 -124
- data/sig/prism_static.rbs +1 -0
- data/src/diagnostic.c +228 -222
- data/src/encoding.c +5137 -0
- data/src/node.c +66 -0
- data/src/options.c +21 -2
- data/src/prettyprint.c +806 -406
- data/src/prism.c +1092 -700
- data/src/regexp.c +3 -3
- data/src/serialize.c +227 -157
- data/src/util/pm_buffer.c +10 -1
- data/src/util/pm_memchr.c +1 -1
- data/src/util/pm_strpbrk.c +4 -4
- metadata +5 -11
- data/include/prism/enc/pm_encoding.h +0 -227
- data/src/enc/pm_big5.c +0 -116
- data/src/enc/pm_cp51932.c +0 -57
- data/src/enc/pm_euc_jp.c +0 -69
- data/src/enc/pm_gbk.c +0 -65
- data/src/enc/pm_shift_jis.c +0 -57
- data/src/enc/pm_tables.c +0 -2073
- data/src/enc/pm_unicode.c +0 -2369
- data/src/enc/pm_windows_31j.c +0 -57
data/lib/prism/node.rb
CHANGED
@@ -470,16 +470,16 @@ module Prism
|
|
470
470
|
# return foo, bar, baz
|
471
471
|
# ^^^^^^^^^^^^^
|
472
472
|
class ArgumentsNode < Node
|
473
|
-
# attr_reader arguments: Array[Node]
|
474
|
-
attr_reader :arguments
|
475
|
-
|
476
473
|
# attr_reader flags: Integer
|
477
474
|
private attr_reader :flags
|
478
475
|
|
479
|
-
#
|
480
|
-
|
481
|
-
|
476
|
+
# attr_reader arguments: Array[Node]
|
477
|
+
attr_reader :arguments
|
478
|
+
|
479
|
+
# def initialize: (flags: Integer, arguments: Array[Node], location: Location) -> void
|
480
|
+
def initialize(flags, arguments, location)
|
482
481
|
@flags = flags
|
482
|
+
@arguments = arguments
|
483
483
|
@location = location
|
484
484
|
end
|
485
485
|
|
@@ -506,8 +506,8 @@ module Prism
|
|
506
506
|
# def copy: (**params) -> ArgumentsNode
|
507
507
|
def copy(**params)
|
508
508
|
ArgumentsNode.new(
|
509
|
-
params.fetch(:arguments) { arguments },
|
510
509
|
params.fetch(:flags) { flags },
|
510
|
+
params.fetch(:arguments) { arguments },
|
511
511
|
params.fetch(:location) { location },
|
512
512
|
)
|
513
513
|
end
|
@@ -517,20 +517,20 @@ module Prism
|
|
517
517
|
|
518
518
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
519
519
|
def deconstruct_keys(keys)
|
520
|
-
{
|
520
|
+
{ flags: flags, arguments: arguments, location: location }
|
521
521
|
end
|
522
522
|
|
523
|
-
# def
|
524
|
-
def
|
525
|
-
flags.anybits?(ArgumentsNodeFlags::
|
523
|
+
# def contains_keyword_splat?: () -> bool
|
524
|
+
def contains_keyword_splat?
|
525
|
+
flags.anybits?(ArgumentsNodeFlags::CONTAINS_KEYWORD_SPLAT)
|
526
526
|
end
|
527
527
|
|
528
528
|
# def inspect(inspector: NodeInspector) -> String
|
529
529
|
def inspect(inspector = NodeInspector.new)
|
530
530
|
inspector << inspector.header(self)
|
531
|
-
|
532
|
-
flags
|
533
|
-
inspector << "└──
|
531
|
+
flags = [("contains_keyword_splat" if contains_keyword_splat?)].compact
|
532
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
533
|
+
inspector << "└── arguments: #{inspector.list("#{inspector.prefix} ", arguments)}"
|
534
534
|
inspector.to_str
|
535
535
|
end
|
536
536
|
|
@@ -569,6 +569,9 @@ module Prism
|
|
569
569
|
# [1, 2, 3]
|
570
570
|
# ^^^^^^^^^
|
571
571
|
class ArrayNode < Node
|
572
|
+
# attr_reader flags: Integer
|
573
|
+
private attr_reader :flags
|
574
|
+
|
572
575
|
# attr_reader elements: Array[Node]
|
573
576
|
attr_reader :elements
|
574
577
|
|
@@ -578,8 +581,9 @@ module Prism
|
|
578
581
|
# attr_reader closing_loc: Location?
|
579
582
|
attr_reader :closing_loc
|
580
583
|
|
581
|
-
# def initialize: (elements: Array[Node], opening_loc: Location?, closing_loc: Location?, location: Location) -> void
|
582
|
-
def initialize(elements, opening_loc, closing_loc, location)
|
584
|
+
# def initialize: (flags: Integer, elements: Array[Node], opening_loc: Location?, closing_loc: Location?, location: Location) -> void
|
585
|
+
def initialize(flags, elements, opening_loc, closing_loc, location)
|
586
|
+
@flags = flags
|
583
587
|
@elements = elements
|
584
588
|
@opening_loc = opening_loc
|
585
589
|
@closing_loc = closing_loc
|
@@ -609,6 +613,7 @@ module Prism
|
|
609
613
|
# def copy: (**params) -> ArrayNode
|
610
614
|
def copy(**params)
|
611
615
|
ArrayNode.new(
|
616
|
+
params.fetch(:flags) { flags },
|
612
617
|
params.fetch(:elements) { elements },
|
613
618
|
params.fetch(:opening_loc) { opening_loc },
|
614
619
|
params.fetch(:closing_loc) { closing_loc },
|
@@ -621,7 +626,12 @@ module Prism
|
|
621
626
|
|
622
627
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
623
628
|
def deconstruct_keys(keys)
|
624
|
-
{ elements: elements, opening_loc: opening_loc, closing_loc: closing_loc, location: location }
|
629
|
+
{ flags: flags, elements: elements, opening_loc: opening_loc, closing_loc: closing_loc, location: location }
|
630
|
+
end
|
631
|
+
|
632
|
+
# def contains_splat?: () -> bool
|
633
|
+
def contains_splat?
|
634
|
+
flags.anybits?(ArrayNodeFlags::CONTAINS_SPLAT)
|
625
635
|
end
|
626
636
|
|
627
637
|
# def opening: () -> String?
|
@@ -637,6 +647,8 @@ module Prism
|
|
637
647
|
# def inspect(inspector: NodeInspector) -> String
|
638
648
|
def inspect(inspector = NodeInspector.new)
|
639
649
|
inspector << inspector.header(self)
|
650
|
+
flags = [("contains_splat" if contains_splat?)].compact
|
651
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
640
652
|
inspector << "├── elements: #{inspector.list("#{inspector.prefix}│ ", elements)}"
|
641
653
|
inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
|
642
654
|
inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
|
@@ -1482,7 +1494,10 @@ module Prism
|
|
1482
1494
|
# attr_reader locals: Array[Symbol]
|
1483
1495
|
attr_reader :locals
|
1484
1496
|
|
1485
|
-
# attr_reader
|
1497
|
+
# attr_reader locals_body_index: Integer
|
1498
|
+
attr_reader :locals_body_index
|
1499
|
+
|
1500
|
+
# attr_reader parameters: Node?
|
1486
1501
|
attr_reader :parameters
|
1487
1502
|
|
1488
1503
|
# attr_reader body: Node?
|
@@ -1494,9 +1509,10 @@ module Prism
|
|
1494
1509
|
# attr_reader closing_loc: Location
|
1495
1510
|
attr_reader :closing_loc
|
1496
1511
|
|
1497
|
-
# def initialize: (locals: Array[Symbol], parameters:
|
1498
|
-
def initialize(locals, parameters, body, opening_loc, closing_loc, location)
|
1512
|
+
# def initialize: (locals: Array[Symbol], locals_body_index: Integer, parameters: Node?, body: Node?, opening_loc: Location, closing_loc: Location, location: Location) -> void
|
1513
|
+
def initialize(locals, locals_body_index, parameters, body, opening_loc, closing_loc, location)
|
1499
1514
|
@locals = locals
|
1515
|
+
@locals_body_index = locals_body_index
|
1500
1516
|
@parameters = parameters
|
1501
1517
|
@body = body
|
1502
1518
|
@opening_loc = opening_loc
|
@@ -1531,6 +1547,7 @@ module Prism
|
|
1531
1547
|
def copy(**params)
|
1532
1548
|
BlockNode.new(
|
1533
1549
|
params.fetch(:locals) { locals },
|
1550
|
+
params.fetch(:locals_body_index) { locals_body_index },
|
1534
1551
|
params.fetch(:parameters) { parameters },
|
1535
1552
|
params.fetch(:body) { body },
|
1536
1553
|
params.fetch(:opening_loc) { opening_loc },
|
@@ -1544,7 +1561,7 @@ module Prism
|
|
1544
1561
|
|
1545
1562
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
1546
1563
|
def deconstruct_keys(keys)
|
1547
|
-
{ locals: locals, parameters: parameters, body: body, opening_loc: opening_loc, closing_loc: closing_loc, location: location }
|
1564
|
+
{ locals: locals, locals_body_index: locals_body_index, parameters: parameters, body: body, opening_loc: opening_loc, closing_loc: closing_loc, location: location }
|
1548
1565
|
end
|
1549
1566
|
|
1550
1567
|
# def opening: () -> String
|
@@ -1561,6 +1578,7 @@ module Prism
|
|
1561
1578
|
def inspect(inspector = NodeInspector.new)
|
1562
1579
|
inspector << inspector.header(self)
|
1563
1580
|
inspector << "├── locals: #{locals.inspect}\n"
|
1581
|
+
inspector << "├── locals_body_index: #{locals_body_index.inspect}\n"
|
1564
1582
|
if (parameters = self.parameters).nil?
|
1565
1583
|
inspector << "├── parameters: ∅\n"
|
1566
1584
|
else
|
@@ -1950,6 +1968,9 @@ module Prism
|
|
1950
1968
|
# foo.bar &&= value
|
1951
1969
|
# ^^^^^^^^^^^^^^^^^
|
1952
1970
|
class CallAndWriteNode < Node
|
1971
|
+
# attr_reader flags: Integer
|
1972
|
+
private attr_reader :flags
|
1973
|
+
|
1953
1974
|
# attr_reader receiver: Node?
|
1954
1975
|
attr_reader :receiver
|
1955
1976
|
|
@@ -1959,9 +1980,6 @@ module Prism
|
|
1959
1980
|
# attr_reader message_loc: Location?
|
1960
1981
|
attr_reader :message_loc
|
1961
1982
|
|
1962
|
-
# attr_reader flags: Integer
|
1963
|
-
private attr_reader :flags
|
1964
|
-
|
1965
1983
|
# attr_reader read_name: Symbol
|
1966
1984
|
attr_reader :read_name
|
1967
1985
|
|
@@ -1974,12 +1992,12 @@ module Prism
|
|
1974
1992
|
# attr_reader value: Node
|
1975
1993
|
attr_reader :value
|
1976
1994
|
|
1977
|
-
# def initialize: (receiver: Node?, call_operator_loc: Location?, message_loc: Location?,
|
1978
|
-
def initialize(receiver, call_operator_loc, message_loc,
|
1995
|
+
# def initialize: (flags: Integer, receiver: Node?, call_operator_loc: Location?, message_loc: Location?, read_name: Symbol, write_name: Symbol, operator_loc: Location, value: Node, location: Location) -> void
|
1996
|
+
def initialize(flags, receiver, call_operator_loc, message_loc, read_name, write_name, operator_loc, value, location)
|
1997
|
+
@flags = flags
|
1979
1998
|
@receiver = receiver
|
1980
1999
|
@call_operator_loc = call_operator_loc
|
1981
2000
|
@message_loc = message_loc
|
1982
|
-
@flags = flags
|
1983
2001
|
@read_name = read_name
|
1984
2002
|
@write_name = write_name
|
1985
2003
|
@operator_loc = operator_loc
|
@@ -2013,10 +2031,10 @@ module Prism
|
|
2013
2031
|
# def copy: (**params) -> CallAndWriteNode
|
2014
2032
|
def copy(**params)
|
2015
2033
|
CallAndWriteNode.new(
|
2034
|
+
params.fetch(:flags) { flags },
|
2016
2035
|
params.fetch(:receiver) { receiver },
|
2017
2036
|
params.fetch(:call_operator_loc) { call_operator_loc },
|
2018
2037
|
params.fetch(:message_loc) { message_loc },
|
2019
|
-
params.fetch(:flags) { flags },
|
2020
2038
|
params.fetch(:read_name) { read_name },
|
2021
2039
|
params.fetch(:write_name) { write_name },
|
2022
2040
|
params.fetch(:operator_loc) { operator_loc },
|
@@ -2030,17 +2048,7 @@ module Prism
|
|
2030
2048
|
|
2031
2049
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
2032
2050
|
def deconstruct_keys(keys)
|
2033
|
-
{ receiver: receiver, call_operator_loc: call_operator_loc, message_loc: message_loc,
|
2034
|
-
end
|
2035
|
-
|
2036
|
-
# def call_operator: () -> String?
|
2037
|
-
def call_operator
|
2038
|
-
call_operator_loc&.slice
|
2039
|
-
end
|
2040
|
-
|
2041
|
-
# def message: () -> String?
|
2042
|
-
def message
|
2043
|
-
message_loc&.slice
|
2051
|
+
{ flags: flags, receiver: receiver, call_operator_loc: call_operator_loc, message_loc: message_loc, read_name: read_name, write_name: write_name, operator_loc: operator_loc, value: value, location: location }
|
2044
2052
|
end
|
2045
2053
|
|
2046
2054
|
# def safe_navigation?: () -> bool
|
@@ -2053,6 +2061,21 @@ module Prism
|
|
2053
2061
|
flags.anybits?(CallNodeFlags::VARIABLE_CALL)
|
2054
2062
|
end
|
2055
2063
|
|
2064
|
+
# def attribute_write?: () -> bool
|
2065
|
+
def attribute_write?
|
2066
|
+
flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE)
|
2067
|
+
end
|
2068
|
+
|
2069
|
+
# def call_operator: () -> String?
|
2070
|
+
def call_operator
|
2071
|
+
call_operator_loc&.slice
|
2072
|
+
end
|
2073
|
+
|
2074
|
+
# def message: () -> String?
|
2075
|
+
def message
|
2076
|
+
message_loc&.slice
|
2077
|
+
end
|
2078
|
+
|
2056
2079
|
# def operator: () -> String
|
2057
2080
|
def operator
|
2058
2081
|
operator_loc.slice
|
@@ -2061,6 +2084,8 @@ module Prism
|
|
2061
2084
|
# def inspect(inspector: NodeInspector) -> String
|
2062
2085
|
def inspect(inspector = NodeInspector.new)
|
2063
2086
|
inspector << inspector.header(self)
|
2087
|
+
flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?)].compact
|
2088
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
2064
2089
|
if (receiver = self.receiver).nil?
|
2065
2090
|
inspector << "├── receiver: ∅\n"
|
2066
2091
|
else
|
@@ -2069,8 +2094,6 @@ module Prism
|
|
2069
2094
|
end
|
2070
2095
|
inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n"
|
2071
2096
|
inspector << "├── message_loc: #{inspector.location(message_loc)}\n"
|
2072
|
-
flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?)].compact
|
2073
|
-
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
2074
2097
|
inspector << "├── read_name: #{read_name.inspect}\n"
|
2075
2098
|
inspector << "├── write_name: #{write_name.inspect}\n"
|
2076
2099
|
inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
|
@@ -2128,12 +2151,18 @@ module Prism
|
|
2128
2151
|
# foo&.bar
|
2129
2152
|
# ^^^^^^^^
|
2130
2153
|
class CallNode < Node
|
2154
|
+
# attr_reader flags: Integer
|
2155
|
+
private attr_reader :flags
|
2156
|
+
|
2131
2157
|
# attr_reader receiver: Node?
|
2132
2158
|
attr_reader :receiver
|
2133
2159
|
|
2134
2160
|
# attr_reader call_operator_loc: Location?
|
2135
2161
|
attr_reader :call_operator_loc
|
2136
2162
|
|
2163
|
+
# attr_reader name: Symbol
|
2164
|
+
attr_reader :name
|
2165
|
+
|
2137
2166
|
# attr_reader message_loc: Location?
|
2138
2167
|
attr_reader :message_loc
|
2139
2168
|
|
@@ -2149,23 +2178,17 @@ module Prism
|
|
2149
2178
|
# attr_reader block: Node?
|
2150
2179
|
attr_reader :block
|
2151
2180
|
|
2152
|
-
#
|
2153
|
-
|
2154
|
-
|
2155
|
-
# attr_reader name: Symbol
|
2156
|
-
attr_reader :name
|
2157
|
-
|
2158
|
-
# def initialize: (receiver: Node?, call_operator_loc: Location?, message_loc: Location?, opening_loc: Location?, arguments: ArgumentsNode?, closing_loc: Location?, block: Node?, flags: Integer, name: Symbol, location: Location) -> void
|
2159
|
-
def initialize(receiver, call_operator_loc, message_loc, opening_loc, arguments, closing_loc, block, flags, name, location)
|
2181
|
+
# def initialize: (flags: Integer, receiver: Node?, call_operator_loc: Location?, name: Symbol, message_loc: Location?, opening_loc: Location?, arguments: ArgumentsNode?, closing_loc: Location?, block: Node?, location: Location) -> void
|
2182
|
+
def initialize(flags, receiver, call_operator_loc, name, message_loc, opening_loc, arguments, closing_loc, block, location)
|
2183
|
+
@flags = flags
|
2160
2184
|
@receiver = receiver
|
2161
2185
|
@call_operator_loc = call_operator_loc
|
2186
|
+
@name = name
|
2162
2187
|
@message_loc = message_loc
|
2163
2188
|
@opening_loc = opening_loc
|
2164
2189
|
@arguments = arguments
|
2165
2190
|
@closing_loc = closing_loc
|
2166
2191
|
@block = block
|
2167
|
-
@flags = flags
|
2168
|
-
@name = name
|
2169
2192
|
@location = location
|
2170
2193
|
end
|
2171
2194
|
|
@@ -2196,15 +2219,15 @@ module Prism
|
|
2196
2219
|
# def copy: (**params) -> CallNode
|
2197
2220
|
def copy(**params)
|
2198
2221
|
CallNode.new(
|
2222
|
+
params.fetch(:flags) { flags },
|
2199
2223
|
params.fetch(:receiver) { receiver },
|
2200
2224
|
params.fetch(:call_operator_loc) { call_operator_loc },
|
2225
|
+
params.fetch(:name) { name },
|
2201
2226
|
params.fetch(:message_loc) { message_loc },
|
2202
2227
|
params.fetch(:opening_loc) { opening_loc },
|
2203
2228
|
params.fetch(:arguments) { arguments },
|
2204
2229
|
params.fetch(:closing_loc) { closing_loc },
|
2205
2230
|
params.fetch(:block) { block },
|
2206
|
-
params.fetch(:flags) { flags },
|
2207
|
-
params.fetch(:name) { name },
|
2208
2231
|
params.fetch(:location) { location },
|
2209
2232
|
)
|
2210
2233
|
end
|
@@ -2214,7 +2237,22 @@ module Prism
|
|
2214
2237
|
|
2215
2238
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
2216
2239
|
def deconstruct_keys(keys)
|
2217
|
-
{ receiver: receiver, call_operator_loc: call_operator_loc, message_loc: message_loc, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block,
|
2240
|
+
{ flags: flags, receiver: receiver, call_operator_loc: call_operator_loc, name: name, message_loc: message_loc, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block, location: location }
|
2241
|
+
end
|
2242
|
+
|
2243
|
+
# def safe_navigation?: () -> bool
|
2244
|
+
def safe_navigation?
|
2245
|
+
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
2246
|
+
end
|
2247
|
+
|
2248
|
+
# def variable_call?: () -> bool
|
2249
|
+
def variable_call?
|
2250
|
+
flags.anybits?(CallNodeFlags::VARIABLE_CALL)
|
2251
|
+
end
|
2252
|
+
|
2253
|
+
# def attribute_write?: () -> bool
|
2254
|
+
def attribute_write?
|
2255
|
+
flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE)
|
2218
2256
|
end
|
2219
2257
|
|
2220
2258
|
# def call_operator: () -> String?
|
@@ -2237,19 +2275,11 @@ module Prism
|
|
2237
2275
|
closing_loc&.slice
|
2238
2276
|
end
|
2239
2277
|
|
2240
|
-
# def safe_navigation?: () -> bool
|
2241
|
-
def safe_navigation?
|
2242
|
-
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
2243
|
-
end
|
2244
|
-
|
2245
|
-
# def variable_call?: () -> bool
|
2246
|
-
def variable_call?
|
2247
|
-
flags.anybits?(CallNodeFlags::VARIABLE_CALL)
|
2248
|
-
end
|
2249
|
-
|
2250
2278
|
# def inspect(inspector: NodeInspector) -> String
|
2251
2279
|
def inspect(inspector = NodeInspector.new)
|
2252
2280
|
inspector << inspector.header(self)
|
2281
|
+
flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?)].compact
|
2282
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
2253
2283
|
if (receiver = self.receiver).nil?
|
2254
2284
|
inspector << "├── receiver: ∅\n"
|
2255
2285
|
else
|
@@ -2257,6 +2287,7 @@ module Prism
|
|
2257
2287
|
inspector << receiver.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
|
2258
2288
|
end
|
2259
2289
|
inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n"
|
2290
|
+
inspector << "├── name: #{name.inspect}\n"
|
2260
2291
|
inspector << "├── message_loc: #{inspector.location(message_loc)}\n"
|
2261
2292
|
inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
|
2262
2293
|
if (arguments = self.arguments).nil?
|
@@ -2267,14 +2298,11 @@ module Prism
|
|
2267
2298
|
end
|
2268
2299
|
inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
|
2269
2300
|
if (block = self.block).nil?
|
2270
|
-
inspector << "
|
2301
|
+
inspector << "└── block: ∅\n"
|
2271
2302
|
else
|
2272
|
-
inspector << "
|
2273
|
-
inspector << block.inspect(inspector.child_inspector("
|
2303
|
+
inspector << "└── block:\n"
|
2304
|
+
inspector << block.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix)
|
2274
2305
|
end
|
2275
|
-
flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?)].compact
|
2276
|
-
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
2277
|
-
inspector << "└── name: #{name.inspect}\n"
|
2278
2306
|
inspector.to_str
|
2279
2307
|
end
|
2280
2308
|
|
@@ -2312,6 +2340,9 @@ module Prism
|
|
2312
2340
|
# foo.bar += baz
|
2313
2341
|
# ^^^^^^^^^^^^^^
|
2314
2342
|
class CallOperatorWriteNode < Node
|
2343
|
+
# attr_reader flags: Integer
|
2344
|
+
private attr_reader :flags
|
2345
|
+
|
2315
2346
|
# attr_reader receiver: Node?
|
2316
2347
|
attr_reader :receiver
|
2317
2348
|
|
@@ -2321,9 +2352,6 @@ module Prism
|
|
2321
2352
|
# attr_reader message_loc: Location?
|
2322
2353
|
attr_reader :message_loc
|
2323
2354
|
|
2324
|
-
# attr_reader flags: Integer
|
2325
|
-
private attr_reader :flags
|
2326
|
-
|
2327
2355
|
# attr_reader read_name: Symbol
|
2328
2356
|
attr_reader :read_name
|
2329
2357
|
|
@@ -2339,12 +2367,12 @@ module Prism
|
|
2339
2367
|
# attr_reader value: Node
|
2340
2368
|
attr_reader :value
|
2341
2369
|
|
2342
|
-
# def initialize: (receiver: Node?, call_operator_loc: Location?, message_loc: Location?,
|
2343
|
-
def initialize(receiver, call_operator_loc, message_loc,
|
2370
|
+
# def initialize: (flags: Integer, receiver: Node?, call_operator_loc: Location?, message_loc: Location?, read_name: Symbol, write_name: Symbol, operator: Symbol, operator_loc: Location, value: Node, location: Location) -> void
|
2371
|
+
def initialize(flags, receiver, call_operator_loc, message_loc, read_name, write_name, operator, operator_loc, value, location)
|
2372
|
+
@flags = flags
|
2344
2373
|
@receiver = receiver
|
2345
2374
|
@call_operator_loc = call_operator_loc
|
2346
2375
|
@message_loc = message_loc
|
2347
|
-
@flags = flags
|
2348
2376
|
@read_name = read_name
|
2349
2377
|
@write_name = write_name
|
2350
2378
|
@operator = operator
|
@@ -2379,10 +2407,10 @@ module Prism
|
|
2379
2407
|
# def copy: (**params) -> CallOperatorWriteNode
|
2380
2408
|
def copy(**params)
|
2381
2409
|
CallOperatorWriteNode.new(
|
2410
|
+
params.fetch(:flags) { flags },
|
2382
2411
|
params.fetch(:receiver) { receiver },
|
2383
2412
|
params.fetch(:call_operator_loc) { call_operator_loc },
|
2384
2413
|
params.fetch(:message_loc) { message_loc },
|
2385
|
-
params.fetch(:flags) { flags },
|
2386
2414
|
params.fetch(:read_name) { read_name },
|
2387
2415
|
params.fetch(:write_name) { write_name },
|
2388
2416
|
params.fetch(:operator) { operator },
|
@@ -2397,17 +2425,7 @@ module Prism
|
|
2397
2425
|
|
2398
2426
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
2399
2427
|
def deconstruct_keys(keys)
|
2400
|
-
{ receiver: receiver, call_operator_loc: call_operator_loc, message_loc: message_loc,
|
2401
|
-
end
|
2402
|
-
|
2403
|
-
# def call_operator: () -> String?
|
2404
|
-
def call_operator
|
2405
|
-
call_operator_loc&.slice
|
2406
|
-
end
|
2407
|
-
|
2408
|
-
# def message: () -> String?
|
2409
|
-
def message
|
2410
|
-
message_loc&.slice
|
2428
|
+
{ flags: flags, receiver: receiver, call_operator_loc: call_operator_loc, message_loc: message_loc, read_name: read_name, write_name: write_name, operator: operator, operator_loc: operator_loc, value: value, location: location }
|
2411
2429
|
end
|
2412
2430
|
|
2413
2431
|
# def safe_navigation?: () -> bool
|
@@ -2420,9 +2438,26 @@ module Prism
|
|
2420
2438
|
flags.anybits?(CallNodeFlags::VARIABLE_CALL)
|
2421
2439
|
end
|
2422
2440
|
|
2441
|
+
# def attribute_write?: () -> bool
|
2442
|
+
def attribute_write?
|
2443
|
+
flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE)
|
2444
|
+
end
|
2445
|
+
|
2446
|
+
# def call_operator: () -> String?
|
2447
|
+
def call_operator
|
2448
|
+
call_operator_loc&.slice
|
2449
|
+
end
|
2450
|
+
|
2451
|
+
# def message: () -> String?
|
2452
|
+
def message
|
2453
|
+
message_loc&.slice
|
2454
|
+
end
|
2455
|
+
|
2423
2456
|
# def inspect(inspector: NodeInspector) -> String
|
2424
2457
|
def inspect(inspector = NodeInspector.new)
|
2425
2458
|
inspector << inspector.header(self)
|
2459
|
+
flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?)].compact
|
2460
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
2426
2461
|
if (receiver = self.receiver).nil?
|
2427
2462
|
inspector << "├── receiver: ∅\n"
|
2428
2463
|
else
|
@@ -2431,8 +2466,6 @@ module Prism
|
|
2431
2466
|
end
|
2432
2467
|
inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n"
|
2433
2468
|
inspector << "├── message_loc: #{inspector.location(message_loc)}\n"
|
2434
|
-
flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?)].compact
|
2435
|
-
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
2436
2469
|
inspector << "├── read_name: #{read_name.inspect}\n"
|
2437
2470
|
inspector << "├── write_name: #{write_name.inspect}\n"
|
2438
2471
|
inspector << "├── operator: #{operator.inspect}\n"
|
@@ -2476,6 +2509,9 @@ module Prism
|
|
2476
2509
|
# foo.bar ||= value
|
2477
2510
|
# ^^^^^^^^^^^^^^^^^
|
2478
2511
|
class CallOrWriteNode < Node
|
2512
|
+
# attr_reader flags: Integer
|
2513
|
+
private attr_reader :flags
|
2514
|
+
|
2479
2515
|
# attr_reader receiver: Node?
|
2480
2516
|
attr_reader :receiver
|
2481
2517
|
|
@@ -2485,9 +2521,6 @@ module Prism
|
|
2485
2521
|
# attr_reader message_loc: Location?
|
2486
2522
|
attr_reader :message_loc
|
2487
2523
|
|
2488
|
-
# attr_reader flags: Integer
|
2489
|
-
private attr_reader :flags
|
2490
|
-
|
2491
2524
|
# attr_reader read_name: Symbol
|
2492
2525
|
attr_reader :read_name
|
2493
2526
|
|
@@ -2500,12 +2533,12 @@ module Prism
|
|
2500
2533
|
# attr_reader value: Node
|
2501
2534
|
attr_reader :value
|
2502
2535
|
|
2503
|
-
# def initialize: (receiver: Node?, call_operator_loc: Location?, message_loc: Location?,
|
2504
|
-
def initialize(receiver, call_operator_loc, message_loc,
|
2536
|
+
# def initialize: (flags: Integer, receiver: Node?, call_operator_loc: Location?, message_loc: Location?, read_name: Symbol, write_name: Symbol, operator_loc: Location, value: Node, location: Location) -> void
|
2537
|
+
def initialize(flags, receiver, call_operator_loc, message_loc, read_name, write_name, operator_loc, value, location)
|
2538
|
+
@flags = flags
|
2505
2539
|
@receiver = receiver
|
2506
2540
|
@call_operator_loc = call_operator_loc
|
2507
2541
|
@message_loc = message_loc
|
2508
|
-
@flags = flags
|
2509
2542
|
@read_name = read_name
|
2510
2543
|
@write_name = write_name
|
2511
2544
|
@operator_loc = operator_loc
|
@@ -2539,10 +2572,10 @@ module Prism
|
|
2539
2572
|
# def copy: (**params) -> CallOrWriteNode
|
2540
2573
|
def copy(**params)
|
2541
2574
|
CallOrWriteNode.new(
|
2575
|
+
params.fetch(:flags) { flags },
|
2542
2576
|
params.fetch(:receiver) { receiver },
|
2543
2577
|
params.fetch(:call_operator_loc) { call_operator_loc },
|
2544
2578
|
params.fetch(:message_loc) { message_loc },
|
2545
|
-
params.fetch(:flags) { flags },
|
2546
2579
|
params.fetch(:read_name) { read_name },
|
2547
2580
|
params.fetch(:write_name) { write_name },
|
2548
2581
|
params.fetch(:operator_loc) { operator_loc },
|
@@ -2556,17 +2589,7 @@ module Prism
|
|
2556
2589
|
|
2557
2590
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
2558
2591
|
def deconstruct_keys(keys)
|
2559
|
-
{ receiver: receiver, call_operator_loc: call_operator_loc, message_loc: message_loc,
|
2560
|
-
end
|
2561
|
-
|
2562
|
-
# def call_operator: () -> String?
|
2563
|
-
def call_operator
|
2564
|
-
call_operator_loc&.slice
|
2565
|
-
end
|
2566
|
-
|
2567
|
-
# def message: () -> String?
|
2568
|
-
def message
|
2569
|
-
message_loc&.slice
|
2592
|
+
{ flags: flags, receiver: receiver, call_operator_loc: call_operator_loc, message_loc: message_loc, read_name: read_name, write_name: write_name, operator_loc: operator_loc, value: value, location: location }
|
2570
2593
|
end
|
2571
2594
|
|
2572
2595
|
# def safe_navigation?: () -> bool
|
@@ -2579,6 +2602,21 @@ module Prism
|
|
2579
2602
|
flags.anybits?(CallNodeFlags::VARIABLE_CALL)
|
2580
2603
|
end
|
2581
2604
|
|
2605
|
+
# def attribute_write?: () -> bool
|
2606
|
+
def attribute_write?
|
2607
|
+
flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE)
|
2608
|
+
end
|
2609
|
+
|
2610
|
+
# def call_operator: () -> String?
|
2611
|
+
def call_operator
|
2612
|
+
call_operator_loc&.slice
|
2613
|
+
end
|
2614
|
+
|
2615
|
+
# def message: () -> String?
|
2616
|
+
def message
|
2617
|
+
message_loc&.slice
|
2618
|
+
end
|
2619
|
+
|
2582
2620
|
# def operator: () -> String
|
2583
2621
|
def operator
|
2584
2622
|
operator_loc.slice
|
@@ -2587,6 +2625,8 @@ module Prism
|
|
2587
2625
|
# def inspect(inspector: NodeInspector) -> String
|
2588
2626
|
def inspect(inspector = NodeInspector.new)
|
2589
2627
|
inspector << inspector.header(self)
|
2628
|
+
flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?)].compact
|
2629
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
2590
2630
|
if (receiver = self.receiver).nil?
|
2591
2631
|
inspector << "├── receiver: ∅\n"
|
2592
2632
|
else
|
@@ -2595,8 +2635,6 @@ module Prism
|
|
2595
2635
|
end
|
2596
2636
|
inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n"
|
2597
2637
|
inspector << "├── message_loc: #{inspector.location(message_loc)}\n"
|
2598
|
-
flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?)].compact
|
2599
|
-
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
2600
2638
|
inspector << "├── read_name: #{read_name.inspect}\n"
|
2601
2639
|
inspector << "├── write_name: #{write_name.inspect}\n"
|
2602
2640
|
inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
|
@@ -2634,54 +2672,72 @@ module Prism
|
|
2634
2672
|
end
|
2635
2673
|
end
|
2636
2674
|
|
2637
|
-
# Represents assigning to a
|
2675
|
+
# Represents assigning to a method call.
|
2638
2676
|
#
|
2639
|
-
# foo
|
2640
|
-
#
|
2641
|
-
|
2642
|
-
|
2643
|
-
|
2677
|
+
# foo.bar, = 1
|
2678
|
+
# ^^^^^^^
|
2679
|
+
#
|
2680
|
+
# begin
|
2681
|
+
# rescue => foo.bar
|
2682
|
+
# ^^^^^^^
|
2683
|
+
# end
|
2684
|
+
#
|
2685
|
+
# for foo.bar in baz do end
|
2686
|
+
# ^^^^^^^
|
2687
|
+
class CallTargetNode < Node
|
2688
|
+
# attr_reader flags: Integer
|
2689
|
+
private attr_reader :flags
|
2644
2690
|
|
2645
|
-
# attr_reader
|
2646
|
-
attr_reader :
|
2691
|
+
# attr_reader receiver: Node
|
2692
|
+
attr_reader :receiver
|
2647
2693
|
|
2648
|
-
# attr_reader
|
2649
|
-
attr_reader :
|
2694
|
+
# attr_reader call_operator_loc: Location
|
2695
|
+
attr_reader :call_operator_loc
|
2650
2696
|
|
2651
|
-
#
|
2652
|
-
|
2653
|
-
|
2654
|
-
|
2655
|
-
|
2697
|
+
# attr_reader name: Symbol
|
2698
|
+
attr_reader :name
|
2699
|
+
|
2700
|
+
# attr_reader message_loc: Location
|
2701
|
+
attr_reader :message_loc
|
2702
|
+
|
2703
|
+
# def initialize: (flags: Integer, receiver: Node, call_operator_loc: Location, name: Symbol, message_loc: Location, location: Location) -> void
|
2704
|
+
def initialize(flags, receiver, call_operator_loc, name, message_loc, location)
|
2705
|
+
@flags = flags
|
2706
|
+
@receiver = receiver
|
2707
|
+
@call_operator_loc = call_operator_loc
|
2708
|
+
@name = name
|
2709
|
+
@message_loc = message_loc
|
2656
2710
|
@location = location
|
2657
2711
|
end
|
2658
2712
|
|
2659
2713
|
# def accept: (visitor: Visitor) -> void
|
2660
2714
|
def accept(visitor)
|
2661
|
-
visitor.
|
2715
|
+
visitor.visit_call_target_node(self)
|
2662
2716
|
end
|
2663
2717
|
|
2664
2718
|
# def child_nodes: () -> Array[nil | Node]
|
2665
2719
|
def child_nodes
|
2666
|
-
[
|
2720
|
+
[receiver]
|
2667
2721
|
end
|
2668
2722
|
|
2669
2723
|
# def compact_child_nodes: () -> Array[Node]
|
2670
2724
|
def compact_child_nodes
|
2671
|
-
[
|
2725
|
+
[receiver]
|
2672
2726
|
end
|
2673
2727
|
|
2674
2728
|
# def comment_targets: () -> Array[Node | Location]
|
2675
2729
|
def comment_targets
|
2676
|
-
[
|
2730
|
+
[receiver, call_operator_loc, message_loc]
|
2677
2731
|
end
|
2678
2732
|
|
2679
|
-
# def copy: (**params) ->
|
2733
|
+
# def copy: (**params) -> CallTargetNode
|
2680
2734
|
def copy(**params)
|
2681
|
-
|
2682
|
-
params.fetch(:
|
2683
|
-
params.fetch(:
|
2684
|
-
params.fetch(:
|
2735
|
+
CallTargetNode.new(
|
2736
|
+
params.fetch(:flags) { flags },
|
2737
|
+
params.fetch(:receiver) { receiver },
|
2738
|
+
params.fetch(:call_operator_loc) { call_operator_loc },
|
2739
|
+
params.fetch(:name) { name },
|
2740
|
+
params.fetch(:message_loc) { message_loc },
|
2685
2741
|
params.fetch(:location) { location },
|
2686
2742
|
)
|
2687
2743
|
end
|
@@ -2691,22 +2747,44 @@ module Prism
|
|
2691
2747
|
|
2692
2748
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
2693
2749
|
def deconstruct_keys(keys)
|
2694
|
-
{
|
2750
|
+
{ flags: flags, receiver: receiver, call_operator_loc: call_operator_loc, name: name, message_loc: message_loc, location: location }
|
2695
2751
|
end
|
2696
2752
|
|
2697
|
-
# def
|
2698
|
-
def
|
2699
|
-
|
2753
|
+
# def safe_navigation?: () -> bool
|
2754
|
+
def safe_navigation?
|
2755
|
+
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
2756
|
+
end
|
2757
|
+
|
2758
|
+
# def variable_call?: () -> bool
|
2759
|
+
def variable_call?
|
2760
|
+
flags.anybits?(CallNodeFlags::VARIABLE_CALL)
|
2761
|
+
end
|
2762
|
+
|
2763
|
+
# def attribute_write?: () -> bool
|
2764
|
+
def attribute_write?
|
2765
|
+
flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE)
|
2766
|
+
end
|
2767
|
+
|
2768
|
+
# def call_operator: () -> String
|
2769
|
+
def call_operator
|
2770
|
+
call_operator_loc.slice
|
2771
|
+
end
|
2772
|
+
|
2773
|
+
# def message: () -> String
|
2774
|
+
def message
|
2775
|
+
message_loc.slice
|
2700
2776
|
end
|
2701
2777
|
|
2702
2778
|
# def inspect(inspector: NodeInspector) -> String
|
2703
2779
|
def inspect(inspector = NodeInspector.new)
|
2704
2780
|
inspector << inspector.header(self)
|
2705
|
-
|
2706
|
-
inspector <<
|
2707
|
-
inspector << "├──
|
2708
|
-
inspector << inspector.child_node(
|
2709
|
-
inspector << "
|
2781
|
+
flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?)].compact
|
2782
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
2783
|
+
inspector << "├── receiver:\n"
|
2784
|
+
inspector << inspector.child_node(receiver, "│ ")
|
2785
|
+
inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n"
|
2786
|
+
inspector << "├── name: #{name.inspect}\n"
|
2787
|
+
inspector << "└── message_loc: #{inspector.location(message_loc)}\n"
|
2710
2788
|
inspector.to_str
|
2711
2789
|
end
|
2712
2790
|
|
@@ -2725,7 +2803,7 @@ module Prism
|
|
2725
2803
|
#
|
2726
2804
|
# def type: () -> Symbol
|
2727
2805
|
def type
|
2728
|
-
:
|
2806
|
+
:call_target_node
|
2729
2807
|
end
|
2730
2808
|
|
2731
2809
|
# Similar to #type, this method returns a symbol that you can use for
|
@@ -2735,13 +2813,118 @@ module Prism
|
|
2735
2813
|
#
|
2736
2814
|
# def self.type: () -> Symbol
|
2737
2815
|
def self.type
|
2738
|
-
:
|
2816
|
+
:call_target_node
|
2739
2817
|
end
|
2740
2818
|
end
|
2741
2819
|
|
2742
|
-
# Represents
|
2820
|
+
# Represents assigning to a local variable in pattern matching.
|
2743
2821
|
#
|
2744
|
-
#
|
2822
|
+
# foo => [bar => baz]
|
2823
|
+
# ^^^^^^^^^^^^
|
2824
|
+
class CapturePatternNode < Node
|
2825
|
+
# attr_reader value: Node
|
2826
|
+
attr_reader :value
|
2827
|
+
|
2828
|
+
# attr_reader target: Node
|
2829
|
+
attr_reader :target
|
2830
|
+
|
2831
|
+
# attr_reader operator_loc: Location
|
2832
|
+
attr_reader :operator_loc
|
2833
|
+
|
2834
|
+
# def initialize: (value: Node, target: Node, operator_loc: Location, location: Location) -> void
|
2835
|
+
def initialize(value, target, operator_loc, location)
|
2836
|
+
@value = value
|
2837
|
+
@target = target
|
2838
|
+
@operator_loc = operator_loc
|
2839
|
+
@location = location
|
2840
|
+
end
|
2841
|
+
|
2842
|
+
# def accept: (visitor: Visitor) -> void
|
2843
|
+
def accept(visitor)
|
2844
|
+
visitor.visit_capture_pattern_node(self)
|
2845
|
+
end
|
2846
|
+
|
2847
|
+
# def child_nodes: () -> Array[nil | Node]
|
2848
|
+
def child_nodes
|
2849
|
+
[value, target]
|
2850
|
+
end
|
2851
|
+
|
2852
|
+
# def compact_child_nodes: () -> Array[Node]
|
2853
|
+
def compact_child_nodes
|
2854
|
+
[value, target]
|
2855
|
+
end
|
2856
|
+
|
2857
|
+
# def comment_targets: () -> Array[Node | Location]
|
2858
|
+
def comment_targets
|
2859
|
+
[value, target, operator_loc]
|
2860
|
+
end
|
2861
|
+
|
2862
|
+
# def copy: (**params) -> CapturePatternNode
|
2863
|
+
def copy(**params)
|
2864
|
+
CapturePatternNode.new(
|
2865
|
+
params.fetch(:value) { value },
|
2866
|
+
params.fetch(:target) { target },
|
2867
|
+
params.fetch(:operator_loc) { operator_loc },
|
2868
|
+
params.fetch(:location) { location },
|
2869
|
+
)
|
2870
|
+
end
|
2871
|
+
|
2872
|
+
# def deconstruct: () -> Array[nil | Node]
|
2873
|
+
alias deconstruct child_nodes
|
2874
|
+
|
2875
|
+
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
2876
|
+
def deconstruct_keys(keys)
|
2877
|
+
{ value: value, target: target, operator_loc: operator_loc, location: location }
|
2878
|
+
end
|
2879
|
+
|
2880
|
+
# def operator: () -> String
|
2881
|
+
def operator
|
2882
|
+
operator_loc.slice
|
2883
|
+
end
|
2884
|
+
|
2885
|
+
# def inspect(inspector: NodeInspector) -> String
|
2886
|
+
def inspect(inspector = NodeInspector.new)
|
2887
|
+
inspector << inspector.header(self)
|
2888
|
+
inspector << "├── value:\n"
|
2889
|
+
inspector << inspector.child_node(value, "│ ")
|
2890
|
+
inspector << "├── target:\n"
|
2891
|
+
inspector << inspector.child_node(target, "│ ")
|
2892
|
+
inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
|
2893
|
+
inspector.to_str
|
2894
|
+
end
|
2895
|
+
|
2896
|
+
# Sometimes you want to check an instance of a node against a list of
|
2897
|
+
# classes to see what kind of behavior to perform. Usually this is done by
|
2898
|
+
# calling `[cls1, cls2].include?(node.class)` or putting the node into a
|
2899
|
+
# case statement and doing `case node; when cls1; when cls2; end`. Both of
|
2900
|
+
# these approaches are relatively slow because of the constant lookups,
|
2901
|
+
# method calls, and/or array allocations.
|
2902
|
+
#
|
2903
|
+
# Instead, you can call #type, which will return to you a symbol that you
|
2904
|
+
# can use for comparison. This is faster than the other approaches because
|
2905
|
+
# it uses a single integer comparison, but also because if you're on CRuby
|
2906
|
+
# you can take advantage of the fact that case statements with all symbol
|
2907
|
+
# keys will use a jump table.
|
2908
|
+
#
|
2909
|
+
# def type: () -> Symbol
|
2910
|
+
def type
|
2911
|
+
:capture_pattern_node
|
2912
|
+
end
|
2913
|
+
|
2914
|
+
# Similar to #type, this method returns a symbol that you can use for
|
2915
|
+
# splitting on the type of the node without having to do a long === chain.
|
2916
|
+
# Note that like #type, it will still be slower than using == for a single
|
2917
|
+
# class, but should be faster in a case statement or an array comparison.
|
2918
|
+
#
|
2919
|
+
# def self.type: () -> Symbol
|
2920
|
+
def self.type
|
2921
|
+
:capture_pattern_node
|
2922
|
+
end
|
2923
|
+
end
|
2924
|
+
|
2925
|
+
# Represents the use of a case statement for pattern matching.
|
2926
|
+
#
|
2927
|
+
# case true
|
2745
2928
|
# in false
|
2746
2929
|
# end
|
2747
2930
|
# ^^^^^^^^^
|
@@ -5070,6 +5253,9 @@ module Prism
|
|
5070
5253
|
# attr_reader locals: Array[Symbol]
|
5071
5254
|
attr_reader :locals
|
5072
5255
|
|
5256
|
+
# attr_reader locals_body_index: Integer
|
5257
|
+
attr_reader :locals_body_index
|
5258
|
+
|
5073
5259
|
# attr_reader def_keyword_loc: Location
|
5074
5260
|
attr_reader :def_keyword_loc
|
5075
5261
|
|
@@ -5088,14 +5274,15 @@ module Prism
|
|
5088
5274
|
# attr_reader end_keyword_loc: Location?
|
5089
5275
|
attr_reader :end_keyword_loc
|
5090
5276
|
|
5091
|
-
# def initialize: (name: Symbol, name_loc: Location, receiver: Node?, parameters: ParametersNode?, body: Node?, locals: Array[Symbol], def_keyword_loc: Location, operator_loc: Location?, lparen_loc: Location?, rparen_loc: Location?, equal_loc: Location?, end_keyword_loc: Location?, location: Location) -> void
|
5092
|
-
def initialize(name, name_loc, receiver, parameters, body, locals, def_keyword_loc, operator_loc, lparen_loc, rparen_loc, equal_loc, end_keyword_loc, location)
|
5277
|
+
# def initialize: (name: Symbol, name_loc: Location, receiver: Node?, parameters: ParametersNode?, body: Node?, locals: Array[Symbol], locals_body_index: Integer, def_keyword_loc: Location, operator_loc: Location?, lparen_loc: Location?, rparen_loc: Location?, equal_loc: Location?, end_keyword_loc: Location?, location: Location) -> void
|
5278
|
+
def initialize(name, name_loc, receiver, parameters, body, locals, locals_body_index, def_keyword_loc, operator_loc, lparen_loc, rparen_loc, equal_loc, end_keyword_loc, location)
|
5093
5279
|
@name = name
|
5094
5280
|
@name_loc = name_loc
|
5095
5281
|
@receiver = receiver
|
5096
5282
|
@parameters = parameters
|
5097
5283
|
@body = body
|
5098
5284
|
@locals = locals
|
5285
|
+
@locals_body_index = locals_body_index
|
5099
5286
|
@def_keyword_loc = def_keyword_loc
|
5100
5287
|
@operator_loc = operator_loc
|
5101
5288
|
@lparen_loc = lparen_loc
|
@@ -5138,6 +5325,7 @@ module Prism
|
|
5138
5325
|
params.fetch(:parameters) { parameters },
|
5139
5326
|
params.fetch(:body) { body },
|
5140
5327
|
params.fetch(:locals) { locals },
|
5328
|
+
params.fetch(:locals_body_index) { locals_body_index },
|
5141
5329
|
params.fetch(:def_keyword_loc) { def_keyword_loc },
|
5142
5330
|
params.fetch(:operator_loc) { operator_loc },
|
5143
5331
|
params.fetch(:lparen_loc) { lparen_loc },
|
@@ -5153,7 +5341,7 @@ module Prism
|
|
5153
5341
|
|
5154
5342
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
5155
5343
|
def deconstruct_keys(keys)
|
5156
|
-
{ name: name, name_loc: name_loc, receiver: receiver, parameters: parameters, body: body, locals: locals, def_keyword_loc: def_keyword_loc, operator_loc: operator_loc, lparen_loc: lparen_loc, rparen_loc: rparen_loc, equal_loc: equal_loc, end_keyword_loc: end_keyword_loc, location: location }
|
5344
|
+
{ name: name, name_loc: name_loc, receiver: receiver, parameters: parameters, body: body, locals: locals, locals_body_index: locals_body_index, def_keyword_loc: def_keyword_loc, operator_loc: operator_loc, lparen_loc: lparen_loc, rparen_loc: rparen_loc, equal_loc: equal_loc, end_keyword_loc: end_keyword_loc, location: location }
|
5157
5345
|
end
|
5158
5346
|
|
5159
5347
|
# def def_keyword: () -> String
|
@@ -5210,6 +5398,7 @@ module Prism
|
|
5210
5398
|
inspector << body.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
|
5211
5399
|
end
|
5212
5400
|
inspector << "├── locals: #{locals.inspect}\n"
|
5401
|
+
inspector << "├── locals_body_index: #{locals_body_index.inspect}\n"
|
5213
5402
|
inspector << "├── def_keyword_loc: #{inspector.location(def_keyword_loc)}\n"
|
5214
5403
|
inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
|
5215
5404
|
inspector << "├── lparen_loc: #{inspector.location(lparen_loc)}\n"
|
@@ -6044,6 +6233,9 @@ module Prism
|
|
6044
6233
|
# baz if foo .. bar
|
6045
6234
|
# ^^^^^^^^^^
|
6046
6235
|
class FlipFlopNode < Node
|
6236
|
+
# attr_reader flags: Integer
|
6237
|
+
private attr_reader :flags
|
6238
|
+
|
6047
6239
|
# attr_reader left: Node?
|
6048
6240
|
attr_reader :left
|
6049
6241
|
|
@@ -6053,15 +6245,12 @@ module Prism
|
|
6053
6245
|
# attr_reader operator_loc: Location
|
6054
6246
|
attr_reader :operator_loc
|
6055
6247
|
|
6056
|
-
#
|
6057
|
-
|
6058
|
-
|
6059
|
-
# def initialize: (left: Node?, right: Node?, operator_loc: Location, flags: Integer, location: Location) -> void
|
6060
|
-
def initialize(left, right, operator_loc, flags, location)
|
6248
|
+
# def initialize: (flags: Integer, left: Node?, right: Node?, operator_loc: Location, location: Location) -> void
|
6249
|
+
def initialize(flags, left, right, operator_loc, location)
|
6250
|
+
@flags = flags
|
6061
6251
|
@left = left
|
6062
6252
|
@right = right
|
6063
6253
|
@operator_loc = operator_loc
|
6064
|
-
@flags = flags
|
6065
6254
|
@location = location
|
6066
6255
|
end
|
6067
6256
|
|
@@ -6091,10 +6280,10 @@ module Prism
|
|
6091
6280
|
# def copy: (**params) -> FlipFlopNode
|
6092
6281
|
def copy(**params)
|
6093
6282
|
FlipFlopNode.new(
|
6283
|
+
params.fetch(:flags) { flags },
|
6094
6284
|
params.fetch(:left) { left },
|
6095
6285
|
params.fetch(:right) { right },
|
6096
6286
|
params.fetch(:operator_loc) { operator_loc },
|
6097
|
-
params.fetch(:flags) { flags },
|
6098
6287
|
params.fetch(:location) { location },
|
6099
6288
|
)
|
6100
6289
|
end
|
@@ -6104,12 +6293,7 @@ module Prism
|
|
6104
6293
|
|
6105
6294
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
6106
6295
|
def deconstruct_keys(keys)
|
6107
|
-
{ left: left, right: right, operator_loc: operator_loc,
|
6108
|
-
end
|
6109
|
-
|
6110
|
-
# def operator: () -> String
|
6111
|
-
def operator
|
6112
|
-
operator_loc.slice
|
6296
|
+
{ flags: flags, left: left, right: right, operator_loc: operator_loc, location: location }
|
6113
6297
|
end
|
6114
6298
|
|
6115
6299
|
# def exclude_end?: () -> bool
|
@@ -6117,9 +6301,16 @@ module Prism
|
|
6117
6301
|
flags.anybits?(RangeFlags::EXCLUDE_END)
|
6118
6302
|
end
|
6119
6303
|
|
6304
|
+
# def operator: () -> String
|
6305
|
+
def operator
|
6306
|
+
operator_loc.slice
|
6307
|
+
end
|
6308
|
+
|
6120
6309
|
# def inspect(inspector: NodeInspector) -> String
|
6121
6310
|
def inspect(inspector = NodeInspector.new)
|
6122
6311
|
inspector << inspector.header(self)
|
6312
|
+
flags = [("exclude_end" if exclude_end?)].compact
|
6313
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
6123
6314
|
if (left = self.left).nil?
|
6124
6315
|
inspector << "├── left: ∅\n"
|
6125
6316
|
else
|
@@ -6132,9 +6323,7 @@ module Prism
|
|
6132
6323
|
inspector << "├── right:\n"
|
6133
6324
|
inspector << right.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
|
6134
6325
|
end
|
6135
|
-
inspector << "
|
6136
|
-
flags = [("exclude_end" if exclude_end?)].compact
|
6137
|
-
inspector << "└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
6326
|
+
inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
|
6138
6327
|
inspector.to_str
|
6139
6328
|
end
|
6140
6329
|
|
@@ -7845,6 +8034,95 @@ module Prism
|
|
7845
8034
|
end
|
7846
8035
|
end
|
7847
8036
|
|
8037
|
+
# Represents using a trailing comma to indicate an implicit rest parameter.
|
8038
|
+
#
|
8039
|
+
# foo { |bar,| }
|
8040
|
+
# ^
|
8041
|
+
#
|
8042
|
+
# foo in [bar,]
|
8043
|
+
# ^
|
8044
|
+
#
|
8045
|
+
# for foo, in bar do end
|
8046
|
+
# ^
|
8047
|
+
#
|
8048
|
+
# foo, = bar
|
8049
|
+
# ^
|
8050
|
+
class ImplicitRestNode < Node
|
8051
|
+
# def initialize: (location: Location) -> void
|
8052
|
+
def initialize(location)
|
8053
|
+
@location = location
|
8054
|
+
end
|
8055
|
+
|
8056
|
+
# def accept: (visitor: Visitor) -> void
|
8057
|
+
def accept(visitor)
|
8058
|
+
visitor.visit_implicit_rest_node(self)
|
8059
|
+
end
|
8060
|
+
|
8061
|
+
# def child_nodes: () -> Array[nil | Node]
|
8062
|
+
def child_nodes
|
8063
|
+
[]
|
8064
|
+
end
|
8065
|
+
|
8066
|
+
# def compact_child_nodes: () -> Array[Node]
|
8067
|
+
def compact_child_nodes
|
8068
|
+
[]
|
8069
|
+
end
|
8070
|
+
|
8071
|
+
# def comment_targets: () -> Array[Node | Location]
|
8072
|
+
def comment_targets
|
8073
|
+
[]
|
8074
|
+
end
|
8075
|
+
|
8076
|
+
# def copy: (**params) -> ImplicitRestNode
|
8077
|
+
def copy(**params)
|
8078
|
+
ImplicitRestNode.new(
|
8079
|
+
params.fetch(:location) { location },
|
8080
|
+
)
|
8081
|
+
end
|
8082
|
+
|
8083
|
+
# def deconstruct: () -> Array[nil | Node]
|
8084
|
+
alias deconstruct child_nodes
|
8085
|
+
|
8086
|
+
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
8087
|
+
def deconstruct_keys(keys)
|
8088
|
+
{ location: location }
|
8089
|
+
end
|
8090
|
+
|
8091
|
+
# def inspect(inspector: NodeInspector) -> String
|
8092
|
+
def inspect(inspector = NodeInspector.new)
|
8093
|
+
inspector << inspector.header(self)
|
8094
|
+
inspector.to_str
|
8095
|
+
end
|
8096
|
+
|
8097
|
+
# Sometimes you want to check an instance of a node against a list of
|
8098
|
+
# classes to see what kind of behavior to perform. Usually this is done by
|
8099
|
+
# calling `[cls1, cls2].include?(node.class)` or putting the node into a
|
8100
|
+
# case statement and doing `case node; when cls1; when cls2; end`. Both of
|
8101
|
+
# these approaches are relatively slow because of the constant lookups,
|
8102
|
+
# method calls, and/or array allocations.
|
8103
|
+
#
|
8104
|
+
# Instead, you can call #type, which will return to you a symbol that you
|
8105
|
+
# can use for comparison. This is faster than the other approaches because
|
8106
|
+
# it uses a single integer comparison, but also because if you're on CRuby
|
8107
|
+
# you can take advantage of the fact that case statements with all symbol
|
8108
|
+
# keys will use a jump table.
|
8109
|
+
#
|
8110
|
+
# def type: () -> Symbol
|
8111
|
+
def type
|
8112
|
+
:implicit_rest_node
|
8113
|
+
end
|
8114
|
+
|
8115
|
+
# Similar to #type, this method returns a symbol that you can use for
|
8116
|
+
# splitting on the type of the node without having to do a long === chain.
|
8117
|
+
# Note that like #type, it will still be slower than using == for a single
|
8118
|
+
# class, but should be faster in a case statement or an array comparison.
|
8119
|
+
#
|
8120
|
+
# def self.type: () -> Symbol
|
8121
|
+
def self.type
|
8122
|
+
:implicit_rest_node
|
8123
|
+
end
|
8124
|
+
end
|
8125
|
+
|
7848
8126
|
# Represents the use of the `in` keyword in a case statement.
|
7849
8127
|
#
|
7850
8128
|
# case a; in b then c end
|
@@ -7973,6 +8251,9 @@ module Prism
|
|
7973
8251
|
# foo.bar[baz] &&= value
|
7974
8252
|
# ^^^^^^^^^^^^^^^^^^^^^^
|
7975
8253
|
class IndexAndWriteNode < Node
|
8254
|
+
# attr_reader flags: Integer
|
8255
|
+
private attr_reader :flags
|
8256
|
+
|
7976
8257
|
# attr_reader receiver: Node?
|
7977
8258
|
attr_reader :receiver
|
7978
8259
|
|
@@ -7991,24 +8272,21 @@ module Prism
|
|
7991
8272
|
# attr_reader block: Node?
|
7992
8273
|
attr_reader :block
|
7993
8274
|
|
7994
|
-
# attr_reader flags: Integer
|
7995
|
-
private attr_reader :flags
|
7996
|
-
|
7997
8275
|
# attr_reader operator_loc: Location
|
7998
8276
|
attr_reader :operator_loc
|
7999
8277
|
|
8000
8278
|
# attr_reader value: Node
|
8001
8279
|
attr_reader :value
|
8002
8280
|
|
8003
|
-
# def initialize: (receiver: Node?, call_operator_loc: Location?, opening_loc: Location, arguments: ArgumentsNode?, closing_loc: Location, block: Node?,
|
8004
|
-
def initialize(receiver, call_operator_loc, opening_loc, arguments, closing_loc, block,
|
8281
|
+
# def initialize: (flags: Integer, receiver: Node?, call_operator_loc: Location?, opening_loc: Location, arguments: ArgumentsNode?, closing_loc: Location, block: Node?, operator_loc: Location, value: Node, location: Location) -> void
|
8282
|
+
def initialize(flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator_loc, value, location)
|
8283
|
+
@flags = flags
|
8005
8284
|
@receiver = receiver
|
8006
8285
|
@call_operator_loc = call_operator_loc
|
8007
8286
|
@opening_loc = opening_loc
|
8008
8287
|
@arguments = arguments
|
8009
8288
|
@closing_loc = closing_loc
|
8010
8289
|
@block = block
|
8011
|
-
@flags = flags
|
8012
8290
|
@operator_loc = operator_loc
|
8013
8291
|
@value = value
|
8014
8292
|
@location = location
|
@@ -8042,13 +8320,13 @@ module Prism
|
|
8042
8320
|
# def copy: (**params) -> IndexAndWriteNode
|
8043
8321
|
def copy(**params)
|
8044
8322
|
IndexAndWriteNode.new(
|
8323
|
+
params.fetch(:flags) { flags },
|
8045
8324
|
params.fetch(:receiver) { receiver },
|
8046
8325
|
params.fetch(:call_operator_loc) { call_operator_loc },
|
8047
8326
|
params.fetch(:opening_loc) { opening_loc },
|
8048
8327
|
params.fetch(:arguments) { arguments },
|
8049
8328
|
params.fetch(:closing_loc) { closing_loc },
|
8050
8329
|
params.fetch(:block) { block },
|
8051
|
-
params.fetch(:flags) { flags },
|
8052
8330
|
params.fetch(:operator_loc) { operator_loc },
|
8053
8331
|
params.fetch(:value) { value },
|
8054
8332
|
params.fetch(:location) { location },
|
@@ -8060,7 +8338,22 @@ module Prism
|
|
8060
8338
|
|
8061
8339
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
8062
8340
|
def deconstruct_keys(keys)
|
8063
|
-
{ receiver: receiver, call_operator_loc: call_operator_loc, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block,
|
8341
|
+
{ flags: flags, receiver: receiver, call_operator_loc: call_operator_loc, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block, operator_loc: operator_loc, value: value, location: location }
|
8342
|
+
end
|
8343
|
+
|
8344
|
+
# def safe_navigation?: () -> bool
|
8345
|
+
def safe_navigation?
|
8346
|
+
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
8347
|
+
end
|
8348
|
+
|
8349
|
+
# def variable_call?: () -> bool
|
8350
|
+
def variable_call?
|
8351
|
+
flags.anybits?(CallNodeFlags::VARIABLE_CALL)
|
8352
|
+
end
|
8353
|
+
|
8354
|
+
# def attribute_write?: () -> bool
|
8355
|
+
def attribute_write?
|
8356
|
+
flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE)
|
8064
8357
|
end
|
8065
8358
|
|
8066
8359
|
# def call_operator: () -> String?
|
@@ -8078,16 +8371,6 @@ module Prism
|
|
8078
8371
|
closing_loc.slice
|
8079
8372
|
end
|
8080
8373
|
|
8081
|
-
# def safe_navigation?: () -> bool
|
8082
|
-
def safe_navigation?
|
8083
|
-
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
8084
|
-
end
|
8085
|
-
|
8086
|
-
# def variable_call?: () -> bool
|
8087
|
-
def variable_call?
|
8088
|
-
flags.anybits?(CallNodeFlags::VARIABLE_CALL)
|
8089
|
-
end
|
8090
|
-
|
8091
8374
|
# def operator: () -> String
|
8092
8375
|
def operator
|
8093
8376
|
operator_loc.slice
|
@@ -8096,6 +8379,8 @@ module Prism
|
|
8096
8379
|
# def inspect(inspector: NodeInspector) -> String
|
8097
8380
|
def inspect(inspector = NodeInspector.new)
|
8098
8381
|
inspector << inspector.header(self)
|
8382
|
+
flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?)].compact
|
8383
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
8099
8384
|
if (receiver = self.receiver).nil?
|
8100
8385
|
inspector << "├── receiver: ∅\n"
|
8101
8386
|
else
|
@@ -8117,8 +8402,6 @@ module Prism
|
|
8117
8402
|
inspector << "├── block:\n"
|
8118
8403
|
inspector << block.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
|
8119
8404
|
end
|
8120
|
-
flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?)].compact
|
8121
|
-
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
8122
8405
|
inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
|
8123
8406
|
inspector << "└── value:\n"
|
8124
8407
|
inspector << inspector.child_node(value, " ")
|
@@ -8159,6 +8442,9 @@ module Prism
|
|
8159
8442
|
# foo.bar[baz] += value
|
8160
8443
|
# ^^^^^^^^^^^^^^^^^^^^^
|
8161
8444
|
class IndexOperatorWriteNode < Node
|
8445
|
+
# attr_reader flags: Integer
|
8446
|
+
private attr_reader :flags
|
8447
|
+
|
8162
8448
|
# attr_reader receiver: Node?
|
8163
8449
|
attr_reader :receiver
|
8164
8450
|
|
@@ -8177,9 +8463,6 @@ module Prism
|
|
8177
8463
|
# attr_reader block: Node?
|
8178
8464
|
attr_reader :block
|
8179
8465
|
|
8180
|
-
# attr_reader flags: Integer
|
8181
|
-
private attr_reader :flags
|
8182
|
-
|
8183
8466
|
# attr_reader operator: Symbol
|
8184
8467
|
attr_reader :operator
|
8185
8468
|
|
@@ -8189,15 +8472,15 @@ module Prism
|
|
8189
8472
|
# attr_reader value: Node
|
8190
8473
|
attr_reader :value
|
8191
8474
|
|
8192
|
-
# def initialize: (receiver: Node?, call_operator_loc: Location?, opening_loc: Location, arguments: ArgumentsNode?, closing_loc: Location, block: Node?,
|
8193
|
-
def initialize(receiver, call_operator_loc, opening_loc, arguments, closing_loc, block,
|
8475
|
+
# def initialize: (flags: Integer, receiver: Node?, call_operator_loc: Location?, opening_loc: Location, arguments: ArgumentsNode?, closing_loc: Location, block: Node?, operator: Symbol, operator_loc: Location, value: Node, location: Location) -> void
|
8476
|
+
def initialize(flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator, operator_loc, value, location)
|
8477
|
+
@flags = flags
|
8194
8478
|
@receiver = receiver
|
8195
8479
|
@call_operator_loc = call_operator_loc
|
8196
8480
|
@opening_loc = opening_loc
|
8197
8481
|
@arguments = arguments
|
8198
8482
|
@closing_loc = closing_loc
|
8199
8483
|
@block = block
|
8200
|
-
@flags = flags
|
8201
8484
|
@operator = operator
|
8202
8485
|
@operator_loc = operator_loc
|
8203
8486
|
@value = value
|
@@ -8232,13 +8515,13 @@ module Prism
|
|
8232
8515
|
# def copy: (**params) -> IndexOperatorWriteNode
|
8233
8516
|
def copy(**params)
|
8234
8517
|
IndexOperatorWriteNode.new(
|
8518
|
+
params.fetch(:flags) { flags },
|
8235
8519
|
params.fetch(:receiver) { receiver },
|
8236
8520
|
params.fetch(:call_operator_loc) { call_operator_loc },
|
8237
8521
|
params.fetch(:opening_loc) { opening_loc },
|
8238
8522
|
params.fetch(:arguments) { arguments },
|
8239
8523
|
params.fetch(:closing_loc) { closing_loc },
|
8240
8524
|
params.fetch(:block) { block },
|
8241
|
-
params.fetch(:flags) { flags },
|
8242
8525
|
params.fetch(:operator) { operator },
|
8243
8526
|
params.fetch(:operator_loc) { operator_loc },
|
8244
8527
|
params.fetch(:value) { value },
|
@@ -8251,7 +8534,22 @@ module Prism
|
|
8251
8534
|
|
8252
8535
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
8253
8536
|
def deconstruct_keys(keys)
|
8254
|
-
{ receiver: receiver, call_operator_loc: call_operator_loc, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block,
|
8537
|
+
{ flags: flags, receiver: receiver, call_operator_loc: call_operator_loc, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block, operator: operator, operator_loc: operator_loc, value: value, location: location }
|
8538
|
+
end
|
8539
|
+
|
8540
|
+
# def safe_navigation?: () -> bool
|
8541
|
+
def safe_navigation?
|
8542
|
+
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
8543
|
+
end
|
8544
|
+
|
8545
|
+
# def variable_call?: () -> bool
|
8546
|
+
def variable_call?
|
8547
|
+
flags.anybits?(CallNodeFlags::VARIABLE_CALL)
|
8548
|
+
end
|
8549
|
+
|
8550
|
+
# def attribute_write?: () -> bool
|
8551
|
+
def attribute_write?
|
8552
|
+
flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE)
|
8255
8553
|
end
|
8256
8554
|
|
8257
8555
|
# def call_operator: () -> String?
|
@@ -8269,19 +8567,11 @@ module Prism
|
|
8269
8567
|
closing_loc.slice
|
8270
8568
|
end
|
8271
8569
|
|
8272
|
-
# def safe_navigation?: () -> bool
|
8273
|
-
def safe_navigation?
|
8274
|
-
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
8275
|
-
end
|
8276
|
-
|
8277
|
-
# def variable_call?: () -> bool
|
8278
|
-
def variable_call?
|
8279
|
-
flags.anybits?(CallNodeFlags::VARIABLE_CALL)
|
8280
|
-
end
|
8281
|
-
|
8282
8570
|
# def inspect(inspector: NodeInspector) -> String
|
8283
8571
|
def inspect(inspector = NodeInspector.new)
|
8284
8572
|
inspector << inspector.header(self)
|
8573
|
+
flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?)].compact
|
8574
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
8285
8575
|
if (receiver = self.receiver).nil?
|
8286
8576
|
inspector << "├── receiver: ∅\n"
|
8287
8577
|
else
|
@@ -8303,8 +8593,6 @@ module Prism
|
|
8303
8593
|
inspector << "├── block:\n"
|
8304
8594
|
inspector << block.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
|
8305
8595
|
end
|
8306
|
-
flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?)].compact
|
8307
|
-
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
8308
8596
|
inspector << "├── operator: #{operator.inspect}\n"
|
8309
8597
|
inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
|
8310
8598
|
inspector << "└── value:\n"
|
@@ -8346,6 +8634,9 @@ module Prism
|
|
8346
8634
|
# foo.bar[baz] ||= value
|
8347
8635
|
# ^^^^^^^^^^^^^^^^^^^^^^
|
8348
8636
|
class IndexOrWriteNode < Node
|
8637
|
+
# attr_reader flags: Integer
|
8638
|
+
private attr_reader :flags
|
8639
|
+
|
8349
8640
|
# attr_reader receiver: Node?
|
8350
8641
|
attr_reader :receiver
|
8351
8642
|
|
@@ -8364,24 +8655,21 @@ module Prism
|
|
8364
8655
|
# attr_reader block: Node?
|
8365
8656
|
attr_reader :block
|
8366
8657
|
|
8367
|
-
# attr_reader flags: Integer
|
8368
|
-
private attr_reader :flags
|
8369
|
-
|
8370
8658
|
# attr_reader operator_loc: Location
|
8371
8659
|
attr_reader :operator_loc
|
8372
8660
|
|
8373
8661
|
# attr_reader value: Node
|
8374
8662
|
attr_reader :value
|
8375
8663
|
|
8376
|
-
# def initialize: (receiver: Node?, call_operator_loc: Location?, opening_loc: Location, arguments: ArgumentsNode?, closing_loc: Location, block: Node?,
|
8377
|
-
def initialize(receiver, call_operator_loc, opening_loc, arguments, closing_loc, block,
|
8664
|
+
# def initialize: (flags: Integer, receiver: Node?, call_operator_loc: Location?, opening_loc: Location, arguments: ArgumentsNode?, closing_loc: Location, block: Node?, operator_loc: Location, value: Node, location: Location) -> void
|
8665
|
+
def initialize(flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator_loc, value, location)
|
8666
|
+
@flags = flags
|
8378
8667
|
@receiver = receiver
|
8379
8668
|
@call_operator_loc = call_operator_loc
|
8380
8669
|
@opening_loc = opening_loc
|
8381
8670
|
@arguments = arguments
|
8382
8671
|
@closing_loc = closing_loc
|
8383
8672
|
@block = block
|
8384
|
-
@flags = flags
|
8385
8673
|
@operator_loc = operator_loc
|
8386
8674
|
@value = value
|
8387
8675
|
@location = location
|
@@ -8415,13 +8703,13 @@ module Prism
|
|
8415
8703
|
# def copy: (**params) -> IndexOrWriteNode
|
8416
8704
|
def copy(**params)
|
8417
8705
|
IndexOrWriteNode.new(
|
8706
|
+
params.fetch(:flags) { flags },
|
8418
8707
|
params.fetch(:receiver) { receiver },
|
8419
8708
|
params.fetch(:call_operator_loc) { call_operator_loc },
|
8420
8709
|
params.fetch(:opening_loc) { opening_loc },
|
8421
8710
|
params.fetch(:arguments) { arguments },
|
8422
8711
|
params.fetch(:closing_loc) { closing_loc },
|
8423
8712
|
params.fetch(:block) { block },
|
8424
|
-
params.fetch(:flags) { flags },
|
8425
8713
|
params.fetch(:operator_loc) { operator_loc },
|
8426
8714
|
params.fetch(:value) { value },
|
8427
8715
|
params.fetch(:location) { location },
|
@@ -8433,7 +8721,22 @@ module Prism
|
|
8433
8721
|
|
8434
8722
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
8435
8723
|
def deconstruct_keys(keys)
|
8436
|
-
{ receiver: receiver, call_operator_loc: call_operator_loc, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block,
|
8724
|
+
{ flags: flags, receiver: receiver, call_operator_loc: call_operator_loc, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block, operator_loc: operator_loc, value: value, location: location }
|
8725
|
+
end
|
8726
|
+
|
8727
|
+
# def safe_navigation?: () -> bool
|
8728
|
+
def safe_navigation?
|
8729
|
+
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
8730
|
+
end
|
8731
|
+
|
8732
|
+
# def variable_call?: () -> bool
|
8733
|
+
def variable_call?
|
8734
|
+
flags.anybits?(CallNodeFlags::VARIABLE_CALL)
|
8735
|
+
end
|
8736
|
+
|
8737
|
+
# def attribute_write?: () -> bool
|
8738
|
+
def attribute_write?
|
8739
|
+
flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE)
|
8437
8740
|
end
|
8438
8741
|
|
8439
8742
|
# def call_operator: () -> String?
|
@@ -8451,6 +8754,159 @@ module Prism
|
|
8451
8754
|
closing_loc.slice
|
8452
8755
|
end
|
8453
8756
|
|
8757
|
+
# def operator: () -> String
|
8758
|
+
def operator
|
8759
|
+
operator_loc.slice
|
8760
|
+
end
|
8761
|
+
|
8762
|
+
# def inspect(inspector: NodeInspector) -> String
|
8763
|
+
def inspect(inspector = NodeInspector.new)
|
8764
|
+
inspector << inspector.header(self)
|
8765
|
+
flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?)].compact
|
8766
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
8767
|
+
if (receiver = self.receiver).nil?
|
8768
|
+
inspector << "├── receiver: ∅\n"
|
8769
|
+
else
|
8770
|
+
inspector << "├── receiver:\n"
|
8771
|
+
inspector << receiver.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
|
8772
|
+
end
|
8773
|
+
inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n"
|
8774
|
+
inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
|
8775
|
+
if (arguments = self.arguments).nil?
|
8776
|
+
inspector << "├── arguments: ∅\n"
|
8777
|
+
else
|
8778
|
+
inspector << "├── arguments:\n"
|
8779
|
+
inspector << arguments.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
|
8780
|
+
end
|
8781
|
+
inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
|
8782
|
+
if (block = self.block).nil?
|
8783
|
+
inspector << "├── block: ∅\n"
|
8784
|
+
else
|
8785
|
+
inspector << "├── block:\n"
|
8786
|
+
inspector << block.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
|
8787
|
+
end
|
8788
|
+
inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
|
8789
|
+
inspector << "└── value:\n"
|
8790
|
+
inspector << inspector.child_node(value, " ")
|
8791
|
+
inspector.to_str
|
8792
|
+
end
|
8793
|
+
|
8794
|
+
# Sometimes you want to check an instance of a node against a list of
|
8795
|
+
# classes to see what kind of behavior to perform. Usually this is done by
|
8796
|
+
# calling `[cls1, cls2].include?(node.class)` or putting the node into a
|
8797
|
+
# case statement and doing `case node; when cls1; when cls2; end`. Both of
|
8798
|
+
# these approaches are relatively slow because of the constant lookups,
|
8799
|
+
# method calls, and/or array allocations.
|
8800
|
+
#
|
8801
|
+
# Instead, you can call #type, which will return to you a symbol that you
|
8802
|
+
# can use for comparison. This is faster than the other approaches because
|
8803
|
+
# it uses a single integer comparison, but also because if you're on CRuby
|
8804
|
+
# you can take advantage of the fact that case statements with all symbol
|
8805
|
+
# keys will use a jump table.
|
8806
|
+
#
|
8807
|
+
# def type: () -> Symbol
|
8808
|
+
def type
|
8809
|
+
:index_or_write_node
|
8810
|
+
end
|
8811
|
+
|
8812
|
+
# Similar to #type, this method returns a symbol that you can use for
|
8813
|
+
# splitting on the type of the node without having to do a long === chain.
|
8814
|
+
# Note that like #type, it will still be slower than using == for a single
|
8815
|
+
# class, but should be faster in a case statement or an array comparison.
|
8816
|
+
#
|
8817
|
+
# def self.type: () -> Symbol
|
8818
|
+
def self.type
|
8819
|
+
:index_or_write_node
|
8820
|
+
end
|
8821
|
+
end
|
8822
|
+
|
8823
|
+
# Represents assigning to an index.
|
8824
|
+
#
|
8825
|
+
# foo[bar], = 1
|
8826
|
+
# ^^^^^^^^
|
8827
|
+
#
|
8828
|
+
# begin
|
8829
|
+
# rescue => foo[bar]
|
8830
|
+
# ^^^^^^^^
|
8831
|
+
# end
|
8832
|
+
#
|
8833
|
+
# for foo[bar] in baz do end
|
8834
|
+
# ^^^^^^^^
|
8835
|
+
class IndexTargetNode < Node
|
8836
|
+
# attr_reader flags: Integer
|
8837
|
+
private attr_reader :flags
|
8838
|
+
|
8839
|
+
# attr_reader receiver: Node
|
8840
|
+
attr_reader :receiver
|
8841
|
+
|
8842
|
+
# attr_reader opening_loc: Location
|
8843
|
+
attr_reader :opening_loc
|
8844
|
+
|
8845
|
+
# attr_reader arguments: ArgumentsNode?
|
8846
|
+
attr_reader :arguments
|
8847
|
+
|
8848
|
+
# attr_reader closing_loc: Location
|
8849
|
+
attr_reader :closing_loc
|
8850
|
+
|
8851
|
+
# attr_reader block: Node?
|
8852
|
+
attr_reader :block
|
8853
|
+
|
8854
|
+
# def initialize: (flags: Integer, receiver: Node, opening_loc: Location, arguments: ArgumentsNode?, closing_loc: Location, block: Node?, location: Location) -> void
|
8855
|
+
def initialize(flags, receiver, opening_loc, arguments, closing_loc, block, location)
|
8856
|
+
@flags = flags
|
8857
|
+
@receiver = receiver
|
8858
|
+
@opening_loc = opening_loc
|
8859
|
+
@arguments = arguments
|
8860
|
+
@closing_loc = closing_loc
|
8861
|
+
@block = block
|
8862
|
+
@location = location
|
8863
|
+
end
|
8864
|
+
|
8865
|
+
# def accept: (visitor: Visitor) -> void
|
8866
|
+
def accept(visitor)
|
8867
|
+
visitor.visit_index_target_node(self)
|
8868
|
+
end
|
8869
|
+
|
8870
|
+
# def child_nodes: () -> Array[nil | Node]
|
8871
|
+
def child_nodes
|
8872
|
+
[receiver, arguments, block]
|
8873
|
+
end
|
8874
|
+
|
8875
|
+
# def compact_child_nodes: () -> Array[Node]
|
8876
|
+
def compact_child_nodes
|
8877
|
+
compact = []
|
8878
|
+
compact << receiver
|
8879
|
+
compact << arguments if arguments
|
8880
|
+
compact << block if block
|
8881
|
+
compact
|
8882
|
+
end
|
8883
|
+
|
8884
|
+
# def comment_targets: () -> Array[Node | Location]
|
8885
|
+
def comment_targets
|
8886
|
+
[receiver, opening_loc, *arguments, closing_loc, *block]
|
8887
|
+
end
|
8888
|
+
|
8889
|
+
# def copy: (**params) -> IndexTargetNode
|
8890
|
+
def copy(**params)
|
8891
|
+
IndexTargetNode.new(
|
8892
|
+
params.fetch(:flags) { flags },
|
8893
|
+
params.fetch(:receiver) { receiver },
|
8894
|
+
params.fetch(:opening_loc) { opening_loc },
|
8895
|
+
params.fetch(:arguments) { arguments },
|
8896
|
+
params.fetch(:closing_loc) { closing_loc },
|
8897
|
+
params.fetch(:block) { block },
|
8898
|
+
params.fetch(:location) { location },
|
8899
|
+
)
|
8900
|
+
end
|
8901
|
+
|
8902
|
+
# def deconstruct: () -> Array[nil | Node]
|
8903
|
+
alias deconstruct child_nodes
|
8904
|
+
|
8905
|
+
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
8906
|
+
def deconstruct_keys(keys)
|
8907
|
+
{ flags: flags, receiver: receiver, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block, location: location }
|
8908
|
+
end
|
8909
|
+
|
8454
8910
|
# def safe_navigation?: () -> bool
|
8455
8911
|
def safe_navigation?
|
8456
8912
|
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
@@ -8461,21 +8917,28 @@ module Prism
|
|
8461
8917
|
flags.anybits?(CallNodeFlags::VARIABLE_CALL)
|
8462
8918
|
end
|
8463
8919
|
|
8464
|
-
# def
|
8465
|
-
def
|
8466
|
-
|
8920
|
+
# def attribute_write?: () -> bool
|
8921
|
+
def attribute_write?
|
8922
|
+
flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE)
|
8923
|
+
end
|
8924
|
+
|
8925
|
+
# def opening: () -> String
|
8926
|
+
def opening
|
8927
|
+
opening_loc.slice
|
8928
|
+
end
|
8929
|
+
|
8930
|
+
# def closing: () -> String
|
8931
|
+
def closing
|
8932
|
+
closing_loc.slice
|
8467
8933
|
end
|
8468
8934
|
|
8469
8935
|
# def inspect(inspector: NodeInspector) -> String
|
8470
8936
|
def inspect(inspector = NodeInspector.new)
|
8471
8937
|
inspector << inspector.header(self)
|
8472
|
-
if (
|
8473
|
-
|
8474
|
-
|
8475
|
-
|
8476
|
-
inspector << receiver.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
|
8477
|
-
end
|
8478
|
-
inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n"
|
8938
|
+
flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?)].compact
|
8939
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
8940
|
+
inspector << "├── receiver:\n"
|
8941
|
+
inspector << inspector.child_node(receiver, "│ ")
|
8479
8942
|
inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
|
8480
8943
|
if (arguments = self.arguments).nil?
|
8481
8944
|
inspector << "├── arguments: ∅\n"
|
@@ -8485,16 +8948,11 @@ module Prism
|
|
8485
8948
|
end
|
8486
8949
|
inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
|
8487
8950
|
if (block = self.block).nil?
|
8488
|
-
inspector << "
|
8951
|
+
inspector << "└── block: ∅\n"
|
8489
8952
|
else
|
8490
|
-
inspector << "
|
8491
|
-
inspector << block.inspect(inspector.child_inspector("
|
8953
|
+
inspector << "└── block:\n"
|
8954
|
+
inspector << block.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix)
|
8492
8955
|
end
|
8493
|
-
flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?)].compact
|
8494
|
-
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
8495
|
-
inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
|
8496
|
-
inspector << "└── value:\n"
|
8497
|
-
inspector << inspector.child_node(value, " ")
|
8498
8956
|
inspector.to_str
|
8499
8957
|
end
|
8500
8958
|
|
@@ -8513,7 +8971,7 @@ module Prism
|
|
8513
8971
|
#
|
8514
8972
|
# def type: () -> Symbol
|
8515
8973
|
def type
|
8516
|
-
:
|
8974
|
+
:index_target_node
|
8517
8975
|
end
|
8518
8976
|
|
8519
8977
|
# Similar to #type, this method returns a symbol that you can use for
|
@@ -8523,7 +8981,7 @@ module Prism
|
|
8523
8981
|
#
|
8524
8982
|
# def self.type: () -> Symbol
|
8525
8983
|
def self.type
|
8526
|
-
:
|
8984
|
+
:index_target_node
|
8527
8985
|
end
|
8528
8986
|
end
|
8529
8987
|
|
@@ -9195,16 +9653,16 @@ module Prism
|
|
9195
9653
|
flags.anybits?(IntegerBaseFlags::BINARY)
|
9196
9654
|
end
|
9197
9655
|
|
9198
|
-
# def octal?: () -> bool
|
9199
|
-
def octal?
|
9200
|
-
flags.anybits?(IntegerBaseFlags::OCTAL)
|
9201
|
-
end
|
9202
|
-
|
9203
9656
|
# def decimal?: () -> bool
|
9204
9657
|
def decimal?
|
9205
9658
|
flags.anybits?(IntegerBaseFlags::DECIMAL)
|
9206
9659
|
end
|
9207
9660
|
|
9661
|
+
# def octal?: () -> bool
|
9662
|
+
def octal?
|
9663
|
+
flags.anybits?(IntegerBaseFlags::OCTAL)
|
9664
|
+
end
|
9665
|
+
|
9208
9666
|
# def hexadecimal?: () -> bool
|
9209
9667
|
def hexadecimal?
|
9210
9668
|
flags.anybits?(IntegerBaseFlags::HEXADECIMAL)
|
@@ -9213,7 +9671,7 @@ module Prism
|
|
9213
9671
|
# def inspect(inspector: NodeInspector) -> String
|
9214
9672
|
def inspect(inspector = NodeInspector.new)
|
9215
9673
|
inspector << inspector.header(self)
|
9216
|
-
flags = [("binary" if binary?), ("
|
9674
|
+
flags = [("binary" if binary?), ("decimal" if decimal?), ("octal" if octal?), ("hexadecimal" if hexadecimal?)].compact
|
9217
9675
|
inspector << "└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
9218
9676
|
inspector.to_str
|
9219
9677
|
end
|
@@ -9254,6 +9712,9 @@ module Prism
|
|
9254
9712
|
# if /foo #{bar} baz/ then end
|
9255
9713
|
# ^^^^^^^^^^^^^^^^
|
9256
9714
|
class InterpolatedMatchLastLineNode < Node
|
9715
|
+
# attr_reader flags: Integer
|
9716
|
+
private attr_reader :flags
|
9717
|
+
|
9257
9718
|
# attr_reader opening_loc: Location
|
9258
9719
|
attr_reader :opening_loc
|
9259
9720
|
|
@@ -9263,15 +9724,12 @@ module Prism
|
|
9263
9724
|
# attr_reader closing_loc: Location
|
9264
9725
|
attr_reader :closing_loc
|
9265
9726
|
|
9266
|
-
#
|
9267
|
-
|
9268
|
-
|
9269
|
-
# def initialize: (opening_loc: Location, parts: Array[Node], closing_loc: Location, flags: Integer, location: Location) -> void
|
9270
|
-
def initialize(opening_loc, parts, closing_loc, flags, location)
|
9727
|
+
# def initialize: (flags: Integer, opening_loc: Location, parts: Array[Node], closing_loc: Location, location: Location) -> void
|
9728
|
+
def initialize(flags, opening_loc, parts, closing_loc, location)
|
9729
|
+
@flags = flags
|
9271
9730
|
@opening_loc = opening_loc
|
9272
9731
|
@parts = parts
|
9273
9732
|
@closing_loc = closing_loc
|
9274
|
-
@flags = flags
|
9275
9733
|
@location = location
|
9276
9734
|
end
|
9277
9735
|
|
@@ -9303,10 +9761,10 @@ module Prism
|
|
9303
9761
|
# def copy: (**params) -> InterpolatedMatchLastLineNode
|
9304
9762
|
def copy(**params)
|
9305
9763
|
InterpolatedMatchLastLineNode.new(
|
9764
|
+
params.fetch(:flags) { flags },
|
9306
9765
|
params.fetch(:opening_loc) { opening_loc },
|
9307
9766
|
params.fetch(:parts) { parts },
|
9308
9767
|
params.fetch(:closing_loc) { closing_loc },
|
9309
|
-
params.fetch(:flags) { flags },
|
9310
9768
|
params.fetch(:location) { location },
|
9311
9769
|
)
|
9312
9770
|
end
|
@@ -9316,17 +9774,7 @@ module Prism
|
|
9316
9774
|
|
9317
9775
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
9318
9776
|
def deconstruct_keys(keys)
|
9319
|
-
{ opening_loc: opening_loc, parts: parts, closing_loc: closing_loc,
|
9320
|
-
end
|
9321
|
-
|
9322
|
-
# def opening: () -> String
|
9323
|
-
def opening
|
9324
|
-
opening_loc.slice
|
9325
|
-
end
|
9326
|
-
|
9327
|
-
# def closing: () -> String
|
9328
|
-
def closing
|
9329
|
-
closing_loc.slice
|
9777
|
+
{ flags: flags, opening_loc: opening_loc, parts: parts, closing_loc: closing_loc, location: location }
|
9330
9778
|
end
|
9331
9779
|
|
9332
9780
|
# def ignore_case?: () -> bool
|
@@ -9369,14 +9817,39 @@ module Prism
|
|
9369
9817
|
flags.anybits?(RegularExpressionFlags::UTF_8)
|
9370
9818
|
end
|
9371
9819
|
|
9820
|
+
# def forced_utf8_encoding?: () -> bool
|
9821
|
+
def forced_utf8_encoding?
|
9822
|
+
flags.anybits?(RegularExpressionFlags::FORCED_UTF8_ENCODING)
|
9823
|
+
end
|
9824
|
+
|
9825
|
+
# def forced_binary_encoding?: () -> bool
|
9826
|
+
def forced_binary_encoding?
|
9827
|
+
flags.anybits?(RegularExpressionFlags::FORCED_BINARY_ENCODING)
|
9828
|
+
end
|
9829
|
+
|
9830
|
+
# def forced_us_ascii_encoding?: () -> bool
|
9831
|
+
def forced_us_ascii_encoding?
|
9832
|
+
flags.anybits?(RegularExpressionFlags::FORCED_US_ASCII_ENCODING)
|
9833
|
+
end
|
9834
|
+
|
9835
|
+
# def opening: () -> String
|
9836
|
+
def opening
|
9837
|
+
opening_loc.slice
|
9838
|
+
end
|
9839
|
+
|
9840
|
+
# def closing: () -> String
|
9841
|
+
def closing
|
9842
|
+
closing_loc.slice
|
9843
|
+
end
|
9844
|
+
|
9372
9845
|
# def inspect(inspector: NodeInspector) -> String
|
9373
9846
|
def inspect(inspector = NodeInspector.new)
|
9374
9847
|
inspector << inspector.header(self)
|
9848
|
+
flags = [("ignore_case" if ignore_case?), ("extended" if extended?), ("multi_line" if multi_line?), ("once" if once?), ("euc_jp" if euc_jp?), ("ascii_8bit" if ascii_8bit?), ("windows_31j" if windows_31j?), ("utf_8" if utf_8?), ("forced_utf8_encoding" if forced_utf8_encoding?), ("forced_binary_encoding" if forced_binary_encoding?), ("forced_us_ascii_encoding" if forced_us_ascii_encoding?)].compact
|
9849
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
9375
9850
|
inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
|
9376
9851
|
inspector << "├── parts: #{inspector.list("#{inspector.prefix}│ ", parts)}"
|
9377
|
-
inspector << "
|
9378
|
-
flags = [("ignore_case" if ignore_case?), ("extended" if extended?), ("multi_line" if multi_line?), ("once" if once?), ("euc_jp" if euc_jp?), ("ascii_8bit" if ascii_8bit?), ("windows_31j" if windows_31j?), ("utf_8" if utf_8?)].compact
|
9379
|
-
inspector << "└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
9852
|
+
inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
|
9380
9853
|
inspector.to_str
|
9381
9854
|
end
|
9382
9855
|
|
@@ -9414,6 +9887,9 @@ module Prism
|
|
9414
9887
|
# /foo #{bar} baz/
|
9415
9888
|
# ^^^^^^^^^^^^^^^^
|
9416
9889
|
class InterpolatedRegularExpressionNode < Node
|
9890
|
+
# attr_reader flags: Integer
|
9891
|
+
private attr_reader :flags
|
9892
|
+
|
9417
9893
|
# attr_reader opening_loc: Location
|
9418
9894
|
attr_reader :opening_loc
|
9419
9895
|
|
@@ -9423,15 +9899,12 @@ module Prism
|
|
9423
9899
|
# attr_reader closing_loc: Location
|
9424
9900
|
attr_reader :closing_loc
|
9425
9901
|
|
9426
|
-
#
|
9427
|
-
|
9428
|
-
|
9429
|
-
# def initialize: (opening_loc: Location, parts: Array[Node], closing_loc: Location, flags: Integer, location: Location) -> void
|
9430
|
-
def initialize(opening_loc, parts, closing_loc, flags, location)
|
9902
|
+
# def initialize: (flags: Integer, opening_loc: Location, parts: Array[Node], closing_loc: Location, location: Location) -> void
|
9903
|
+
def initialize(flags, opening_loc, parts, closing_loc, location)
|
9904
|
+
@flags = flags
|
9431
9905
|
@opening_loc = opening_loc
|
9432
9906
|
@parts = parts
|
9433
9907
|
@closing_loc = closing_loc
|
9434
|
-
@flags = flags
|
9435
9908
|
@location = location
|
9436
9909
|
end
|
9437
9910
|
|
@@ -9463,10 +9936,10 @@ module Prism
|
|
9463
9936
|
# def copy: (**params) -> InterpolatedRegularExpressionNode
|
9464
9937
|
def copy(**params)
|
9465
9938
|
InterpolatedRegularExpressionNode.new(
|
9939
|
+
params.fetch(:flags) { flags },
|
9466
9940
|
params.fetch(:opening_loc) { opening_loc },
|
9467
9941
|
params.fetch(:parts) { parts },
|
9468
9942
|
params.fetch(:closing_loc) { closing_loc },
|
9469
|
-
params.fetch(:flags) { flags },
|
9470
9943
|
params.fetch(:location) { location },
|
9471
9944
|
)
|
9472
9945
|
end
|
@@ -9476,17 +9949,7 @@ module Prism
|
|
9476
9949
|
|
9477
9950
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
9478
9951
|
def deconstruct_keys(keys)
|
9479
|
-
{ opening_loc: opening_loc, parts: parts, closing_loc: closing_loc,
|
9480
|
-
end
|
9481
|
-
|
9482
|
-
# def opening: () -> String
|
9483
|
-
def opening
|
9484
|
-
opening_loc.slice
|
9485
|
-
end
|
9486
|
-
|
9487
|
-
# def closing: () -> String
|
9488
|
-
def closing
|
9489
|
-
closing_loc.slice
|
9952
|
+
{ flags: flags, opening_loc: opening_loc, parts: parts, closing_loc: closing_loc, location: location }
|
9490
9953
|
end
|
9491
9954
|
|
9492
9955
|
# def ignore_case?: () -> bool
|
@@ -9529,14 +9992,39 @@ module Prism
|
|
9529
9992
|
flags.anybits?(RegularExpressionFlags::UTF_8)
|
9530
9993
|
end
|
9531
9994
|
|
9995
|
+
# def forced_utf8_encoding?: () -> bool
|
9996
|
+
def forced_utf8_encoding?
|
9997
|
+
flags.anybits?(RegularExpressionFlags::FORCED_UTF8_ENCODING)
|
9998
|
+
end
|
9999
|
+
|
10000
|
+
# def forced_binary_encoding?: () -> bool
|
10001
|
+
def forced_binary_encoding?
|
10002
|
+
flags.anybits?(RegularExpressionFlags::FORCED_BINARY_ENCODING)
|
10003
|
+
end
|
10004
|
+
|
10005
|
+
# def forced_us_ascii_encoding?: () -> bool
|
10006
|
+
def forced_us_ascii_encoding?
|
10007
|
+
flags.anybits?(RegularExpressionFlags::FORCED_US_ASCII_ENCODING)
|
10008
|
+
end
|
10009
|
+
|
10010
|
+
# def opening: () -> String
|
10011
|
+
def opening
|
10012
|
+
opening_loc.slice
|
10013
|
+
end
|
10014
|
+
|
10015
|
+
# def closing: () -> String
|
10016
|
+
def closing
|
10017
|
+
closing_loc.slice
|
10018
|
+
end
|
10019
|
+
|
9532
10020
|
# def inspect(inspector: NodeInspector) -> String
|
9533
10021
|
def inspect(inspector = NodeInspector.new)
|
9534
10022
|
inspector << inspector.header(self)
|
10023
|
+
flags = [("ignore_case" if ignore_case?), ("extended" if extended?), ("multi_line" if multi_line?), ("once" if once?), ("euc_jp" if euc_jp?), ("ascii_8bit" if ascii_8bit?), ("windows_31j" if windows_31j?), ("utf_8" if utf_8?), ("forced_utf8_encoding" if forced_utf8_encoding?), ("forced_binary_encoding" if forced_binary_encoding?), ("forced_us_ascii_encoding" if forced_us_ascii_encoding?)].compact
|
10024
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
9535
10025
|
inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
|
9536
10026
|
inspector << "├── parts: #{inspector.list("#{inspector.prefix}│ ", parts)}"
|
9537
|
-
inspector << "
|
9538
|
-
flags = [("ignore_case" if ignore_case?), ("extended" if extended?), ("multi_line" if multi_line?), ("once" if once?), ("euc_jp" if euc_jp?), ("ascii_8bit" if ascii_8bit?), ("windows_31j" if windows_31j?), ("utf_8" if utf_8?)].compact
|
9539
|
-
inspector << "└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
10027
|
+
inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
|
9540
10028
|
inspector.to_str
|
9541
10029
|
end
|
9542
10030
|
|
@@ -9913,11 +10401,15 @@ module Prism
|
|
9913
10401
|
# foo(a: b)
|
9914
10402
|
# ^^^^
|
9915
10403
|
class KeywordHashNode < Node
|
10404
|
+
# attr_reader flags: Integer
|
10405
|
+
private attr_reader :flags
|
10406
|
+
|
9916
10407
|
# attr_reader elements: Array[Node]
|
9917
10408
|
attr_reader :elements
|
9918
10409
|
|
9919
|
-
# def initialize: (elements: Array[Node], location: Location) -> void
|
9920
|
-
def initialize(elements, location)
|
10410
|
+
# def initialize: (flags: Integer, elements: Array[Node], location: Location) -> void
|
10411
|
+
def initialize(flags, elements, location)
|
10412
|
+
@flags = flags
|
9921
10413
|
@elements = elements
|
9922
10414
|
@location = location
|
9923
10415
|
end
|
@@ -9945,6 +10437,7 @@ module Prism
|
|
9945
10437
|
# def copy: (**params) -> KeywordHashNode
|
9946
10438
|
def copy(**params)
|
9947
10439
|
KeywordHashNode.new(
|
10440
|
+
params.fetch(:flags) { flags },
|
9948
10441
|
params.fetch(:elements) { elements },
|
9949
10442
|
params.fetch(:location) { location },
|
9950
10443
|
)
|
@@ -9955,12 +10448,19 @@ module Prism
|
|
9955
10448
|
|
9956
10449
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
9957
10450
|
def deconstruct_keys(keys)
|
9958
|
-
{ elements: elements, location: location }
|
10451
|
+
{ flags: flags, elements: elements, location: location }
|
10452
|
+
end
|
10453
|
+
|
10454
|
+
# def static_keys?: () -> bool
|
10455
|
+
def static_keys?
|
10456
|
+
flags.anybits?(KeywordHashNodeFlags::STATIC_KEYS)
|
9959
10457
|
end
|
9960
10458
|
|
9961
10459
|
# def inspect(inspector: NodeInspector) -> String
|
9962
10460
|
def inspect(inspector = NodeInspector.new)
|
9963
10461
|
inspector << inspector.header(self)
|
10462
|
+
flags = [("static_keys" if static_keys?)].compact
|
10463
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
9964
10464
|
inspector << "└── elements: #{inspector.list("#{inspector.prefix} ", elements)}"
|
9965
10465
|
inspector.to_str
|
9966
10466
|
end
|
@@ -10110,6 +10610,9 @@ module Prism
|
|
10110
10610
|
# attr_reader locals: Array[Symbol]
|
10111
10611
|
attr_reader :locals
|
10112
10612
|
|
10613
|
+
# attr_reader locals_body_index: Integer
|
10614
|
+
attr_reader :locals_body_index
|
10615
|
+
|
10113
10616
|
# attr_reader operator_loc: Location
|
10114
10617
|
attr_reader :operator_loc
|
10115
10618
|
|
@@ -10119,15 +10622,16 @@ module Prism
|
|
10119
10622
|
# attr_reader closing_loc: Location
|
10120
10623
|
attr_reader :closing_loc
|
10121
10624
|
|
10122
|
-
# attr_reader parameters:
|
10625
|
+
# attr_reader parameters: Node?
|
10123
10626
|
attr_reader :parameters
|
10124
10627
|
|
10125
10628
|
# attr_reader body: Node?
|
10126
10629
|
attr_reader :body
|
10127
10630
|
|
10128
|
-
# def initialize: (locals: Array[Symbol], operator_loc: Location, opening_loc: Location, closing_loc: Location, parameters:
|
10129
|
-
def initialize(locals, operator_loc, opening_loc, closing_loc, parameters, body, location)
|
10631
|
+
# def initialize: (locals: Array[Symbol], locals_body_index: Integer, operator_loc: Location, opening_loc: Location, closing_loc: Location, parameters: Node?, body: Node?, location: Location) -> void
|
10632
|
+
def initialize(locals, locals_body_index, operator_loc, opening_loc, closing_loc, parameters, body, location)
|
10130
10633
|
@locals = locals
|
10634
|
+
@locals_body_index = locals_body_index
|
10131
10635
|
@operator_loc = operator_loc
|
10132
10636
|
@opening_loc = opening_loc
|
10133
10637
|
@closing_loc = closing_loc
|
@@ -10163,6 +10667,7 @@ module Prism
|
|
10163
10667
|
def copy(**params)
|
10164
10668
|
LambdaNode.new(
|
10165
10669
|
params.fetch(:locals) { locals },
|
10670
|
+
params.fetch(:locals_body_index) { locals_body_index },
|
10166
10671
|
params.fetch(:operator_loc) { operator_loc },
|
10167
10672
|
params.fetch(:opening_loc) { opening_loc },
|
10168
10673
|
params.fetch(:closing_loc) { closing_loc },
|
@@ -10177,7 +10682,7 @@ module Prism
|
|
10177
10682
|
|
10178
10683
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
10179
10684
|
def deconstruct_keys(keys)
|
10180
|
-
{ locals: locals, operator_loc: operator_loc, opening_loc: opening_loc, closing_loc: closing_loc, parameters: parameters, body: body, location: location }
|
10685
|
+
{ locals: locals, locals_body_index: locals_body_index, operator_loc: operator_loc, opening_loc: opening_loc, closing_loc: closing_loc, parameters: parameters, body: body, location: location }
|
10181
10686
|
end
|
10182
10687
|
|
10183
10688
|
# def operator: () -> String
|
@@ -10199,6 +10704,7 @@ module Prism
|
|
10199
10704
|
def inspect(inspector = NodeInspector.new)
|
10200
10705
|
inspector << inspector.header(self)
|
10201
10706
|
inspector << "├── locals: #{locals.inspect}\n"
|
10707
|
+
inspector << "├── locals_body_index: #{locals_body_index.inspect}\n"
|
10202
10708
|
inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
|
10203
10709
|
inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
|
10204
10710
|
inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
|
@@ -10904,6 +11410,9 @@ module Prism
|
|
10904
11410
|
# if /foo/i then end
|
10905
11411
|
# ^^^^^^
|
10906
11412
|
class MatchLastLineNode < Node
|
11413
|
+
# attr_reader flags: Integer
|
11414
|
+
private attr_reader :flags
|
11415
|
+
|
10907
11416
|
# attr_reader opening_loc: Location
|
10908
11417
|
attr_reader :opening_loc
|
10909
11418
|
|
@@ -10916,16 +11425,13 @@ module Prism
|
|
10916
11425
|
# attr_reader unescaped: String
|
10917
11426
|
attr_reader :unescaped
|
10918
11427
|
|
10919
|
-
#
|
10920
|
-
|
10921
|
-
|
10922
|
-
# def initialize: (opening_loc: Location, content_loc: Location, closing_loc: Location, unescaped: String, flags: Integer, location: Location) -> void
|
10923
|
-
def initialize(opening_loc, content_loc, closing_loc, unescaped, flags, location)
|
11428
|
+
# def initialize: (flags: Integer, opening_loc: Location, content_loc: Location, closing_loc: Location, unescaped: String, location: Location) -> void
|
11429
|
+
def initialize(flags, opening_loc, content_loc, closing_loc, unescaped, location)
|
11430
|
+
@flags = flags
|
10924
11431
|
@opening_loc = opening_loc
|
10925
11432
|
@content_loc = content_loc
|
10926
11433
|
@closing_loc = closing_loc
|
10927
11434
|
@unescaped = unescaped
|
10928
|
-
@flags = flags
|
10929
11435
|
@location = location
|
10930
11436
|
end
|
10931
11437
|
|
@@ -10952,11 +11458,11 @@ module Prism
|
|
10952
11458
|
# def copy: (**params) -> MatchLastLineNode
|
10953
11459
|
def copy(**params)
|
10954
11460
|
MatchLastLineNode.new(
|
11461
|
+
params.fetch(:flags) { flags },
|
10955
11462
|
params.fetch(:opening_loc) { opening_loc },
|
10956
11463
|
params.fetch(:content_loc) { content_loc },
|
10957
11464
|
params.fetch(:closing_loc) { closing_loc },
|
10958
11465
|
params.fetch(:unescaped) { unescaped },
|
10959
|
-
params.fetch(:flags) { flags },
|
10960
11466
|
params.fetch(:location) { location },
|
10961
11467
|
)
|
10962
11468
|
end
|
@@ -10966,22 +11472,7 @@ module Prism
|
|
10966
11472
|
|
10967
11473
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
10968
11474
|
def deconstruct_keys(keys)
|
10969
|
-
{ opening_loc: opening_loc, content_loc: content_loc, closing_loc: closing_loc, unescaped: unescaped,
|
10970
|
-
end
|
10971
|
-
|
10972
|
-
# def opening: () -> String
|
10973
|
-
def opening
|
10974
|
-
opening_loc.slice
|
10975
|
-
end
|
10976
|
-
|
10977
|
-
# def content: () -> String
|
10978
|
-
def content
|
10979
|
-
content_loc.slice
|
10980
|
-
end
|
10981
|
-
|
10982
|
-
# def closing: () -> String
|
10983
|
-
def closing
|
10984
|
-
closing_loc.slice
|
11475
|
+
{ flags: flags, opening_loc: opening_loc, content_loc: content_loc, closing_loc: closing_loc, unescaped: unescaped, location: location }
|
10985
11476
|
end
|
10986
11477
|
|
10987
11478
|
# def ignore_case?: () -> bool
|
@@ -11024,15 +11515,45 @@ module Prism
|
|
11024
11515
|
flags.anybits?(RegularExpressionFlags::UTF_8)
|
11025
11516
|
end
|
11026
11517
|
|
11518
|
+
# def forced_utf8_encoding?: () -> bool
|
11519
|
+
def forced_utf8_encoding?
|
11520
|
+
flags.anybits?(RegularExpressionFlags::FORCED_UTF8_ENCODING)
|
11521
|
+
end
|
11522
|
+
|
11523
|
+
# def forced_binary_encoding?: () -> bool
|
11524
|
+
def forced_binary_encoding?
|
11525
|
+
flags.anybits?(RegularExpressionFlags::FORCED_BINARY_ENCODING)
|
11526
|
+
end
|
11527
|
+
|
11528
|
+
# def forced_us_ascii_encoding?: () -> bool
|
11529
|
+
def forced_us_ascii_encoding?
|
11530
|
+
flags.anybits?(RegularExpressionFlags::FORCED_US_ASCII_ENCODING)
|
11531
|
+
end
|
11532
|
+
|
11533
|
+
# def opening: () -> String
|
11534
|
+
def opening
|
11535
|
+
opening_loc.slice
|
11536
|
+
end
|
11537
|
+
|
11538
|
+
# def content: () -> String
|
11539
|
+
def content
|
11540
|
+
content_loc.slice
|
11541
|
+
end
|
11542
|
+
|
11543
|
+
# def closing: () -> String
|
11544
|
+
def closing
|
11545
|
+
closing_loc.slice
|
11546
|
+
end
|
11547
|
+
|
11027
11548
|
# def inspect(inspector: NodeInspector) -> String
|
11028
11549
|
def inspect(inspector = NodeInspector.new)
|
11029
11550
|
inspector << inspector.header(self)
|
11551
|
+
flags = [("ignore_case" if ignore_case?), ("extended" if extended?), ("multi_line" if multi_line?), ("once" if once?), ("euc_jp" if euc_jp?), ("ascii_8bit" if ascii_8bit?), ("windows_31j" if windows_31j?), ("utf_8" if utf_8?), ("forced_utf8_encoding" if forced_utf8_encoding?), ("forced_binary_encoding" if forced_binary_encoding?), ("forced_us_ascii_encoding" if forced_us_ascii_encoding?)].compact
|
11552
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
11030
11553
|
inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
|
11031
11554
|
inspector << "├── content_loc: #{inspector.location(content_loc)}\n"
|
11032
11555
|
inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
|
11033
|
-
inspector << "
|
11034
|
-
flags = [("ignore_case" if ignore_case?), ("extended" if extended?), ("multi_line" if multi_line?), ("once" if once?), ("euc_jp" if euc_jp?), ("ascii_8bit" if ascii_8bit?), ("windows_31j" if windows_31j?), ("utf_8" if utf_8?)].compact
|
11035
|
-
inspector << "└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
11556
|
+
inspector << "└── unescaped: #{unescaped.inspect}\n"
|
11036
11557
|
inspector.to_str
|
11037
11558
|
end
|
11038
11559
|
|
@@ -11975,7 +12496,96 @@ module Prism
|
|
11975
12496
|
|
11976
12497
|
# def accept: (visitor: Visitor) -> void
|
11977
12498
|
def accept(visitor)
|
11978
|
-
visitor.visit_nil_node(self)
|
12499
|
+
visitor.visit_nil_node(self)
|
12500
|
+
end
|
12501
|
+
|
12502
|
+
# def child_nodes: () -> Array[nil | Node]
|
12503
|
+
def child_nodes
|
12504
|
+
[]
|
12505
|
+
end
|
12506
|
+
|
12507
|
+
# def compact_child_nodes: () -> Array[Node]
|
12508
|
+
def compact_child_nodes
|
12509
|
+
[]
|
12510
|
+
end
|
12511
|
+
|
12512
|
+
# def comment_targets: () -> Array[Node | Location]
|
12513
|
+
def comment_targets
|
12514
|
+
[]
|
12515
|
+
end
|
12516
|
+
|
12517
|
+
# def copy: (**params) -> NilNode
|
12518
|
+
def copy(**params)
|
12519
|
+
NilNode.new(
|
12520
|
+
params.fetch(:location) { location },
|
12521
|
+
)
|
12522
|
+
end
|
12523
|
+
|
12524
|
+
# def deconstruct: () -> Array[nil | Node]
|
12525
|
+
alias deconstruct child_nodes
|
12526
|
+
|
12527
|
+
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
12528
|
+
def deconstruct_keys(keys)
|
12529
|
+
{ location: location }
|
12530
|
+
end
|
12531
|
+
|
12532
|
+
# def inspect(inspector: NodeInspector) -> String
|
12533
|
+
def inspect(inspector = NodeInspector.new)
|
12534
|
+
inspector << inspector.header(self)
|
12535
|
+
inspector.to_str
|
12536
|
+
end
|
12537
|
+
|
12538
|
+
# Sometimes you want to check an instance of a node against a list of
|
12539
|
+
# classes to see what kind of behavior to perform. Usually this is done by
|
12540
|
+
# calling `[cls1, cls2].include?(node.class)` or putting the node into a
|
12541
|
+
# case statement and doing `case node; when cls1; when cls2; end`. Both of
|
12542
|
+
# these approaches are relatively slow because of the constant lookups,
|
12543
|
+
# method calls, and/or array allocations.
|
12544
|
+
#
|
12545
|
+
# Instead, you can call #type, which will return to you a symbol that you
|
12546
|
+
# can use for comparison. This is faster than the other approaches because
|
12547
|
+
# it uses a single integer comparison, but also because if you're on CRuby
|
12548
|
+
# you can take advantage of the fact that case statements with all symbol
|
12549
|
+
# keys will use a jump table.
|
12550
|
+
#
|
12551
|
+
# def type: () -> Symbol
|
12552
|
+
def type
|
12553
|
+
:nil_node
|
12554
|
+
end
|
12555
|
+
|
12556
|
+
# Similar to #type, this method returns a symbol that you can use for
|
12557
|
+
# splitting on the type of the node without having to do a long === chain.
|
12558
|
+
# Note that like #type, it will still be slower than using == for a single
|
12559
|
+
# class, but should be faster in a case statement or an array comparison.
|
12560
|
+
#
|
12561
|
+
# def self.type: () -> Symbol
|
12562
|
+
def self.type
|
12563
|
+
:nil_node
|
12564
|
+
end
|
12565
|
+
end
|
12566
|
+
|
12567
|
+
# Represents the use of `**nil` inside method arguments.
|
12568
|
+
#
|
12569
|
+
# def a(**nil)
|
12570
|
+
# ^^^^^
|
12571
|
+
# end
|
12572
|
+
class NoKeywordsParameterNode < Node
|
12573
|
+
# attr_reader operator_loc: Location
|
12574
|
+
attr_reader :operator_loc
|
12575
|
+
|
12576
|
+
# attr_reader keyword_loc: Location
|
12577
|
+
attr_reader :keyword_loc
|
12578
|
+
|
12579
|
+
# def initialize: (operator_loc: Location, keyword_loc: Location, location: Location) -> void
|
12580
|
+
def initialize(operator_loc, keyword_loc, location)
|
12581
|
+
@operator_loc = operator_loc
|
12582
|
+
@keyword_loc = keyword_loc
|
12583
|
+
@location = location
|
12584
|
+
end
|
12585
|
+
|
12586
|
+
# def accept: (visitor: Visitor) -> void
|
12587
|
+
def accept(visitor)
|
12588
|
+
visitor.visit_no_keywords_parameter_node(self)
|
11979
12589
|
end
|
11980
12590
|
|
11981
12591
|
# def child_nodes: () -> Array[nil | Node]
|
@@ -11990,12 +12600,14 @@ module Prism
|
|
11990
12600
|
|
11991
12601
|
# def comment_targets: () -> Array[Node | Location]
|
11992
12602
|
def comment_targets
|
11993
|
-
[]
|
12603
|
+
[operator_loc, keyword_loc]
|
11994
12604
|
end
|
11995
12605
|
|
11996
|
-
# def copy: (**params) ->
|
12606
|
+
# def copy: (**params) -> NoKeywordsParameterNode
|
11997
12607
|
def copy(**params)
|
11998
|
-
|
12608
|
+
NoKeywordsParameterNode.new(
|
12609
|
+
params.fetch(:operator_loc) { operator_loc },
|
12610
|
+
params.fetch(:keyword_loc) { keyword_loc },
|
11999
12611
|
params.fetch(:location) { location },
|
12000
12612
|
)
|
12001
12613
|
end
|
@@ -12005,12 +12617,24 @@ module Prism
|
|
12005
12617
|
|
12006
12618
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
12007
12619
|
def deconstruct_keys(keys)
|
12008
|
-
{ location: location }
|
12620
|
+
{ operator_loc: operator_loc, keyword_loc: keyword_loc, location: location }
|
12621
|
+
end
|
12622
|
+
|
12623
|
+
# def operator: () -> String
|
12624
|
+
def operator
|
12625
|
+
operator_loc.slice
|
12626
|
+
end
|
12627
|
+
|
12628
|
+
# def keyword: () -> String
|
12629
|
+
def keyword
|
12630
|
+
keyword_loc.slice
|
12009
12631
|
end
|
12010
12632
|
|
12011
12633
|
# def inspect(inspector: NodeInspector) -> String
|
12012
12634
|
def inspect(inspector = NodeInspector.new)
|
12013
12635
|
inspector << inspector.header(self)
|
12636
|
+
inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
|
12637
|
+
inspector << "└── keyword_loc: #{inspector.location(keyword_loc)}\n"
|
12014
12638
|
inspector.to_str
|
12015
12639
|
end
|
12016
12640
|
|
@@ -12029,7 +12653,7 @@ module Prism
|
|
12029
12653
|
#
|
12030
12654
|
# def type: () -> Symbol
|
12031
12655
|
def type
|
12032
|
-
:
|
12656
|
+
:no_keywords_parameter_node
|
12033
12657
|
end
|
12034
12658
|
|
12035
12659
|
# Similar to #type, this method returns a symbol that you can use for
|
@@ -12039,32 +12663,28 @@ module Prism
|
|
12039
12663
|
#
|
12040
12664
|
# def self.type: () -> Symbol
|
12041
12665
|
def self.type
|
12042
|
-
:
|
12666
|
+
:no_keywords_parameter_node
|
12043
12667
|
end
|
12044
12668
|
end
|
12045
12669
|
|
12046
|
-
# Represents
|
12670
|
+
# Represents an implicit set of parameters through the use of numbered
|
12671
|
+
# parameters within a block or lambda.
|
12047
12672
|
#
|
12048
|
-
#
|
12049
|
-
#
|
12050
|
-
|
12051
|
-
|
12052
|
-
|
12053
|
-
attr_reader :operator_loc
|
12054
|
-
|
12055
|
-
# attr_reader keyword_loc: Location
|
12056
|
-
attr_reader :keyword_loc
|
12673
|
+
# -> { _1 + _2 }
|
12674
|
+
# ^^^^^^^^^^^^^^
|
12675
|
+
class NumberedParametersNode < Node
|
12676
|
+
# attr_reader maximum: Integer
|
12677
|
+
attr_reader :maximum
|
12057
12678
|
|
12058
|
-
# def initialize: (
|
12059
|
-
def initialize(
|
12060
|
-
@
|
12061
|
-
@keyword_loc = keyword_loc
|
12679
|
+
# def initialize: (maximum: Integer, location: Location) -> void
|
12680
|
+
def initialize(maximum, location)
|
12681
|
+
@maximum = maximum
|
12062
12682
|
@location = location
|
12063
12683
|
end
|
12064
12684
|
|
12065
12685
|
# def accept: (visitor: Visitor) -> void
|
12066
12686
|
def accept(visitor)
|
12067
|
-
visitor.
|
12687
|
+
visitor.visit_numbered_parameters_node(self)
|
12068
12688
|
end
|
12069
12689
|
|
12070
12690
|
# def child_nodes: () -> Array[nil | Node]
|
@@ -12079,14 +12699,13 @@ module Prism
|
|
12079
12699
|
|
12080
12700
|
# def comment_targets: () -> Array[Node | Location]
|
12081
12701
|
def comment_targets
|
12082
|
-
[
|
12702
|
+
[]
|
12083
12703
|
end
|
12084
12704
|
|
12085
|
-
# def copy: (**params) ->
|
12705
|
+
# def copy: (**params) -> NumberedParametersNode
|
12086
12706
|
def copy(**params)
|
12087
|
-
|
12088
|
-
params.fetch(:
|
12089
|
-
params.fetch(:keyword_loc) { keyword_loc },
|
12707
|
+
NumberedParametersNode.new(
|
12708
|
+
params.fetch(:maximum) { maximum },
|
12090
12709
|
params.fetch(:location) { location },
|
12091
12710
|
)
|
12092
12711
|
end
|
@@ -12096,24 +12715,13 @@ module Prism
|
|
12096
12715
|
|
12097
12716
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
12098
12717
|
def deconstruct_keys(keys)
|
12099
|
-
{
|
12100
|
-
end
|
12101
|
-
|
12102
|
-
# def operator: () -> String
|
12103
|
-
def operator
|
12104
|
-
operator_loc.slice
|
12105
|
-
end
|
12106
|
-
|
12107
|
-
# def keyword: () -> String
|
12108
|
-
def keyword
|
12109
|
-
keyword_loc.slice
|
12718
|
+
{ maximum: maximum, location: location }
|
12110
12719
|
end
|
12111
12720
|
|
12112
12721
|
# def inspect(inspector: NodeInspector) -> String
|
12113
12722
|
def inspect(inspector = NodeInspector.new)
|
12114
12723
|
inspector << inspector.header(self)
|
12115
|
-
inspector << "
|
12116
|
-
inspector << "└── keyword_loc: #{inspector.location(keyword_loc)}\n"
|
12724
|
+
inspector << "└── maximum: #{maximum.inspect}\n"
|
12117
12725
|
inspector.to_str
|
12118
12726
|
end
|
12119
12727
|
|
@@ -12132,7 +12740,7 @@ module Prism
|
|
12132
12740
|
#
|
12133
12741
|
# def type: () -> Symbol
|
12134
12742
|
def type
|
12135
|
-
:
|
12743
|
+
:numbered_parameters_node
|
12136
12744
|
end
|
12137
12745
|
|
12138
12746
|
# Similar to #type, this method returns a symbol that you can use for
|
@@ -12142,7 +12750,7 @@ module Prism
|
|
12142
12750
|
#
|
12143
12751
|
# def self.type: () -> Symbol
|
12144
12752
|
def self.type
|
12145
|
-
:
|
12753
|
+
:numbered_parameters_node
|
12146
12754
|
end
|
12147
12755
|
end
|
12148
12756
|
|
@@ -12560,7 +13168,7 @@ module Prism
|
|
12560
13168
|
# attr_reader optionals: Array[Node]
|
12561
13169
|
attr_reader :optionals
|
12562
13170
|
|
12563
|
-
# attr_reader rest:
|
13171
|
+
# attr_reader rest: Node?
|
12564
13172
|
attr_reader :rest
|
12565
13173
|
|
12566
13174
|
# attr_reader posts: Array[Node]
|
@@ -12575,7 +13183,7 @@ module Prism
|
|
12575
13183
|
# attr_reader block: BlockParameterNode?
|
12576
13184
|
attr_reader :block
|
12577
13185
|
|
12578
|
-
# def initialize: (requireds: Array[Node], optionals: Array[Node], rest:
|
13186
|
+
# def initialize: (requireds: Array[Node], optionals: Array[Node], rest: Node?, posts: Array[Node], keywords: Array[Node], keyword_rest: Node?, block: BlockParameterNode?, location: Location) -> void
|
12579
13187
|
def initialize(requireds, optionals, rest, posts, keywords, keyword_rest, block, location)
|
12580
13188
|
@requireds = requireds
|
12581
13189
|
@optionals = optionals
|
@@ -13383,6 +13991,9 @@ module Prism
|
|
13383
13991
|
# c if a =~ /left/ ... b =~ /right/
|
13384
13992
|
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
13385
13993
|
class RangeNode < Node
|
13994
|
+
# attr_reader flags: Integer
|
13995
|
+
private attr_reader :flags
|
13996
|
+
|
13386
13997
|
# attr_reader left: Node?
|
13387
13998
|
attr_reader :left
|
13388
13999
|
|
@@ -13392,15 +14003,12 @@ module Prism
|
|
13392
14003
|
# attr_reader operator_loc: Location
|
13393
14004
|
attr_reader :operator_loc
|
13394
14005
|
|
13395
|
-
#
|
13396
|
-
|
13397
|
-
|
13398
|
-
# def initialize: (left: Node?, right: Node?, operator_loc: Location, flags: Integer, location: Location) -> void
|
13399
|
-
def initialize(left, right, operator_loc, flags, location)
|
14006
|
+
# def initialize: (flags: Integer, left: Node?, right: Node?, operator_loc: Location, location: Location) -> void
|
14007
|
+
def initialize(flags, left, right, operator_loc, location)
|
14008
|
+
@flags = flags
|
13400
14009
|
@left = left
|
13401
14010
|
@right = right
|
13402
14011
|
@operator_loc = operator_loc
|
13403
|
-
@flags = flags
|
13404
14012
|
@location = location
|
13405
14013
|
end
|
13406
14014
|
|
@@ -13430,10 +14038,10 @@ module Prism
|
|
13430
14038
|
# def copy: (**params) -> RangeNode
|
13431
14039
|
def copy(**params)
|
13432
14040
|
RangeNode.new(
|
14041
|
+
params.fetch(:flags) { flags },
|
13433
14042
|
params.fetch(:left) { left },
|
13434
14043
|
params.fetch(:right) { right },
|
13435
14044
|
params.fetch(:operator_loc) { operator_loc },
|
13436
|
-
params.fetch(:flags) { flags },
|
13437
14045
|
params.fetch(:location) { location },
|
13438
14046
|
)
|
13439
14047
|
end
|
@@ -13443,12 +14051,7 @@ module Prism
|
|
13443
14051
|
|
13444
14052
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
13445
14053
|
def deconstruct_keys(keys)
|
13446
|
-
{ left: left, right: right, operator_loc: operator_loc,
|
13447
|
-
end
|
13448
|
-
|
13449
|
-
# def operator: () -> String
|
13450
|
-
def operator
|
13451
|
-
operator_loc.slice
|
14054
|
+
{ flags: flags, left: left, right: right, operator_loc: operator_loc, location: location }
|
13452
14055
|
end
|
13453
14056
|
|
13454
14057
|
# def exclude_end?: () -> bool
|
@@ -13456,9 +14059,16 @@ module Prism
|
|
13456
14059
|
flags.anybits?(RangeFlags::EXCLUDE_END)
|
13457
14060
|
end
|
13458
14061
|
|
14062
|
+
# def operator: () -> String
|
14063
|
+
def operator
|
14064
|
+
operator_loc.slice
|
14065
|
+
end
|
14066
|
+
|
13459
14067
|
# def inspect(inspector: NodeInspector) -> String
|
13460
14068
|
def inspect(inspector = NodeInspector.new)
|
13461
14069
|
inspector << inspector.header(self)
|
14070
|
+
flags = [("exclude_end" if exclude_end?)].compact
|
14071
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
13462
14072
|
if (left = self.left).nil?
|
13463
14073
|
inspector << "├── left: ∅\n"
|
13464
14074
|
else
|
@@ -13471,9 +14081,7 @@ module Prism
|
|
13471
14081
|
inspector << "├── right:\n"
|
13472
14082
|
inspector << right.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
|
13473
14083
|
end
|
13474
|
-
inspector << "
|
13475
|
-
flags = [("exclude_end" if exclude_end?)].compact
|
13476
|
-
inspector << "└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
14084
|
+
inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
|
13477
14085
|
inspector.to_str
|
13478
14086
|
end
|
13479
14087
|
|
@@ -13678,6 +14286,9 @@ module Prism
|
|
13678
14286
|
# /foo/i
|
13679
14287
|
# ^^^^^^
|
13680
14288
|
class RegularExpressionNode < Node
|
14289
|
+
# attr_reader flags: Integer
|
14290
|
+
private attr_reader :flags
|
14291
|
+
|
13681
14292
|
# attr_reader opening_loc: Location
|
13682
14293
|
attr_reader :opening_loc
|
13683
14294
|
|
@@ -13690,16 +14301,13 @@ module Prism
|
|
13690
14301
|
# attr_reader unescaped: String
|
13691
14302
|
attr_reader :unescaped
|
13692
14303
|
|
13693
|
-
#
|
13694
|
-
|
13695
|
-
|
13696
|
-
# def initialize: (opening_loc: Location, content_loc: Location, closing_loc: Location, unescaped: String, flags: Integer, location: Location) -> void
|
13697
|
-
def initialize(opening_loc, content_loc, closing_loc, unescaped, flags, location)
|
14304
|
+
# def initialize: (flags: Integer, opening_loc: Location, content_loc: Location, closing_loc: Location, unescaped: String, location: Location) -> void
|
14305
|
+
def initialize(flags, opening_loc, content_loc, closing_loc, unescaped, location)
|
14306
|
+
@flags = flags
|
13698
14307
|
@opening_loc = opening_loc
|
13699
14308
|
@content_loc = content_loc
|
13700
14309
|
@closing_loc = closing_loc
|
13701
14310
|
@unescaped = unescaped
|
13702
|
-
@flags = flags
|
13703
14311
|
@location = location
|
13704
14312
|
end
|
13705
14313
|
|
@@ -13726,11 +14334,11 @@ module Prism
|
|
13726
14334
|
# def copy: (**params) -> RegularExpressionNode
|
13727
14335
|
def copy(**params)
|
13728
14336
|
RegularExpressionNode.new(
|
14337
|
+
params.fetch(:flags) { flags },
|
13729
14338
|
params.fetch(:opening_loc) { opening_loc },
|
13730
14339
|
params.fetch(:content_loc) { content_loc },
|
13731
14340
|
params.fetch(:closing_loc) { closing_loc },
|
13732
14341
|
params.fetch(:unescaped) { unescaped },
|
13733
|
-
params.fetch(:flags) { flags },
|
13734
14342
|
params.fetch(:location) { location },
|
13735
14343
|
)
|
13736
14344
|
end
|
@@ -13740,22 +14348,7 @@ module Prism
|
|
13740
14348
|
|
13741
14349
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
13742
14350
|
def deconstruct_keys(keys)
|
13743
|
-
{ opening_loc: opening_loc, content_loc: content_loc, closing_loc: closing_loc, unescaped: unescaped,
|
13744
|
-
end
|
13745
|
-
|
13746
|
-
# def opening: () -> String
|
13747
|
-
def opening
|
13748
|
-
opening_loc.slice
|
13749
|
-
end
|
13750
|
-
|
13751
|
-
# def content: () -> String
|
13752
|
-
def content
|
13753
|
-
content_loc.slice
|
13754
|
-
end
|
13755
|
-
|
13756
|
-
# def closing: () -> String
|
13757
|
-
def closing
|
13758
|
-
closing_loc.slice
|
14351
|
+
{ flags: flags, opening_loc: opening_loc, content_loc: content_loc, closing_loc: closing_loc, unescaped: unescaped, location: location }
|
13759
14352
|
end
|
13760
14353
|
|
13761
14354
|
# def ignore_case?: () -> bool
|
@@ -13798,15 +14391,45 @@ module Prism
|
|
13798
14391
|
flags.anybits?(RegularExpressionFlags::UTF_8)
|
13799
14392
|
end
|
13800
14393
|
|
14394
|
+
# def forced_utf8_encoding?: () -> bool
|
14395
|
+
def forced_utf8_encoding?
|
14396
|
+
flags.anybits?(RegularExpressionFlags::FORCED_UTF8_ENCODING)
|
14397
|
+
end
|
14398
|
+
|
14399
|
+
# def forced_binary_encoding?: () -> bool
|
14400
|
+
def forced_binary_encoding?
|
14401
|
+
flags.anybits?(RegularExpressionFlags::FORCED_BINARY_ENCODING)
|
14402
|
+
end
|
14403
|
+
|
14404
|
+
# def forced_us_ascii_encoding?: () -> bool
|
14405
|
+
def forced_us_ascii_encoding?
|
14406
|
+
flags.anybits?(RegularExpressionFlags::FORCED_US_ASCII_ENCODING)
|
14407
|
+
end
|
14408
|
+
|
14409
|
+
# def opening: () -> String
|
14410
|
+
def opening
|
14411
|
+
opening_loc.slice
|
14412
|
+
end
|
14413
|
+
|
14414
|
+
# def content: () -> String
|
14415
|
+
def content
|
14416
|
+
content_loc.slice
|
14417
|
+
end
|
14418
|
+
|
14419
|
+
# def closing: () -> String
|
14420
|
+
def closing
|
14421
|
+
closing_loc.slice
|
14422
|
+
end
|
14423
|
+
|
13801
14424
|
# def inspect(inspector: NodeInspector) -> String
|
13802
14425
|
def inspect(inspector = NodeInspector.new)
|
13803
14426
|
inspector << inspector.header(self)
|
14427
|
+
flags = [("ignore_case" if ignore_case?), ("extended" if extended?), ("multi_line" if multi_line?), ("once" if once?), ("euc_jp" if euc_jp?), ("ascii_8bit" if ascii_8bit?), ("windows_31j" if windows_31j?), ("utf_8" if utf_8?), ("forced_utf8_encoding" if forced_utf8_encoding?), ("forced_binary_encoding" if forced_binary_encoding?), ("forced_us_ascii_encoding" if forced_us_ascii_encoding?)].compact
|
14428
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
13804
14429
|
inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
|
13805
14430
|
inspector << "├── content_loc: #{inspector.location(content_loc)}\n"
|
13806
14431
|
inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
|
13807
|
-
inspector << "
|
13808
|
-
flags = [("ignore_case" if ignore_case?), ("extended" if extended?), ("multi_line" if multi_line?), ("once" if once?), ("euc_jp" if euc_jp?), ("ascii_8bit" if ascii_8bit?), ("windows_31j" if windows_31j?), ("utf_8" if utf_8?)].compact
|
13809
|
-
inspector << "└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
14432
|
+
inspector << "└── unescaped: #{unescaped.inspect}\n"
|
13810
14433
|
inspector.to_str
|
13811
14434
|
end
|
13812
14435
|
|
@@ -15305,6 +15928,16 @@ module Prism
|
|
15305
15928
|
{ flags: flags, opening_loc: opening_loc, content_loc: content_loc, closing_loc: closing_loc, unescaped: unescaped, location: location }
|
15306
15929
|
end
|
15307
15930
|
|
15931
|
+
# def forced_utf8_encoding?: () -> bool
|
15932
|
+
def forced_utf8_encoding?
|
15933
|
+
flags.anybits?(StringFlags::FORCED_UTF8_ENCODING)
|
15934
|
+
end
|
15935
|
+
|
15936
|
+
# def forced_binary_encoding?: () -> bool
|
15937
|
+
def forced_binary_encoding?
|
15938
|
+
flags.anybits?(StringFlags::FORCED_BINARY_ENCODING)
|
15939
|
+
end
|
15940
|
+
|
15308
15941
|
# def frozen?: () -> bool
|
15309
15942
|
def frozen?
|
15310
15943
|
flags.anybits?(StringFlags::FROZEN)
|
@@ -15328,7 +15961,7 @@ module Prism
|
|
15328
15961
|
# def inspect(inspector: NodeInspector) -> String
|
15329
15962
|
def inspect(inspector = NodeInspector.new)
|
15330
15963
|
inspector << inspector.header(self)
|
15331
|
-
flags = [("frozen" if frozen?)].compact
|
15964
|
+
flags = [("forced_utf8_encoding" if forced_utf8_encoding?), ("forced_binary_encoding" if forced_binary_encoding?), ("frozen" if frozen?)].compact
|
15332
15965
|
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
15333
15966
|
inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
|
15334
15967
|
inspector << "├── content_loc: #{inspector.location(content_loc)}\n"
|
@@ -15515,6 +16148,9 @@ module Prism
|
|
15515
16148
|
# %i[foo]
|
15516
16149
|
# ^^^
|
15517
16150
|
class SymbolNode < Node
|
16151
|
+
# attr_reader flags: Integer
|
16152
|
+
private attr_reader :flags
|
16153
|
+
|
15518
16154
|
# attr_reader opening_loc: Location?
|
15519
16155
|
attr_reader :opening_loc
|
15520
16156
|
|
@@ -15527,8 +16163,9 @@ module Prism
|
|
15527
16163
|
# attr_reader unescaped: String
|
15528
16164
|
attr_reader :unescaped
|
15529
16165
|
|
15530
|
-
# def initialize: (opening_loc: Location?, value_loc: Location?, closing_loc: Location?, unescaped: String, location: Location) -> void
|
15531
|
-
def initialize(opening_loc, value_loc, closing_loc, unescaped, location)
|
16166
|
+
# def initialize: (flags: Integer, opening_loc: Location?, value_loc: Location?, closing_loc: Location?, unescaped: String, location: Location) -> void
|
16167
|
+
def initialize(flags, opening_loc, value_loc, closing_loc, unescaped, location)
|
16168
|
+
@flags = flags
|
15532
16169
|
@opening_loc = opening_loc
|
15533
16170
|
@value_loc = value_loc
|
15534
16171
|
@closing_loc = closing_loc
|
@@ -15559,6 +16196,7 @@ module Prism
|
|
15559
16196
|
# def copy: (**params) -> SymbolNode
|
15560
16197
|
def copy(**params)
|
15561
16198
|
SymbolNode.new(
|
16199
|
+
params.fetch(:flags) { flags },
|
15562
16200
|
params.fetch(:opening_loc) { opening_loc },
|
15563
16201
|
params.fetch(:value_loc) { value_loc },
|
15564
16202
|
params.fetch(:closing_loc) { closing_loc },
|
@@ -15572,7 +16210,22 @@ module Prism
|
|
15572
16210
|
|
15573
16211
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
15574
16212
|
def deconstruct_keys(keys)
|
15575
|
-
{ opening_loc: opening_loc, value_loc: value_loc, closing_loc: closing_loc, unescaped: unescaped, location: location }
|
16213
|
+
{ flags: flags, opening_loc: opening_loc, value_loc: value_loc, closing_loc: closing_loc, unescaped: unescaped, location: location }
|
16214
|
+
end
|
16215
|
+
|
16216
|
+
# def forced_utf8_encoding?: () -> bool
|
16217
|
+
def forced_utf8_encoding?
|
16218
|
+
flags.anybits?(SymbolFlags::FORCED_UTF8_ENCODING)
|
16219
|
+
end
|
16220
|
+
|
16221
|
+
# def forced_binary_encoding?: () -> bool
|
16222
|
+
def forced_binary_encoding?
|
16223
|
+
flags.anybits?(SymbolFlags::FORCED_BINARY_ENCODING)
|
16224
|
+
end
|
16225
|
+
|
16226
|
+
# def forced_us_ascii_encoding?: () -> bool
|
16227
|
+
def forced_us_ascii_encoding?
|
16228
|
+
flags.anybits?(SymbolFlags::FORCED_US_ASCII_ENCODING)
|
15576
16229
|
end
|
15577
16230
|
|
15578
16231
|
# def opening: () -> String?
|
@@ -15593,6 +16246,8 @@ module Prism
|
|
15593
16246
|
# def inspect(inspector: NodeInspector) -> String
|
15594
16247
|
def inspect(inspector = NodeInspector.new)
|
15595
16248
|
inspector << inspector.header(self)
|
16249
|
+
flags = [("forced_utf8_encoding" if forced_utf8_encoding?), ("forced_binary_encoding" if forced_binary_encoding?), ("forced_us_ascii_encoding" if forced_us_ascii_encoding?)].compact
|
16250
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
15596
16251
|
inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
|
15597
16252
|
inspector << "├── value_loc: #{inspector.location(value_loc)}\n"
|
15598
16253
|
inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
|
@@ -15967,6 +16622,9 @@ module Prism
|
|
15967
16622
|
# until foo do bar end
|
15968
16623
|
# ^^^^^^^^^^^^^^^^^^^^
|
15969
16624
|
class UntilNode < Node
|
16625
|
+
# attr_reader flags: Integer
|
16626
|
+
private attr_reader :flags
|
16627
|
+
|
15970
16628
|
# attr_reader keyword_loc: Location
|
15971
16629
|
attr_reader :keyword_loc
|
15972
16630
|
|
@@ -15979,16 +16637,13 @@ module Prism
|
|
15979
16637
|
# attr_reader statements: StatementsNode?
|
15980
16638
|
attr_reader :statements
|
15981
16639
|
|
15982
|
-
#
|
15983
|
-
|
15984
|
-
|
15985
|
-
# def initialize: (keyword_loc: Location, closing_loc: Location?, predicate: Node, statements: StatementsNode?, flags: Integer, location: Location) -> void
|
15986
|
-
def initialize(keyword_loc, closing_loc, predicate, statements, flags, location)
|
16640
|
+
# def initialize: (flags: Integer, keyword_loc: Location, closing_loc: Location?, predicate: Node, statements: StatementsNode?, location: Location) -> void
|
16641
|
+
def initialize(flags, keyword_loc, closing_loc, predicate, statements, location)
|
16642
|
+
@flags = flags
|
15987
16643
|
@keyword_loc = keyword_loc
|
15988
16644
|
@closing_loc = closing_loc
|
15989
16645
|
@predicate = predicate
|
15990
16646
|
@statements = statements
|
15991
|
-
@flags = flags
|
15992
16647
|
@location = location
|
15993
16648
|
end
|
15994
16649
|
|
@@ -16022,11 +16677,11 @@ module Prism
|
|
16022
16677
|
# def copy: (**params) -> UntilNode
|
16023
16678
|
def copy(**params)
|
16024
16679
|
UntilNode.new(
|
16680
|
+
params.fetch(:flags) { flags },
|
16025
16681
|
params.fetch(:keyword_loc) { keyword_loc },
|
16026
16682
|
params.fetch(:closing_loc) { closing_loc },
|
16027
16683
|
params.fetch(:predicate) { predicate },
|
16028
16684
|
params.fetch(:statements) { statements },
|
16029
|
-
params.fetch(:flags) { flags },
|
16030
16685
|
params.fetch(:location) { location },
|
16031
16686
|
)
|
16032
16687
|
end
|
@@ -16036,7 +16691,12 @@ module Prism
|
|
16036
16691
|
|
16037
16692
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
16038
16693
|
def deconstruct_keys(keys)
|
16039
|
-
{ keyword_loc: keyword_loc, closing_loc: closing_loc, predicate: predicate, statements: statements,
|
16694
|
+
{ flags: flags, keyword_loc: keyword_loc, closing_loc: closing_loc, predicate: predicate, statements: statements, location: location }
|
16695
|
+
end
|
16696
|
+
|
16697
|
+
# def begin_modifier?: () -> bool
|
16698
|
+
def begin_modifier?
|
16699
|
+
flags.anybits?(LoopFlags::BEGIN_MODIFIER)
|
16040
16700
|
end
|
16041
16701
|
|
16042
16702
|
# def keyword: () -> String
|
@@ -16049,26 +16709,21 @@ module Prism
|
|
16049
16709
|
closing_loc&.slice
|
16050
16710
|
end
|
16051
16711
|
|
16052
|
-
# def begin_modifier?: () -> bool
|
16053
|
-
def begin_modifier?
|
16054
|
-
flags.anybits?(LoopFlags::BEGIN_MODIFIER)
|
16055
|
-
end
|
16056
|
-
|
16057
16712
|
# def inspect(inspector: NodeInspector) -> String
|
16058
16713
|
def inspect(inspector = NodeInspector.new)
|
16059
16714
|
inspector << inspector.header(self)
|
16715
|
+
flags = [("begin_modifier" if begin_modifier?)].compact
|
16716
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
16060
16717
|
inspector << "├── keyword_loc: #{inspector.location(keyword_loc)}\n"
|
16061
16718
|
inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
|
16062
16719
|
inspector << "├── predicate:\n"
|
16063
16720
|
inspector << inspector.child_node(predicate, "│ ")
|
16064
16721
|
if (statements = self.statements).nil?
|
16065
|
-
inspector << "
|
16722
|
+
inspector << "└── statements: ∅\n"
|
16066
16723
|
else
|
16067
|
-
inspector << "
|
16068
|
-
inspector << statements.inspect(inspector.child_inspector("
|
16724
|
+
inspector << "└── statements:\n"
|
16725
|
+
inspector << statements.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix)
|
16069
16726
|
end
|
16070
|
-
flags = [("begin_modifier" if begin_modifier?)].compact
|
16071
|
-
inspector << "└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
16072
16727
|
inspector.to_str
|
16073
16728
|
end
|
16074
16729
|
|
@@ -16222,6 +16877,9 @@ module Prism
|
|
16222
16877
|
# while foo do bar end
|
16223
16878
|
# ^^^^^^^^^^^^^^^^^^^^
|
16224
16879
|
class WhileNode < Node
|
16880
|
+
# attr_reader flags: Integer
|
16881
|
+
private attr_reader :flags
|
16882
|
+
|
16225
16883
|
# attr_reader keyword_loc: Location
|
16226
16884
|
attr_reader :keyword_loc
|
16227
16885
|
|
@@ -16234,16 +16892,13 @@ module Prism
|
|
16234
16892
|
# attr_reader statements: StatementsNode?
|
16235
16893
|
attr_reader :statements
|
16236
16894
|
|
16237
|
-
#
|
16238
|
-
|
16239
|
-
|
16240
|
-
# def initialize: (keyword_loc: Location, closing_loc: Location?, predicate: Node, statements: StatementsNode?, flags: Integer, location: Location) -> void
|
16241
|
-
def initialize(keyword_loc, closing_loc, predicate, statements, flags, location)
|
16895
|
+
# def initialize: (flags: Integer, keyword_loc: Location, closing_loc: Location?, predicate: Node, statements: StatementsNode?, location: Location) -> void
|
16896
|
+
def initialize(flags, keyword_loc, closing_loc, predicate, statements, location)
|
16897
|
+
@flags = flags
|
16242
16898
|
@keyword_loc = keyword_loc
|
16243
16899
|
@closing_loc = closing_loc
|
16244
16900
|
@predicate = predicate
|
16245
16901
|
@statements = statements
|
16246
|
-
@flags = flags
|
16247
16902
|
@location = location
|
16248
16903
|
end
|
16249
16904
|
|
@@ -16277,11 +16932,11 @@ module Prism
|
|
16277
16932
|
# def copy: (**params) -> WhileNode
|
16278
16933
|
def copy(**params)
|
16279
16934
|
WhileNode.new(
|
16935
|
+
params.fetch(:flags) { flags },
|
16280
16936
|
params.fetch(:keyword_loc) { keyword_loc },
|
16281
16937
|
params.fetch(:closing_loc) { closing_loc },
|
16282
16938
|
params.fetch(:predicate) { predicate },
|
16283
16939
|
params.fetch(:statements) { statements },
|
16284
|
-
params.fetch(:flags) { flags },
|
16285
16940
|
params.fetch(:location) { location },
|
16286
16941
|
)
|
16287
16942
|
end
|
@@ -16291,7 +16946,12 @@ module Prism
|
|
16291
16946
|
|
16292
16947
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
16293
16948
|
def deconstruct_keys(keys)
|
16294
|
-
{ keyword_loc: keyword_loc, closing_loc: closing_loc, predicate: predicate, statements: statements,
|
16949
|
+
{ flags: flags, keyword_loc: keyword_loc, closing_loc: closing_loc, predicate: predicate, statements: statements, location: location }
|
16950
|
+
end
|
16951
|
+
|
16952
|
+
# def begin_modifier?: () -> bool
|
16953
|
+
def begin_modifier?
|
16954
|
+
flags.anybits?(LoopFlags::BEGIN_MODIFIER)
|
16295
16955
|
end
|
16296
16956
|
|
16297
16957
|
# def keyword: () -> String
|
@@ -16304,26 +16964,21 @@ module Prism
|
|
16304
16964
|
closing_loc&.slice
|
16305
16965
|
end
|
16306
16966
|
|
16307
|
-
# def begin_modifier?: () -> bool
|
16308
|
-
def begin_modifier?
|
16309
|
-
flags.anybits?(LoopFlags::BEGIN_MODIFIER)
|
16310
|
-
end
|
16311
|
-
|
16312
16967
|
# def inspect(inspector: NodeInspector) -> String
|
16313
16968
|
def inspect(inspector = NodeInspector.new)
|
16314
16969
|
inspector << inspector.header(self)
|
16970
|
+
flags = [("begin_modifier" if begin_modifier?)].compact
|
16971
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
16315
16972
|
inspector << "├── keyword_loc: #{inspector.location(keyword_loc)}\n"
|
16316
16973
|
inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
|
16317
16974
|
inspector << "├── predicate:\n"
|
16318
16975
|
inspector << inspector.child_node(predicate, "│ ")
|
16319
16976
|
if (statements = self.statements).nil?
|
16320
|
-
inspector << "
|
16977
|
+
inspector << "└── statements: ∅\n"
|
16321
16978
|
else
|
16322
|
-
inspector << "
|
16323
|
-
inspector << statements.inspect(inspector.child_inspector("
|
16979
|
+
inspector << "└── statements:\n"
|
16980
|
+
inspector << statements.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix)
|
16324
16981
|
end
|
16325
|
-
flags = [("begin_modifier" if begin_modifier?)].compact
|
16326
|
-
inspector << "└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
16327
16982
|
inspector.to_str
|
16328
16983
|
end
|
16329
16984
|
|
@@ -16361,6 +17016,9 @@ module Prism
|
|
16361
17016
|
# `foo`
|
16362
17017
|
# ^^^^^
|
16363
17018
|
class XStringNode < Node
|
17019
|
+
# attr_reader flags: Integer
|
17020
|
+
private attr_reader :flags
|
17021
|
+
|
16364
17022
|
# attr_reader opening_loc: Location
|
16365
17023
|
attr_reader :opening_loc
|
16366
17024
|
|
@@ -16373,8 +17031,9 @@ module Prism
|
|
16373
17031
|
# attr_reader unescaped: String
|
16374
17032
|
attr_reader :unescaped
|
16375
17033
|
|
16376
|
-
# def initialize: (opening_loc: Location, content_loc: Location, closing_loc: Location, unescaped: String, location: Location) -> void
|
16377
|
-
def initialize(opening_loc, content_loc, closing_loc, unescaped, location)
|
17034
|
+
# def initialize: (flags: Integer, opening_loc: Location, content_loc: Location, closing_loc: Location, unescaped: String, location: Location) -> void
|
17035
|
+
def initialize(flags, opening_loc, content_loc, closing_loc, unescaped, location)
|
17036
|
+
@flags = flags
|
16378
17037
|
@opening_loc = opening_loc
|
16379
17038
|
@content_loc = content_loc
|
16380
17039
|
@closing_loc = closing_loc
|
@@ -16405,6 +17064,7 @@ module Prism
|
|
16405
17064
|
# def copy: (**params) -> XStringNode
|
16406
17065
|
def copy(**params)
|
16407
17066
|
XStringNode.new(
|
17067
|
+
params.fetch(:flags) { flags },
|
16408
17068
|
params.fetch(:opening_loc) { opening_loc },
|
16409
17069
|
params.fetch(:content_loc) { content_loc },
|
16410
17070
|
params.fetch(:closing_loc) { closing_loc },
|
@@ -16418,7 +17078,17 @@ module Prism
|
|
16418
17078
|
|
16419
17079
|
# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
|
16420
17080
|
def deconstruct_keys(keys)
|
16421
|
-
{ opening_loc: opening_loc, content_loc: content_loc, closing_loc: closing_loc, unescaped: unescaped, location: location }
|
17081
|
+
{ flags: flags, opening_loc: opening_loc, content_loc: content_loc, closing_loc: closing_loc, unescaped: unescaped, location: location }
|
17082
|
+
end
|
17083
|
+
|
17084
|
+
# def forced_utf8_encoding?: () -> bool
|
17085
|
+
def forced_utf8_encoding?
|
17086
|
+
flags.anybits?(EncodingFlags::FORCED_UTF8_ENCODING)
|
17087
|
+
end
|
17088
|
+
|
17089
|
+
# def forced_binary_encoding?: () -> bool
|
17090
|
+
def forced_binary_encoding?
|
17091
|
+
flags.anybits?(EncodingFlags::FORCED_BINARY_ENCODING)
|
16422
17092
|
end
|
16423
17093
|
|
16424
17094
|
# def opening: () -> String
|
@@ -16439,6 +17109,8 @@ module Prism
|
|
16439
17109
|
# def inspect(inspector: NodeInspector) -> String
|
16440
17110
|
def inspect(inspector = NodeInspector.new)
|
16441
17111
|
inspector << inspector.header(self)
|
17112
|
+
flags = [("forced_utf8_encoding" if forced_utf8_encoding?), ("forced_binary_encoding" if forced_binary_encoding?)].compact
|
17113
|
+
inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
|
16442
17114
|
inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
|
16443
17115
|
inspector << "├── content_loc: #{inspector.location(content_loc)}\n"
|
16444
17116
|
inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
|
@@ -16604,7 +17276,13 @@ module Prism
|
|
16604
17276
|
# Flags for arguments nodes.
|
16605
17277
|
module ArgumentsNodeFlags
|
16606
17278
|
# if arguments contain keyword splat
|
16607
|
-
|
17279
|
+
CONTAINS_KEYWORD_SPLAT = 1 << 0
|
17280
|
+
end
|
17281
|
+
|
17282
|
+
# Flags for array nodes.
|
17283
|
+
module ArrayNodeFlags
|
17284
|
+
# if array contains splat nodes
|
17285
|
+
CONTAINS_SPLAT = 1 << 0
|
16608
17286
|
end
|
16609
17287
|
|
16610
17288
|
# Flags for call nodes.
|
@@ -16614,6 +17292,18 @@ module Prism
|
|
16614
17292
|
|
16615
17293
|
# a call that could have been a local variable
|
16616
17294
|
VARIABLE_CALL = 1 << 1
|
17295
|
+
|
17296
|
+
# a call that is an attribute write, so the value being written should be returned
|
17297
|
+
ATTRIBUTE_WRITE = 1 << 2
|
17298
|
+
end
|
17299
|
+
|
17300
|
+
# Flags for nodes that have unescaped content.
|
17301
|
+
module EncodingFlags
|
17302
|
+
# internal bytes forced the encoding to UTF-8
|
17303
|
+
FORCED_UTF8_ENCODING = 1 << 0
|
17304
|
+
|
17305
|
+
# internal bytes forced the encoding to binary
|
17306
|
+
FORCED_BINARY_ENCODING = 1 << 1
|
16617
17307
|
end
|
16618
17308
|
|
16619
17309
|
# Flags for integer nodes that correspond to the base of the integer.
|
@@ -16621,16 +17311,22 @@ module Prism
|
|
16621
17311
|
# 0b prefix
|
16622
17312
|
BINARY = 1 << 0
|
16623
17313
|
|
16624
|
-
# 0o or 0 prefix
|
16625
|
-
OCTAL = 1 << 1
|
16626
|
-
|
16627
17314
|
# 0d or no prefix
|
16628
|
-
DECIMAL = 1 <<
|
17315
|
+
DECIMAL = 1 << 1
|
17316
|
+
|
17317
|
+
# 0o or 0 prefix
|
17318
|
+
OCTAL = 1 << 2
|
16629
17319
|
|
16630
17320
|
# 0x prefix
|
16631
17321
|
HEXADECIMAL = 1 << 3
|
16632
17322
|
end
|
16633
17323
|
|
17324
|
+
# Flags for keyword hash nodes.
|
17325
|
+
module KeywordHashNodeFlags
|
17326
|
+
# a keyword hash which only has `AssocNode` elements all with static literal keys, which means the elements can be treated as keyword arguments
|
17327
|
+
STATIC_KEYS = 1 << 0
|
17328
|
+
end
|
17329
|
+
|
16634
17330
|
# Flags for while and until loop nodes.
|
16635
17331
|
module LoopFlags
|
16636
17332
|
# a loop after a begin statement, so the body is executed first before the condition
|
@@ -16668,11 +17364,38 @@ module Prism
|
|
16668
17364
|
|
16669
17365
|
# u - forces the UTF-8 encoding
|
16670
17366
|
UTF_8 = 1 << 7
|
17367
|
+
|
17368
|
+
# internal bytes forced the encoding to UTF-8
|
17369
|
+
FORCED_UTF8_ENCODING = 1 << 8
|
17370
|
+
|
17371
|
+
# internal bytes forced the encoding to binary
|
17372
|
+
FORCED_BINARY_ENCODING = 1 << 9
|
17373
|
+
|
17374
|
+
# internal bytes forced the encoding to US-ASCII
|
17375
|
+
FORCED_US_ASCII_ENCODING = 1 << 10
|
16671
17376
|
end
|
16672
17377
|
|
16673
17378
|
# Flags for string nodes.
|
16674
17379
|
module StringFlags
|
17380
|
+
# internal bytes forced the encoding to UTF-8
|
17381
|
+
FORCED_UTF8_ENCODING = 1 << 0
|
17382
|
+
|
17383
|
+
# internal bytes forced the encoding to binary
|
17384
|
+
FORCED_BINARY_ENCODING = 1 << 1
|
17385
|
+
|
16675
17386
|
# frozen by virtue of a `frozen_string_literal` comment
|
16676
|
-
FROZEN = 1 <<
|
17387
|
+
FROZEN = 1 << 2
|
17388
|
+
end
|
17389
|
+
|
17390
|
+
# Flags for symbol nodes.
|
17391
|
+
module SymbolFlags
|
17392
|
+
# internal bytes forced the encoding to UTF-8
|
17393
|
+
FORCED_UTF8_ENCODING = 1 << 0
|
17394
|
+
|
17395
|
+
# internal bytes forced the encoding to binary
|
17396
|
+
FORCED_BINARY_ENCODING = 1 << 1
|
17397
|
+
|
17398
|
+
# internal bytes forced the encoding to US-ASCII
|
17399
|
+
FORCED_US_ASCII_ENCODING = 1 << 2
|
16677
17400
|
end
|
16678
17401
|
end
|