prism 2.0.0.rc1-x86_64-linux-gnu

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. checksums.yaml +7 -0
  2. data/BSDmakefile +58 -0
  3. data/CHANGELOG.md +870 -0
  4. data/CODE_OF_CONDUCT.md +76 -0
  5. data/CONTRIBUTING.md +58 -0
  6. data/LICENSE.md +7 -0
  7. data/Makefile +145 -0
  8. data/README.md +81 -0
  9. data/config.yml +4752 -0
  10. data/docs/build_system.md +119 -0
  11. data/docs/configuration.md +69 -0
  12. data/docs/cruby_compilation.md +27 -0
  13. data/docs/design.md +53 -0
  14. data/docs/encoding.md +121 -0
  15. data/docs/fuzzing.md +81 -0
  16. data/docs/heredocs.md +36 -0
  17. data/docs/javascript.md +133 -0
  18. data/docs/local_variable_depth.md +229 -0
  19. data/docs/mapping.md +117 -0
  20. data/docs/parser_translation.md +24 -0
  21. data/docs/parsing_rules.md +22 -0
  22. data/docs/releasing.md +147 -0
  23. data/docs/relocation.md +32 -0
  24. data/docs/ripper_translation.md +63 -0
  25. data/docs/ruby_api.md +45 -0
  26. data/docs/ruby_parser_translation.md +19 -0
  27. data/docs/serialization.md +230 -0
  28. data/docs/testing.md +72 -0
  29. data/ext/prism/api_node.c +7005 -0
  30. data/ext/prism/extconf.rb +126 -0
  31. data/ext/prism/extension.c +1783 -0
  32. data/ext/prism/extension.h +19 -0
  33. data/include/prism/arena.h +37 -0
  34. data/include/prism/ast.h +10371 -0
  35. data/include/prism/buffer.h +52 -0
  36. data/include/prism/comments.h +55 -0
  37. data/include/prism/compiler/accel.h +24 -0
  38. data/include/prism/compiler/align.h +36 -0
  39. data/include/prism/compiler/assume.h +25 -0
  40. data/include/prism/compiler/exported.h +24 -0
  41. data/include/prism/compiler/fallthrough.h +22 -0
  42. data/include/prism/compiler/filesystem.h +32 -0
  43. data/include/prism/compiler/flex_array.h +19 -0
  44. data/include/prism/compiler/force_inline.h +21 -0
  45. data/include/prism/compiler/format.h +25 -0
  46. data/include/prism/compiler/inline.h +17 -0
  47. data/include/prism/compiler/nodiscard.h +22 -0
  48. data/include/prism/compiler/nonnull.h +18 -0
  49. data/include/prism/compiler/unused.h +18 -0
  50. data/include/prism/constant_pool.h +81 -0
  51. data/include/prism/diagnostic.h +93 -0
  52. data/include/prism/errors_format.h +53 -0
  53. data/include/prism/excludes.h +29 -0
  54. data/include/prism/integer.h +41 -0
  55. data/include/prism/internal/allocator.h +68 -0
  56. data/include/prism/internal/allocator_debug.h +88 -0
  57. data/include/prism/internal/arena.h +108 -0
  58. data/include/prism/internal/bit.h +42 -0
  59. data/include/prism/internal/buffer.h +91 -0
  60. data/include/prism/internal/char.h +145 -0
  61. data/include/prism/internal/comments.h +53 -0
  62. data/include/prism/internal/constant_pool.h +152 -0
  63. data/include/prism/internal/diagnostic.h +389 -0
  64. data/include/prism/internal/encoding.h +242 -0
  65. data/include/prism/internal/integer.h +68 -0
  66. data/include/prism/internal/isinf.h +16 -0
  67. data/include/prism/internal/line_offset_list.h +34 -0
  68. data/include/prism/internal/list.h +62 -0
  69. data/include/prism/internal/magic_comments.h +23 -0
  70. data/include/prism/internal/memchr.h +15 -0
  71. data/include/prism/internal/node.h +38 -0
  72. data/include/prism/internal/options.h +232 -0
  73. data/include/prism/internal/parser.h +984 -0
  74. data/include/prism/internal/regexp.h +26 -0
  75. data/include/prism/internal/serialize.h +39 -0
  76. data/include/prism/internal/source.h +72 -0
  77. data/include/prism/internal/static_literals.h +100 -0
  78. data/include/prism/internal/stringy.h +35 -0
  79. data/include/prism/internal/strncasecmp.h +18 -0
  80. data/include/prism/internal/strpbrk.h +33 -0
  81. data/include/prism/internal/tokens.h +11 -0
  82. data/include/prism/json.h +32 -0
  83. data/include/prism/line_offset_list.h +61 -0
  84. data/include/prism/magic_comments.h +35 -0
  85. data/include/prism/node.h +94 -0
  86. data/include/prism/options.h +354 -0
  87. data/include/prism/parser.h +404 -0
  88. data/include/prism/prettyprint.h +31 -0
  89. data/include/prism/serialize.h +115 -0
  90. data/include/prism/source.h +155 -0
  91. data/include/prism/stream.h +28 -0
  92. data/include/prism/string_query.h +63 -0
  93. data/include/prism/stringy.h +72 -0
  94. data/include/prism/version.h +38 -0
  95. data/include/prism.h +131 -0
  96. data/lib/prism/3.3/prism.so +0 -0
  97. data/lib/prism/3.4/prism.so +0 -0
  98. data/lib/prism/4.0/prism.so +0 -0
  99. data/lib/prism/compiler.rb +815 -0
  100. data/lib/prism/desugar_compiler.rb +463 -0
  101. data/lib/prism/dispatcher.rb +2383 -0
  102. data/lib/prism/dot_visitor.rb +4848 -0
  103. data/lib/prism/dsl.rb +1369 -0
  104. data/lib/prism/ffi.rb +740 -0
  105. data/lib/prism/inspect_visitor.rb +2425 -0
  106. data/lib/prism/lex_compat.rb +953 -0
  107. data/lib/prism/mutation_compiler.rb +780 -0
  108. data/lib/prism/node.rb +33204 -0
  109. data/lib/prism/node_ext.rb +504 -0
  110. data/lib/prism/node_find.rb +215 -0
  111. data/lib/prism/parse_result/errors.rb +72 -0
  112. data/lib/prism/parse_result/newlines.rb +423 -0
  113. data/lib/prism/parse_result.rb +1221 -0
  114. data/lib/prism/pattern.rb +314 -0
  115. data/lib/prism/polyfill/append_as_bytes.rb +15 -0
  116. data/lib/prism/polyfill/byteindex.rb +13 -0
  117. data/lib/prism/polyfill/scan_byte.rb +14 -0
  118. data/lib/prism/polyfill/unpack1.rb +14 -0
  119. data/lib/prism/polyfill/warn.rb +36 -0
  120. data/lib/prism/reflection.rb +427 -0
  121. data/lib/prism/relocation.rb +567 -0
  122. data/lib/prism/serialize.rb +5308 -0
  123. data/lib/prism/string_query.rb +46 -0
  124. data/lib/prism/translation/parser/builder.rb +70 -0
  125. data/lib/prism/translation/parser/compiler.rb +2226 -0
  126. data/lib/prism/translation/parser/lexer.rb +769 -0
  127. data/lib/prism/translation/parser.rb +376 -0
  128. data/lib/prism/translation/parser_current.rb +26 -0
  129. data/lib/prism/translation/parser_versions.rb +36 -0
  130. data/lib/prism/translation/ripper/filter.rb +53 -0
  131. data/lib/prism/translation/ripper/lexer.rb +133 -0
  132. data/lib/prism/translation/ripper/sexp.rb +118 -0
  133. data/lib/prism/translation/ripper/shim.rb +7 -0
  134. data/lib/prism/translation/ripper.rb +4278 -0
  135. data/lib/prism/translation/ruby_parser.rb +1721 -0
  136. data/lib/prism/translation.rb +20 -0
  137. data/lib/prism/visitor.rb +1440 -0
  138. data/lib/prism.rb +168 -0
  139. data/prism.gemspec +234 -0
  140. data/rbi/generated/prism/compiler.rbi +489 -0
  141. data/rbi/generated/prism/desugar_compiler.rbi +306 -0
  142. data/rbi/generated/prism/dispatcher.rbi +1138 -0
  143. data/rbi/generated/prism/dot_visitor.rbi +618 -0
  144. data/rbi/generated/prism/dsl.rbi +751 -0
  145. data/rbi/generated/prism/inspect_visitor.rbi +503 -0
  146. data/rbi/generated/prism/lex_compat.rbi +162 -0
  147. data/rbi/generated/prism/mutation_compiler.rbi +464 -0
  148. data/rbi/generated/prism/node.rbi +13681 -0
  149. data/rbi/generated/prism/node_ext.rbi +259 -0
  150. data/rbi/generated/prism/node_find.rbi +79 -0
  151. data/rbi/generated/prism/parse_result/errors.rbi +21 -0
  152. data/rbi/generated/prism/parse_result/newlines.rbi +208 -0
  153. data/rbi/generated/prism/parse_result.rbi +764 -0
  154. data/rbi/generated/prism/pattern.rbi +134 -0
  155. data/rbi/generated/prism/reflection.rbi +89 -0
  156. data/rbi/generated/prism/relocation.rbi +329 -0
  157. data/rbi/generated/prism/serialize.rbi +181 -0
  158. data/rbi/generated/prism/string_query.rbi +36 -0
  159. data/rbi/generated/prism/translation.rbi +7 -0
  160. data/rbi/generated/prism/visitor.rbi +650 -0
  161. data/rbi/generated/prism.rbi +86 -0
  162. data/rbi/prism/translation/parser.rbi +11 -0
  163. data/rbi/prism/translation/parser_versions.rbi +28 -0
  164. data/rbi/prism/translation/ripper.rbi +15 -0
  165. data/rbi/rubyvm/node_find.rbi +14 -0
  166. data/sig/generated/prism/compiler.rbs +492 -0
  167. data/sig/generated/prism/desugar_compiler.rbs +305 -0
  168. data/sig/generated/prism/dispatcher.rbs +1292 -0
  169. data/sig/generated/prism/dot_visitor.rbs +635 -0
  170. data/sig/generated/prism/dsl.rbs +928 -0
  171. data/sig/generated/prism/inspect_visitor.rbs +509 -0
  172. data/sig/generated/prism/lex_compat.rbs +166 -0
  173. data/sig/generated/prism/mutation_compiler.rbs +464 -0
  174. data/sig/generated/prism/node.rbs +20160 -0
  175. data/sig/generated/prism/node_ext.rbs +290 -0
  176. data/sig/generated/prism/node_find.rbs +90 -0
  177. data/sig/generated/prism/parse_result/errors.rbs +22 -0
  178. data/sig/generated/prism/parse_result/newlines.rbs +223 -0
  179. data/sig/generated/prism/parse_result.rbs +859 -0
  180. data/sig/generated/prism/pattern.rbs +156 -0
  181. data/sig/generated/prism/reflection.rbs +101 -0
  182. data/sig/generated/prism/relocation.rbs +428 -0
  183. data/sig/generated/prism/serialize.rbs +195 -0
  184. data/sig/generated/prism/string_query.rbs +36 -0
  185. data/sig/generated/prism/translation.rbs +8 -0
  186. data/sig/generated/prism/visitor.rbs +1111 -0
  187. data/sig/generated/prism.rbs +84 -0
  188. data/sig/manifest.yaml +2 -0
  189. data/src/arena.c +117 -0
  190. data/src/buffer.c +380 -0
  191. data/src/char.c +289 -0
  192. data/src/comments.c +454 -0
  193. data/src/constant_pool.c +406 -0
  194. data/src/diagnostic.c +886 -0
  195. data/src/encoding.c +5345 -0
  196. data/src/errors_format.c +519 -0
  197. data/src/integer.c +681 -0
  198. data/src/json.c +5733 -0
  199. data/src/line_offset_list.c +100 -0
  200. data/src/list.c +24 -0
  201. data/src/memchr.c +37 -0
  202. data/src/node.c +4515 -0
  203. data/src/options.c +451 -0
  204. data/src/parser.c +349 -0
  205. data/src/prettyprint.c +9024 -0
  206. data/src/prism.c +23739 -0
  207. data/src/regexp.c +1706 -0
  208. data/src/serialize.c +2309 -0
  209. data/src/source.c +518 -0
  210. data/src/static_literals.c +685 -0
  211. data/src/string_query.c +166 -0
  212. data/src/stringy.c +91 -0
  213. data/src/strncasecmp.c +37 -0
  214. data/src/strpbrk.c +447 -0
  215. data/src/tokens.c +724 -0
  216. metadata +259 -0
