Ruby 4.1.0dev (2026-04-04 revision 3b6245536cf55da9e8bfcdb03c845fe9ef931d7f)
static_literals.c
1#include "prism/internal/static_literals.h"
2
5
6#include "prism/internal/allocator.h"
7#include "prism/internal/buffer.h"
8#include "prism/internal/integer.h"
9#include "prism/internal/isinf.h"
10#include "prism/internal/stringy.h"
11
12#include <assert.h>
13#include <math.h>
14#include <stdlib.h>
15#include <string.h>
16
22typedef struct {
25
27 const uint8_t *start;
28
30 int32_t start_line;
31
33 const char *encoding_name;
35
36static PRISM_INLINE uint32_t
37murmur_scramble(uint32_t value) {
38 value *= 0xcc9e2d51;
39 value = (value << 15) | (value >> 17);
40 value *= 0x1b873593;
41 return value;
42}
43
49static uint32_t
50murmur_hash(const uint8_t *key, size_t length) {
51 uint32_t hash = 0x9747b28c;
52 uint32_t segment;
53
54 for (size_t index = length >> 2; index; index--) {
55 memcpy(&segment, key, sizeof(uint32_t));
56 key += sizeof(uint32_t);
57 hash ^= murmur_scramble(segment);
58 hash = (hash << 13) | (hash >> 19);
59 hash = hash * 5 + 0xe6546b64;
60 }
61
62 segment = 0;
63 for (size_t index = length & 3; index; index--) {
64 segment <<= 8;
65 segment |= key[index - 1];
66 }
67
68 hash ^= murmur_scramble(segment);
69 hash ^= (uint32_t) length;
70 hash ^= hash >> 16;
71 hash *= 0x85ebca6b;
72 hash ^= hash >> 13;
73 hash *= 0xc2b2ae35;
74 hash ^= hash >> 16;
75 return hash;
76}
77
81static uint32_t
82integer_hash(const pm_integer_t *integer) {
83 uint32_t hash;
84 if (integer->values) {
85 hash = murmur_hash((const uint8_t *) integer->values, sizeof(uint32_t) * integer->length);
86 } else {
87 hash = murmur_hash((const uint8_t *) &integer->value, sizeof(uint32_t));
88 }
89
90 if (integer->negative) {
91 hash ^= murmur_scramble((uint32_t) 1);
92 }
93
94 return hash;
95}
96
102static uint32_t
103node_hash(const pm_static_literals_metadata_t *metadata, const pm_node_t *node) {
104 switch (PM_NODE_TYPE(node)) {
105 case PM_INTEGER_NODE: {
106 // Integers hash their value.
107 const pm_integer_node_t *cast = (const pm_integer_node_t *) node;
108 return integer_hash(&cast->value);
109 }
110 case PM_SOURCE_LINE_NODE: {
111 // Source lines hash their line number.
112 const pm_line_column_t line_column = pm_line_offset_list_line_column(metadata->line_offsets, node->location.start, metadata->start_line);
113 const int32_t *value = &line_column.line;
114 return murmur_hash((const uint8_t *) value, sizeof(int32_t));
115 }
116 case PM_FLOAT_NODE: {
117 // Floats hash their value.
118 const double *value = &((const pm_float_node_t *) node)->value;
119 return murmur_hash((const uint8_t *) value, sizeof(double));
120 }
121 case PM_RATIONAL_NODE: {
122 // Rationals hash their numerator and denominator.
123 const pm_rational_node_t *cast = (const pm_rational_node_t *) node;
124 return integer_hash(&cast->numerator) ^ integer_hash(&cast->denominator) ^ murmur_scramble((uint32_t) cast->base.type);
125 }
126 case PM_IMAGINARY_NODE: {
127 // Imaginaries hash their numeric value. Because their numeric value
128 // is stored as a subnode, we hash that node and then mix in the
129 // fact that this is an imaginary node.
130 const pm_node_t *numeric = ((const pm_imaginary_node_t *) node)->numeric;
131 return node_hash(metadata, numeric) ^ murmur_scramble((uint32_t) node->type);
132 }
133 case PM_STRING_NODE: {
134 // Strings hash their value and mix in their flags so that different
135 // encodings are not considered equal.
136 const pm_string_t *value = &((const pm_string_node_t *) node)->unescaped;
137
138 pm_node_flags_t flags = node->flags;
139 flags &= (PM_STRING_FLAGS_FORCED_BINARY_ENCODING | PM_STRING_FLAGS_FORCED_UTF8_ENCODING);
140
141 return murmur_hash(pm_string_source(value), pm_string_length(value) * sizeof(uint8_t)) ^ murmur_scramble((uint32_t) flags);
142 }
143 case PM_SOURCE_FILE_NODE: {
144 // Source files hash their value and mix in their flags so that
145 // different encodings are not considered equal.
146 const pm_string_t *value = &((const pm_source_file_node_t *) node)->filepath;
147 return murmur_hash(pm_string_source(value), pm_string_length(value) * sizeof(uint8_t));
148 }
149 case PM_REGULAR_EXPRESSION_NODE: {
150 // Regular expressions hash their value and mix in their flags so
151 // that different encodings are not considered equal.
152 const pm_string_t *value = &((const pm_regular_expression_node_t *) node)->unescaped;
153 return murmur_hash(pm_string_source(value), pm_string_length(value) * sizeof(uint8_t)) ^ murmur_scramble((uint32_t) node->flags);
154 }
155 case PM_SYMBOL_NODE: {
156 // Symbols hash their value and mix in their flags so that different
157 // encodings are not considered equal.
158 const pm_string_t *value = &((const pm_symbol_node_t *) node)->unescaped;
159 return murmur_hash(pm_string_source(value), pm_string_length(value) * sizeof(uint8_t)) ^ murmur_scramble((uint32_t) node->flags);
160 }
161 default:
162 assert(false && "unreachable");
163 return 0;
164 }
165}
166
173static pm_node_t *
174pm_node_hash_insert(pm_node_hash_t *hash, const pm_static_literals_metadata_t *metadata, pm_node_t *node, bool replace, int (*compare)(const pm_static_literals_metadata_t *metadata, const pm_node_t *left, const pm_node_t *right)) {
175 // If we are out of space, we need to resize the hash. This will cause all
176 // of the nodes to be rehashed and reinserted into the new hash.
177 if (hash->size * 2 >= hash->capacity) {
178 // First, allocate space for the new node list.
179 uint32_t new_capacity = hash->capacity == 0 ? 4 : hash->capacity * 2;
180 pm_node_t **new_nodes = xcalloc(new_capacity, sizeof(pm_node_t *));
181 if (new_nodes == NULL) return NULL;
182
183 // It turns out to be more efficient to mask the hash value than to use
184 // the modulo operator. Because our capacities are always powers of two,
185 // we can use a bitwise AND to get the same result as the modulo
186 // operator.
187 uint32_t mask = new_capacity - 1;
188
189 // Now, rehash all of the nodes into the new list.
190 for (uint32_t index = 0; index < hash->capacity; index++) {
191 pm_node_t *node = hash->nodes[index];
192
193 if (node != NULL) {
194 uint32_t index = node_hash(metadata, node) & mask;
195 new_nodes[index] = node;
196 }
197 }
198
199 // Finally, free the old node list and update the hash.
200 xfree_sized(hash->nodes, hash->capacity * sizeof(pm_node_t *));
201 hash->nodes = new_nodes;
202 hash->capacity = new_capacity;
203 }
204
205 // Now, insert the node into the hash.
206 uint32_t mask = hash->capacity - 1;
207 uint32_t index = node_hash(metadata, node) & mask;
208
209 // We use linear probing to resolve collisions. This means that if the
210 // current index is occupied, we will move to the next index and try again.
211 // We are guaranteed that this will eventually find an empty slot because we
212 // resize the hash when it gets too full.
213 while (hash->nodes[index] != NULL) {
214 if (compare(metadata, hash->nodes[index], node) == 0) break;
215 index = (index + 1) & mask;
216 }
217
218 // If the current index is occupied, we need to return the node that was
219 // already in the hash. Otherwise, we can just increment the size and insert
220 // the new node.
221 pm_node_t *result = hash->nodes[index];
222
223 if (result == NULL) {
224 hash->size++;
225 hash->nodes[index] = node;
226 } else if (replace) {
227 hash->nodes[index] = node;
228 }
229
230 return result;
231}
232
236static void
237pm_node_hash_free(pm_node_hash_t *hash) {
238 if (hash->capacity > 0) xfree_sized(hash->nodes, hash->capacity * sizeof(pm_node_t *));
239}
240
244#define PM_NUMERIC_COMPARISON(left, right) ((left < right) ? -1 : (left > right) ? 1 : 0)
245
249static int64_t
250pm_int64_value(const pm_static_literals_metadata_t *metadata, const pm_node_t *node) {
251 switch (PM_NODE_TYPE(node)) {
252 case PM_INTEGER_NODE: {
253 const pm_integer_t *integer = &((const pm_integer_node_t *) node)->value;
254 if (integer->values) return integer->negative ? INT64_MIN : INT64_MAX;
255
256 int64_t value = (int64_t) integer->value;
257 return integer->negative ? -value : value;
258 }
259 case PM_SOURCE_LINE_NODE:
260 return (int64_t) pm_line_offset_list_line_column(metadata->line_offsets, node->location.start, metadata->start_line).line;
261 default:
262 assert(false && "unreachable");
263 return 0;
264 }
265}
266
271static int
272pm_compare_integer_nodes(const pm_static_literals_metadata_t *metadata, const pm_node_t *left, const pm_node_t *right) {
273 if (PM_NODE_TYPE_P(left, PM_SOURCE_LINE_NODE) || PM_NODE_TYPE_P(right, PM_SOURCE_LINE_NODE)) {
274 int64_t left_value = pm_int64_value(metadata, left);
275 int64_t right_value = pm_int64_value(metadata, right);
276 return PM_NUMERIC_COMPARISON(left_value, right_value);
277 }
278
279 const pm_integer_t *left_integer = &((const pm_integer_node_t *) left)->value;
280 const pm_integer_t *right_integer = &((const pm_integer_node_t *) right)->value;
281 return pm_integer_compare(left_integer, right_integer);
282}
283
287static int
288pm_compare_float_nodes(PRISM_UNUSED const pm_static_literals_metadata_t *metadata, const pm_node_t *left, const pm_node_t *right) {
289 const double left_value = ((const pm_float_node_t *) left)->value;
290 const double right_value = ((const pm_float_node_t *) right)->value;
291 return PM_NUMERIC_COMPARISON(left_value, right_value);
292}
293
297static int
298pm_compare_number_nodes(const pm_static_literals_metadata_t *metadata, const pm_node_t *left, const pm_node_t *right) {
299 if (PM_NODE_TYPE(left) != PM_NODE_TYPE(right)) {
300 return PM_NUMERIC_COMPARISON(PM_NODE_TYPE(left), PM_NODE_TYPE(right));
301 }
302
303 switch (PM_NODE_TYPE(left)) {
304 case PM_IMAGINARY_NODE:
305 return pm_compare_number_nodes(metadata, ((const pm_imaginary_node_t *) left)->numeric, ((const pm_imaginary_node_t *) right)->numeric);
306 case PM_RATIONAL_NODE: {
307 const pm_rational_node_t *left_rational = (const pm_rational_node_t *) left;
308 const pm_rational_node_t *right_rational = (const pm_rational_node_t *) right;
309
310 int result = pm_integer_compare(&left_rational->denominator, &right_rational->denominator);
311 if (result != 0) return result;
312
313 return pm_integer_compare(&left_rational->numerator, &right_rational->numerator);
314 }
315 case PM_INTEGER_NODE:
316 return pm_compare_integer_nodes(metadata, left, right);
317 case PM_FLOAT_NODE:
318 return pm_compare_float_nodes(metadata, left, right);
319 default:
320 assert(false && "unreachable");
321 return 0;
322 }
323}
324
328static const pm_string_t *
329pm_string_value(const pm_node_t *node) {
330 switch (PM_NODE_TYPE(node)) {
331 case PM_STRING_NODE:
332 return &((const pm_string_node_t *) node)->unescaped;
333 case PM_SOURCE_FILE_NODE:
334 return &((const pm_source_file_node_t *) node)->filepath;
335 case PM_SYMBOL_NODE:
336 return &((const pm_symbol_node_t *) node)->unescaped;
337 default:
338 assert(false && "unreachable");
339 return NULL;
340 }
341}
342
346static int
347pm_compare_string_nodes(PRISM_UNUSED const pm_static_literals_metadata_t *metadata, const pm_node_t *left, const pm_node_t *right) {
348 const pm_string_t *left_string = pm_string_value(left);
349 const pm_string_t *right_string = pm_string_value(right);
350 return pm_string_compare(left_string, right_string);
351}
352
356static int
357pm_compare_regular_expression_nodes(PRISM_UNUSED const pm_static_literals_metadata_t *metadata, const pm_node_t *left, const pm_node_t *right) {
358 const pm_regular_expression_node_t *left_regexp = (const pm_regular_expression_node_t *) left;
359 const pm_regular_expression_node_t *right_regexp = (const pm_regular_expression_node_t *) right;
360
361 int result = pm_string_compare(&left_regexp->unescaped, &right_regexp->unescaped);
362 if (result != 0) return result;
363
364 return PM_NUMERIC_COMPARISON(left_regexp->base.flags, right_regexp->base.flags);
365}
366
367#undef PM_NUMERIC_COMPARISON
368
372pm_node_t *
373pm_static_literals_add(const pm_line_offset_list_t *line_offsets, const uint8_t *start, int32_t start_line, pm_static_literals_t *literals, pm_node_t *node, bool replace) {
374 switch (PM_NODE_TYPE(node)) {
375 case PM_INTEGER_NODE:
376 case PM_SOURCE_LINE_NODE:
377 return pm_node_hash_insert(
378 &literals->integer_nodes,
380 .line_offsets = line_offsets,
381 .start = start,
382 .start_line = start_line,
383 .encoding_name = NULL
384 },
385 node,
386 replace,
387 pm_compare_integer_nodes
388 );
389 case PM_FLOAT_NODE:
390 return pm_node_hash_insert(
391 &literals->float_nodes,
393 .line_offsets = line_offsets,
394 .start = start,
395 .start_line = start_line,
396 .encoding_name = NULL
397 },
398 node,
399 replace,
400 pm_compare_float_nodes
401 );
402 case PM_RATIONAL_NODE:
403 case PM_IMAGINARY_NODE:
404 return pm_node_hash_insert(
405 &literals->number_nodes,
407 .line_offsets = line_offsets,
408 .start = start,
409 .start_line = start_line,
410 .encoding_name = NULL
411 },
412 node,
413 replace,
414 pm_compare_number_nodes
415 );
416 case PM_STRING_NODE:
417 case PM_SOURCE_FILE_NODE:
418 return pm_node_hash_insert(
419 &literals->string_nodes,
421 .line_offsets = line_offsets,
422 .start = start,
423 .start_line = start_line,
424 .encoding_name = NULL
425 },
426 node,
427 replace,
428 pm_compare_string_nodes
429 );
430 case PM_REGULAR_EXPRESSION_NODE:
431 return pm_node_hash_insert(
432 &literals->regexp_nodes,
434 .line_offsets = line_offsets,
435 .start = start,
436 .start_line = start_line,
437 .encoding_name = NULL
438 },
439 node,
440 replace,
441 pm_compare_regular_expression_nodes
442 );
443 case PM_SYMBOL_NODE:
444 return pm_node_hash_insert(
445 &literals->symbol_nodes,
447 .line_offsets = line_offsets,
448 .start = start,
449 .start_line = start_line,
450 .encoding_name = NULL
451 },
452 node,
453 replace,
454 pm_compare_string_nodes
455 );
456 case PM_TRUE_NODE: {
457 pm_node_t *duplicated = literals->true_node;
458 if ((duplicated == NULL) || replace) literals->true_node = node;
459 return duplicated;
460 }
461 case PM_FALSE_NODE: {
462 pm_node_t *duplicated = literals->false_node;
463 if ((duplicated == NULL) || replace) literals->false_node = node;
464 return duplicated;
465 }
466 case PM_NIL_NODE: {
467 pm_node_t *duplicated = literals->nil_node;
468 if ((duplicated == NULL) || replace) literals->nil_node = node;
469 return duplicated;
470 }
471 case PM_SOURCE_ENCODING_NODE: {
472 pm_node_t *duplicated = literals->source_encoding_node;
473 if ((duplicated == NULL) || replace) literals->source_encoding_node = node;
474 return duplicated;
475 }
476 default:
477 return NULL;
478 }
479}
480
484void
485pm_static_literals_free(pm_static_literals_t *literals) {
486 pm_node_hash_free(&literals->integer_nodes);
487 pm_node_hash_free(&literals->float_nodes);
488 pm_node_hash_free(&literals->number_nodes);
489 pm_node_hash_free(&literals->string_nodes);
490 pm_node_hash_free(&literals->regexp_nodes);
491 pm_node_hash_free(&literals->symbol_nodes);
492}
493
498static bool
499pm_static_literal_positive_p(const pm_node_t *node) {
500 switch (PM_NODE_TYPE(node)) {
501 case PM_FLOAT_NODE:
502 return ((const pm_float_node_t *) node)->value > 0;
503 case PM_INTEGER_NODE:
504 return !((const pm_integer_node_t *) node)->value.negative;
505 case PM_RATIONAL_NODE:
506 return !((const pm_rational_node_t *) node)->numerator.negative;
507 case PM_IMAGINARY_NODE:
508 return pm_static_literal_positive_p(((const pm_imaginary_node_t *) node)->numeric);
509 default:
510 assert(false && "unreachable");
511 return false;
512 }
513}
514
518static PRISM_INLINE void
519pm_static_literal_inspect_node(pm_buffer_t *buffer, const pm_static_literals_metadata_t *metadata, const pm_node_t *node) {
520 switch (PM_NODE_TYPE(node)) {
521 case PM_FALSE_NODE:
522 pm_buffer_append_string(buffer, "false", 5);
523 break;
524 case PM_FLOAT_NODE: {
525 const double value = ((const pm_float_node_t *) node)->value;
526
527 if (PRISM_ISINF(value)) {
528 if (metadata->start[node->location.start] == '-') {
529 pm_buffer_append_byte(buffer, '-');
530 }
531 pm_buffer_append_string(buffer, "Infinity", 8);
532 } else if (value == 0.0) {
533 if (metadata->start[node->location.start] == '-') {
534 pm_buffer_append_byte(buffer, '-');
535 }
536 pm_buffer_append_string(buffer, "0.0", 3);
537 } else {
538 pm_buffer_append_format(buffer, "%g", value);
539
540 // %g will not insert a .0 for 1e100 (we'll get back 1e+100). So
541 // we check for the decimal point and add it in here if it's not
542 // present.
543 if (pm_buffer_index(buffer, '.') == SIZE_MAX) {
544 size_t exponent_index = pm_buffer_index(buffer, 'e');
545 size_t index = exponent_index == SIZE_MAX ? pm_buffer_length(buffer) : exponent_index;
546 pm_buffer_insert(buffer, index, ".0", 2);
547 }
548 }
549
550 break;
551 }
552 case PM_IMAGINARY_NODE: {
553 const pm_node_t *numeric = ((const pm_imaginary_node_t *) node)->numeric;
554 pm_buffer_append_string(buffer, "(0", 2);
555 if (pm_static_literal_positive_p(numeric)) pm_buffer_append_byte(buffer, '+');
556 pm_static_literal_inspect_node(buffer, metadata, numeric);
557 if (PM_NODE_TYPE_P(numeric, PM_RATIONAL_NODE)) {
558 pm_buffer_append_byte(buffer, '*');
559 }
560 pm_buffer_append_string(buffer, "i)", 2);
561 break;
562 }
563 case PM_INTEGER_NODE:
564 pm_integer_string(buffer, &((const pm_integer_node_t *) node)->value);
565 break;
566 case PM_NIL_NODE:
567 pm_buffer_append_string(buffer, "nil", 3);
568 break;
569 case PM_RATIONAL_NODE: {
570 const pm_rational_node_t *rational = (const pm_rational_node_t *) node;
571 pm_buffer_append_byte(buffer, '(');
572 pm_integer_string(buffer, &rational->numerator);
573 pm_buffer_append_byte(buffer, '/');
574 pm_integer_string(buffer, &rational->denominator);
575 pm_buffer_append_byte(buffer, ')');
576 break;
577 }
578 case PM_REGULAR_EXPRESSION_NODE: {
579 const pm_string_t *unescaped = &((const pm_regular_expression_node_t *) node)->unescaped;
580 pm_buffer_append_byte(buffer, '/');
581 pm_buffer_append_source(buffer, pm_string_source(unescaped), pm_string_length(unescaped), PM_BUFFER_ESCAPING_RUBY);
582 pm_buffer_append_byte(buffer, '/');
583
584 if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_MULTI_LINE)) pm_buffer_append_string(buffer, "m", 1);
585 if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_IGNORE_CASE)) pm_buffer_append_string(buffer, "i", 1);
586 if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_EXTENDED)) pm_buffer_append_string(buffer, "x", 1);
587 if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_ASCII_8BIT)) pm_buffer_append_string(buffer, "n", 1);
588
589 break;
590 }
591 case PM_SOURCE_ENCODING_NODE:
592 pm_buffer_append_format(buffer, "#<Encoding:%s>", metadata->encoding_name);
593 break;
594 case PM_SOURCE_FILE_NODE: {
595 const pm_string_t *filepath = &((const pm_source_file_node_t *) node)->filepath;
596 pm_buffer_append_byte(buffer, '"');
597 pm_buffer_append_source(buffer, pm_string_source(filepath), pm_string_length(filepath), PM_BUFFER_ESCAPING_RUBY);
598 pm_buffer_append_byte(buffer, '"');
599 break;
600 }
601 case PM_SOURCE_LINE_NODE:
602 pm_buffer_append_format(buffer, "%d", pm_line_offset_list_line_column(metadata->line_offsets, node->location.start, metadata->start_line).line);
603 break;
604 case PM_STRING_NODE: {
605 const pm_string_t *unescaped = &((const pm_string_node_t *) node)->unescaped;
606 pm_buffer_append_byte(buffer, '"');
607 pm_buffer_append_source(buffer, pm_string_source(unescaped), pm_string_length(unescaped), PM_BUFFER_ESCAPING_RUBY);
608 pm_buffer_append_byte(buffer, '"');
609 break;
610 }
611 case PM_SYMBOL_NODE: {
612 const pm_string_t *unescaped = &((const pm_symbol_node_t *) node)->unescaped;
613 pm_buffer_append_byte(buffer, ':');
614 pm_buffer_append_source(buffer, pm_string_source(unescaped), pm_string_length(unescaped), PM_BUFFER_ESCAPING_RUBY);
615 break;
616 }
617 case PM_TRUE_NODE:
618 pm_buffer_append_string(buffer, "true", 4);
619 break;
620 default:
621 assert(false && "unreachable");
622 break;
623 }
624}
625
629void
630pm_static_literal_inspect(pm_buffer_t *buffer, const pm_line_offset_list_t *line_offsets, const uint8_t *start, int32_t start_line, const char *encoding_name, const pm_node_t *node) {
631 pm_static_literal_inspect_node(
632 buffer,
634 .line_offsets = line_offsets,
635 .start = start,
636 .start_line = start_line,
637 .encoding_name = encoding_name
638 },
639 node
640 );
641}
#define xcalloc
Old name of ruby_xcalloc.
Definition xmalloc.h:55
#define PRISM_INLINE
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Definition inline.h:12
FloatNode.
Definition ast.h:3950
ImaginaryNode.
Definition ast.h:4619
IntegerNode.
Definition ast.h:5215
pm_integer_t value
IntegerNode::value.
Definition ast.h:5224
A structure represents an arbitrary-sized integer.
Definition integer.h:16
size_t length
The number of allocated values.
Definition integer.h:21
uint32_t value
Embedded value for small integer.
Definition integer.h:32
uint32_t * values
List of 32-bit integers.
Definition integer.h:26
bool negative
Whether or not the integer is negative.
Definition integer.h:38
A line and column in a string.
int32_t line
The line number.
A list of offsets of the start of lines in a string.
uint32_t start
The offset of the location from the start of the source.
Definition ast.h:556
This is the base structure that represents a node in the syntax tree.
Definition ast.h:1065
pm_node_type_t type
This represents the type of the node.
Definition ast.h:1070
pm_node_flags_t flags
This represents any flags on the node.
Definition ast.h:1076
pm_location_t location
This is the location of the node in the source.
Definition ast.h:1088
RationalNode.
Definition ast.h:6911
pm_node_t base
The embedded base node.
Definition ast.h:6913
pm_integer_t denominator
RationalNode::denominator.
Definition ast.h:6931
pm_integer_t numerator
RationalNode::numerator.
Definition ast.h:6922
RegularExpressionNode.
Definition ast.h:6976
pm_node_t base
The embedded base node.
Definition ast.h:6978
pm_string_t unescaped
RegularExpressionNode::unescaped.
Definition ast.h:6998
SourceFileNode.
Definition ast.h:7356
A small struct used for passing around a subset of the information that is stored on the parser.
const char * encoding_name
The name of the encoding that the parser is using.
const uint8_t * start
The start of the source being parsed.
const pm_line_offset_list_t * line_offsets
The list of newline offsets to use to calculate line numbers.
int32_t start_line
The line number that the parser starts on.
StringNode.
Definition ast.h:7458
A generic string type that can have various ownership semantics.
Definition stringy.h:18
SymbolNode.
Definition ast.h:7552
#define PRISM_UNUSED
GCC will warn if you specify a function or parameter that is unused at runtime.
Definition unused.h:13