yarp 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -8
  3. data/CONTRIBUTING.md +2 -2
  4. data/Makefile +5 -5
  5. data/README.md +11 -12
  6. data/config.yml +6 -2
  7. data/docs/build_system.md +21 -21
  8. data/docs/building.md +4 -4
  9. data/docs/configuration.md +25 -21
  10. data/docs/design.md +2 -2
  11. data/docs/encoding.md +17 -17
  12. data/docs/fuzzing.md +4 -4
  13. data/docs/heredocs.md +3 -3
  14. data/docs/mapping.md +94 -94
  15. data/docs/ripper.md +4 -4
  16. data/docs/ruby_api.md +11 -11
  17. data/docs/serialization.md +17 -16
  18. data/docs/testing.md +6 -6
  19. data/ext/prism/api_node.c +4725 -0
  20. data/ext/{yarp → prism}/api_pack.c +82 -82
  21. data/ext/{yarp → prism}/extconf.rb +13 -13
  22. data/ext/{yarp → prism}/extension.c +175 -168
  23. data/ext/prism/extension.h +18 -0
  24. data/include/prism/ast.h +1932 -0
  25. data/include/prism/defines.h +45 -0
  26. data/include/prism/diagnostic.h +231 -0
  27. data/include/{yarp/enc/yp_encoding.h → prism/enc/pm_encoding.h} +40 -40
  28. data/include/prism/node.h +41 -0
  29. data/include/prism/pack.h +141 -0
  30. data/include/{yarp → prism}/parser.h +143 -142
  31. data/include/prism/regexp.h +19 -0
  32. data/include/prism/unescape.h +48 -0
  33. data/include/prism/util/pm_buffer.h +51 -0
  34. data/include/{yarp/util/yp_char.h → prism/util/pm_char.h} +20 -20
  35. data/include/{yarp/util/yp_constant_pool.h → prism/util/pm_constant_pool.h} +26 -22
  36. data/include/{yarp/util/yp_list.h → prism/util/pm_list.h} +21 -21
  37. data/include/prism/util/pm_memchr.h +14 -0
  38. data/include/{yarp/util/yp_newline_list.h → prism/util/pm_newline_list.h} +11 -11
  39. data/include/prism/util/pm_state_stack.h +24 -0
  40. data/include/{yarp/util/yp_string.h → prism/util/pm_string.h} +20 -20
  41. data/include/prism/util/pm_string_list.h +25 -0
  42. data/include/{yarp/util/yp_strpbrk.h → prism/util/pm_strpbrk.h} +7 -7
  43. data/include/prism/version.h +4 -0
  44. data/include/prism.h +82 -0
  45. data/lib/prism/compiler.rb +465 -0
  46. data/lib/prism/debug.rb +157 -0
  47. data/lib/{yarp/desugar_visitor.rb → prism/desugar_compiler.rb} +4 -2
  48. data/lib/prism/dispatcher.rb +2051 -0
  49. data/lib/prism/dsl.rb +750 -0
  50. data/lib/{yarp → prism}/ffi.rb +66 -67
  51. data/lib/{yarp → prism}/lex_compat.rb +40 -43
  52. data/lib/{yarp/mutation_visitor.rb → prism/mutation_compiler.rb} +3 -3
  53. data/lib/{yarp → prism}/node.rb +2012 -2593
  54. data/lib/prism/node_ext.rb +55 -0
  55. data/lib/prism/node_inspector.rb +68 -0
  56. data/lib/{yarp → prism}/pack.rb +1 -1
  57. data/lib/{yarp → prism}/parse_result/comments.rb +1 -1
  58. data/lib/{yarp → prism}/parse_result/newlines.rb +1 -1
  59. data/lib/prism/parse_result.rb +266 -0
  60. data/lib/{yarp → prism}/pattern.rb +14 -14
  61. data/lib/{yarp → prism}/ripper_compat.rb +5 -5
  62. data/lib/{yarp → prism}/serialize.rb +12 -7
  63. data/lib/prism/visitor.rb +470 -0
  64. data/lib/prism.rb +64 -0
  65. data/lib/yarp.rb +2 -614
  66. data/src/diagnostic.c +213 -208
  67. data/src/enc/pm_big5.c +52 -0
  68. data/src/enc/pm_euc_jp.c +58 -0
  69. data/src/enc/{yp_gbk.c → pm_gbk.c} +16 -16
  70. data/src/enc/pm_shift_jis.c +56 -0
  71. data/src/enc/{yp_tables.c → pm_tables.c} +69 -69
  72. data/src/enc/{yp_unicode.c → pm_unicode.c} +40 -40
  73. data/src/enc/pm_windows_31j.c +56 -0
  74. data/src/node.c +1293 -1233
  75. data/src/pack.c +247 -247
  76. data/src/prettyprint.c +1479 -1479
  77. data/src/{yarp.c → prism.c} +5205 -5083
  78. data/src/regexp.c +132 -132
  79. data/src/serialize.c +1121 -1121
  80. data/src/token_type.c +169 -167
  81. data/src/unescape.c +106 -87
  82. data/src/util/pm_buffer.c +103 -0
  83. data/src/util/{yp_char.c → pm_char.c} +72 -72
  84. data/src/util/{yp_constant_pool.c → pm_constant_pool.c} +85 -64
  85. data/src/util/{yp_list.c → pm_list.c} +10 -10
  86. data/src/util/{yp_memchr.c → pm_memchr.c} +6 -4
  87. data/src/util/{yp_newline_list.c → pm_newline_list.c} +21 -21
  88. data/src/util/{yp_state_stack.c → pm_state_stack.c} +4 -4
  89. data/src/util/{yp_string.c → pm_string.c} +38 -38
  90. data/src/util/pm_string_list.c +29 -0
  91. data/src/util/{yp_strncasecmp.c → pm_strncasecmp.c} +1 -1
  92. data/src/util/{yp_strpbrk.c → pm_strpbrk.c} +8 -8
  93. data/yarp.gemspec +68 -59
  94. metadata +70 -61
  95. data/ext/yarp/api_node.c +0 -4728
  96. data/ext/yarp/extension.h +0 -18
  97. data/include/yarp/ast.h +0 -1929
  98. data/include/yarp/defines.h +0 -45
  99. data/include/yarp/diagnostic.h +0 -226
  100. data/include/yarp/node.h +0 -42
  101. data/include/yarp/pack.h +0 -141
  102. data/include/yarp/regexp.h +0 -19
  103. data/include/yarp/unescape.h +0 -44
  104. data/include/yarp/util/yp_buffer.h +0 -51
  105. data/include/yarp/util/yp_memchr.h +0 -14
  106. data/include/yarp/util/yp_state_stack.h +0 -24
  107. data/include/yarp/util/yp_string_list.h +0 -25
  108. data/include/yarp/version.h +0 -4
  109. data/include/yarp.h +0 -82
  110. data/src/enc/yp_big5.c +0 -52
  111. data/src/enc/yp_euc_jp.c +0 -58
  112. data/src/enc/yp_shift_jis.c +0 -56
  113. data/src/enc/yp_windows_31j.c +0 -56
  114. data/src/util/yp_buffer.c +0 -101
  115. data/src/util/yp_string_list.c +0 -29
