prism 2.0.0.rc1-x86_64-linux-gnu

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.
Files changed (216) hide show
  1. checksums.yaml +7 -0
  2. data/BSDmakefile +58 -0
  3. data/CHANGELOG.md +870 -0
  4. data/CODE_OF_CONDUCT.md +76 -0
  5. data/CONTRIBUTING.md +58 -0
  6. data/LICENSE.md +7 -0
  7. data/Makefile +145 -0
  8. data/README.md +81 -0
  9. data/config.yml +4752 -0
  10. data/docs/build_system.md +119 -0
  11. data/docs/configuration.md +69 -0
  12. data/docs/cruby_compilation.md +27 -0
  13. data/docs/design.md +53 -0
  14. data/docs/encoding.md +121 -0
  15. data/docs/fuzzing.md +81 -0
  16. data/docs/heredocs.md +36 -0
  17. data/docs/javascript.md +133 -0
  18. data/docs/local_variable_depth.md +229 -0
  19. data/docs/mapping.md +117 -0
  20. data/docs/parser_translation.md +24 -0
  21. data/docs/parsing_rules.md +22 -0
  22. data/docs/releasing.md +147 -0
  23. data/docs/relocation.md +32 -0
  24. data/docs/ripper_translation.md +63 -0
  25. data/docs/ruby_api.md +45 -0
  26. data/docs/ruby_parser_translation.md +19 -0
  27. data/docs/serialization.md +230 -0
  28. data/docs/testing.md +72 -0
  29. data/ext/prism/api_node.c +7005 -0
  30. data/ext/prism/extconf.rb +126 -0
  31. data/ext/prism/extension.c +1783 -0
  32. data/ext/prism/extension.h +19 -0
  33. data/include/prism/arena.h +37 -0
  34. data/include/prism/ast.h +10371 -0
  35. data/include/prism/buffer.h +52 -0
  36. data/include/prism/comments.h +55 -0
  37. data/include/prism/compiler/accel.h +24 -0
  38. data/include/prism/compiler/align.h +36 -0
  39. data/include/prism/compiler/assume.h +25 -0
  40. data/include/prism/compiler/exported.h +24 -0
  41. data/include/prism/compiler/fallthrough.h +22 -0
  42. data/include/prism/compiler/filesystem.h +32 -0
  43. data/include/prism/compiler/flex_array.h +19 -0
  44. data/include/prism/compiler/force_inline.h +21 -0
  45. data/include/prism/compiler/format.h +25 -0
  46. data/include/prism/compiler/inline.h +17 -0
  47. data/include/prism/compiler/nodiscard.h +22 -0
  48. data/include/prism/compiler/nonnull.h +18 -0
  49. data/include/prism/compiler/unused.h +18 -0
  50. data/include/prism/constant_pool.h +81 -0
  51. data/include/prism/diagnostic.h +93 -0
  52. data/include/prism/errors_format.h +53 -0
  53. data/include/prism/excludes.h +29 -0
  54. data/include/prism/integer.h +41 -0
  55. data/include/prism/internal/allocator.h +68 -0
  56. data/include/prism/internal/allocator_debug.h +88 -0
  57. data/include/prism/internal/arena.h +108 -0
  58. data/include/prism/internal/bit.h +42 -0
  59. data/include/prism/internal/buffer.h +91 -0
  60. data/include/prism/internal/char.h +145 -0
  61. data/include/prism/internal/comments.h +53 -0
  62. data/include/prism/internal/constant_pool.h +152 -0
  63. data/include/prism/internal/diagnostic.h +389 -0
  64. data/include/prism/internal/encoding.h +242 -0
  65. data/include/prism/internal/integer.h +68 -0
  66. data/include/prism/internal/isinf.h +16 -0
  67. data/include/prism/internal/line_offset_list.h +34 -0
  68. data/include/prism/internal/list.h +62 -0
  69. data/include/prism/internal/magic_comments.h +23 -0
  70. data/include/prism/internal/memchr.h +15 -0
  71. data/include/prism/internal/node.h +38 -0
  72. data/include/prism/internal/options.h +232 -0
  73. data/include/prism/internal/parser.h +984 -0
  74. data/include/prism/internal/regexp.h +26 -0
  75. data/include/prism/internal/serialize.h +39 -0
  76. data/include/prism/internal/source.h +72 -0
  77. data/include/prism/internal/static_literals.h +100 -0
  78. data/include/prism/internal/stringy.h +35 -0
  79. data/include/prism/internal/strncasecmp.h +18 -0
  80. data/include/prism/internal/strpbrk.h +33 -0
  81. data/include/prism/internal/tokens.h +11 -0
  82. data/include/prism/json.h +32 -0
  83. data/include/prism/line_offset_list.h +61 -0
  84. data/include/prism/magic_comments.h +35 -0
  85. data/include/prism/node.h +94 -0
  86. data/include/prism/options.h +354 -0
  87. data/include/prism/parser.h +404 -0
  88. data/include/prism/prettyprint.h +31 -0
  89. data/include/prism/serialize.h +115 -0
  90. data/include/prism/source.h +155 -0
  91. data/include/prism/stream.h +28 -0
  92. data/include/prism/string_query.h +63 -0
  93. data/include/prism/stringy.h +72 -0
  94. data/include/prism/version.h +38 -0
  95. data/include/prism.h +131 -0
  96. data/lib/prism/3.3/prism.so +0 -0
  97. data/lib/prism/3.4/prism.so +0 -0
  98. data/lib/prism/4.0/prism.so +0 -0
  99. data/lib/prism/compiler.rb +815 -0
  100. data/lib/prism/desugar_compiler.rb +463 -0
  101. data/lib/prism/dispatcher.rb +2383 -0
  102. data/lib/prism/dot_visitor.rb +4848 -0
  103. data/lib/prism/dsl.rb +1369 -0
  104. data/lib/prism/ffi.rb +740 -0
  105. data/lib/prism/inspect_visitor.rb +2425 -0
  106. data/lib/prism/lex_compat.rb +953 -0
  107. data/lib/prism/mutation_compiler.rb +780 -0
  108. data/lib/prism/node.rb +33204 -0
  109. data/lib/prism/node_ext.rb +504 -0
  110. data/lib/prism/node_find.rb +215 -0
  111. data/lib/prism/parse_result/errors.rb +72 -0
  112. data/lib/prism/parse_result/newlines.rb +423 -0
  113. data/lib/prism/parse_result.rb +1221 -0
  114. data/lib/prism/pattern.rb +314 -0
  115. data/lib/prism/polyfill/append_as_bytes.rb +15 -0
  116. data/lib/prism/polyfill/byteindex.rb +13 -0
  117. data/lib/prism/polyfill/scan_byte.rb +14 -0
  118. data/lib/prism/polyfill/unpack1.rb +14 -0
  119. data/lib/prism/polyfill/warn.rb +36 -0
  120. data/lib/prism/reflection.rb +427 -0
  121. data/lib/prism/relocation.rb +567 -0
  122. data/lib/prism/serialize.rb +5308 -0
  123. data/lib/prism/string_query.rb +46 -0
  124. data/lib/prism/translation/parser/builder.rb +70 -0
  125. data/lib/prism/translation/parser/compiler.rb +2226 -0
  126. data/lib/prism/translation/parser/lexer.rb +769 -0
  127. data/lib/prism/translation/parser.rb +376 -0
  128. data/lib/prism/translation/parser_current.rb +26 -0
  129. data/lib/prism/translation/parser_versions.rb +36 -0
  130. data/lib/prism/translation/ripper/filter.rb +53 -0
  131. data/lib/prism/translation/ripper/lexer.rb +133 -0
  132. data/lib/prism/translation/ripper/sexp.rb +118 -0
  133. data/lib/prism/translation/ripper/shim.rb +7 -0
  134. data/lib/prism/translation/ripper.rb +4278 -0
  135. data/lib/prism/translation/ruby_parser.rb +1721 -0
  136. data/lib/prism/translation.rb +20 -0
  137. data/lib/prism/visitor.rb +1440 -0
  138. data/lib/prism.rb +168 -0
  139. data/prism.gemspec +234 -0
  140. data/rbi/generated/prism/compiler.rbi +489 -0
  141. data/rbi/generated/prism/desugar_compiler.rbi +306 -0
  142. data/rbi/generated/prism/dispatcher.rbi +1138 -0
  143. data/rbi/generated/prism/dot_visitor.rbi +618 -0
  144. data/rbi/generated/prism/dsl.rbi +751 -0
  145. data/rbi/generated/prism/inspect_visitor.rbi +503 -0
  146. data/rbi/generated/prism/lex_compat.rbi +162 -0
  147. data/rbi/generated/prism/mutation_compiler.rbi +464 -0
  148. data/rbi/generated/prism/node.rbi +13681 -0
  149. data/rbi/generated/prism/node_ext.rbi +259 -0
  150. data/rbi/generated/prism/node_find.rbi +79 -0
  151. data/rbi/generated/prism/parse_result/errors.rbi +21 -0
  152. data/rbi/generated/prism/parse_result/newlines.rbi +208 -0
  153. data/rbi/generated/prism/parse_result.rbi +764 -0
  154. data/rbi/generated/prism/pattern.rbi +134 -0
  155. data/rbi/generated/prism/reflection.rbi +89 -0
  156. data/rbi/generated/prism/relocation.rbi +329 -0
  157. data/rbi/generated/prism/serialize.rbi +181 -0
  158. data/rbi/generated/prism/string_query.rbi +36 -0
  159. data/rbi/generated/prism/translation.rbi +7 -0
  160. data/rbi/generated/prism/visitor.rbi +650 -0
  161. data/rbi/generated/prism.rbi +86 -0
  162. data/rbi/prism/translation/parser.rbi +11 -0
  163. data/rbi/prism/translation/parser_versions.rbi +28 -0
  164. data/rbi/prism/translation/ripper.rbi +15 -0
  165. data/rbi/rubyvm/node_find.rbi +14 -0
  166. data/sig/generated/prism/compiler.rbs +492 -0
  167. data/sig/generated/prism/desugar_compiler.rbs +305 -0
  168. data/sig/generated/prism/dispatcher.rbs +1292 -0
  169. data/sig/generated/prism/dot_visitor.rbs +635 -0
  170. data/sig/generated/prism/dsl.rbs +928 -0
  171. data/sig/generated/prism/inspect_visitor.rbs +509 -0
  172. data/sig/generated/prism/lex_compat.rbs +166 -0
  173. data/sig/generated/prism/mutation_compiler.rbs +464 -0
  174. data/sig/generated/prism/node.rbs +20160 -0
  175. data/sig/generated/prism/node_ext.rbs +290 -0
  176. data/sig/generated/prism/node_find.rbs +90 -0
  177. data/sig/generated/prism/parse_result/errors.rbs +22 -0
  178. data/sig/generated/prism/parse_result/newlines.rbs +223 -0
  179. data/sig/generated/prism/parse_result.rbs +859 -0
  180. data/sig/generated/prism/pattern.rbs +156 -0
  181. data/sig/generated/prism/reflection.rbs +101 -0
  182. data/sig/generated/prism/relocation.rbs +428 -0
  183. data/sig/generated/prism/serialize.rbs +195 -0
  184. data/sig/generated/prism/string_query.rbs +36 -0
  185. data/sig/generated/prism/translation.rbs +8 -0
  186. data/sig/generated/prism/visitor.rbs +1111 -0
  187. data/sig/generated/prism.rbs +84 -0
  188. data/sig/manifest.yaml +2 -0
  189. data/src/arena.c +117 -0
  190. data/src/buffer.c +380 -0
  191. data/src/char.c +289 -0
  192. data/src/comments.c +454 -0
  193. data/src/constant_pool.c +406 -0
  194. data/src/diagnostic.c +886 -0
  195. data/src/encoding.c +5345 -0
  196. data/src/errors_format.c +519 -0
  197. data/src/integer.c +681 -0
  198. data/src/json.c +5733 -0
  199. data/src/line_offset_list.c +100 -0
  200. data/src/list.c +24 -0
  201. data/src/memchr.c +37 -0
  202. data/src/node.c +4515 -0
  203. data/src/options.c +451 -0
  204. data/src/parser.c +349 -0
  205. data/src/prettyprint.c +9024 -0
  206. data/src/prism.c +23739 -0
  207. data/src/regexp.c +1706 -0
  208. data/src/serialize.c +2309 -0
  209. data/src/source.c +518 -0
  210. data/src/static_literals.c +685 -0
  211. data/src/string_query.c +166 -0
  212. data/src/stringy.c +91 -0
  213. data/src/strncasecmp.c +37 -0
  214. data/src/strpbrk.c +447 -0
  215. data/src/tokens.c +724 -0
  216. metadata +259 -0