data/src/parser.c ADDED
@@ -0,0 +1,349 @@
1
+ #include "prism/internal/parser.h"
2
+
3
+ #include "prism/internal/allocator.h"
4
+ #include "prism/internal/comments.h"
5
+ #include "prism/internal/diagnostic.h"
6
+ #include "prism/internal/encoding.h"
7
+ #include "prism/internal/magic_comments.h"
8
+
9
+ #include <stdlib.h>
10
+
11
+ /**
12
+ * Register a callback that will be called whenever prism changes the encoding
13
+ * it is using to parse based on the magic comment.
14
+ */
15
+ void
16
+ pm_parser_encoding_changed_callback_set(pm_parser_t *parser, pm_encoding_changed_callback_t callback) {
17
+ parser->encoding_changed_callback = callback;
18
+ }
19
+
20
+ /**
21
+ * Register a callback that will be called whenever a token is lexed.
22
+ */
23
+ void
24
+ pm_parser_lex_callback_set(pm_parser_t *parser, pm_lex_callback_t callback, void *data) {
25
+ parser->lex_callback.callback = callback;
26
+ parser->lex_callback.data = data;
27
+ }
28
+
29
+ /**
30
+ * Returns the opaque data that is passed to the lex callback when it is called.
31
+ */
32
+ void *
33
+ pm_parser_lex_callback_data(const pm_parser_t *parser) {
34
+ return parser->lex_callback.data;
35
+ }
36
+
37
+ /**
38
+ * Returns the raw pointer to the start of the source that is being parsed.
39
+ */
40
+ const uint8_t *
41
+ pm_parser_start(const pm_parser_t *parser) {
42
+ return parser->start;
43
+ }
44
+
45
+ /**
46
+ * Returns the raw pointer to the end of the source that is being parsed.
47
+ */
48
+ const uint8_t *
49
+ pm_parser_end(const pm_parser_t *parser) {
50
+ return parser->end;
51
+ }
52
+
53
+ /**
54
+ * Returns the line that the parser was considered to have started on.
55
+ *
56
+ * @param parser the parser whose start line we want to get
57
+ * @return the line that the parser was considered to have started on
58
+ */
59
+ int32_t
60
+ pm_parser_start_line(const pm_parser_t *parser) {
61
+ return parser->start_line;
62
+ }
63
+
64
+ /**
65
+ * Returns the name of the encoding that is being used to parse the source.
66
+ */
67
+ const char *
68
+ pm_parser_encoding_name(const pm_parser_t *parser) {
69
+ return parser->encoding->name;
70
+ }
71
+
72
+ /**
73
+ * Returns the width of the character at the given pointer in the encoding that
74
+ * is being used to parse the source.
75
+ */
76
+ size_t
77
+ pm_parser_encoding_char_width(const pm_parser_t *parser, const uint8_t *start, ptrdiff_t remaining) {
78
+ return parser->encoding->char_width(start, remaining);
79
+ }
80
+
81
+ /**
82
+ * Returns whether or not the parser is using the US-ASCII encoding.
83
+ */
84
+ bool
85
+ pm_parser_encoding_us_ascii(const pm_parser_t *parser) {
86
+ return parser->encoding == PM_ENCODING_US_ASCII_ENTRY;
87
+ }
88
+
89
+ /**
90
+ * Returns the filepath that is being used to parse the source.
91
+ */
92
+ const pm_string_t *
93
+ pm_parser_filepath(const pm_parser_t *parser) {
94
+ return &parser->filepath;
95
+ }
96
+
97
+ /**
98
+ * Find a constant in the parser's constant pool. Returns the id of the
99
+ * constant, or 0 if the constant is not found.
100
+ */
101
+ pm_constant_id_t
102
+ pm_parser_constant_find(const pm_parser_t *parser, const uint8_t *start, size_t length) {
103
+ return pm_constant_pool_find(&parser->constant_pool, start, length);
104
+ }
105
+
106
+ /**
107
+ * Returns the frozen string literal value of the parser.
108
+ */
109
+ int8_t
110
+ pm_parser_frozen_string_literal(const pm_parser_t *parser) {
111
+ return parser->frozen_string_literal;
112
+ }
113
+
114
+ /**
115
+ * Returns the line offsets that are associated with the given parser.
116
+ *
117
+ * @param parser the parser whose line offsets we want to get
118
+ * @return the line offsets that are associated with the given parser
119
+ */
120
+ const pm_line_offset_list_t *
121
+ pm_parser_line_offsets(const pm_parser_t *parser) {
122
+ return &parser->line_offsets;
123
+ }
124
+
125
+ /**
126
+ * Returns the location of the __DATA__ section that is associated with the
127
+ * given parser, if it exists.
128
+ */
129
+ const pm_location_t *
130
+ pm_parser_data_loc(const pm_parser_t *parser) {
131
+ return &parser->data_loc;
132
+ }
133
+
134
+ /**
135
+ * Returns whether the given parser is continuable, meaning that it could become
136
+ * valid if more input were appended, as opposed to being definitively invalid.
137
+ */
138
+ bool
139
+ pm_parser_continuable(const pm_parser_t *parser) {
140
+ return parser->continuable;
141
+ }
142
+
143
+ /**
144
+ * Returns the lex state of the parser. Note that this is an internal detail,
145
+ * and we are purposefully not returning an instance of the internal enum that
146
+ * we use to track this. This is only exposed because we need it for some very
147
+ * niche use cases. Most consumers should avoid this function.
148
+ */
149
+ int
150
+ pm_parser_lex_state(const pm_parser_t *parser) {
151
+ return (int) parser->lex_state;
152
+ }
153
+
154
+ /**
155
+ * Returns the location associated with the given comment.
156
+ */
157
+ pm_location_t
158
+ pm_comment_location(const pm_comment_t *comment) {
159
+ return comment->location;
160
+ }
161
+
162
+ /**
163
+ * Returns the type associated with the given comment.
164
+ */
165
+ pm_comment_type_t
166
+ pm_comment_type(const pm_comment_t *comment) {
167
+ return comment->type;
168
+ }
169
+
170
+ /**
171
+ * Returns the number of comments associated with the given parser.
172
+ */
173
+ size_t
174
+ pm_parser_comments_size(const pm_parser_t *parser) {
175
+ return parser->comment_list.size;
176
+ }
177
+
178
+ /**
179
+ * Iterates over the comments associated with the given parser and calls the
180
+ * given callback for each comment.
181
+ */
182
+ void
183
+ pm_parser_comments_each(const pm_parser_t *parser, pm_comment_callback_t callback, void *data) {
184
+ const pm_list_node_t *current = parser->comment_list.head;
185
+ while (current != NULL) {
186
+ const pm_comment_t *comment = (const pm_comment_t *) current;
187
+ callback(comment, data);
188
+ current = current->next;
189
+ }
190
+ }
191
+
192
+ /**
193
+ * Returns the number of comments owned by the given node.
194
+ */
195
+ uint32_t
196
+ pm_node_comments_size(const pm_parser_t *parser, const pm_node_t *node) {
197
+ return pm_parser_comment_range(parser, node->node_id).length;
198
+ }
199
+
200
+ /**
201
+ * Returns the comment at the given index among the comments owned by the given
202
+ * node.
203
+ */
204
+ const pm_comment_t *
205
+ pm_node_comment(const pm_parser_t *parser, const pm_node_t *node, uint32_t index) {
206
+ pm_comment_range_t range = pm_parser_comment_range(parser, node->node_id);
207
+ if (index >= range.length) return NULL;
208
+
209
+ return parser->comment_attachments.comments[parser->comment_attachments.attachments[range.index + index]];
210
+ }
211
+
212
+ /**
213
+ * Returns the index, among the comments associated with the given parser, of
214
+ * the comment at the given index among the comment attachments.
215
+ */
216
+ uint32_t
217
+ pm_parser_comment_attachment(const pm_parser_t *parser, uint32_t index) {
218
+ if (parser->comment_attachments.attachments == NULL || index >= parser->comment_list.size) return UINT32_MAX;
219
+ return parser->comment_attachments.attachments[index];
220
+ }
221
+
222
+ /**
223
+ * Returns the number of node ids that have a comment range.
224
+ */
225
+ uint32_t
226
+ pm_parser_comment_ranges_size(const pm_parser_t *parser) {
227
+ return parser->comment_attachments.ranges_size;
228
+ }
229
+
230
+ /**
231
+ * Returns the range of comment attachments owned by the node with the given id.
232
+ */
233
+ pm_comment_range_t
234
+ pm_parser_comment_range(const pm_parser_t *parser, uint32_t node_id) {
235
+ if (node_id >= parser->comment_attachments.ranges_size) return (pm_comment_range_t) { .index = 0, .length = 0 };
236
+ return parser->comment_attachments.ranges[node_id];
237
+ }
238
+
239
+ /**
240
+ * Returns the location associated with the given magic comment key.
241
+ */
242
+ pm_location_t
243
+ pm_magic_comment_key(const pm_magic_comment_t *magic_comment) {
244
+ return magic_comment->key;
245
+ }
246
+
247
+ /**
248
+ * Returns the location associated with the given magic comment value.
249
+ */
250
+ pm_location_t
251
+ pm_magic_comment_value(const pm_magic_comment_t *magic_comment) {
252
+ return magic_comment->value;
253
+ }
254
+
255
+ /**
256
+ * Returns the number of magic comments associated with the given parser.
257
+ */
258
+ size_t
259
+ pm_parser_magic_comments_size(const pm_parser_t *parser) {
260
+ return parser->magic_comment_list.size;
261
+ }
262
+
263
+ /**
264
+ * Iterates over the magic comments associated with the given parser and calls
265
+ * the given callback for each magic comment.
266
+ */
267
+ void
268
+ pm_parser_magic_comments_each(const pm_parser_t *parser, pm_magic_comment_callback_t callback, void *data) {
269
+ const pm_list_node_t *current = parser->magic_comment_list.head;
270
+ while (current != NULL) {
271
+ const pm_magic_comment_t *magic_comment = (const pm_magic_comment_t *) current;
272
+ callback(magic_comment, data);
273
+ current = current->next;
274
+ }
275
+ }
276
+
277
+ /**
278
+ * Returns the number of errors associated with the given parser.
279
+ */
280
+ size_t
281
+ pm_parser_errors_size(const pm_parser_t *parser) {
282
+ return parser->error_list.size;
283
+ }
284
+
285
+ /**
286
+ * Returns the number of warnings associated with the given parser.
287
+ */
288
+ size_t
289
+ pm_parser_warnings_size(const pm_parser_t *parser) {
290
+ return parser->warning_list.size;
291
+ }
292
+
293
+ static inline void
294
+ pm_parser_diagnostics_each(const pm_list_t *list, pm_diagnostic_callback_t callback, void *data) {
295
+ const pm_list_node_t *current = list->head;
296
+ while (current != NULL) {
297
+ const pm_diagnostic_t *diagnostic = (const pm_diagnostic_t *) current;
298
+ callback(diagnostic, data);
299
+ current = current->next;
300
+ }
301
+ }
302
+
303
+ /**
304
+ * Iterates over the errors associated with the given parser and calls the
305
+ * given callback for each error.
306
+ */
307
+ void
308
+ pm_parser_errors_each(const pm_parser_t *parser, pm_diagnostic_callback_t callback, void *data) {
309
+ pm_parser_diagnostics_each(&parser->error_list, callback, data);
310
+ }
311
+
312
+ /**
313
+ * Iterates over the warnings associated with the given parser and calls the
314
+ * given callback for each warning.
315
+ */
316
+ void
317
+ pm_parser_warnings_each(const pm_parser_t *parser, pm_diagnostic_callback_t callback, void *data) {
318
+ pm_parser_diagnostics_each(&parser->warning_list, callback, data);
319
+ }
320
+
321
+ /**
322
+ * Returns the number of constants in the constant pool associated with the
323
+ * given parser.
324
+ */
325
+ size_t
326
+ pm_parser_constants_size(const pm_parser_t *parser) {
327
+ return parser->constant_pool.size;
328
+ }
329
+
330
+ /**
331
+ * Iterates over the constants in the constant pool associated with the given
332
+ * parser and calls the given callback for each constant.
333
+ */
334
+ void
335
+ pm_parser_constants_each(const pm_parser_t *parser, pm_constant_callback_t callback, void *data) {
336
+ for (uint32_t index = 0; index < parser->constant_pool.size; index++) {
337
+ const pm_constant_t *constant = &parser->constant_pool.constants[index];
338
+ callback(constant, data);
339
+ }
340
+ }
341
+
342
+ /**
343
+ * Returns a pointer to the constant at the given id in the constant pool
344
+ * associated with the given parser.
345
+ */
346
+ const pm_constant_t *
347
+ pm_parser_constant(const pm_parser_t *parser, pm_constant_id_t constant_id) {
348
+ return pm_constant_pool_id_to_constant(&parser->constant_pool, constant_id);
349
+ }