@@ -6,7 +6,7 @@
6
6
  require "rbconfig"
7
7
  require "ffi"
8
8
 
9
- module YARP
9
+ module Prism
10
10
  BACKEND = :FFI
11
11
 
12
12
  module LibRubyParser
@@ -35,13 +35,13 @@ module YARP
35
35
  def self.load_exported_functions_from(header, *functions)
36
36
  File.foreach(File.expand_path("../../include/#{header}", __dir__)) do |line|
37
37
  # We only want to attempt to load exported functions.
38
- next unless line.start_with?("YP_EXPORTED_FUNCTION ")
38
+ next unless line.start_with?("PRISM_EXPORTED_FUNCTION ")
39
39
 
40
40
  # We only want to load the functions that we are interested in.
41
41
  next unless functions.any? { |function| line.include?(function) }
42
42
 
43
43
  # Parse the function declaration.
44
- unless /^YP_EXPORTED_FUNCTION (?<return_type>.+) (?<name>\w+)\((?<arg_types>.+)\);$/ =~ line
44
+ unless /^PRISM_EXPORTED_FUNCTION (?<return_type>.+) (?<name>\w+)\((?<arg_types>.+)\);$/ =~ line
45
45
  raise "Could not parse #{line}"
46
46
  end
47
47
 
