yarp 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,7 @@
6
6
 
7
7
  #include <stdbool.h>
8
8
  #include <stdlib.h>
9
+ #include <assert.h>
9
10
 
10
11
  // This struct represents a diagnostic found during parsing.
11
12
  typedef struct {
@@ -15,8 +16,204 @@ typedef struct {
15
16
  const char *message;
16
17
  } yp_diagnostic_t;
17
18
 
19
+ typedef enum {
20
+ YP_ERR_ALIAS_ARGUMENT,
21
+ YP_ERR_AMPAMPEQ_MULTI_ASSIGN,
22
+ YP_ERR_ARGUMENT_AFTER_BLOCK,
23
+ YP_ERR_ARGUMENT_BARE_HASH,
24
+ YP_ERR_ARGUMENT_BLOCK_MULTI,
25
+ YP_ERR_ARGUMENT_FORMAL_CLASS,
26
+ YP_ERR_ARGUMENT_FORMAL_CONSTANT,
27
+ YP_ERR_ARGUMENT_FORMAL_GLOBAL,
28
+ YP_ERR_ARGUMENT_FORMAL_IVAR,
29
+ YP_ERR_ARGUMENT_NO_FORWARDING_AMP,
30
+ YP_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES,
31
+ YP_ERR_ARGUMENT_NO_FORWARDING_STAR,
32
+ YP_ERR_ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT,
33
+ YP_ERR_ARGUMENT_SPLAT_AFTER_SPLAT,
34
+ YP_ERR_ARGUMENT_TERM_PAREN,
35
+ YP_ERR_ARRAY_ELEMENT,
36
+ YP_ERR_ARRAY_EXPRESSION,
37
+ YP_ERR_ARRAY_EXPRESSION_AFTER_STAR,
38
+ YP_ERR_ARRAY_SEPARATOR,
39
+ YP_ERR_ARRAY_TERM,
40
+ YP_ERR_BEGIN_LONELY_ELSE,
41
+ YP_ERR_BEGIN_TERM,
42
+ YP_ERR_BEGIN_UPCASE_BRACE,
43
+ YP_ERR_BEGIN_UPCASE_TERM,
44
+ YP_ERR_BLOCK_PARAM_LOCAL_VARIABLE,
45
+ YP_ERR_BLOCK_PARAM_PIPE_TERM,
46
+ YP_ERR_BLOCK_TERM_BRACE,
47
+ YP_ERR_BLOCK_TERM_END,
48
+ YP_ERR_CANNOT_PARSE_EXPRESSION,
49
+ YP_ERR_CANNOT_PARSE_STRING_PART,
50
+ YP_ERR_CASE_EXPRESSION_AFTER_CASE,
51
+ YP_ERR_CASE_EXPRESSION_AFTER_WHEN,
52
+ YP_ERR_CASE_LONELY_ELSE,
53
+ YP_ERR_CASE_TERM,
54
+ YP_ERR_CLASS_IN_METHOD,
55
+ YP_ERR_CLASS_NAME,
56
+ YP_ERR_CLASS_SUPERCLASS,
57
+ YP_ERR_CLASS_TERM,
58
+ YP_ERR_CONDITIONAL_ELSIF_PREDICATE,
59
+ YP_ERR_CONDITIONAL_IF_PREDICATE,
60
+ YP_ERR_CONDITIONAL_TERM,
61
+ YP_ERR_CONDITIONAL_TERM_ELSE,
62
+ YP_ERR_CONDITIONAL_UNLESS_PREDICATE,
63
+ YP_ERR_CONDITIONAL_UNTIL_PREDICATE,
64
+ YP_ERR_CONDITIONAL_WHILE_PREDICATE,
65
+ YP_ERR_CONSTANT_PATH_COLON_COLON_CONSTANT,
66
+ YP_ERR_DEF_ENDLESS,
67
+ YP_ERR_DEF_ENDLESS_SETTER,
68
+ YP_ERR_DEF_NAME,
69
+ YP_ERR_DEF_NAME_AFTER_RECEIVER,
70
+ YP_ERR_DEF_PARAMS_TERM,
71
+ YP_ERR_DEF_PARAMS_TERM_PAREN,
72
+ YP_ERR_DEF_RECEIVER,
73
+ YP_ERR_DEF_RECEIVER_TERM,
74
+ YP_ERR_DEF_TERM,
75
+ YP_ERR_DEFINED_EXPRESSION,
76
+ YP_ERR_EMBDOC_TERM,
77
+ YP_ERR_EMBEXPR_END,
78
+ YP_ERR_EMBVAR_INVALID,
79
+ YP_ERR_END_UPCASE_BRACE,
80
+ YP_ERR_END_UPCASE_TERM,
81
+ YP_ERR_ESCAPE_INVALID_CONTROL,
82
+ YP_ERR_ESCAPE_INVALID_CONTROL_REPEAT,
83
+ YP_ERR_ESCAPE_INVALID_HEXADECIMAL,
84
+ YP_ERR_ESCAPE_INVALID_META,
85
+ YP_ERR_ESCAPE_INVALID_META_REPEAT,
86
+ YP_ERR_ESCAPE_INVALID_UNICODE,
87
+ YP_ERR_ESCAPE_INVALID_UNICODE_CM_FLAGS,
88
+ YP_ERR_ESCAPE_INVALID_UNICODE_LITERAL,
89
+ YP_ERR_ESCAPE_INVALID_UNICODE_LONG,
90
+ YP_ERR_ESCAPE_INVALID_UNICODE_TERM,
91
+ YP_ERR_EXPECT_ARGUMENT,
92
+ YP_ERR_EXPECT_EOL_AFTER_STATEMENT,
93
+ YP_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ,
94
+ YP_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ,
95
+ YP_ERR_EXPECT_EXPRESSION_AFTER_COMMA,
96
+ YP_ERR_EXPECT_EXPRESSION_AFTER_EQUAL,
97
+ YP_ERR_EXPECT_EXPRESSION_AFTER_LESS_LESS,
98
+ YP_ERR_EXPECT_EXPRESSION_AFTER_LPAREN,
99
+ YP_ERR_EXPECT_EXPRESSION_AFTER_QUESTION,
100
+ YP_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR,
101
+ YP_ERR_EXPECT_EXPRESSION_AFTER_SPLAT,
102
+ YP_ERR_EXPECT_EXPRESSION_AFTER_SPLAT_HASH,
103
+ YP_ERR_EXPECT_EXPRESSION_AFTER_STAR,
104
+ YP_ERR_EXPECT_IDENT_REQ_PARAMETER,
105
+ YP_ERR_EXPECT_LPAREN_REQ_PARAMETER,
106
+ YP_ERR_EXPECT_RBRACKET,
107
+ YP_ERR_EXPECT_RPAREN,
108
+ YP_ERR_EXPECT_RPAREN_AFTER_MULTI,
109
+ YP_ERR_EXPECT_RPAREN_REQ_PARAMETER,
110
+ YP_ERR_EXPECT_STRING_CONTENT,
111
+ YP_ERR_EXPECT_WHEN_DELIMITER,
112
+ YP_ERR_EXPRESSION_BARE_HASH,
113
+ YP_ERR_FOR_COLLECTION,
114
+ YP_ERR_FOR_IN,
115
+ YP_ERR_FOR_INDEX,
116
+ YP_ERR_FOR_TERM,
117
+ YP_ERR_HASH_EXPRESSION_AFTER_LABEL,
118
+ YP_ERR_HASH_KEY,
119
+ YP_ERR_HASH_ROCKET,
120
+ YP_ERR_HASH_TERM,
121
+ YP_ERR_HASH_VALUE,
122
+ YP_ERR_HEREDOC_TERM,
123
+ YP_ERR_INCOMPLETE_QUESTION_MARK,
124
+ YP_ERR_INCOMPLETE_VARIABLE_CLASS,
125
+ YP_ERR_INCOMPLETE_VARIABLE_INSTANCE,
126
+ YP_ERR_INVALID_ENCODING_MAGIC_COMMENT,
127
+ YP_ERR_INVALID_FLOAT_EXPONENT,
128
+ YP_ERR_INVALID_NUMBER_BINARY,
129
+ YP_ERR_INVALID_NUMBER_DECIMAL,
130
+ YP_ERR_INVALID_NUMBER_HEXADECIMAL,
131
+ YP_ERR_INVALID_NUMBER_OCTAL,
132
+ YP_ERR_INVALID_PERCENT,
133
+ YP_ERR_INVALID_TOKEN,
134
+ YP_ERR_INVALID_VARIABLE_GLOBAL,
135
+ YP_ERR_LAMBDA_OPEN,
136
+ YP_ERR_LAMBDA_TERM_BRACE,
137
+ YP_ERR_LAMBDA_TERM_END,
138
+ YP_ERR_LIST_I_LOWER_ELEMENT,
139
+ YP_ERR_LIST_I_LOWER_TERM,
140
+ YP_ERR_LIST_I_UPPER_ELEMENT,
141
+ YP_ERR_LIST_I_UPPER_TERM,
142
+ YP_ERR_LIST_W_LOWER_ELEMENT,
143
+ YP_ERR_LIST_W_LOWER_TERM,
144
+ YP_ERR_LIST_W_UPPER_ELEMENT,
145
+ YP_ERR_LIST_W_UPPER_TERM,
146
+ YP_ERR_MALLOC_FAILED,
147
+ YP_ERR_MODULE_IN_METHOD,
148
+ YP_ERR_MODULE_NAME,
149
+ YP_ERR_MODULE_TERM,
150
+ YP_ERR_MULTI_ASSIGN_MULTI_SPLATS,
151
+ YP_ERR_NOT_EXPRESSION,
152
+ YP_ERR_NUMBER_LITERAL_UNDERSCORE,
153
+ YP_ERR_OPERATOR_MULTI_ASSIGN,
154
+ YP_ERR_PARAMETER_ASSOC_SPLAT_MULTI,
155
+ YP_ERR_PARAMETER_BLOCK_MULTI,
156
+ YP_ERR_PARAMETER_NAME_REPEAT,
157
+ YP_ERR_PARAMETER_NO_DEFAULT,
158
+ YP_ERR_PARAMETER_NO_DEFAULT_KW,
159
+ YP_ERR_PARAMETER_NUMBERED_RESERVED,
160
+ YP_ERR_PARAMETER_ORDER,
161
+ YP_ERR_PARAMETER_SPLAT_MULTI,
162
+ YP_ERR_PARAMETER_STAR,
163
+ YP_ERR_PARAMETER_WILD_LOOSE_COMMA,
164
+ YP_ERR_PATTERN_EXPRESSION_AFTER_BRACKET,
165
+ YP_ERR_PATTERN_EXPRESSION_AFTER_HROCKET,
166
+ YP_ERR_PATTERN_EXPRESSION_AFTER_COMMA,
167
+ YP_ERR_PATTERN_EXPRESSION_AFTER_IN,
168
+ YP_ERR_PATTERN_EXPRESSION_AFTER_KEY,
169
+ YP_ERR_PATTERN_EXPRESSION_AFTER_PAREN,
170
+ YP_ERR_PATTERN_EXPRESSION_AFTER_PIN,
171
+ YP_ERR_PATTERN_EXPRESSION_AFTER_PIPE,
172
+ YP_ERR_PATTERN_EXPRESSION_AFTER_RANGE,
173
+ YP_ERR_PATTERN_HASH_KEY,
174
+ YP_ERR_PATTERN_HASH_KEY_LABEL,
175
+ YP_ERR_PATTERN_IDENT_AFTER_HROCKET,
176
+ YP_ERR_PATTERN_LABEL_AFTER_COMMA,
177
+ YP_ERR_PATTERN_REST,
178
+ YP_ERR_PATTERN_TERM_BRACE,
179
+ YP_ERR_PATTERN_TERM_BRACKET,
180
+ YP_ERR_PATTERN_TERM_PAREN,
181
+ YP_ERR_PIPEPIPEEQ_MULTI_ASSIGN,
182
+ YP_ERR_REGEXP_TERM,
183
+ YP_ERR_RESCUE_EXPRESSION,
184
+ YP_ERR_RESCUE_MODIFIER_VALUE,
185
+ YP_ERR_RESCUE_TERM,
186
+ YP_ERR_RESCUE_VARIABLE,
187
+ YP_ERR_RETURN_INVALID,
188
+ YP_ERR_STRING_CONCATENATION,
189
+ YP_ERR_STRING_INTERPOLATED_TERM,
190
+ YP_ERR_STRING_LITERAL_TERM,
191
+ YP_ERR_SYMBOL_INVALID,
192
+ YP_ERR_SYMBOL_TERM_DYNAMIC,
193
+ YP_ERR_SYMBOL_TERM_INTERPOLATED,
194
+ YP_ERR_TERNARY_COLON,
195
+ YP_ERR_TERNARY_EXPRESSION_FALSE,
196
+ YP_ERR_TERNARY_EXPRESSION_TRUE,
197
+ YP_ERR_UNDEF_ARGUMENT,
198
+ YP_ERR_UNARY_RECEIVER_BANG,
199
+ YP_ERR_UNARY_RECEIVER_MINUS,
200
+ YP_ERR_UNARY_RECEIVER_PLUS,
201
+ YP_ERR_UNARY_RECEIVER_TILDE,
202
+ YP_ERR_UNTIL_TERM,
203
+ YP_ERR_WHILE_TERM,
204
+ YP_ERR_WRITE_TARGET_READONLY,
205
+ YP_ERR_WRITE_TARGET_UNEXPECTED,
206
+ YP_ERR_XSTRING_TERM,
207
+ YP_WARN_AMBIGUOUS_FIRST_ARGUMENT_MINUS,
208
+ YP_WARN_AMBIGUOUS_FIRST_ARGUMENT_PLUS,
209
+ YP_WARN_AMBIGUOUS_PREFIX_STAR,
210
+ YP_WARN_AMBIGUOUS_SLASH,
211
+ /* This must be the last member. */
212
+ YP_DIAGNOSTIC_ID_LEN,
213
+ } yp_diagnostic_id_t;
214
+
18
215
  // Append a diagnostic to the given list of diagnostics.
19
- bool yp_diagnostic_list_append(yp_list_t *list, const uint8_t *start, const uint8_t *end, const char *message);
216
+ bool yp_diagnostic_list_append(yp_list_t *list, const uint8_t *start, const uint8_t *end, yp_diagnostic_id_t diag_id);
20
217
 
21
218
  // Deallocate the internal state of the given diagnostic list.
22
219
  void yp_diagnostic_list_free(yp_list_t *list);
data/include/yarp/node.h CHANGED
@@ -4,9 +4,6 @@
4
4
  #include "yarp/defines.h"
5
5
  #include "yarp/parser.h"
6
6
 
7
- // Append a token to the given list.
8
- void yp_location_list_append(yp_location_list_t *list, const yp_token_t *token);
9
-
10
7
  // Append a new node onto the end of the node list.
11
8
  void yp_node_list_append(yp_node_list_t *list, yp_node_t *node);
12
9
 
@@ -31,7 +28,6 @@ YP_EXPORTED_FUNCTION void yp_node_memsize(yp_node_t *node, yp_memsize_t *memsize
31
28
  YP_EXPORTED_FUNCTION const char * yp_node_type_to_str(yp_node_type_t node_type);
32
29
 
33
30
  #define YP_EMPTY_NODE_LIST ((yp_node_list_t) { .nodes = NULL, .size = 0, .capacity = 0 })
34
- #define YP_EMPTY_LOCATION_LIST ((yp_location_list_t) { .locations = NULL, .size = 0, .capacity = 0 })
35
31
 
36
32
  #endif // YARP_NODE_H
37
33
 
@@ -15,7 +15,7 @@ size_t yp_strspn_whitespace(const uint8_t *string, ptrdiff_t length);
15
15
  // whitespace while also tracking the location of each newline. Disallows
16
16
  // searching past the given maximum number of characters.
17
17
  size_t
18
- yp_strspn_whitespace_newlines(const uint8_t *string, ptrdiff_t length, yp_newline_list_t *newline_list, bool stop_at_newline);
18
+ yp_strspn_whitespace_newlines(const uint8_t *string, ptrdiff_t length, yp_newline_list_t *newline_list);
19
19
 
20
20
  // Returns the number of characters at the start of the string that are inline
21
21
  // whitespace. Disallows searching past the given maximum number of characters.
@@ -8,6 +8,7 @@
8
8
 
9
9
  #include "yarp/defines.h"
10
10
 
11
+ #include <assert.h>
11
12
  #include <stdbool.h>
12
13
  #include <stdint.h>
13
14
  #include <stdlib.h>
@@ -39,7 +40,8 @@ size_t yp_constant_id_list_memsize(yp_constant_id_list_t *list);
39
40
  void yp_constant_id_list_free(yp_constant_id_list_t *list);
40
41
 
41
42
  typedef struct {
42
- yp_constant_id_t id;
43
+ unsigned int id: 31;
44
+ bool owned: 1;
43
45
  const uint8_t *start;
44
46
  size_t length;
45
47
  size_t hash;
@@ -57,9 +59,14 @@ typedef struct {
57
59
  // Initialize a new constant pool with a given capacity.
58
60
  bool yp_constant_pool_init(yp_constant_pool_t *pool, size_t capacity);
59
61
 
60
- // Insert a constant into a constant pool. Returns the id of the constant, or 0
61
- // if any potential calls to resize fail.
62
- yp_constant_id_t yp_constant_pool_insert(yp_constant_pool_t *pool, const uint8_t *start, size_t length);
62
+ // Insert a constant into a constant pool that is a slice of a source string.
63
+ // Returns the id of the constant, or 0 if any potential calls to resize fail.
64
+ yp_constant_id_t yp_constant_pool_insert_shared(yp_constant_pool_t *pool, const uint8_t *start, size_t length);
65
+
66
+ // Insert a constant into a constant pool from memory that is now owned by the
67
+ // constant pool. Returns the id of the constant, or 0 if any potential calls to
68
+ // resize fail.
69
+ yp_constant_id_t yp_constant_pool_insert_owned(yp_constant_pool_t *pool, const uint8_t *start, size_t length);
63
70
 
64
71
  // Free the memory associated with a constant pool.
65
72
  void yp_constant_pool_free(yp_constant_pool_t *pool);
@@ -1,4 +1,4 @@
1
1
  #define YP_VERSION_MAJOR 0
2
- #define YP_VERSION_MINOR 10
2
+ #define YP_VERSION_MINOR 11
3
3
  #define YP_VERSION_PATCH 0
4
- #define YP_VERSION "0.10.0"
4
+ #define YP_VERSION "0.11.0"
@@ -8,7 +8,7 @@ module YARP
8
8
  #
9
9
  # @@foo && @@foo = bar
10
10
  def visit_class_variable_and_write_node(node)
11
- desugar_and_write_node(node, ClassVariableReadNode, ClassVariableWriteNode, arguments: [node.name])
11
+ desugar_and_write_node(node, ClassVariableReadNode, ClassVariableWriteNode, node.name)
12
12
  end
13
13
 
14
14
  # @@foo ||= bar
@@ -17,7 +17,7 @@ module YARP
17
17
  #
18
18
  # defined?(@@foo) ? @@foo : @@foo = bar
19
19
  def visit_class_variable_or_write_node(node)
20
- desugar_or_write_defined_node(node, ClassVariableReadNode, ClassVariableWriteNode, arguments: [node.name])
20
+ desugar_or_write_defined_node(node, ClassVariableReadNode, ClassVariableWriteNode, node.name)
21
21
  end
22
22
 
23
23
  # @@foo += bar
@@ -26,7 +26,7 @@ module YARP
26
26
  #
27
27
  # @@foo = @@foo + bar
28
28
  def visit_class_variable_operator_write_node(node)
29
- desugar_operator_write_node(node, ClassVariableReadNode, ClassVariableWriteNode, arguments: [node.name])
29
+ desugar_operator_write_node(node, ClassVariableReadNode, ClassVariableWriteNode, node.name)
30
30
  end
31
31
 
32
32
  # Foo &&= bar
@@ -35,7 +35,7 @@ module YARP
35
35
  #
36
36
  # Foo && Foo = bar
37
37
  def visit_constant_and_write_node(node)
38
- desugar_and_write_node(node, ConstantReadNode, ConstantWriteNode)
38
+ desugar_and_write_node(node, ConstantReadNode, ConstantWriteNode, node.name)
39
39
  end
40
40
 
41
41
  # Foo ||= bar
@@ -44,7 +44,7 @@ module YARP
44
44
  #
45
45
  # defined?(Foo) ? Foo : Foo = bar
46
46
  def visit_constant_or_write_node(node)
47
- desugar_or_write_defined_node(node, ConstantReadNode, ConstantWriteNode)
47
+ desugar_or_write_defined_node(node, ConstantReadNode, ConstantWriteNode, node.name)
48
48
  end
49
49
 
50
50
  # Foo += bar
@@ -53,7 +53,7 @@ module YARP
53
53
  #
54
54
  # Foo = Foo + bar
55
55
  def visit_constant_operator_write_node(node)
56
- desugar_operator_write_node(node, ConstantReadNode, ConstantWriteNode)
56
+ desugar_operator_write_node(node, ConstantReadNode, ConstantWriteNode, node.name)
57
57
  end
58
58
 
59
59
  # $foo &&= bar
@@ -62,7 +62,7 @@ module YARP
62
62
  #
63
63
  # $foo && $foo = bar
64
64
  def visit_global_variable_and_write_node(node)
65
- desugar_and_write_node(node, GlobalVariableReadNode, GlobalVariableWriteNode)
65
+ desugar_and_write_node(node, GlobalVariableReadNode, GlobalVariableWriteNode, node.name)
66
66
  end
67
67
 
68
68
  # $foo ||= bar
@@ -71,7 +71,7 @@ module YARP
71
71
  #
72
72
  # defined?($foo) ? $foo : $foo = bar
73
73
  def visit_global_variable_or_write_node(node)
74
- desugar_or_write_defined_node(node, GlobalVariableReadNode, GlobalVariableWriteNode)
74
+ desugar_or_write_defined_node(node, GlobalVariableReadNode, GlobalVariableWriteNode, node.name)
75
75
  end
76
76
 
77
77
  # $foo += bar
@@ -80,7 +80,7 @@ module YARP
80
80
  #
81
81
  # $foo = $foo + bar
82
82
  def visit_global_variable_operator_write_node(node)
83
- desugar_operator_write_node(node, GlobalVariableReadNode, GlobalVariableWriteNode)
83
+ desugar_operator_write_node(node, GlobalVariableReadNode, GlobalVariableWriteNode, node.name)
84
84
  end
85
85
 
86
86
  # @foo &&= bar
@@ -89,7 +89,7 @@ module YARP
89
89
  #
90
90
  # @foo && @foo = bar
91
91
  def visit_instance_variable_and_write_node(node)
92
- desugar_and_write_node(node, InstanceVariableReadNode, InstanceVariableWriteNode, arguments: [node.name])
92
+ desugar_and_write_node(node, InstanceVariableReadNode, InstanceVariableWriteNode, node.name)
93
93
  end
94
94
 
95
95
  # @foo ||= bar
@@ -98,7 +98,7 @@ module YARP
98
98
  #
99
99
  # @foo || @foo = bar
100
100
  def visit_instance_variable_or_write_node(node)
101
- desugar_or_write_node(node, InstanceVariableReadNode, InstanceVariableWriteNode, arguments: [node.name])
101
+ desugar_or_write_node(node, InstanceVariableReadNode, InstanceVariableWriteNode, node.name)
102
102
  end
103
103
 
104
104
  # @foo += bar
@@ -107,7 +107,7 @@ module YARP
107
107
  #
108
108
  # @foo = @foo + bar
109
109
  def visit_instance_variable_operator_write_node(node)
110
- desugar_operator_write_node(node, InstanceVariableReadNode, InstanceVariableWriteNode, arguments: [node.name])
110
+ desugar_operator_write_node(node, InstanceVariableReadNode, InstanceVariableWriteNode, node.name)
111
111
  end
112
112
 
113
113
  # foo &&= bar
@@ -116,7 +116,7 @@ module YARP
116
116
  #
117
117
  # foo && foo = bar
118
118
  def visit_local_variable_and_write_node(node)
119
- desugar_and_write_node(node, LocalVariableReadNode, LocalVariableWriteNode, arguments: [node.name, node.depth])
119
+ desugar_and_write_node(node, LocalVariableReadNode, LocalVariableWriteNode, node.name, node.depth)
120
120
  end
121
121
 
122
122
  # foo ||= bar
@@ -125,7 +125,7 @@ module YARP
125
125
  #
126
126
  # foo || foo = bar
127
127
  def visit_local_variable_or_write_node(node)
128
- desugar_or_write_node(node, LocalVariableReadNode, LocalVariableWriteNode, arguments: [node.name, node.depth])
128
+ desugar_or_write_node(node, LocalVariableReadNode, LocalVariableWriteNode, node.name, node.depth)
129
129
  end
130
130
 
131
131
  # foo += bar
@@ -134,13 +134,13 @@ module YARP
134
134
  #
135
135
  # foo = foo + bar
136
136
  def visit_local_variable_operator_write_node(node)
137
- desugar_operator_write_node(node, LocalVariableReadNode, LocalVariableWriteNode, arguments: [node.name, node.depth])
137
+ desugar_operator_write_node(node, LocalVariableReadNode, LocalVariableWriteNode, node.name, node.depth)
138
138
  end
139
139
 
140
140
  private
141
141
 
142
142
  # Desugar `x &&= y` to `x && x = y`
143
- def desugar_and_write_node(node, read_class, write_class, arguments: [])
143
+ def desugar_and_write_node(node, read_class, write_class, *arguments)
144
144
  AndNode.new(
145
145
  read_class.new(*arguments, node.name_loc),
146
146
  write_class.new(*arguments, node.name_loc, node.value, node.operator_loc, node.location),
@@ -150,7 +150,7 @@ module YARP
150
150
  end
151
151
 
152
152
  # Desugar `x += y` to `x = x + y`
153
- def desugar_operator_write_node(node, read_class, write_class, arguments: [])
153
+ def desugar_operator_write_node(node, read_class, write_class, *arguments)
154
154
  write_class.new(
155
155
  *arguments,
156
156
  node.name_loc,
@@ -172,7 +172,7 @@ module YARP
172
172
  end
173
173
 
174
174
  # Desugar `x ||= y` to `x || x = y`
175
- def desugar_or_write_node(node, read_class, write_class, arguments: [])
175
+ def desugar_or_write_node(node, read_class, write_class, *arguments)
176
176
  OrNode.new(
177
177
  read_class.new(*arguments, node.name_loc),
178
178
  write_class.new(*arguments, node.name_loc, node.value, node.operator_loc, node.location),
@@ -182,7 +182,7 @@ module YARP
182
182
  end
183
183
 
184
184
  # Desugar `x ||= y` to `defined?(x) ? x : x = y`
185
- def desugar_or_write_defined_node(node, read_class, write_class, arguments: [])
185
+ def desugar_or_write_defined_node(node, read_class, write_class, *arguments)
186
186
  IfNode.new(
187
187
  node.operator_loc,
188
188
  DefinedNode.new(nil, read_class.new(*arguments, node.name_loc), nil, node.operator_loc, node.name_loc),
@@ -65,6 +65,11 @@ module YARP
65
65
  node.copy(expression: visit(node.expression))
66
66
  end
67
67
 
68
+ # Copy a BlockLocalVariableNode node
69
+ def visit_block_local_variable_node(node)
70
+ node.copy
71
+ end
72
+
68
73
  # Copy a BlockNode node
69
74
  def visit_block_node(node)
70
75
  node.copy(parameters: visit(node.parameters), body: visit(node.body))
@@ -77,7 +82,7 @@ module YARP
77
82
 
78
83
  # Copy a BlockParametersNode node
79
84
  def visit_block_parameters_node(node)
80
- node.copy(parameters: visit(node.parameters))
85
+ node.copy(parameters: visit(node.parameters), locals: visit_all(node.locals))
81
86
  end
82
87
 
83
88
  # Copy a BreakNode node
@@ -85,24 +90,24 @@ module YARP
85
90
  node.copy(arguments: visit(node.arguments))
86
91
  end
87
92
 
93
+ # Copy a CallAndWriteNode node
94
+ def visit_call_and_write_node(node)
95
+ node.copy(receiver: visit(node.receiver), arguments: visit(node.arguments), value: visit(node.value))
96
+ end
97
+
88
98
  # Copy a CallNode node
89
99
  def visit_call_node(node)
90
100
  node.copy(receiver: visit(node.receiver), arguments: visit(node.arguments), block: visit(node.block))
91
101
  end
92
102
 
93
- # Copy a CallOperatorAndWriteNode node
94
- def visit_call_operator_and_write_node(node)
95
- node.copy(target: visit(node.target), value: visit(node.value))
96
- end
97
-
98
- # Copy a CallOperatorOrWriteNode node
99
- def visit_call_operator_or_write_node(node)
100
- node.copy(target: visit(node.target), value: visit(node.value))
101
- end
102
-
103
103
  # Copy a CallOperatorWriteNode node
104
104
  def visit_call_operator_write_node(node)
105
- node.copy(target: visit(node.target), value: visit(node.value))
105
+ node.copy(receiver: visit(node.receiver), arguments: visit(node.arguments), value: visit(node.value))
106
+ end
107
+
108
+ # Copy a CallOrWriteNode node
109
+ def visit_call_or_write_node(node)
110
+ node.copy(receiver: visit(node.receiver), arguments: visit(node.arguments), value: visit(node.value))
106
111
  end
107
112
 
108
113
  # Copy a CapturePatternNode node
@@ -460,6 +465,11 @@ module YARP
460
465
  node.copy(constant_path: visit(node.constant_path), body: visit(node.body))
461
466
  end
462
467
 
468
+ # Copy a MultiTargetNode node
469
+ def visit_multi_target_node(node)
470
+ node.copy(targets: visit_all(node.targets))
471
+ end
472
+
463
473
  # Copy a MultiWriteNode node
464
474
  def visit_multi_write_node(node)
465
475
  node.copy(targets: visit_all(node.targets), value: visit(node.value))