Debian Codegraph @

src/static_literals.c

raw symbols SCIP
1 #cxx . . $ `<file>/src/static_literals.c`/include "prism/static_literals.h"cxx . . $ `<file>/include/prism/static_literals.h`/
2
3 /**
4 * A small struct used for passing around a subset of the information that is
5 * stored on the parser. We use this to avoid having static literals explicitly
6 * depend on the parser struct.
7 */
8 typedef structcxx . . $ $anonymous_type_6c69e7cbeffceec8_0# {
9 /** The list of newline offsets to use to calculate line numbers. */
10 const pm_newline_list_tcxx . . $ pm_newline_list_t# *newline_listcxx . . $ $anonymous_type_6c69e7cbeffceec8_0#newline_list.;
11
12 /** The line number that the parser starts on. */
13 int32_tcxx . . $ int32_t# start_linecxx . . $ $anonymous_type_6c69e7cbeffceec8_0#start_line.;
14
15 /** The name of the encoding that the parser is using. */
16 const char *encoding_namecxx . . $ $anonymous_type_6c69e7cbeffceec8_0#encoding_name.;
17 } pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t#;
18
19 static inline uint32_tcxx . . $ uint32_t#
20 murmur_scramblecxx . . $ murmur_scramble(2141b656ce2cc063).(uint32_tcxx . . $ uint32_t# value) {
21 value *= 0xcc9e2d51;
22 value = (value << 15) | (value >> 17);
23 value *= 0x1b873593;
24 return value;
25 }
26
27 /**
28 * Murmur hash (https://en.wikipedia.org/wiki/MurmurHash) is a non-cryptographic
29 * general-purpose hash function. It is fast, which is what we care about in
30 * this case.
31 */
32 static uint32_tcxx . . $ uint32_t#
33 murmur_hashcxx . . $ murmur_hash(13d9c8ea4fc589cf).(const uint8_tcxx . . $ uint8_t# *key, size_t length) {
34 uint32_tcxx . . $ uint32_t# hash = 0x9747b28c;
35 uint32_tcxx . . $ uint32_t# segment;
36
37 for (size_t index = length >> 2; index; index--) {
38 memcpycxx . . $ memcpy(cc817cb175f282d).(&segment, key, sizeof(uint32_tcxx . . $ uint32_t#));
39 key += sizeof(uint32_tcxx . . $ uint32_t#);
40 hash ^= murmur_scramblecxx . . $ murmur_scramble(2141b656ce2cc063).(segment);
41 hash = (hash << 13) | (hash >> 19);
42 hash = hash * 5 + 0xe6546b64;
43 }
44
45 segment = 0;
46 for (size_t index = length & 3; index; index--) {
47 segment <<= 8;
48 segment |= key[index - 1];
49 }
50
51 hash ^= murmur_scramblecxx . . $ murmur_scramble(2141b656ce2cc063).(segment);
52 hash ^= (uint32_tcxx . . $ uint32_t#) length;
53 hash ^= hash >> 16;
54 hash *= 0x85ebca6b;
55 hash ^= hash >> 13;
56 hash *= 0xc2b2ae35;
57 hash ^= hash >> 16;
58 return hash;
59 }
60
61 /**
62 * Hash the value of an integer and return it.
63 */
64 static uint32_tcxx . . $ uint32_t#
65 integer_hashcxx . . $ integer_hash(ef29f881b953d7f4).(const pm_integer_tcxx . . $ pm_integer_t# *integer) {
66 uint32_tcxx . . $ uint32_t# hash;
67 if (integer->valuescxx . . $ $anonymous_type_65facc28bc11402_0#values.) {
68 hash = murmur_hashcxx . . $ murmur_hash(13d9c8ea4fc589cf).((const uint8_tcxx . . $ uint8_t# *) integer->valuescxx . . $ $anonymous_type_65facc28bc11402_0#values., sizeof(uint32_tcxx . . $ uint32_t#) * integer->lengthcxx . . $ $anonymous_type_65facc28bc11402_0#length.);
69 } else {
70 hash = murmur_hashcxx . . $ murmur_hash(13d9c8ea4fc589cf).((const uint8_tcxx . . $ uint8_t# *) &integer->valuecxx . . $ $anonymous_type_65facc28bc11402_0#value., sizeof(uint32_tcxx . . $ uint32_t#));
71 }
72
73 if (integer->negativecxx . . $ $anonymous_type_65facc28bc11402_0#negative.) {
74 hash ^= murmur_scramblecxx . . $ murmur_scramble(2141b656ce2cc063).((uint32_tcxx . . $ uint32_t#) 1);
75 }
76
77 return hash;
78 }
79
80 /**
81 * Return the hash of the given node. It is important that nodes that have
82 * equivalent static literal values have the same hash. This is because we use
83 * these hashes to look for duplicates.
84 */
85 static uint32_tcxx . . $ uint32_t#
86 node_hashcxx . . $ node_hash(e98bb68b461047bc).(const pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t# *metadata, const pm_node_tcxx . . $ pm_node_t# *node) {
87 switch (PM_NODE_TYPEcxx . . $ `include/prism/ast.h:1092:9`!(node)) {
88 case PM_INTEGER_NODEcxx . . $ PM_INTEGER_NODE.: {
89 // Integers hash their value.
90 const pm_integer_node_tcxx . . $ pm_integer_node_t# *cast = (const pm_integer_node_tcxx . . $ pm_integer_node_t# *) node;
91 return integer_hashcxx . . $ integer_hash(ef29f881b953d7f4).(&cast->valuecxx . . $ pm_integer_node#value.);
92 }
93 case PM_SOURCE_LINE_NODEcxx . . $ PM_SOURCE_LINE_NODE.: {
94 // Source lines hash their line number.
95 const pm_line_column_tcxx . . $ pm_line_column_t# line_column = pm_newline_list_line_columncxx . . $ pm_newline_list_line_column(1a8b391d550aa6bd).(metadata->newline_listcxx . . $ $anonymous_type_6c69e7cbeffceec8_0#newline_list., node->locationcxx . . $ pm_node#location..startcxx . . $ $anonymous_type_926221c61b414ea8_1#start., metadata->start_linecxx . . $ $anonymous_type_6c69e7cbeffceec8_0#start_line.);
96 const int32_tcxx . . $ int32_t# *value = &line_column.linecxx . . $ $anonymous_type_9901d064858912af_1#line.;
97 return murmur_hashcxx . . $ murmur_hash(13d9c8ea4fc589cf).((const uint8_tcxx . . $ uint8_t# *) value, sizeof(int32_tcxx . . $ int32_t#));
98 }
99 case PM_FLOAT_NODEcxx . . $ PM_FLOAT_NODE.: {
100 // Floats hash their value.
101 const double *value = &((const pm_float_node_tcxx . . $ pm_float_node_t# *) node)->valuecxx . . $ pm_float_node#value.;
102 return murmur_hashcxx . . $ murmur_hash(13d9c8ea4fc589cf).((const uint8_tcxx . . $ uint8_t# *) value, sizeof(double));
103 }
104 case PM_RATIONAL_NODEcxx . . $ PM_RATIONAL_NODE.: {
105 // Rationals hash their numerator and denominator.
106 const pm_rational_node_tcxx . . $ pm_rational_node_t# *cast = (const pm_rational_node_tcxx . . $ pm_rational_node_t# *) node;
107 return integer_hashcxx . . $ integer_hash(ef29f881b953d7f4).(&cast->numeratorcxx . . $ pm_rational_node#numerator.) ^ integer_hashcxx . . $ integer_hash(ef29f881b953d7f4).(&cast->denominatorcxx . . $ pm_rational_node#denominator.) ^ murmur_scramblecxx . . $ murmur_scramble(2141b656ce2cc063).((uint32_tcxx . . $ uint32_t#) cast->basecxx . . $ pm_rational_node#base..typecxx . . $ pm_node#type.);
108 }
109 case PM_IMAGINARY_NODEcxx . . $ PM_IMAGINARY_NODE.: {
110 // Imaginaries hash their numeric value. Because their numeric value
111 // is stored as a subnode, we hash that node and then mix in the
112 // fact that this is an imaginary node.
113 const pm_node_tcxx . . $ pm_node_t# *numeric = ((const pm_imaginary_node_tcxx . . $ pm_imaginary_node_t# *) node)->numericcxx . . $ pm_imaginary_node#numeric.;
114 return node_hashcxx . . $ node_hash(e98bb68b461047bc).(metadata, numeric) ^ murmur_scramblecxx . . $ murmur_scramble(2141b656ce2cc063).((uint32_tcxx . . $ uint32_t#) node->typecxx . . $ pm_node#type.);
115 }
116 case PM_STRING_NODEcxx . . $ PM_STRING_NODE.: {
117 // Strings hash their value and mix in their flags so that different
118 // encodings are not considered equal.
119 const pm_string_tcxx . . $ pm_string_t# *value = &((const pm_string_node_tcxx . . $ pm_string_node_t# *) node)->unescapedcxx . . $ pm_string_node#unescaped.;
120
121 pm_node_flags_tcxx . . $ pm_node_flags_t# flags = node->flagscxx . . $ pm_node#flags.;
122 flags &= (PM_STRING_FLAGS_FORCED_BINARY_ENCODINGcxx . . $ PM_STRING_FLAGS_FORCED_BINARY_ENCODING. | PM_STRING_FLAGS_FORCED_UTF8_ENCODINGcxx . . $ PM_STRING_FLAGS_FORCED_UTF8_ENCODING.);
123
124 return murmur_hashcxx . . $ murmur_hash(13d9c8ea4fc589cf).(pm_string_sourcecxx . . $ pm_string_source(37c9bd456e9b3712).(value), pm_string_lengthcxx . . $ pm_string_length(576a13ceb66f8a15).(value) * sizeof(uint8_tcxx . . $ uint8_t#)) ^ murmur_scramblecxx . . $ murmur_scramble(2141b656ce2cc063).((uint32_tcxx . . $ uint32_t#) flags);
125 }
126 case PM_SOURCE_FILE_NODEcxx . . $ PM_SOURCE_FILE_NODE.: {
127 // Source files hash their value and mix in their flags so that
128 // different encodings are not considered equal.
129 const pm_string_tcxx . . $ pm_string_t# *value = &((const pm_source_file_node_tcxx . . $ pm_source_file_node_t# *) node)->filepathcxx . . $ pm_source_file_node#filepath.;
130 return murmur_hashcxx . . $ murmur_hash(13d9c8ea4fc589cf).(pm_string_sourcecxx . . $ pm_string_source(37c9bd456e9b3712).(value), pm_string_lengthcxx . . $ pm_string_length(576a13ceb66f8a15).(value) * sizeof(uint8_tcxx . . $ uint8_t#));
131 }
132 case PM_REGULAR_EXPRESSION_NODEcxx . . $ PM_REGULAR_EXPRESSION_NODE.: {
133 // Regular expressions hash their value and mix in their flags so
134 // that different encodings are not considered equal.
135 const pm_string_tcxx . . $ pm_string_t# *value = &((const pm_regular_expression_node_tcxx . . $ pm_regular_expression_node_t# *) node)->unescapedcxx . . $ pm_regular_expression_node#unescaped.;
136 return murmur_hashcxx . . $ murmur_hash(13d9c8ea4fc589cf).(pm_string_sourcecxx . . $ pm_string_source(37c9bd456e9b3712).(value), pm_string_lengthcxx . . $ pm_string_length(576a13ceb66f8a15).(value) * sizeof(uint8_tcxx . . $ uint8_t#)) ^ murmur_scramblecxx . . $ murmur_scramble(2141b656ce2cc063).((uint32_tcxx . . $ uint32_t#) node->flagscxx . . $ pm_node#flags.);
137 }
138 case PM_SYMBOL_NODEcxx . . $ PM_SYMBOL_NODE.: {
139 // Symbols hash their value and mix in their flags so that different
140 // encodings are not considered equal.
141 const pm_string_tcxx . . $ pm_string_t# *value = &((const pm_symbol_node_tcxx . . $ pm_symbol_node_t# *) node)->unescapedcxx . . $ pm_symbol_node#unescaped.;
142 return murmur_hashcxx . . $ murmur_hash(13d9c8ea4fc589cf).(pm_string_sourcecxx . . $ pm_string_source(37c9bd456e9b3712).(value), pm_string_lengthcxx . . $ pm_string_length(576a13ceb66f8a15).(value) * sizeof(uint8_tcxx . . $ uint8_t#)) ^ murmur_scramblecxx . . $ murmur_scramble(2141b656ce2cc063).((uint32_tcxx . . $ uint32_t#) node->flagscxx . . $ pm_node#flags.);
143 }
144 default:
145 assertcxx . . $ `/usr/include/assert.h:108:11`!(falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`! && "unreachable");
146 return 0;
147 }
148 }
149
150 /**
151 * Insert a node into the node hash. It accepts the hash that should hold the
152 * new node, the parser that generated the node, the node to insert, and a
153 * comparison function. The comparison function is used for collision detection,
154 * and must be able to compare all node types that will be stored in this hash.
155 */
156 static pm_node_tcxx . . $ pm_node_t# *
157 pm_node_hash_insertcxx . . $ pm_node_hash_insert(9c1d8aa64522c10).(pm_node_hash_tcxx . . $ pm_node_hash_t# *hash, const pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t# *metadata, pm_node_tcxx . . $ pm_node_t# *node, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! replace, int (*compare)(const pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t# *metadata, const pm_node_tcxx . . $ pm_node_t# *left, const pm_node_tcxx . . $ pm_node_t# *right)) {
158 // If we are out of space, we need to resize the hash. This will cause all
159 // of the nodes to be rehashed and reinserted into the new hash.
160 if (hash->sizecxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#size. * 2 >= hash->capacitycxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#capacity.) {
161 // First, allocate space for the new node list.
162 uint32_tcxx . . $ uint32_t# new_capacity = hash->capacitycxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#capacity. == 0 ? 4 : hash->capacitycxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#capacity. * 2;
163 pm_node_tcxx . . $ pm_node_t# **new_nodes = xcalloccxx . . $ `include/prism/defines.h:195:17`!(new_capacity, sizeof(pm_node_tcxx . . $ pm_node_t# *));
164 if (new_nodes == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
165
166 // It turns out to be more efficient to mask the hash value than to use
167 // the modulo operator. Because our capacities are always powers of two,
168 // we can use a bitwise AND to get the same result as the modulo
169 // operator.
170 uint32_tcxx . . $ uint32_t# mask = new_capacity - 1;
171
172 // Now, rehash all of the nodes into the new list.
173 for (uint32_tcxx . . $ uint32_t# index = 0; index < hash->capacitycxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#capacity.; index++) {
174 pm_node_tcxx . . $ pm_node_t# *node = hash->nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#nodes.[index];
175
176 if (node != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
177 uint32_tcxx . . $ uint32_t# index = node_hashcxx . . $ node_hash(e98bb68b461047bc).(metadata, node) & mask;
178 new_nodes[index] = node;
179 }
180 }
181
182 // Finally, free the old node list and update the hash.
183 xfreecxx . . $ `include/prism/defines.h:203:17`!(hash->nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#nodes.);
184 hash->nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#nodes. = new_nodes;
185 hash->capacitycxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#capacity. = new_capacity;
186 }
187
188 // Now, insert the node into the hash.
189 uint32_tcxx . . $ uint32_t# mask = hash->capacitycxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#capacity. - 1;
190 uint32_tcxx . . $ uint32_t# index = node_hashcxx . . $ node_hash(e98bb68b461047bc).(metadata, node) & mask;
191
192 // We use linear probing to resolve collisions. This means that if the
193 // current index is occupied, we will move to the next index and try again.
194 // We are guaranteed that this will eventually find an empty slot because we
195 // resize the hash when it gets too full.
196 while (hash->nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#nodes.[index] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
197 if (compare(metadata, hash->nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#nodes.[index], node) == 0) break;
198 index = (index + 1) & mask;
199 }
200
201 // If the current index is occupied, we need to return the node that was
202 // already in the hash. Otherwise, we can just increment the size and insert
203 // the new node.
204 pm_node_tcxx . . $ pm_node_t# *result = hash->nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#nodes.[index];
205
206 if (result == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
207 hash->sizecxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#size.++;
208 hash->nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#nodes.[index] = node;
209 } else if (replace) {
210 hash->nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#nodes.[index] = node;
211 }
212
213 return result;
214 }
215
216 /**
217 * Free the internal memory associated with the given node hash.
218 */
219 static void
220 pm_node_hash_freecxx . . $ pm_node_hash_free(659c87428fef947b).(pm_node_hash_tcxx . . $ pm_node_hash_t# *hash) {
221 if (hash->capacitycxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#capacity. > 0) xfreecxx . . $ `include/prism/defines.h:203:17`!(hash->nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#nodes.);
222 }
223
224 /**
225 * Compare two values that can be compared with a simple numeric comparison.
226 */
227 #define PM_NUMERIC_COMPARISONcxx . . $ `src/static_literals.c:227:9`!(left, right) ((left < right) ? -1 : (left > right) ? 1 : 0)
228
229 /**
230 * Return the integer value of the given node as an int64_t.
231 */
232 static int64_tcxx . . $ int64_t#
233 pm_int64_valuecxx . . $ pm_int64_value(e6e6db5fdd9efb7c).(const pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t# *metadata, const pm_node_tcxx . . $ pm_node_t# *node) {
234 switch (PM_NODE_TYPEcxx . . $ `include/prism/ast.h:1092:9`!(node)) {
235 case PM_INTEGER_NODEcxx . . $ PM_INTEGER_NODE.: {
236 const pm_integer_tcxx . . $ pm_integer_t# *integer = &((const pm_integer_node_tcxx . . $ pm_integer_node_t# *) node)->valuecxx . . $ pm_integer_node#value.;
237 if (integer->valuescxx . . $ $anonymous_type_65facc28bc11402_0#values.) return integer->negativecxx . . $ $anonymous_type_65facc28bc11402_0#negative. ? INT64_MINcxx . . $ `<external>/3415975807581488833/stdint.h:108:10`! : INT64_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:113:10`!;
238
239 int64_tcxx . . $ int64_t# value = (int64_tcxx . . $ int64_t#) integer->valuecxx . . $ $anonymous_type_65facc28bc11402_0#value.;
240 return integer->negativecxx . . $ $anonymous_type_65facc28bc11402_0#negative. ? -value : value;
241 }
242 case PM_SOURCE_LINE_NODEcxx . . $ PM_SOURCE_LINE_NODE.:
243 return (int64_tcxx . . $ int64_t#) pm_newline_list_line_columncxx . . $ pm_newline_list_line_column(1a8b391d550aa6bd).(metadata->newline_listcxx . . $ $anonymous_type_6c69e7cbeffceec8_0#newline_list., node->locationcxx . . $ pm_node#location..startcxx . . $ $anonymous_type_926221c61b414ea8_1#start., metadata->start_linecxx . . $ $anonymous_type_6c69e7cbeffceec8_0#start_line.).linecxx . . $ $anonymous_type_9901d064858912af_1#line.;
244 default:
245 assertcxx . . $ `/usr/include/assert.h:108:11`!(falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`! && "unreachable");
246 return 0;
247 }
248 }
249
250 /**
251 * A comparison function for comparing two IntegerNode or SourceLineNode
252 * instances.
253 */
254 static int
255 pm_compare_integer_nodescxx . . $ pm_compare_integer_nodes(b1ccf7050308417b).(const pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t# *metadata, const pm_node_tcxx . . $ pm_node_t# *left, const pm_node_tcxx . . $ pm_node_t# *right) {
256 if (PM_NODE_TYPE_Pcxx . . $ `include/prism/ast.h:1097:9`!(left, PM_SOURCE_LINE_NODE) || PM_NODE_TYPE_Pcxx . . $ `include/prism/ast.h:1097:9`!(right, PM_SOURCE_LINE_NODE)) {
257 int64_tcxx . . $ int64_t# left_value = pm_int64_valuecxx . . $ pm_int64_value(e6e6db5fdd9efb7c).(metadata, left);
258 int64_tcxx . . $ int64_t# right_value = pm_int64_valuecxx . . $ pm_int64_value(e6e6db5fdd9efb7c).(metadata, right);
259 return PM_NUMERIC_COMPARISONcxx . . $ `src/static_literals.c:227:9`!(left_value, right_value);
260 }
261
262 const pm_integer_tcxx . . $ pm_integer_t# *left_integer = &((const pm_integer_node_tcxx . . $ pm_integer_node_t# *) left)->valuecxx . . $ pm_integer_node#value.;
263 const pm_integer_tcxx . . $ pm_integer_t# *right_integer = &((const pm_integer_node_tcxx . . $ pm_integer_node_t# *) right)->valuecxx . . $ pm_integer_node#value.;
264 return pm_integer_comparecxx . . $ pm_integer_compare(f66d737860cc2d9).(left_integer, right_integer);
265 }
266
267 /**
268 * A comparison function for comparing two FloatNode instances.
269 */
270 static int
271 pm_compare_float_nodescxx . . $ pm_compare_float_nodes(b1ccf7050308417b).(PRISM_ATTRIBUTE_UNUSEDcxx . . $ `include/prism/defines.h:81:12`! const pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t# *metadata, const pm_node_tcxx . . $ pm_node_t# *left, const pm_node_tcxx . . $ pm_node_t# *right) {
272 const double left_value = ((const pm_float_node_tcxx . . $ pm_float_node_t# *) left)->valuecxx . . $ pm_float_node#value.;
273 const double right_value = ((const pm_float_node_tcxx . . $ pm_float_node_t# *) right)->valuecxx . . $ pm_float_node#value.;
274 return PM_NUMERIC_COMPARISONcxx . . $ `src/static_literals.c:227:9`!(left_value, right_value);
275 }
276
277 /**
278 * A comparison function for comparing two nodes that have attached numbers.
279 */
280 static int
281 pm_compare_number_nodescxx . . $ pm_compare_number_nodes(b1ccf7050308417b).(const pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t# *metadata, const pm_node_tcxx . . $ pm_node_t# *left, const pm_node_tcxx . . $ pm_node_t# *right) {
282 if (PM_NODE_TYPEcxx . . $ `include/prism/ast.h:1092:9`!(left) != PM_NODE_TYPEcxx . . $ `include/prism/ast.h:1092:9`!(right)) {
283 return PM_NUMERIC_COMPARISONcxx . . $ `src/static_literals.c:227:9`!(PM_NODE_TYPEcxx . . $ `include/prism/ast.h:1092:9`!(left), PM_NODE_TYPEcxx . . $ `include/prism/ast.h:1092:9`!(right));
284 }
285
286 switch (PM_NODE_TYPEcxx . . $ `include/prism/ast.h:1092:9`!(left)) {
287 case PM_IMAGINARY_NODEcxx . . $ PM_IMAGINARY_NODE.:
288 return pm_compare_number_nodescxx . . $ pm_compare_number_nodes(b1ccf7050308417b).(metadata, ((const pm_imaginary_node_tcxx . . $ pm_imaginary_node_t# *) left)->numericcxx . . $ pm_imaginary_node#numeric., ((const pm_imaginary_node_tcxx . . $ pm_imaginary_node_t# *) right)->numericcxx . . $ pm_imaginary_node#numeric.);
289 case PM_RATIONAL_NODEcxx . . $ PM_RATIONAL_NODE.: {
290 const pm_rational_node_tcxx . . $ pm_rational_node_t# *left_rational = (const pm_rational_node_tcxx . . $ pm_rational_node_t# *) left;
291 const pm_rational_node_tcxx . . $ pm_rational_node_t# *right_rational = (const pm_rational_node_tcxx . . $ pm_rational_node_t# *) right;
292
293 int result = pm_integer_comparecxx . . $ pm_integer_compare(f66d737860cc2d9).(&left_rational->denominatorcxx . . $ pm_rational_node#denominator., &right_rational->denominatorcxx . . $ pm_rational_node#denominator.);
294 if (result != 0) return result;
295
296 return pm_integer_comparecxx . . $ pm_integer_compare(f66d737860cc2d9).(&left_rational->numeratorcxx . . $ pm_rational_node#numerator., &right_rational->numeratorcxx . . $ pm_rational_node#numerator.);
297 }
298 case PM_INTEGER_NODEcxx . . $ PM_INTEGER_NODE.:
299 return pm_compare_integer_nodescxx . . $ pm_compare_integer_nodes(b1ccf7050308417b).(metadata, left, right);
300 case PM_FLOAT_NODEcxx . . $ PM_FLOAT_NODE.:
301 return pm_compare_float_nodescxx . . $ pm_compare_float_nodes(b1ccf7050308417b).(metadata, left, right);
302 default:
303 assertcxx . . $ `/usr/include/assert.h:108:11`!(falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`! && "unreachable");
304 return 0;
305 }
306 }
307
308 /**
309 * Return a pointer to the string value of the given node.
310 */
311 static const pm_string_tcxx . . $ pm_string_t# *
312 pm_string_valuecxx . . $ pm_string_value(2b2aa889e4207a88).(const pm_node_tcxx . . $ pm_node_t# *node) {
313 switch (PM_NODE_TYPEcxx . . $ `include/prism/ast.h:1092:9`!(node)) {
314 case PM_STRING_NODEcxx . . $ PM_STRING_NODE.:
315 return &((const pm_string_node_tcxx . . $ pm_string_node_t# *) node)->unescapedcxx . . $ pm_string_node#unescaped.;
316 case PM_SOURCE_FILE_NODEcxx . . $ PM_SOURCE_FILE_NODE.:
317 return &((const pm_source_file_node_tcxx . . $ pm_source_file_node_t# *) node)->filepathcxx . . $ pm_source_file_node#filepath.;
318 case PM_SYMBOL_NODEcxx . . $ PM_SYMBOL_NODE.:
319 return &((const pm_symbol_node_tcxx . . $ pm_symbol_node_t# *) node)->unescapedcxx . . $ pm_symbol_node#unescaped.;
320 default:
321 assertcxx . . $ `/usr/include/assert.h:108:11`!(falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`! && "unreachable");
322 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
323 }
324 }
325
326 /**
327 * A comparison function for comparing two nodes that have attached strings.
328 */
329 static int
330 pm_compare_string_nodescxx . . $ pm_compare_string_nodes(b1ccf7050308417b).(PRISM_ATTRIBUTE_UNUSEDcxx . . $ `include/prism/defines.h:81:12`! const pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t# *metadata, const pm_node_tcxx . . $ pm_node_t# *left, const pm_node_tcxx . . $ pm_node_t# *right) {
331 const pm_string_tcxx . . $ pm_string_t# *left_string = pm_string_valuecxx . . $ pm_string_value(2b2aa889e4207a88).(left);
332 const pm_string_tcxx . . $ pm_string_t# *right_string = pm_string_valuecxx . . $ pm_string_value(2b2aa889e4207a88).(right);
333 return pm_string_comparecxx . . $ pm_string_compare(89247a2b4ba54e22).(left_string, right_string);
334 }
335
336 /**
337 * A comparison function for comparing two RegularExpressionNode instances.
338 */
339 static int
340 pm_compare_regular_expression_nodescxx . . $ pm_compare_regular_expression_nodes(b1ccf7050308417b).(PRISM_ATTRIBUTE_UNUSEDcxx . . $ `include/prism/defines.h:81:12`! const pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t# *metadata, const pm_node_tcxx . . $ pm_node_t# *left, const pm_node_tcxx . . $ pm_node_t# *right) {
341 const pm_regular_expression_node_tcxx . . $ pm_regular_expression_node_t# *left_regexp = (const pm_regular_expression_node_tcxx . . $ pm_regular_expression_node_t# *) left;
342 const pm_regular_expression_node_tcxx . . $ pm_regular_expression_node_t# *right_regexp = (const pm_regular_expression_node_tcxx . . $ pm_regular_expression_node_t# *) right;
343
344 int result = pm_string_comparecxx . . $ pm_string_compare(89247a2b4ba54e22).(&left_regexp->unescapedcxx . . $ pm_regular_expression_node#unescaped., &right_regexp->unescapedcxx . . $ pm_regular_expression_node#unescaped.);
345 if (result != 0) return result;
346
347 return PM_NUMERIC_COMPARISONcxx . . $ `src/static_literals.c:227:9`!(left_regexp->base.flags, right_regexp->base.flags);
348 }
349
350 #undef PM_NUMERIC_COMPARISONcxx . . $ `src/static_literals.c:227:9`!
351
352 /**
353 * Add a node to the set of static literals.
354 */
355 pm_node_tcxx . . $ pm_node_t# *
356 pm_static_literals_addcxx . . $ pm_static_literals_add(c50d8e366532777f).(const pm_newline_list_tcxx . . $ pm_newline_list_t# *newline_list, int32_tcxx . . $ int32_t# start_line, pm_static_literals_tcxx . . $ pm_static_literals_t# *literals, pm_node_tcxx . . $ pm_node_t# *node, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! replace) {
357 switch (PM_NODE_TYPEcxx . . $ `include/prism/ast.h:1092:9`!(node)) {
358 case PM_INTEGER_NODEcxx . . $ PM_INTEGER_NODE.:
359 case PM_SOURCE_LINE_NODEcxx . . $ PM_SOURCE_LINE_NODE.:
360 return pm_node_hash_insertcxx . . $ pm_node_hash_insert(9c1d8aa64522c10).(
361 &literals->integer_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#integer_nodes.,
362 &(pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t#) {
363 .newline_list = newline_list,
364 .start_line = start_line,
365 .encoding_name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!
366 },
367 node,
368 replace,
369 pm_compare_integer_nodescxx . . $ pm_compare_integer_nodes(b1ccf7050308417b).
370 );
371 case PM_FLOAT_NODEcxx . . $ PM_FLOAT_NODE.:
372 return pm_node_hash_insertcxx . . $ pm_node_hash_insert(9c1d8aa64522c10).(
373 &literals->float_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#float_nodes.,
374 &(pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t#) {
375 .newline_list = newline_list,
376 .start_line = start_line,
377 .encoding_name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!
378 },
379 node,
380 replace,
381 pm_compare_float_nodescxx . . $ pm_compare_float_nodes(b1ccf7050308417b).
382 );
383 case PM_RATIONAL_NODEcxx . . $ PM_RATIONAL_NODE.:
384 case PM_IMAGINARY_NODEcxx . . $ PM_IMAGINARY_NODE.:
385 return pm_node_hash_insertcxx . . $ pm_node_hash_insert(9c1d8aa64522c10).(
386 &literals->number_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#number_nodes.,
387 &(pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t#) {
388 .newline_list = newline_list,
389 .start_line = start_line,
390 .encoding_name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!
391 },
392 node,
393 replace,
394 pm_compare_number_nodescxx . . $ pm_compare_number_nodes(b1ccf7050308417b).
395 );
396 case PM_STRING_NODEcxx . . $ PM_STRING_NODE.:
397 case PM_SOURCE_FILE_NODEcxx . . $ PM_SOURCE_FILE_NODE.:
398 return pm_node_hash_insertcxx . . $ pm_node_hash_insert(9c1d8aa64522c10).(
399 &literals->string_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#string_nodes.,
400 &(pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t#) {
401 .newline_list = newline_list,
402 .start_line = start_line,
403 .encoding_name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!
404 },
405 node,
406 replace,
407 pm_compare_string_nodescxx . . $ pm_compare_string_nodes(b1ccf7050308417b).
408 );
409 case PM_REGULAR_EXPRESSION_NODEcxx . . $ PM_REGULAR_EXPRESSION_NODE.:
410 return pm_node_hash_insertcxx . . $ pm_node_hash_insert(9c1d8aa64522c10).(
411 &literals->regexp_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#regexp_nodes.,
412 &(pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t#) {
413 .newline_list = newline_list,
414 .start_line = start_line,
415 .encoding_name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!
416 },
417 node,
418 replace,
419 pm_compare_regular_expression_nodescxx . . $ pm_compare_regular_expression_nodes(b1ccf7050308417b).
420 );
421 case PM_SYMBOL_NODEcxx . . $ PM_SYMBOL_NODE.:
422 return pm_node_hash_insertcxx . . $ pm_node_hash_insert(9c1d8aa64522c10).(
423 &literals->symbol_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#symbol_nodes.,
424 &(pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t#) {
425 .newline_list = newline_list,
426 .start_line = start_line,
427 .encoding_name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!
428 },
429 node,
430 replace,
431 pm_compare_string_nodescxx . . $ pm_compare_string_nodes(b1ccf7050308417b).
432 );
433 case PM_TRUE_NODEcxx . . $ PM_TRUE_NODE.: {
434 pm_node_tcxx . . $ pm_node_t# *duplicated = literals->true_nodecxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#true_node.;
435 if ((duplicated == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || replace) literals->true_nodecxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#true_node. = node;
436 return duplicated;
437 }
438 case PM_FALSE_NODEcxx . . $ PM_FALSE_NODE.: {
439 pm_node_tcxx . . $ pm_node_t# *duplicated = literals->false_nodecxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#false_node.;
440 if ((duplicated == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || replace) literals->false_nodecxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#false_node. = node;
441 return duplicated;
442 }
443 case PM_NIL_NODEcxx . . $ PM_NIL_NODE.: {
444 pm_node_tcxx . . $ pm_node_t# *duplicated = literals->nil_nodecxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#nil_node.;
445 if ((duplicated == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || replace) literals->nil_nodecxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#nil_node. = node;
446 return duplicated;
447 }
448 case PM_SOURCE_ENCODING_NODEcxx . . $ PM_SOURCE_ENCODING_NODE.: {
449 pm_node_tcxx . . $ pm_node_t# *duplicated = literals->source_encoding_nodecxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#source_encoding_node.;
450 if ((duplicated == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || replace) literals->source_encoding_nodecxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#source_encoding_node. = node;
451 return duplicated;
452 }
453 default:
454 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
455 }
456 }
457
458 /**
459 * Free the internal memory associated with the given static literals set.
460 */
461 void
462 pm_static_literals_freecxx . . $ pm_static_literals_free(f2065820d8222ecd).(pm_static_literals_tcxx . . $ pm_static_literals_t# *literals) {
463 pm_node_hash_freecxx . . $ pm_node_hash_free(659c87428fef947b).(&literals->integer_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#integer_nodes.);
464 pm_node_hash_freecxx . . $ pm_node_hash_free(659c87428fef947b).(&literals->float_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#float_nodes.);
465 pm_node_hash_freecxx . . $ pm_node_hash_free(659c87428fef947b).(&literals->number_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#number_nodes.);
466 pm_node_hash_freecxx . . $ pm_node_hash_free(659c87428fef947b).(&literals->string_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#string_nodes.);
467 pm_node_hash_freecxx . . $ pm_node_hash_free(659c87428fef947b).(&literals->regexp_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#regexp_nodes.);
468 pm_node_hash_freecxx . . $ pm_node_hash_free(659c87428fef947b).(&literals->symbol_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#symbol_nodes.);
469 }
470
471 /**
472 * A helper to determine if the given node is a static literal that is positive.
473 * This is used for formatting imaginary nodes.
474 */
475 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`!
476 pm_static_literal_positive_pcxx . . $ pm_static_literal_positive_p(ac338b78e985bea8).(const pm_node_tcxx . . $ pm_node_t# *node) {
477 switch (PM_NODE_TYPEcxx . . $ `include/prism/ast.h:1092:9`!(node)) {
478 case PM_FLOAT_NODEcxx . . $ PM_FLOAT_NODE.:
479 return ((const pm_float_node_tcxx . . $ pm_float_node_t# *) node)->valuecxx . . $ pm_float_node#value. > 0;
480 case PM_INTEGER_NODEcxx . . $ PM_INTEGER_NODE.:
481 return !((const pm_integer_node_tcxx . . $ pm_integer_node_t# *) node)->valuecxx . . $ pm_integer_node#value..negativecxx . . $ $anonymous_type_65facc28bc11402_0#negative.;
482 case PM_RATIONAL_NODEcxx . . $ PM_RATIONAL_NODE.:
483 return !((const pm_rational_node_tcxx . . $ pm_rational_node_t# *) node)->numeratorcxx . . $ pm_rational_node#numerator..negativecxx . . $ $anonymous_type_65facc28bc11402_0#negative.;
484 case PM_IMAGINARY_NODEcxx . . $ PM_IMAGINARY_NODE.:
485 return pm_static_literal_positive_pcxx . . $ pm_static_literal_positive_p(ac338b78e985bea8).(((const pm_imaginary_node_tcxx . . $ pm_imaginary_node_t# *) node)->numericcxx . . $ pm_imaginary_node#numeric.);
486 default:
487 assertcxx . . $ `/usr/include/assert.h:108:11`!(falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`! && "unreachable");
488 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
489 }
490 }
491
492 /**
493 * Create a string-based representation of the given static literal.
494 */
495 static inline void
496 pm_static_literal_inspect_nodecxx . . $ pm_static_literal_inspect_node(be3e6fbeb43eb554).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer, const pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t# *metadata, const pm_node_tcxx . . $ pm_node_t# *node) {
497 switch (PM_NODE_TYPEcxx . . $ `include/prism/ast.h:1092:9`!(node)) {
498 case PM_FALSE_NODEcxx . . $ PM_FALSE_NODE.:
499 pm_buffer_append_stringcxx . . $ pm_buffer_append_string(c8459e7237ed13a2).(buffer, "false", 5);
500 break;
501 case PM_FLOAT_NODEcxx . . $ PM_FLOAT_NODE.: {
502 const double value = ((const pm_float_node_tcxx . . $ pm_float_node_t# *) node)->valuecxx . . $ pm_float_node#value.;
503
504 if (PRISM_ISINFcxx . . $ `include/prism/defines.h:151:13`!(value)) {
505 if (*node->locationcxx . . $ pm_node#location..startcxx . . $ $anonymous_type_926221c61b414ea8_1#start. == '-') {
506 pm_buffer_append_bytecxx . . $ pm_buffer_append_byte(55d7ca91f770de1b).(buffer, '-');
507 }
508 pm_buffer_append_stringcxx . . $ pm_buffer_append_string(c8459e7237ed13a2).(buffer, "Infinity", 8);
509 } else if (value == 0.0) {
510 if (*node->locationcxx . . $ pm_node#location..startcxx . . $ $anonymous_type_926221c61b414ea8_1#start. == '-') {
511 pm_buffer_append_bytecxx . . $ pm_buffer_append_byte(55d7ca91f770de1b).(buffer, '-');
512 }
513 pm_buffer_append_stringcxx . . $ pm_buffer_append_string(c8459e7237ed13a2).(buffer, "0.0", 3);
514 } else {
515 pm_buffer_append_formatcxx . . $ pm_buffer_append_format(35b6008a4dc68e20).(buffer, "%g", value);
516
517 // %g will not insert a .0 for 1e100 (we'll get back 1e+100). So
518 // we check for the decimal point and add it in here if it's not
519 // present.
520 if (pm_buffer_indexcxx . . $ pm_buffer_index(44ef8fde7718cd5e).(buffer, '.') == SIZE_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:216:11`!) {
521 size_t exponent_index = pm_buffer_indexcxx . . $ pm_buffer_index(44ef8fde7718cd5e).(buffer, 'e');
522 size_t index = exponent_index == SIZE_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:216:11`! ? pm_buffer_lengthcxx . . $ pm_buffer_length(ca208804fbc970c8).(buffer) : exponent_index;
523 pm_buffer_insertcxx . . $ pm_buffer_insert(5ca98b04945ec8ca).(buffer, index, ".0", 2);
524 }
525 }
526
527 break;
528 }
529 case PM_IMAGINARY_NODEcxx . . $ PM_IMAGINARY_NODE.: {
530 const pm_node_tcxx . . $ pm_node_t# *numeric = ((const pm_imaginary_node_tcxx . . $ pm_imaginary_node_t# *) node)->numericcxx . . $ pm_imaginary_node#numeric.;
531 pm_buffer_append_stringcxx . . $ pm_buffer_append_string(c8459e7237ed13a2).(buffer, "(0", 2);
532 if (pm_static_literal_positive_pcxx . . $ pm_static_literal_positive_p(ac338b78e985bea8).(numeric)) pm_buffer_append_bytecxx . . $ pm_buffer_append_byte(55d7ca91f770de1b).(buffer, '+');
533 pm_static_literal_inspect_nodecxx . . $ pm_static_literal_inspect_node(be3e6fbeb43eb554).(buffer, metadata, numeric);
534 if (PM_NODE_TYPE_Pcxx . . $ `include/prism/ast.h:1097:9`!(numeric, PM_RATIONAL_NODE)) {
535 pm_buffer_append_bytecxx . . $ pm_buffer_append_byte(55d7ca91f770de1b).(buffer, '*');
536 }
537 pm_buffer_append_stringcxx . . $ pm_buffer_append_string(c8459e7237ed13a2).(buffer, "i)", 2);
538 break;
539 }
540 case PM_INTEGER_NODEcxx . . $ PM_INTEGER_NODE.:
541 pm_integer_stringcxx . . $ pm_integer_string(2dcf3f917786a674).(buffer, &((const pm_integer_node_tcxx . . $ pm_integer_node_t# *) node)->valuecxx . . $ pm_integer_node#value.);
542 break;
543 case PM_NIL_NODEcxx . . $ PM_NIL_NODE.:
544 pm_buffer_append_stringcxx . . $ pm_buffer_append_string(c8459e7237ed13a2).(buffer, "nil", 3);
545 break;
546 case PM_RATIONAL_NODEcxx . . $ PM_RATIONAL_NODE.: {
547 const pm_rational_node_tcxx . . $ pm_rational_node_t# *rational = (const pm_rational_node_tcxx . . $ pm_rational_node_t# *) node;
548 pm_buffer_append_bytecxx . . $ pm_buffer_append_byte(55d7ca91f770de1b).(buffer, '(');
549 pm_integer_stringcxx . . $ pm_integer_string(2dcf3f917786a674).(buffer, &rational->numeratorcxx . . $ pm_rational_node#numerator.);
550 pm_buffer_append_bytecxx . . $ pm_buffer_append_byte(55d7ca91f770de1b).(buffer, '/');
551 pm_integer_stringcxx . . $ pm_integer_string(2dcf3f917786a674).(buffer, &rational->denominatorcxx . . $ pm_rational_node#denominator.);
552 pm_buffer_append_bytecxx . . $ pm_buffer_append_byte(55d7ca91f770de1b).(buffer, ')');
553 break;
554 }
555 case PM_REGULAR_EXPRESSION_NODEcxx . . $ PM_REGULAR_EXPRESSION_NODE.: {
556 const pm_string_tcxx . . $ pm_string_t# *unescaped = &((const pm_regular_expression_node_tcxx . . $ pm_regular_expression_node_t# *) node)->unescapedcxx . . $ pm_regular_expression_node#unescaped.;
557 pm_buffer_append_bytecxx . . $ pm_buffer_append_byte(55d7ca91f770de1b).(buffer, '/');
558 pm_buffer_append_sourcecxx . . $ pm_buffer_append_source(8150e178a152d1cc).(buffer, pm_string_sourcecxx . . $ pm_string_source(37c9bd456e9b3712).(unescaped), pm_string_lengthcxx . . $ pm_string_length(576a13ceb66f8a15).(unescaped), PM_BUFFER_ESCAPING_RUBYcxx . . $ PM_BUFFER_ESCAPING_RUBY.);
559 pm_buffer_append_bytecxx . . $ pm_buffer_append_byte(55d7ca91f770de1b).(buffer, '/');
560
561 if (PM_NODE_FLAG_Pcxx . . $ `include/prism/ast.h:1107:9`!(node, PM_REGULAR_EXPRESSION_FLAGS_MULTI_LINE)) pm_buffer_append_stringcxx . . $ pm_buffer_append_string(c8459e7237ed13a2).(buffer, "m", 1);
562 if (PM_NODE_FLAG_Pcxx . . $ `include/prism/ast.h:1107:9`!(node, PM_REGULAR_EXPRESSION_FLAGS_IGNORE_CASE)) pm_buffer_append_stringcxx . . $ pm_buffer_append_string(c8459e7237ed13a2).(buffer, "i", 1);
563 if (PM_NODE_FLAG_Pcxx . . $ `include/prism/ast.h:1107:9`!(node, PM_REGULAR_EXPRESSION_FLAGS_EXTENDED)) pm_buffer_append_stringcxx . . $ pm_buffer_append_string(c8459e7237ed13a2).(buffer, "x", 1);
564 if (PM_NODE_FLAG_Pcxx . . $ `include/prism/ast.h:1107:9`!(node, PM_REGULAR_EXPRESSION_FLAGS_ASCII_8BIT)) pm_buffer_append_stringcxx . . $ pm_buffer_append_string(c8459e7237ed13a2).(buffer, "n", 1);
565
566 break;
567 }
568 case PM_SOURCE_ENCODING_NODEcxx . . $ PM_SOURCE_ENCODING_NODE.:
569 pm_buffer_append_formatcxx . . $ pm_buffer_append_format(35b6008a4dc68e20).(buffer, "#<Encoding:%s>", metadata->encoding_namecxx . . $ $anonymous_type_6c69e7cbeffceec8_0#encoding_name.);
570 break;
571 case PM_SOURCE_FILE_NODEcxx . . $ PM_SOURCE_FILE_NODE.: {
572 const pm_string_tcxx . . $ pm_string_t# *filepath = &((const pm_source_file_node_tcxx . . $ pm_source_file_node_t# *) node)->filepathcxx . . $ pm_source_file_node#filepath.;
573 pm_buffer_append_bytecxx . . $ pm_buffer_append_byte(55d7ca91f770de1b).(buffer, '"');
574 pm_buffer_append_sourcecxx . . $ pm_buffer_append_source(8150e178a152d1cc).(buffer, pm_string_sourcecxx . . $ pm_string_source(37c9bd456e9b3712).(filepath), pm_string_lengthcxx . . $ pm_string_length(576a13ceb66f8a15).(filepath), PM_BUFFER_ESCAPING_RUBYcxx . . $ PM_BUFFER_ESCAPING_RUBY.);
575 pm_buffer_append_bytecxx . . $ pm_buffer_append_byte(55d7ca91f770de1b).(buffer, '"');
576 break;
577 }
578 case PM_SOURCE_LINE_NODEcxx . . $ PM_SOURCE_LINE_NODE.:
579 pm_buffer_append_formatcxx . . $ pm_buffer_append_format(35b6008a4dc68e20).(buffer, "%d", pm_newline_list_line_columncxx . . $ pm_newline_list_line_column(1a8b391d550aa6bd).(metadata->newline_listcxx . . $ $anonymous_type_6c69e7cbeffceec8_0#newline_list., node->locationcxx . . $ pm_node#location..startcxx . . $ $anonymous_type_926221c61b414ea8_1#start., metadata->start_linecxx . . $ $anonymous_type_6c69e7cbeffceec8_0#start_line.).linecxx . . $ $anonymous_type_9901d064858912af_1#line.);
580 break;
581 case PM_STRING_NODEcxx . . $ PM_STRING_NODE.: {
582 const pm_string_tcxx . . $ pm_string_t# *unescaped = &((const pm_string_node_tcxx . . $ pm_string_node_t# *) node)->unescapedcxx . . $ pm_string_node#unescaped.;
583 pm_buffer_append_bytecxx . . $ pm_buffer_append_byte(55d7ca91f770de1b).(buffer, '"');
584 pm_buffer_append_sourcecxx . . $ pm_buffer_append_source(8150e178a152d1cc).(buffer, pm_string_sourcecxx . . $ pm_string_source(37c9bd456e9b3712).(unescaped), pm_string_lengthcxx . . $ pm_string_length(576a13ceb66f8a15).(unescaped), PM_BUFFER_ESCAPING_RUBYcxx . . $ PM_BUFFER_ESCAPING_RUBY.);
585 pm_buffer_append_bytecxx . . $ pm_buffer_append_byte(55d7ca91f770de1b).(buffer, '"');
586 break;
587 }
588 case PM_SYMBOL_NODEcxx . . $ PM_SYMBOL_NODE.: {
589 const pm_string_tcxx . . $ pm_string_t# *unescaped = &((const pm_symbol_node_tcxx . . $ pm_symbol_node_t# *) node)->unescapedcxx . . $ pm_symbol_node#unescaped.;
590 pm_buffer_append_bytecxx . . $ pm_buffer_append_byte(55d7ca91f770de1b).(buffer, ':');
591 pm_buffer_append_sourcecxx . . $ pm_buffer_append_source(8150e178a152d1cc).(buffer, pm_string_sourcecxx . . $ pm_string_source(37c9bd456e9b3712).(unescaped), pm_string_lengthcxx . . $ pm_string_length(576a13ceb66f8a15).(unescaped), PM_BUFFER_ESCAPING_RUBYcxx . . $ PM_BUFFER_ESCAPING_RUBY.);
592 break;
593 }
594 case PM_TRUE_NODEcxx . . $ PM_TRUE_NODE.:
595 pm_buffer_append_stringcxx . . $ pm_buffer_append_string(c8459e7237ed13a2).(buffer, "true", 4);
596 break;
597 default:
598 assertcxx . . $ `/usr/include/assert.h:108:11`!(falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`! && "unreachable");
599 break;
600 }
601 }
602
603 /**
604 * Create a string-based representation of the given static literal.
605 */
606 void
607 pm_static_literal_inspectcxx . . $ pm_static_literal_inspect(e469797467607aef).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer, const pm_newline_list_tcxx . . $ pm_newline_list_t# *newline_list, int32_tcxx . . $ int32_t# start_line, const char *encoding_name, const pm_node_tcxx . . $ pm_node_t# *node) {
608 pm_static_literal_inspect_nodecxx . . $ pm_static_literal_inspect_node(be3e6fbeb43eb554).(
609 buffer,
610 &(pm_static_literals_metadata_tcxx . . $ pm_static_literals_metadata_t#) {
611 .newline_list = newline_list,
612 .start_line = start_line,
613 .encoding_name = encoding_name
614 },
615 node
616 );
617 }