@@ -67,35 +67,35 @@ module YARP
67
67
  end
68
68
 
69
69
  load_exported_functions_from(
70
- "yarp.h",
71
- "yp_version",
72
- "yp_parse_serialize",
73
- "yp_lex_serialize",
74
- "yp_parse_lex_serialize"
70
+ "prism.h",
71
+ "pm_version",
72
+ "pm_parse_serialize",
73
+ "pm_lex_serialize",
74
+ "pm_parse_lex_serialize"
75
75
  )
76
76
 
77
77
  load_exported_functions_from(
78
- "yarp/util/yp_buffer.h",
79
- "yp_buffer_sizeof",
80
- "yp_buffer_init",
81
- "yp_buffer_value",
82
- "yp_buffer_length",
83
- "yp_buffer_free"
78
+ "prism/util/pm_buffer.h",
79
+ "pm_buffer_sizeof",
80
+ "pm_buffer_init",
81
+ "pm_buffer_value",
82
+ "pm_buffer_length",
83
+ "pm_buffer_free"
84
84
  )
85
85
 
86
86
  load_exported_functions_from(
87
- "yarp/util/yp_string.h",
88
- "yp_string_mapped_init",
89
- "yp_string_free",
90
- "yp_string_source",
91
- "yp_string_length",
92
- "yp_string_sizeof"
87
+ "prism/util/pm_string.h",
88
+ "pm_string_mapped_init",
89
+ "pm_string_free",
90
+ "pm_string_source",
91
+ "pm_string_length",
92
+ "pm_string_sizeof"
93
93
  )
94
94
 
95
- # This object represents a yp_buffer_t. We only use it as an opaque pointer,
96
- # so it doesn't need to know the fields of yp_buffer_t.
97
- class YPBuffer
98
- SIZEOF = LibRubyParser.yp_buffer_sizeof
95
+ # This object represents a pm_buffer_t. We only use it as an opaque pointer,
96
+ # so it doesn't need to know the fields of pm_buffer_t.
97
+ class PrismBuffer
98
+ SIZEOF = LibRubyParser.pm_buffer_sizeof
99
99
 
100
100
  attr_reader :pointer
101
101
 
@@ -104,11 +104,11 @@ module YARP
104
104
  end
105
105
 
106
106
  def value
107
- LibRubyParser.yp_buffer_value(pointer)
107
+ LibRubyParser.pm_buffer_value(pointer)
108
108
  end
109
109
 
110
110
  def length
111
- LibRubyParser.yp_buffer_length(pointer)
111
+ LibRubyParser.pm_buffer_length(pointer)
112
112
  end
113
113
 
114
114
  def read
@@ -121,19 +121,19 @@ module YARP
121
121
  pointer = FFI::MemoryPointer.new(SIZEOF)
122
122
 
123
123
  begin
124
- raise unless LibRubyParser.yp_buffer_init(pointer)
124
+ raise unless LibRubyParser.pm_buffer_init(pointer)
125
125
  yield new(pointer)
126
126
  ensure
127
- LibRubyParser.yp_buffer_free(pointer)
127
+ LibRubyParser.pm_buffer_free(pointer)
128
128
  pointer.free
129
129
  end
130
130
  end
131
131
  end
132
132
 
133
- # This object represents a yp_string_t. We only use it as an opaque pointer,
133
+ # This object represents a pm_string_t. We only use it as an opaque pointer,
134
134
  # so it doesn't have to be an FFI::Struct.
135
- class YPString
136
- SIZEOF = LibRubyParser.yp_string_sizeof
135
+ class PrismString
136
+ SIZEOF = LibRubyParser.pm_string_sizeof
137
137
 
138
138
  attr_reader :pointer
139
139
 
@@ -142,94 +142,93 @@ module YARP
142
142
  end
143
143
 
144
144
  def source
145
- LibRubyParser.yp_string_source(pointer)
145
+ LibRubyParser.pm_string_source(pointer)
146
146
  end
147
147
 
148
148
  def length
149
- LibRubyParser.yp_string_length(pointer)
149
+ LibRubyParser.pm_string_length(pointer)
150
150
  end
151
151
 
152
152
  def read
153
153
  source.read_string(length)
154
154
  end
