prism 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/README.md +4 -1
- data/config.yml +10 -14
- data/docs/fuzzing.md +5 -10
- data/docs/prism.png +0 -0
- data/docs/serialization.md +10 -0
- data/ext/prism/api_node.c +35 -28
- data/ext/prism/extension.c +35 -48
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +38 -36
- data/include/prism/node.h +1 -0
- data/include/prism/parser.h +26 -0
- data/include/prism/util/pm_buffer.h +3 -0
- data/include/prism/util/pm_constant_pool.h +5 -0
- data/include/prism/util/pm_string.h +2 -1
- data/include/prism/version.h +2 -2
- data/include/prism.h +0 -1
- data/lib/prism/compiler.rb +141 -141
- data/lib/prism/ffi.rb +2 -2
- data/lib/prism/lex_compat.rb +42 -8
- data/lib/prism/node.rb +1456 -46
- data/lib/prism/node_ext.rb +44 -0
- data/lib/prism/parse_result.rb +32 -5
- data/lib/prism/pattern.rb +1 -1
- data/lib/prism/serialize.rb +16 -14
- data/prism.gemspec +2 -3
- data/src/diagnostic.c +1 -1
- data/src/node.c +0 -14
- data/src/prettyprint.c +35 -35
- data/src/prism.c +1728 -811
- data/src/serialize.c +45 -22
- data/src/util/pm_buffer.c +9 -7
- metadata +3 -4
- data/include/prism/unescape.h +0 -48
- data/src/unescape.c +0 -637
data/lib/prism/node_ext.rb
CHANGED
@@ -52,4 +52,48 @@ module Prism
|
|
52
52
|
o
|
53
53
|
end
|
54
54
|
end
|
55
|
+
|
56
|
+
class ConstantReadNode < Node
|
57
|
+
# Returns the list of parts for the full name of this constant. For example: [:Foo]
|
58
|
+
def full_name_parts
|
59
|
+
[name]
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns the full name of this constant. For example: "Foo"
|
63
|
+
def full_name
|
64
|
+
name.name
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class ConstantPathNode < Node
|
69
|
+
# Returns the list of parts for the full name of this constant path. For example: [:Foo, :Bar]
|
70
|
+
def full_name_parts
|
71
|
+
parts = [child.name]
|
72
|
+
current = parent
|
73
|
+
|
74
|
+
while current.is_a?(ConstantPathNode)
|
75
|
+
parts.unshift(current.child.name)
|
76
|
+
current = current.parent
|
77
|
+
end
|
78
|
+
|
79
|
+
parts.unshift(current&.name || :"")
|
80
|
+
end
|
81
|
+
|
82
|
+
# Returns the full name of this constant path. For example: "Foo::Bar"
|
83
|
+
def full_name
|
84
|
+
full_name_parts.join("::")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
class ConstantPathTargetNode < Node
|
89
|
+
# Returns the list of parts for the full name of this constant path. For example: [:Foo, :Bar]
|
90
|
+
def full_name_parts
|
91
|
+
(parent&.full_name_parts || [:""]).push(child.name)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Returns the full name of this constant path. For example: "Foo::Bar"
|
95
|
+
def full_name
|
96
|
+
full_name_parts.join("::")
|
97
|
+
end
|
98
|
+
end
|
55
99
|
end
|
data/lib/prism/parse_result.rb
CHANGED
@@ -117,7 +117,7 @@ module Prism
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def pretty_print(q)
|
120
|
-
q.text("(#{start_line},#{start_column})-(#{end_line},#{end_column})
|
120
|
+
q.text("(#{start_line},#{start_column})-(#{end_line},#{end_column})")
|
121
121
|
end
|
122
122
|
|
123
123
|
def ==(other)
|
@@ -137,7 +137,7 @@ module Prism
|
|
137
137
|
end
|
138
138
|
|
139
139
|
def self.null
|
140
|
-
new(0, 0)
|
140
|
+
new(nil, 0, 0)
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
@@ -166,6 +166,32 @@ module Prism
|
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
169
|
+
# This represents a magic comment that was encountered during parsing.
|
170
|
+
class MagicComment
|
171
|
+
attr_reader :key_loc, :value_loc
|
172
|
+
|
173
|
+
def initialize(key_loc, value_loc)
|
174
|
+
@key_loc = key_loc
|
175
|
+
@value_loc = value_loc
|
176
|
+
end
|
177
|
+
|
178
|
+
def key
|
179
|
+
key_loc.slice
|
180
|
+
end
|
181
|
+
|
182
|
+
def value
|
183
|
+
value_loc.slice
|
184
|
+
end
|
185
|
+
|
186
|
+
def deconstruct_keys(keys)
|
187
|
+
{ key_loc: key_loc, value_loc: value_loc }
|
188
|
+
end
|
189
|
+
|
190
|
+
def inspect
|
191
|
+
"#<Prism::MagicComment @key=#{key.inspect} @value=#{value.inspect}>"
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
169
195
|
# This represents an error that was encountered during parsing.
|
170
196
|
class ParseError
|
171
197
|
attr_reader :message, :location
|
@@ -206,18 +232,19 @@ module Prism
|
|
206
232
|
# the AST, any comments that were encounters, and any errors that were
|
207
233
|
# encountered.
|
208
234
|
class ParseResult
|
209
|
-
attr_reader :value, :comments, :errors, :warnings, :source
|
235
|
+
attr_reader :value, :comments, :magic_comments, :errors, :warnings, :source
|
210
236
|
|
211
|
-
def initialize(value, comments, errors, warnings, source)
|
237
|
+
def initialize(value, comments, magic_comments, errors, warnings, source)
|
212
238
|
@value = value
|
213
239
|
@comments = comments
|
240
|
+
@magic_comments = magic_comments
|
214
241
|
@errors = errors
|
215
242
|
@warnings = warnings
|
216
243
|
@source = source
|
217
244
|
end
|
218
245
|
|
219
246
|
def deconstruct_keys(keys)
|
220
|
-
{ value: value, comments: comments, errors: errors, warnings: warnings }
|
247
|
+
{ value: value, comments: comments, magic_comments: magic_comments, errors: errors, warnings: warnings }
|
221
248
|
end
|
222
249
|
|
223
250
|
def success?
|
data/lib/prism/pattern.rb
CHANGED
@@ -10,7 +10,7 @@ module Prism
|
|
10
10
|
# in ConstantPathNode[ConstantReadNode[name: :Prism], ConstantReadNode[name: :Pattern]]
|
11
11
|
# end
|
12
12
|
#
|
13
|
-
# the pattern is the
|
13
|
+
# the pattern is the <tt>ConstantPathNode[...]</tt> expression.
|
14
14
|
#
|
15
15
|
# The pattern gets compiled into an object that responds to #call by running
|
16
16
|
# the #compile method. This method itself will run back through Prism to
|
data/lib/prism/serialize.rb
CHANGED
@@ -21,7 +21,7 @@ end
|
|
21
21
|
module Prism
|
22
22
|
module Serialize
|
23
23
|
MAJOR_VERSION = 0
|
24
|
-
MINOR_VERSION =
|
24
|
+
MINOR_VERSION = 14
|
25
25
|
PATCH_VERSION = 0
|
26
26
|
|
27
27
|
def self.load(input, serialized)
|
@@ -62,9 +62,10 @@ module Prism
|
|
62
62
|
|
63
63
|
def load_metadata
|
64
64
|
comments = load_varint.times.map { Comment.new(Comment::TYPES.fetch(load_varint), load_location) }
|
65
|
+
magic_comments = load_varint.times.map { MagicComment.new(load_location, load_location) }
|
65
66
|
errors = load_varint.times.map { ParseError.new(load_embedded_string, load_location) }
|
66
67
|
warnings = load_varint.times.map { ParseWarning.new(load_embedded_string, load_location) }
|
67
|
-
[comments, errors, warnings]
|
68
|
+
[comments, magic_comments, errors, warnings]
|
68
69
|
end
|
69
70
|
|
70
71
|
def load_tokens
|
@@ -83,14 +84,14 @@ module Prism
|
|
83
84
|
def load_tokens_result
|
84
85
|
tokens = load_tokens
|
85
86
|
encoding = load_encoding
|
86
|
-
comments, errors, warnings = load_metadata
|
87
|
+
comments, magic_comments, errors, warnings = load_metadata
|
87
88
|
|
88
89
|
if encoding != @encoding
|
89
90
|
tokens.each { |token,| token.value.force_encoding(encoding) }
|
90
91
|
end
|
91
92
|
|
92
93
|
raise "Expected to consume all bytes while deserializing" unless @io.eof?
|
93
|
-
Prism::ParseResult.new(tokens, comments, errors, warnings, @source)
|
94
|
+
Prism::ParseResult.new(tokens, comments, magic_comments, errors, warnings, @source)
|
94
95
|
end
|
95
96
|
|
96
97
|
def load_nodes
|
@@ -104,17 +105,17 @@ module Prism
|
|
104
105
|
@encoding = load_encoding
|
105
106
|
@input = input.force_encoding(@encoding).freeze
|
106
107
|
|
107
|
-
comments, errors, warnings = load_metadata
|
108
|
+
comments, magic_comments, errors, warnings = load_metadata
|
108
109
|
|
109
110
|
@constant_pool_offset = io.read(4).unpack1("L")
|
110
111
|
@constant_pool = Array.new(load_varint, nil)
|
111
112
|
|
112
|
-
[load_node, comments, errors, warnings]
|
113
|
+
[load_node, comments, magic_comments, errors, warnings]
|
113
114
|
end
|
114
115
|
|
115
116
|
def load_result
|
116
|
-
node, comments, errors, warnings = load_nodes
|
117
|
-
Prism::ParseResult.new(node, comments, errors, warnings, @source)
|
117
|
+
node, comments, magic_comments, errors, warnings = load_nodes
|
118
|
+
Prism::ParseResult.new(node, comments, magic_comments, errors, warnings, @source)
|
118
119
|
end
|
119
120
|
|
120
121
|
private
|
@@ -151,13 +152,14 @@ module Prism
|
|
151
152
|
end
|
152
153
|
|
153
154
|
def load_string
|
154
|
-
|
155
|
+
type = io.getbyte
|
156
|
+
case type
|
155
157
|
when 1
|
156
158
|
input.byteslice(load_varint, load_varint).force_encoding(encoding)
|
157
159
|
when 2
|
158
160
|
load_embedded_string
|
159
161
|
else
|
160
|
-
raise
|
162
|
+
raise "Unknown serialized string type: #{type}"
|
161
163
|
end
|
162
164
|
end
|
163
165
|
|
@@ -239,13 +241,13 @@ module Prism
|
|
239
241
|
when 17 then
|
240
242
|
BreakNode.new(load_optional_node, load_location, location)
|
241
243
|
when 18 then
|
242
|
-
CallAndWriteNode.new(load_optional_node, load_optional_location, load_optional_location, load_optional_location, load_optional_node, load_optional_location, load_varint,
|
244
|
+
CallAndWriteNode.new(load_optional_node, load_optional_location, load_optional_location, load_optional_location, load_optional_node, load_optional_location, load_varint, load_required_constant, load_required_constant, load_location, load_node, location)
|
243
245
|
when 19 then
|
244
|
-
CallNode.new(load_optional_node, load_optional_location, load_optional_location, load_optional_location, load_optional_node, load_optional_location, load_optional_node, load_varint,
|
246
|
+
CallNode.new(load_optional_node, load_optional_location, load_optional_location, load_optional_location, load_optional_node, load_optional_location, load_optional_node, load_varint, load_required_constant, location)
|
245
247
|
when 20 then
|
246
|
-
CallOperatorWriteNode.new(load_optional_node, load_optional_location, load_optional_location, load_optional_location, load_optional_node, load_optional_location, load_varint,
|
248
|
+
CallOperatorWriteNode.new(load_optional_node, load_optional_location, load_optional_location, load_optional_location, load_optional_node, load_optional_location, load_varint, load_required_constant, load_required_constant, load_required_constant, load_location, load_node, location)
|
247
249
|
when 21 then
|
248
|
-
CallOrWriteNode.new(load_optional_node, load_optional_location, load_optional_location, load_optional_location, load_optional_node, load_optional_location, load_varint,
|
250
|
+
CallOrWriteNode.new(load_optional_node, load_optional_location, load_optional_location, load_optional_location, load_optional_node, load_optional_location, load_varint, load_required_constant, load_required_constant, load_location, load_node, location)
|
249
251
|
when 22 then
|
250
252
|
CapturePatternNode.new(load_node, load_node, load_location, location)
|
251
253
|
when 23 then
|
data/prism.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "prism"
|
5
|
-
spec.version = "0.
|
5
|
+
spec.version = "0.14.0"
|
6
6
|
spec.authors = ["Shopify"]
|
7
7
|
spec.email = ["ruby@shopify.com"]
|
8
8
|
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
"docs/fuzzing.md",
|
30
30
|
"docs/heredocs.md",
|
31
31
|
"docs/mapping.md",
|
32
|
+
"docs/prism.png",
|
32
33
|
"docs/ripper.md",
|
33
34
|
"docs/ruby_api.md",
|
34
35
|
"docs/serialization.md",
|
@@ -46,7 +47,6 @@ Gem::Specification.new do |spec|
|
|
46
47
|
"include/prism/pack.h",
|
47
48
|
"include/prism/parser.h",
|
48
49
|
"include/prism/regexp.h",
|
49
|
-
"include/prism/unescape.h",
|
50
50
|
"include/prism/util/pm_buffer.h",
|
51
51
|
"include/prism/util/pm_char.h",
|
52
52
|
"include/prism/util/pm_constant_pool.h",
|
@@ -92,7 +92,6 @@ Gem::Specification.new do |spec|
|
|
92
92
|
"src/regexp.c",
|
93
93
|
"src/serialize.c",
|
94
94
|
"src/token_type.c",
|
95
|
-
"src/unescape.c",
|
96
95
|
"src/util/pm_buffer.c",
|
97
96
|
"src/util/pm_char.c",
|
98
97
|
"src/util/pm_constant_pool.c",
|
data/src/diagnostic.c
CHANGED
@@ -265,7 +265,7 @@ pm_diagnostic_message(pm_diagnostic_id_t diag_id) {
|
|
265
265
|
// Append an error to the given list of diagnostic.
|
266
266
|
bool
|
267
267
|
pm_diagnostic_list_append(pm_list_t *list, const uint8_t *start, const uint8_t *end, pm_diagnostic_id_t diag_id) {
|
268
|
-
pm_diagnostic_t *diagnostic = (pm_diagnostic_t *)
|
268
|
+
pm_diagnostic_t *diagnostic = (pm_diagnostic_t *) calloc(sizeof(pm_diagnostic_t), 1);
|
269
269
|
if (diagnostic == NULL) return false;
|
270
270
|
|
271
271
|
*diagnostic = (pm_diagnostic_t) { .start = start, .end = end, .message = pm_diagnostic_message(diag_id) };
|
data/src/node.c
CHANGED
@@ -204,8 +204,6 @@ pm_node_destroy(pm_parser_t *parser, pm_node_t *node) {
|
|
204
204
|
if (cast->arguments != NULL) {
|
205
205
|
pm_node_destroy(parser, (pm_node_t *)cast->arguments);
|
206
206
|
}
|
207
|
-
pm_string_free(&cast->read_name);
|
208
|
-
pm_string_free(&cast->write_name);
|
209
207
|
pm_node_destroy(parser, (pm_node_t *)cast->value);
|
210
208
|
break;
|
211
209
|
}
|
@@ -221,7 +219,6 @@ pm_node_destroy(pm_parser_t *parser, pm_node_t *node) {
|
|
221
219
|
if (cast->block != NULL) {
|
222
220
|
pm_node_destroy(parser, (pm_node_t *)cast->block);
|
223
221
|
}
|
224
|
-
pm_string_free(&cast->name);
|
225
222
|
break;
|
226
223
|
}
|
227
224
|
#line 57 "node.c.erb"
|
@@ -233,8 +230,6 @@ pm_node_destroy(pm_parser_t *parser, pm_node_t *node) {
|
|
233
230
|
if (cast->arguments != NULL) {
|
234
231
|
pm_node_destroy(parser, (pm_node_t *)cast->arguments);
|
235
232
|
}
|
236
|
-
pm_string_free(&cast->read_name);
|
237
|
-
pm_string_free(&cast->write_name);
|
238
233
|
pm_node_destroy(parser, (pm_node_t *)cast->value);
|
239
234
|
break;
|
240
235
|
}
|
@@ -247,8 +242,6 @@ pm_node_destroy(pm_parser_t *parser, pm_node_t *node) {
|
|
247
242
|
if (cast->arguments != NULL) {
|
248
243
|
pm_node_destroy(parser, (pm_node_t *)cast->arguments);
|
249
244
|
}
|
250
|
-
pm_string_free(&cast->read_name);
|
251
|
-
pm_string_free(&cast->write_name);
|
252
245
|
pm_node_destroy(parser, (pm_node_t *)cast->value);
|
253
246
|
break;
|
254
247
|
}
|
@@ -1263,8 +1256,6 @@ pm_node_memsize_node(pm_node_t *node, pm_memsize_t *memsize) {
|
|
1263
1256
|
if (cast->arguments != NULL) {
|
1264
1257
|
pm_node_memsize_node((pm_node_t *)cast->arguments, memsize);
|
1265
1258
|
}
|
1266
|
-
memsize->memsize += pm_string_memsize(&cast->read_name);
|
1267
|
-
memsize->memsize += pm_string_memsize(&cast->write_name);
|
1268
1259
|
pm_node_memsize_node((pm_node_t *)cast->value, memsize);
|
1269
1260
|
break;
|
1270
1261
|
}
|
@@ -1281,7 +1272,6 @@ pm_node_memsize_node(pm_node_t *node, pm_memsize_t *memsize) {
|
|
1281
1272
|
if (cast->block != NULL) {
|
1282
1273
|
pm_node_memsize_node((pm_node_t *)cast->block, memsize);
|
1283
1274
|
}
|
1284
|
-
memsize->memsize += pm_string_memsize(&cast->name);
|
1285
1275
|
break;
|
1286
1276
|
}
|
1287
1277
|
#line 102 "node.c.erb"
|
@@ -1294,8 +1284,6 @@ pm_node_memsize_node(pm_node_t *node, pm_memsize_t *memsize) {
|
|
1294
1284
|
if (cast->arguments != NULL) {
|
1295
1285
|
pm_node_memsize_node((pm_node_t *)cast->arguments, memsize);
|
1296
1286
|
}
|
1297
|
-
memsize->memsize += pm_string_memsize(&cast->read_name);
|
1298
|
-
memsize->memsize += pm_string_memsize(&cast->write_name);
|
1299
1287
|
pm_node_memsize_node((pm_node_t *)cast->value, memsize);
|
1300
1288
|
break;
|
1301
1289
|
}
|
@@ -1309,8 +1297,6 @@ pm_node_memsize_node(pm_node_t *node, pm_memsize_t *memsize) {
|
|
1309
1297
|
if (cast->arguments != NULL) {
|
1310
1298
|
pm_node_memsize_node((pm_node_t *)cast->arguments, memsize);
|
1311
1299
|
}
|
1312
|
-
memsize->memsize += pm_string_memsize(&cast->read_name);
|
1313
|
-
memsize->memsize += pm_string_memsize(&cast->write_name);
|
1314
1300
|
pm_node_memsize_node((pm_node_t *)cast->value, memsize);
|
1315
1301
|
break;
|
1316
1302
|
}
|
data/src/prettyprint.c
CHANGED
@@ -327,14 +327,14 @@ prettyprint_node(pm_buffer_t *buffer, pm_parser_t *parser, pm_node_t *node) {
|
|
327
327
|
prettyprint_location(buffer, parser, &((pm_call_and_write_node_t *)node)->closing_loc);
|
328
328
|
}
|
329
329
|
pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
|
330
|
-
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags
|
330
|
+
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
|
331
331
|
pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
|
332
|
-
pm_buffer_append_str(buffer, ", ", 2);
|
333
|
-
|
334
|
-
pm_buffer_append_str(buffer,
|
335
|
-
pm_buffer_append_str(buffer, ", ", 2);
|
336
|
-
|
337
|
-
pm_buffer_append_str(buffer,
|
332
|
+
pm_buffer_append_str(buffer, ", ", 2); char read_name_buffer[12];
|
333
|
+
snprintf(read_name_buffer, sizeof(read_name_buffer), "%u", ((pm_call_and_write_node_t *)node)->read_name);
|
334
|
+
pm_buffer_append_str(buffer, read_name_buffer, strlen(read_name_buffer));
|
335
|
+
pm_buffer_append_str(buffer, ", ", 2); char write_name_buffer[12];
|
336
|
+
snprintf(write_name_buffer, sizeof(write_name_buffer), "%u", ((pm_call_and_write_node_t *)node)->write_name);
|
337
|
+
pm_buffer_append_str(buffer, write_name_buffer, strlen(write_name_buffer));
|
338
338
|
pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_call_and_write_node_t *)node)->operator_loc);
|
339
339
|
pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_call_and_write_node_t *)node)->value);
|
340
340
|
pm_buffer_append_str(buffer, ")", 1);
|
@@ -378,11 +378,11 @@ prettyprint_node(pm_buffer_t *buffer, pm_parser_t *parser, pm_node_t *node) {
|
|
378
378
|
prettyprint_node(buffer, parser, (pm_node_t *)((pm_call_node_t *)node)->block);
|
379
379
|
}
|
380
380
|
pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
|
381
|
-
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags
|
381
|
+
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
|
382
382
|
pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
|
383
|
-
pm_buffer_append_str(buffer, ", ", 2);
|
384
|
-
|
385
|
-
pm_buffer_append_str(buffer,
|
383
|
+
pm_buffer_append_str(buffer, ", ", 2); char name_buffer[12];
|
384
|
+
snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_call_node_t *)node)->name);
|
385
|
+
pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
|
386
386
|
pm_buffer_append_str(buffer, ")", 1);
|
387
387
|
break;
|
388
388
|
}
|
@@ -419,14 +419,14 @@ prettyprint_node(pm_buffer_t *buffer, pm_parser_t *parser, pm_node_t *node) {
|
|
419
419
|
prettyprint_location(buffer, parser, &((pm_call_operator_write_node_t *)node)->closing_loc);
|
420
420
|
}
|
421
421
|
pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
|
422
|
-
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags
|
422
|
+
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
|
423
423
|
pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
|
424
|
-
pm_buffer_append_str(buffer, ", ", 2);
|
425
|
-
|
426
|
-
pm_buffer_append_str(buffer,
|
427
|
-
pm_buffer_append_str(buffer, ", ", 2);
|
428
|
-
|
429
|
-
pm_buffer_append_str(buffer,
|
424
|
+
pm_buffer_append_str(buffer, ", ", 2); char read_name_buffer[12];
|
425
|
+
snprintf(read_name_buffer, sizeof(read_name_buffer), "%u", ((pm_call_operator_write_node_t *)node)->read_name);
|
426
|
+
pm_buffer_append_str(buffer, read_name_buffer, strlen(read_name_buffer));
|
427
|
+
pm_buffer_append_str(buffer, ", ", 2); char write_name_buffer[12];
|
428
|
+
snprintf(write_name_buffer, sizeof(write_name_buffer), "%u", ((pm_call_operator_write_node_t *)node)->write_name);
|
429
|
+
pm_buffer_append_str(buffer, write_name_buffer, strlen(write_name_buffer));
|
430
430
|
pm_buffer_append_str(buffer, ", ", 2); char operator_buffer[12];
|
431
431
|
snprintf(operator_buffer, sizeof(operator_buffer), "%u", ((pm_call_operator_write_node_t *)node)->operator);
|
432
432
|
pm_buffer_append_str(buffer, operator_buffer, strlen(operator_buffer));
|
@@ -468,14 +468,14 @@ prettyprint_node(pm_buffer_t *buffer, pm_parser_t *parser, pm_node_t *node) {
|
|
468
468
|
prettyprint_location(buffer, parser, &((pm_call_or_write_node_t *)node)->closing_loc);
|
469
469
|
}
|
470
470
|
pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
|
471
|
-
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags
|
471
|
+
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
|
472
472
|
pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
|
473
|
-
pm_buffer_append_str(buffer, ", ", 2);
|
474
|
-
|
475
|
-
pm_buffer_append_str(buffer,
|
476
|
-
pm_buffer_append_str(buffer, ", ", 2);
|
477
|
-
|
478
|
-
pm_buffer_append_str(buffer,
|
473
|
+
pm_buffer_append_str(buffer, ", ", 2); char read_name_buffer[12];
|
474
|
+
snprintf(read_name_buffer, sizeof(read_name_buffer), "%u", ((pm_call_or_write_node_t *)node)->read_name);
|
475
|
+
pm_buffer_append_str(buffer, read_name_buffer, strlen(read_name_buffer));
|
476
|
+
pm_buffer_append_str(buffer, ", ", 2); char write_name_buffer[12];
|
477
|
+
snprintf(write_name_buffer, sizeof(write_name_buffer), "%u", ((pm_call_or_write_node_t *)node)->write_name);
|
478
|
+
pm_buffer_append_str(buffer, write_name_buffer, strlen(write_name_buffer));
|
479
479
|
pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_call_or_write_node_t *)node)->operator_loc);
|
480
480
|
pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_call_or_write_node_t *)node)->value);
|
481
481
|
pm_buffer_append_str(buffer, ")", 1);
|
@@ -904,7 +904,7 @@ prettyprint_node(pm_buffer_t *buffer, pm_parser_t *parser, pm_node_t *node) {
|
|
904
904
|
}
|
905
905
|
pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_flip_flop_node_t *)node)->operator_loc);
|
906
906
|
pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
|
907
|
-
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags
|
907
|
+
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
|
908
908
|
pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
|
909
909
|
pm_buffer_append_str(buffer, ")", 1);
|
910
910
|
break;
|
@@ -1182,7 +1182,7 @@ prettyprint_node(pm_buffer_t *buffer, pm_parser_t *parser, pm_node_t *node) {
|
|
1182
1182
|
case PM_INTEGER_NODE: {
|
1183
1183
|
pm_buffer_append_str(buffer, "IntegerNode(", 12);
|
1184
1184
|
char flags_buffer[12];
|
1185
|
-
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags
|
1185
|
+
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
|
1186
1186
|
pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
|
1187
1187
|
pm_buffer_append_str(buffer, ")", 1);
|
1188
1188
|
break;
|
@@ -1198,7 +1198,7 @@ prettyprint_node(pm_buffer_t *buffer, pm_parser_t *parser, pm_node_t *node) {
|
|
1198
1198
|
pm_buffer_append_str(buffer, "]", 1);
|
1199
1199
|
pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_interpolated_match_last_line_node_t *)node)->closing_loc);
|
1200
1200
|
pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
|
1201
|
-
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags
|
1201
|
+
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
|
1202
1202
|
pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
|
1203
1203
|
pm_buffer_append_str(buffer, ")", 1);
|
1204
1204
|
break;
|
@@ -1214,7 +1214,7 @@ prettyprint_node(pm_buffer_t *buffer, pm_parser_t *parser, pm_node_t *node) {
|
|
1214
1214
|
pm_buffer_append_str(buffer, "]", 1);
|
1215
1215
|
pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_interpolated_regular_expression_node_t *)node)->closing_loc);
|
1216
1216
|
pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
|
1217
|
-
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags
|
1217
|
+
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
|
1218
1218
|
pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
|
1219
1219
|
pm_buffer_append_str(buffer, ")", 1);
|
1220
1220
|
break;
|
@@ -1433,7 +1433,7 @@ prettyprint_node(pm_buffer_t *buffer, pm_parser_t *parser, pm_node_t *node) {
|
|
1433
1433
|
pm_buffer_append_bytes(buffer, pm_string_source(&((pm_match_last_line_node_t *)node)->unescaped), pm_string_length(&((pm_match_last_line_node_t *)node)->unescaped));
|
1434
1434
|
pm_buffer_append_str(buffer, "\"", 1);
|
1435
1435
|
pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
|
1436
|
-
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags
|
1436
|
+
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
|
1437
1437
|
pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
|
1438
1438
|
pm_buffer_append_str(buffer, ")", 1);
|
1439
1439
|
break;
|
@@ -1717,7 +1717,7 @@ prettyprint_node(pm_buffer_t *buffer, pm_parser_t *parser, pm_node_t *node) {
|
|
1717
1717
|
}
|
1718
1718
|
pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_range_node_t *)node)->operator_loc);
|
1719
1719
|
pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
|
1720
|
-
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags
|
1720
|
+
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
|
1721
1721
|
pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
|
1722
1722
|
pm_buffer_append_str(buffer, ")", 1);
|
1723
1723
|
break;
|
@@ -1742,7 +1742,7 @@ prettyprint_node(pm_buffer_t *buffer, pm_parser_t *parser, pm_node_t *node) {
|
|
1742
1742
|
pm_buffer_append_bytes(buffer, pm_string_source(&((pm_regular_expression_node_t *)node)->unescaped), pm_string_length(&((pm_regular_expression_node_t *)node)->unescaped));
|
1743
1743
|
pm_buffer_append_str(buffer, "\"", 1);
|
1744
1744
|
pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
|
1745
|
-
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags
|
1745
|
+
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
|
1746
1746
|
pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
|
1747
1747
|
pm_buffer_append_str(buffer, ")", 1);
|
1748
1748
|
break;
|
@@ -1919,7 +1919,7 @@ prettyprint_node(pm_buffer_t *buffer, pm_parser_t *parser, pm_node_t *node) {
|
|
1919
1919
|
case PM_STRING_NODE: {
|
1920
1920
|
pm_buffer_append_str(buffer, "StringNode(", 11);
|
1921
1921
|
char flags_buffer[12];
|
1922
|
-
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags
|
1922
|
+
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
|
1923
1923
|
pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
|
1924
1924
|
pm_buffer_append_str(buffer, ", ", 2); if (((pm_string_node_t *)node)->opening_loc.start == NULL) {
|
1925
1925
|
pm_buffer_append_str(buffer, "nil", 3);
|
@@ -2041,7 +2041,7 @@ prettyprint_node(pm_buffer_t *buffer, pm_parser_t *parser, pm_node_t *node) {
|
|
2041
2041
|
prettyprint_node(buffer, parser, (pm_node_t *)((pm_until_node_t *)node)->statements);
|
2042
2042
|
}
|
2043
2043
|
pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
|
2044
|
-
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags
|
2044
|
+
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
|
2045
2045
|
pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
|
2046
2046
|
pm_buffer_append_str(buffer, ")", 1);
|
2047
2047
|
break;
|
@@ -2078,7 +2078,7 @@ prettyprint_node(pm_buffer_t *buffer, pm_parser_t *parser, pm_node_t *node) {
|
|
2078
2078
|
prettyprint_node(buffer, parser, (pm_node_t *)((pm_while_node_t *)node)->statements);
|
2079
2079
|
}
|
2080
2080
|
pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
|
2081
|
-
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags
|
2081
|
+
snprintf(flags_buffer, sizeof(flags_buffer), "+%d", (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
|
2082
2082
|
pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
|
2083
2083
|
pm_buffer_append_str(buffer, ")", 1);
|
2084
2084
|
break;
|