@@ -0,0 +1,463 @@
1
+ # frozen_string_literal: true
2
+ # :markup: markdown
3
+ #--
4
+ # rbs_inline: enabled
5
+
6
+ module Prism
7
+ class DesugarAndWriteNode # :nodoc:
8
+ include DSL
9
+
10
+ attr_reader :node #: ClassVariableAndWriteNode | ConstantAndWriteNode | GlobalVariableAndWriteNode | InstanceVariableAndWriteNode | LocalVariableAndWriteNode
11
+ attr_reader :default_source #: Source
12
+ attr_reader :read_class, :write_class #: Symbol
13
+ attr_reader :arguments #: Hash[Symbol, untyped]
14
+
15
+ #: ((ClassVariableAndWriteNode | ConstantAndWriteNode | GlobalVariableAndWriteNode | InstanceVariableAndWriteNode | LocalVariableAndWriteNode) node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void
16
+ def initialize(node, default_source, read_class, write_class, **arguments)
17
+ @node = node
18
+ @default_source = default_source
19
+ @read_class = read_class
20
+ @write_class = write_class
21
+ @arguments = arguments
22
+ end
23
+
24
+ # Desugar `x &&= y` to `x && x = y`
25
+ #
26
+ #: () -> node
27
+ def compile
28
+ and_node(
29
+ location: node.location,
30
+ left: public_send(read_class, location: node.name_loc, **arguments),
31
+ right: public_send(
32
+ write_class,
33
+ location: node.location,
34
+ **arguments,
35
+ name_loc: node.name_loc,
36
+ value: node.value,
37
+ operator_loc: node.operator_loc
38
+ ),
39
+ operator_loc: node.operator_loc
40
+ )
41
+ end
42
+ end
43
+
44
+ class DesugarOrWriteDefinedNode # :nodoc:
45
+ include DSL
46
+
47
+ attr_reader :node #: ClassVariableOrWriteNode | ConstantOrWriteNode | GlobalVariableOrWriteNode
48
+ attr_reader :default_source #: Source
49
+ attr_reader :read_class, :write_class #: Symbol
50
+ attr_reader :arguments #: Hash[Symbol, untyped]
51
+
52
+ #: ((ClassVariableOrWriteNode | ConstantOrWriteNode | GlobalVariableOrWriteNode) node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void
53
+ def initialize(node, default_source, read_class, write_class, **arguments)
54
+ @node = node
55
+ @default_source = default_source
56
+ @read_class = read_class
57
+ @write_class = write_class
58
+ @arguments = arguments
59
+ end
60
+
61
+ # Desugar `x ||= y` to `defined?(x) ? x : x = y`
62
+ #
63
+ #: () -> node
64
+ def compile
65
+ if_node(
66
+ location: node.location,
67
+ if_keyword_loc: node.operator_loc,
68
+ predicate: defined_node(
69
+ location: node.name_loc,
70
+ value: public_send(read_class, location: node.name_loc, **arguments),
71
+ keyword_loc: node.operator_loc
72
+ ),
73
+ then_keyword_loc: node.operator_loc,
74
+ statements: statements_node(
75
+ location: node.location,
76
+ body: [public_send(read_class, location: node.name_loc, **arguments)]
77
+ ),
78
+ subsequent: else_node(
79
+ location: node.location,
80
+ else_keyword_loc: node.operator_loc,
81
+ statements: statements_node(
82
+ location: node.location,
83
+ body: [
84
+ public_send(
85
+ write_class,
86
+ location: node.location,
87
+ **arguments,
88
+ name_loc: node.name_loc,
89
+ value: node.value,
90
+ operator_loc: node.operator_loc
91
+ )
92
+ ]
93
+ ),
94
+ end_keyword_loc: node.operator_loc
95
+ ),
96
+ end_keyword_loc: node.operator_loc
97
+ )
98
+ end
99
+ end
100
+
101
+ class DesugarOperatorWriteNode # :nodoc:
102
+ include DSL
103
+
104
+ attr_reader :node #: ClassVariableOperatorWriteNode | ConstantOperatorWriteNode | GlobalVariableOperatorWriteNode | InstanceVariableOperatorWriteNode | LocalVariableOperatorWriteNode
105
+ attr_reader :default_source #: Source
106
+ attr_reader :read_class, :write_class #: Symbol
107
+ attr_reader :arguments #: Hash[Symbol, untyped]
108
+
109
+ #: ((ClassVariableOperatorWriteNode | ConstantOperatorWriteNode | GlobalVariableOperatorWriteNode | InstanceVariableOperatorWriteNode | LocalVariableOperatorWriteNode) node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void
110
+ def initialize(node, default_source, read_class, write_class, **arguments)
111
+ @node = node
112
+ @default_source = default_source
113
+ @read_class = read_class
114
+ @write_class = write_class
115
+ @arguments = arguments
116
+ end
117
+
118
+ # Desugar `x += y` to `x = x + y`
119
+ #
120
+ #: () -> node
121
+ def compile
122
+ binary_operator_loc = node.binary_operator_loc.chop
123
+
124
+ public_send(
125
+ write_class,
126
+ location: node.location,
127
+ **arguments,
128
+ name_loc: node.name_loc,
129
+ value: call_node(
130
+ location: node.location,
131
+ receiver: public_send(
132
+ read_class,
133
+ location: node.name_loc,
134
+ **arguments
135
+ ),
136
+ name: binary_operator_loc.slice.to_sym,
137
+ message_loc: binary_operator_loc,
138
+ arguments: arguments_node(
139
+ location: node.value.location,
140
+ arguments: [node.value]
141
+ )
142
+ ),
143
+ operator_loc: node.binary_operator_loc.copy(
144
+ start_offset: node.binary_operator_loc.end_offset - 1,
145
+ length: 1
146
+ )
147
+ )
148
+ end
149
+ end
150
+
151
+ class DesugarOrWriteNode # :nodoc:
152
+ include DSL
153
+
154
+ attr_reader :node #: InstanceVariableOrWriteNode | LocalVariableOrWriteNode
155
+ attr_reader :default_source #: Source
156
+ attr_reader :read_class, :write_class #: Symbol
157
+ attr_reader :arguments #: Hash[Symbol, untyped]
158
+
159
+ #: ((InstanceVariableOrWriteNode | LocalVariableOrWriteNode) node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void
160
+ def initialize(node, default_source, read_class, write_class, **arguments)
161
+ @node = node
162
+ @default_source = default_source
163
+ @read_class = read_class
164
+ @write_class = write_class
165
+ @arguments = arguments
166
+ end
167
+
168
+ # Desugar `x ||= y` to `x || x = y`
169
+ #
170
+ #: () -> node
171
+ def compile
172
+ or_node(
173
+ location: node.location,
174
+ left: public_send(read_class, location: node.name_loc, **arguments),
175
+ right: public_send(
176
+ write_class,
177
+ location: node.location,
178
+ **arguments,
179
+ name_loc: node.name_loc,
180
+ value: node.value,
181
+ operator_loc: node.operator_loc
182
+ ),
183
+ operator_loc: node.operator_loc
184
+ )
185
+ end
186
+ end
187
+
188
+ private_constant :DesugarAndWriteNode, :DesugarOrWriteNode, :DesugarOrWriteDefinedNode, :DesugarOperatorWriteNode
189
+
190
+ class ClassVariableAndWriteNode
191
+ #: () -> node
192
+ def desugar # :nodoc:
193
+ DesugarAndWriteNode.new(self, source, :class_variable_read_node, :class_variable_write_node, name: name).compile
194
+ end
195
+ end
196
+
197
+ class ClassVariableOrWriteNode
198
+ #: () -> node
199
+ def desugar # :nodoc:
200
+ DesugarOrWriteDefinedNode.new(self, source, :class_variable_read_node, :class_variable_write_node, name: name).compile
201
+ end
202
+ end
203
+
204
+ class ClassVariableOperatorWriteNode
205
+ #: () -> node
206
+ def desugar # :nodoc:
207
+ DesugarOperatorWriteNode.new(self, source, :class_variable_read_node, :class_variable_write_node, name: name).compile
208
+ end
209
+ end
210
+
211
+ class ConstantAndWriteNode
212
+ #: () -> node
213
+ def desugar # :nodoc:
214
+ DesugarAndWriteNode.new(self, source, :constant_read_node, :constant_write_node, name: name).compile
215
+ end
216
+ end
217
+
218
+ class ConstantOrWriteNode
219
+ #: () -> node
220
+ def desugar # :nodoc:
221
+ DesugarOrWriteDefinedNode.new(self, source, :constant_read_node, :constant_write_node, name: name).compile
222
+ end
223
+ end
224
+
225
+ class ConstantOperatorWriteNode
226
+ #: () -> node
227
+ def desugar # :nodoc:
228
+ DesugarOperatorWriteNode.new(self, source, :constant_read_node, :constant_write_node, name: name).compile
229
+ end
230
+ end
231
+
232
+ class GlobalVariableAndWriteNode
233
+ #: () -> node
234
+ def desugar # :nodoc:
235
+ DesugarAndWriteNode.new(self, source, :global_variable_read_node, :global_variable_write_node, name: name).compile
236
+ end
237
+ end
238
+
239
+ class GlobalVariableOrWriteNode
240
+ #: () -> node
241
+ def desugar # :nodoc:
242
+ DesugarOrWriteDefinedNode.new(self, source, :global_variable_read_node, :global_variable_write_node, name: name).compile
243
+ end
244
+ end
245
+
246
+ class GlobalVariableOperatorWriteNode
247
+ #: () -> node
248
+ def desugar # :nodoc:
249
+ DesugarOperatorWriteNode.new(self, source, :global_variable_read_node, :global_variable_write_node, name: name).compile
250
+ end
251
+ end
252
+
253
+ class InstanceVariableAndWriteNode
254
+ #: () -> node
255
+ def desugar # :nodoc:
256
+ DesugarAndWriteNode.new(self, source, :instance_variable_read_node, :instance_variable_write_node, name: name).compile
257
+ end
258
+ end
259
+
260
+ class InstanceVariableOrWriteNode
261
+ #: () -> node
262
+ def desugar # :nodoc:
263
+ DesugarOrWriteNode.new(self, source, :instance_variable_read_node, :instance_variable_write_node, name: name).compile
264
+ end
265
+ end
266
+
267
+ class InstanceVariableOperatorWriteNode
268
+ #: () -> node
269
+ def desugar # :nodoc:
270
+ DesugarOperatorWriteNode.new(self, source, :instance_variable_read_node, :instance_variable_write_node, name: name).compile
271
+ end
272
+ end
273
+
274
+ class LocalVariableAndWriteNode
275
+ #: () -> node
276
+ def desugar # :nodoc:
277
+ DesugarAndWriteNode.new(self, source, :local_variable_read_node, :local_variable_write_node, name: name, depth: depth).compile
278
+ end
279
+ end
280
+
281
+ class LocalVariableOrWriteNode
282
+ #: () -> node
283
+ def desugar # :nodoc:
284
+ DesugarOrWriteNode.new(self, source, :local_variable_read_node, :local_variable_write_node, name: name, depth: depth).compile
285
+ end
286
+ end
287
+
288
+ class LocalVariableOperatorWriteNode
289
+ #: () -> node
290
+ def desugar # :nodoc:
291
+ DesugarOperatorWriteNode.new(self, source, :local_variable_read_node, :local_variable_write_node, name: name, depth: depth).compile
292
+ end
293
+ end
294
+
295
+ # DesugarCompiler is a compiler that desugars Ruby code into a more primitive
296
+ # form. This is useful for consumers that want to deal with fewer node types.
297
+ class DesugarCompiler < MutationCompiler
298
+ # `@@foo &&= bar`
299
+ #
300
+ # becomes
301
+ #
302
+ # `@@foo && @@foo = bar`
303
+ #
304
+ #: (ClassVariableAndWriteNode node) -> node
305
+ def visit_class_variable_and_write_node(node)
306
+ node.desugar
307
+ end
308
+
309
+ # `@@foo ||= bar`
310
+ #
311
+ # becomes
312
+ #
313
+ # `defined?(@@foo) ? @@foo : @@foo = bar`
314
+ #
315
+ #: (ClassVariableOrWriteNode node) -> node
316
+ def visit_class_variable_or_write_node(node)
317
+ node.desugar
318
+ end
319
+
320
+ # `@@foo += bar`
321
+ #
322
+ # becomes
323
+ #
324
+ # `@@foo = @@foo + bar`
325
+ #
326
+ #: (ClassVariableOperatorWriteNode node) -> node
327
+ def visit_class_variable_operator_write_node(node)
328
+ node.desugar
329
+ end
330
+
331
+ # `Foo &&= bar`
332
+ #
333
+ # becomes
334
+ #
335
+ # `Foo && Foo = bar`
336
+ #
337
+ #: (ConstantAndWriteNode node) -> node
338
+ def visit_constant_and_write_node(node)
339
+ node.desugar
340
+ end
341
+
342
+ # `Foo ||= bar`
343
+ #
344
+ # becomes
345
+ #
346
+ # `defined?(Foo) ? Foo : Foo = bar`
347
+ #
348
+ #: (ConstantOrWriteNode node) -> node
349
+ def visit_constant_or_write_node(node)
350
+ node.desugar
351
+ end
352
+
353
+ # `Foo += bar`
354
+ #
355
+ # becomes
356
+ #
357
+ # `Foo = Foo + bar`
358
+ #
359
+ #: (ConstantOperatorWriteNode node) -> node
360
+ def visit_constant_operator_write_node(node)
361
+ node.desugar
362
+ end
363
+
364
+ # `$foo &&= bar`
365
+ #
366
+ # becomes
367
+ #
368
+ # `$foo && $foo = bar`
369
+ #
370
+ #: (GlobalVariableAndWriteNode node) -> node
371
+ def visit_global_variable_and_write_node(node)
372
+ node.desugar
373
+ end
374
+
375
+ # `$foo ||= bar`
376
+ #
377
+ # becomes
378
+ #
379
+ # `defined?($foo) ? $foo : $foo = bar`
380
+ #
381
+ #: (GlobalVariableOrWriteNode node) -> node
382
+ def visit_global_variable_or_write_node(node)
383
+ node.desugar
384
+ end
385
+
386
+ # `$foo += bar`
387
+ #
388
+ # becomes
389
+ #
390
+ # `$foo = $foo + bar`
391
+ #
392
+ #: (GlobalVariableOperatorWriteNode node) -> node
393
+ def visit_global_variable_operator_write_node(node)
394
+ node.desugar
395
+ end
396
+
397
+ # `@foo &&= bar`
398
+ #
399
+ # becomes
400
+ #
401
+ # `@foo && @foo = bar`
402
+ #
403
+ #: (InstanceVariableAndWriteNode node) -> node
404
+ def visit_instance_variable_and_write_node(node)
405
+ node.desugar
406
+ end
407
+
408
+ # `@foo ||= bar`
409
+ #
410
+ # becomes
411
+ #
412
+ # `@foo || @foo = bar`
413
+ #
414
+ #: (InstanceVariableOrWriteNode node) -> node
415
+ def visit_instance_variable_or_write_node(node)
416
+ node.desugar
417
+ end
418
+
419
+ # `@foo += bar`
420
+ #
421
+ # becomes
422
+ #
423
+ # `@foo = @foo + bar`
424
+ #
425
+ #: (InstanceVariableOperatorWriteNode node) -> node
426
+ def visit_instance_variable_operator_write_node(node)
427
+ node.desugar
428
+ end
429
+
430
+ # `foo &&= bar`
431
+ #
432
+ # becomes
433
+ #
434
+ # `foo && foo = bar`
435
+ #
436
+ #: (LocalVariableAndWriteNode node) -> node
437
+ def visit_local_variable_and_write_node(node)
438
+ node.desugar
439
+ end
440
+
441
+ # `foo ||= bar`
442
+ #
443
+ # becomes
444
+ #
445
+ # `foo || foo = bar`
446
+ #
447
+ #: (LocalVariableOrWriteNode node) -> node
448
+ def visit_local_variable_or_write_node(node)
449
+ node.desugar
450
+ end
451
+
452
+ # `foo += bar`
453
+ #
454
+ # becomes
455
+ #
456
+ # `foo = foo + bar`
457
+ #
458
+ #: (LocalVariableOperatorWriteNode node) -> node
459
+ def visit_local_variable_operator_write_node(node)
460
+ node.desugar
461
+ end
462
+ end
463
+ end