155
155
 
156
- # Yields a yp_string_t pointer to the given block.
156
+ # Yields a pm_string_t pointer to the given block.
157
157
  def self.with(filepath, &block)
158
158
  pointer = FFI::MemoryPointer.new(SIZEOF)
159
159
 
160
160
  begin
161
- raise unless LibRubyParser.yp_string_mapped_init(pointer, filepath)
161
+ raise unless LibRubyParser.pm_string_mapped_init(pointer, filepath)
162
162
  yield new(pointer)
163
163
  ensure
164
- LibRubyParser.yp_string_free(pointer)
164
+ LibRubyParser.pm_string_free(pointer)
165
165
  pointer.free
166
166
  end
167
167
  end
168
168
  end
169
+
170
+ def self.dump_internal(source, source_size, filepath)
171
+ PrismBuffer.with do |buffer|
172
+ metadata = [filepath.bytesize, filepath.b, 0].pack("LA*L") if filepath
173
+ pm_parse_serialize(source, source_size, buffer.pointer, metadata)
174
+ buffer.read
175
+ end
176
+ end
169
177
  end
170
178
 
171
179
  # Mark the LibRubyParser module as private as it should only be called through
172
- # the YARP module.
180
+ # the prism module.
173
181
  private_constant :LibRubyParser
174
182
 
175
- # The version constant is set by reading the result of calling yp_version.
176
- VERSION = LibRubyParser.yp_version.read_string
177
-
178
- def self.dump_internal(source, source_size, filepath)
179
- LibRubyParser::YPBuffer.with do |buffer|
180
- metadata = [filepath.bytesize, filepath.b, 0].pack("LA*L") if filepath
181
- LibRubyParser.yp_parse_serialize(source, source_size, buffer.pointer, metadata)
182
- buffer.read
183
- end
184
- end
185
- private_class_method :dump_internal
183
+ # The version constant is set by reading the result of calling pm_version.
184
+ VERSION = LibRubyParser.pm_version.read_string
186
185
 
187
- # Mirror the YARP.dump API by using the serialization API.
186
+ # Mirror the Prism.dump API by using the serialization API.
188
187
  def self.dump(code, filepath = nil)
189
- dump_internal(code, code.bytesize, filepath)
188
+ LibRubyParser.dump_internal(code, code.bytesize, filepath)
190
189
  end
191
190
 
192
- # Mirror the YARP.dump_file API by using the serialization API.
191
+ # Mirror the Prism.dump_file API by using the serialization API.
193
192
  def self.dump_file(filepath)
194
- LibRubyParser::YPString.with(filepath) do |string|
195
- dump_internal(string.source, string.length, filepath)
193
+ LibRubyParser::PrismString.with(filepath) do |string|
194
+ LibRubyParser.dump_internal(string.source, string.length, filepath)
196
195
  end
197
196
  end
198
197
 
199
- # Mirror the YARP.lex API by using the serialization API.
198
+ # Mirror the Prism.lex API by using the serialization API.
200
199
  def self.lex(code, filepath = nil)
201
- LibRubyParser::YPBuffer.with do |buffer|
202
- LibRubyParser.yp_lex_serialize(code, code.bytesize, filepath, buffer.pointer)
200
+ LibRubyParser::PrismBuffer.with do |buffer|
201
+ LibRubyParser.pm_lex_serialize(code, code.bytesize, filepath, buffer.pointer)
203
202
  Serialize.load_tokens(Source.new(code), buffer.read)
204
203
  end
205
204
  end
206
205
 
207
- # Mirror the YARP.lex_file API by using the serialization API.
206
+ # Mirror the Prism.lex_file API by using the serialization API.
208
207
  def self.lex_file(filepath)
209
- LibRubyParser::YPString.with(filepath) do |string|
208
+ LibRubyParser::PrismString.with(filepath) do |string|
210
209
  lex(string.read, filepath)
211
210
  end
212
211
  end
213
212
 
214
- # Mirror the YARP.parse API by using the serialization API.
213
+ # Mirror the Prism.parse API by using the serialization API.
215
214
  def self.parse(code, filepath = nil)
216
- YARP.load(code, dump(code, filepath))
215
+ Prism.load(code, dump(code, filepath))
217
216
  end
218
217
 
219
- # Mirror the YARP.parse_file API by using the serialization API. This uses
218
+ # Mirror the Prism.parse_file API by using the serialization API. This uses
220
219
  # native strings instead of Ruby strings because it allows us to use mmap when
221
220
  # it is available.
222
221
  def self.parse_file(filepath)
223
- LibRubyParser::YPString.with(filepath) do |string|
222
+ LibRubyParser::PrismString.with(filepath) do |string|
224
223
  parse(string.read, filepath)
225
224
  end
226
225
  end
227
226
 
228
- # Mirror the YARP.parse_lex API by using the serialization API.
227
+ # Mirror the Prism.parse_lex API by using the serialization API.
229
228
  def self.parse_lex(code, filepath = nil)
230
- LibRubyParser::YPBuffer.with do |buffer|
229
+ LibRubyParser::PrismBuffer.with do |buffer|
231
230
  metadata = [filepath.bytesize, filepath.b, 0].pack("LA*L") if filepath
232
- LibRubyParser.yp_parse_lex_serialize(code, code.bytesize, buffer.pointer, metadata)
231
+ LibRubyParser.pm_parse_lex_serialize(code, code.bytesize, buffer.pointer, metadata)
233
232
 
234
233
  source = Source.new(code)
235
234
  loader = Serialize::Loader.new(source, buffer.read)
@@ -243,9 +242,9 @@ module YARP
243
242
  end
244
243
  end
245
244
 
246
- # Mirror the YARP.parse_lex_file API by using the serialization API.
245
+ # Mirror the Prism.parse_lex_file API by using the serialization API.
247
246
  def self.parse_lex_file(filepath)
248
- LibRubyParser::YPString.with(filepath) do |string|
247
+ LibRubyParser::PrismString.with(filepath) do |string|
249
248
  parse_lex(string.read, filepath)
250
249
  end
251
250
  end
@@ -2,14 +2,14 @@
2
2
 
3
3
  require "delegate"
4
4
 
5
- module YARP
6
- # This class is responsible for lexing the source using YARP and then
5
+ module Prism
6
+ # This class is responsible for lexing the source using prism and then
7
7
  # converting those tokens to be compatible with Ripper. In the vast majority
8
8
  # of cases, this is a one-to-one mapping of the token type. Everything else
9
9
  # generally lines up. However, there are a few cases that require special
10
10
  # handling.
11
11
  class LexCompat
12
- # This is a mapping of YARP token types to Ripper token types. This is a
12
+ # This is a mapping of prism token types to Ripper token types. This is a
13
13
  # many-to-one mapping because we split up our token types, whereas Ripper
14
14
  # tends to group them.
15
15
  RIPPER = {
@@ -128,6 +128,7 @@ module YARP
128
128
  LESS_EQUAL_GREATER: :on_op,
129
129
  LESS_LESS: :on_op,
130
130
  LESS_LESS_EQUAL: :on_op,
131
+ METHOD_NAME: :on_ident,
131
132
  MINUS: :on_op,
132
133
  MINUS_EQUAL: :on_op,
133
134
  MINUS_GREATER: :on_tlambda,
@@ -338,8 +339,8 @@ module YARP
338
339
 
339
340
  # Heredocs that are dedenting heredocs are a little more complicated.
340
341
  # Ripper outputs on_ignored_sp tokens for the whitespace that is being
341
- # removed from the output. YARP only modifies the node itself and keeps
342
- # the token the same. This simplifies YARP, but makes comparing against
342
+ # removed from the output. prism only modifies the node itself and keeps
343
+ # the token the same. This simplifies prism, but makes comparing against
343
344
  # Ripper much harder because there is a length mismatch.
344
345
  #
345
346
  # Fortunately, we already have to pull out the heredoc tokens in order to
@@ -562,7 +563,7 @@ module YARP
562
563
  state = :default
563
564
  heredoc_stack = [[]]
564
565
 
565
- result = YARP.lex(source, @filepath)
566
+ result = Prism.lex(source, @filepath)
566
567
  result_value = result.value
567
568
  previous_state = nil
568
569
 
@@ -649,7 +650,7 @@ module YARP
649
650
  IgnoredNewlineToken.new([[lineno, column], event, value, lex_state])
650
651
  when :on_regexp_end
651
652
  # On regex end, Ripper scans and then sets end state, so the ripper
652
- # lexed output is begin, when it should be end. YARP sets lex state
653
+ # lexed output is begin, when it should be end. prism sets lex state
653
654
  # correctly to end state, but we want to be able to compare against
654
655
  # Ripper's lexed state. So here, if it's a regexp end token, we
655
656
  # output the state as the previous state, solely for the sake of
@@ -705,7 +706,7 @@ module YARP
705
706
 
706
707
  # The order in which tokens appear in our lexer is different from the
707
708
  # order that they appear in Ripper. When we hit the declaration of a
708
- # heredoc in YARP, we skip forward and lex the rest of the content of
709
+ # heredoc in prism, we skip forward and lex the rest of the content of
709
710
  # the heredoc before going back and lexing at the end of the heredoc
710
711
  # identifier.
711
712
  #
@@ -794,48 +795,44 @@ module YARP
794
795
  end
795
796
  end
796
797
 
797
- # The constant that wraps the behavior of the lexer to match Ripper's output
798
- # is an implementation detail, so we don't want it to be public.
799
- private_constant :LexCompat
798
+ # This is a class that wraps the Ripper lexer to produce almost exactly the
799
+ # same tokens.
800
+ class LexRipper
801
+ attr_reader :source
800
802
 
801
- # Returns an array of tokens that closely resembles that of the Ripper lexer.
802
- # The only difference is that since we don't keep track of lexer state in the
803
- # same way, it's going to always return the NONE state.
804
- def self.lex_compat(source, filepath = "")
805
- LexCompat.new(source, filepath).result
806
- end
803
+ def initialize(source)
804
+ @source = source
805
+ end
807
806
 
808
- # This lexes with the Ripper lex. It drops any space events but otherwise
809
- # returns the same tokens. Raises SyntaxError if the syntax in source is
810
- # invalid.
811
- def self.lex_ripper(source)
812
- previous = []
813
- results = []
814
-
815
- Ripper.lex(source, raise_errors: true).each do |token|
816
- case token[1]
817
- when :on_sp
818
- # skip
819
- when :on_tstring_content
820
- if previous[1] == :on_tstring_content && (token[2].start_with?("\#$") || token[2].start_with?("\#@"))
821
- previous[2] << token[2]
822
- else
823
- results << token
824
- previous = token
825
- end
826
- when :on_words_sep
827
- if previous[1] == :on_words_sep
828
- previous[2] << token[2]
807
+ def result
808
+ previous = []
809
+ results = []
810
+
811
+ Ripper.lex(source, raise_errors: true).each do |token|
812
+ case token[1]
813
+ when :on_sp
814
+ # skip
815
+ when :on_tstring_content
816
+ if previous[1] == :on_tstring_content && (token[2].start_with?("\#$") || token[2].start_with?("\#@"))
817
+ previous[2] << token[2]
818
+ else
819
+ results << token
820
+ previous = token
821
+ end
822
+ when :on_words_sep
823
+ if previous[1] == :on_words_sep
824
+ previous[2] << token[2]
825
+ else
826
+ results << token
827
+ previous = token
828
+ end
829
829
  else
830
830
  results << token
831
831
  previous = token
832
832
  end
833
- else
834
- results << token
835
- previous = token
836
833
  end
837
- end
838
834
 
839
- results
835
+ results
836
+ end
840
837
  end
841
838
  end
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
  =begin
3
3
  This file is generated by the templates/template.rb script and should not be
4
- modified manually. See templates/lib/yarp/mutation_visitor.rb.erb
4
+ modified manually. See templates/lib/prism/mutation_compiler.rb.erb
5
5
  if you are looking to modify the template
6
6
  =end
7
7
 
8
- module YARP
8
+ module Prism
9
9
  # This visitor walks through the tree and copies each node as it is being
10
10
  # visited. This is useful for consumers that want to mutate the tree, as you
11
11
  # can change subtrees in place without effecting the rest of the tree.
12
- class MutationVisitor < BasicVisitor
12
+ class MutationCompiler < Compiler
13
13
  # Copy a AliasGlobalVariableNode node
14
14
  def visit_alias_global_variable_node(node)
15
15
  node.copy(new_name: visit(node.new_name), old_name: visit(node.old_name))