datadog-ruby_core_source 3.5.4 → 3.5.6

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 (198) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -2
  3. data/datadog-ruby_core_source.gemspec +1 -1
  4. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/build_assert/build_assert.h +40 -0
  5. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/check_type/check_type.h +63 -0
  6. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/container_of/container_of.h +142 -0
  7. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/list/list.h +788 -0
  8. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/str/str.h +16 -0
  9. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/id.h +252 -0
  10. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/internal.h +2465 -0
  11. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/iseq.h +304 -0
  12. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/method.h +229 -0
  13. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/node.h +449 -0
  14. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ruby_assert.h +60 -0
  15. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ruby_atomic.h +244 -0
  16. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/thread_pthread.h +75 -0
  17. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/thread_win32.h +36 -0
  18. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/vm_core.h +1902 -0
  19. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/vm_opts.h +70 -0
  20. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/build_assert/build_assert.h +40 -0
  21. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/check_type/check_type.h +63 -0
  22. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/container_of/container_of.h +142 -0
  23. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/list/list.h +788 -0
  24. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/str/str.h +16 -0
  25. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/id.h +290 -0
  26. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/internal.h +2697 -0
  27. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/iseq.h +312 -0
  28. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/method.h +229 -0
  29. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/node.h +476 -0
  30. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ruby_assert.h +15 -0
  31. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ruby_atomic.h +244 -0
  32. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/thread_pthread.h +75 -0
  33. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/thread_win32.h +36 -0
  34. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/vm_core.h +1968 -0
  35. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/vm_opts.h +72 -0
  36. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/build_assert/build_assert.h +40 -0
  37. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/check_type/check_type.h +63 -0
  38. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/container_of/container_of.h +142 -0
  39. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/list/list.h +788 -0
  40. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/str/str.h +16 -0
  41. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/id.h +290 -0
  42. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/id_table.h +36 -0
  43. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/array.h +119 -0
  44. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/class.h +174 -0
  45. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/compilers.h +108 -0
  46. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/gc.h +161 -0
  47. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/imemo.h +243 -0
  48. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/serial.h +24 -0
  49. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/static_assert.h +17 -0
  50. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/vm.h +136 -0
  51. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/warnings.h +17 -0
  52. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal.h +107 -0
  53. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/iseq.h +305 -0
  54. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/method.h +245 -0
  55. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/node.h +484 -0
  56. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ractor_core.h +343 -0
  57. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ruby_assert.h +15 -0
  58. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ruby_atomic.h +23 -0
  59. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/thread_pthread.h +115 -0
  60. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/thread_win32.h +61 -0
  61. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_core.h +2023 -0
  62. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_debug.h +116 -0
  63. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_opts.h +73 -0
  64. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/build_assert/build_assert.h +40 -0
  65. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/check_type/check_type.h +63 -0
  66. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/container_of/container_of.h +142 -0
  67. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/list/list.h +788 -0
  68. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/str/str.h +16 -0
  69. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/darray.h +198 -0
  70. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/id.h +293 -0
  71. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/id_table.h +36 -0
  72. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/array.h +113 -0
  73. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/class.h +196 -0
  74. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/compilers.h +107 -0
  75. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/gc.h +186 -0
  76. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/imemo.h +243 -0
  77. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/serial.h +23 -0
  78. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/static_assert.h +16 -0
  79. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/vm.h +133 -0
  80. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/warnings.h +16 -0
  81. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal.h +109 -0
  82. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/iseq.h +322 -0
  83. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/method.h +253 -0
  84. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/node.h +510 -0
  85. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ractor_core.h +346 -0
  86. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ruby_assert.h +14 -0
  87. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ruby_atomic.h +23 -0
  88. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/thread_pthread.h +115 -0
  89. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_core.h +2107 -0
  90. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_debug.h +124 -0
  91. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_opts.h +73 -0
  92. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/build_assert/build_assert.h +40 -0
  93. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/check_type/check_type.h +63 -0
  94. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/container_of/container_of.h +142 -0
  95. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/list/list.h +789 -0
  96. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/str/str.h +17 -0
  97. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/id.h +299 -0
  98. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/id_table.h +39 -0
  99. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/array.h +163 -0
  100. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/basic_operators.h +64 -0
  101. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/class.h +182 -0
  102. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/compilers.h +107 -0
  103. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/gc.h +192 -0
  104. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/imemo.h +242 -0
  105. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/serial.h +23 -0
  106. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/static_assert.h +16 -0
  107. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/vm.h +134 -0
  108. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/warnings.h +16 -0
  109. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal.h +113 -0
  110. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/iseq.h +329 -0
  111. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/method.h +254 -0
  112. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/node.h +514 -0
  113. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ractor_core.h +342 -0
  114. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ruby_assert.h +14 -0
  115. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ruby_atomic.h +23 -0
  116. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/shape.h +232 -0
  117. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/thread_none.h +20 -0
  118. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/thread_pthread.h +133 -0
  119. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_core.h +2106 -0
  120. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_debug.h +122 -0
  121. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_opts.h +73 -0
  122. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/build_assert/build_assert.h +40 -0
  123. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/check_type/check_type.h +63 -0
  124. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/container_of/container_of.h +142 -0
  125. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/list/list.h +791 -0
  126. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/str/str.h +17 -0
  127. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/constant.h +53 -0
  128. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/debug_counter.h +428 -0
  129. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/hrtime.h +237 -0
  130. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/id.h +365 -0
  131. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/id_table.h +74 -0
  132. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/array.h +158 -0
  133. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/basic_operators.h +67 -0
  134. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/bits.h +647 -0
  135. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/box.h +103 -0
  136. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/class.h +797 -0
  137. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/compilers.h +104 -0
  138. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/coverage.h +51 -0
  139. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/gc.h +411 -0
  140. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/imemo.h +302 -0
  141. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/sanitizers.h +346 -0
  142. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/serial.h +23 -0
  143. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/set_table.h +77 -0
  144. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/static_assert.h +16 -0
  145. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/time.h +34 -0
  146. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/variable.h +81 -0
  147. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/vm.h +144 -0
  148. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/warnings.h +16 -0
  149. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal.h +106 -0
  150. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/iseq.h +439 -0
  151. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/method.h +279 -0
  152. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/node.h +122 -0
  153. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/parser_st.h +161 -0
  154. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/parser_value.h +116 -0
  155. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/arena.h +37 -0
  156. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/ast.h +10371 -0
  157. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/buffer.h +52 -0
  158. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/comments.h +43 -0
  159. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/align.h +36 -0
  160. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/exported.h +24 -0
  161. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/filesystem.h +32 -0
  162. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nodiscard.h +22 -0
  163. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nonnull.h +18 -0
  164. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/constant_pool.h +81 -0
  165. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/diagnostic.h +93 -0
  166. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/errors_format.h +53 -0
  167. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/excludes.h +29 -0
  168. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/integer.h +41 -0
  169. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/json.h +32 -0
  170. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/line_offset_list.h +61 -0
  171. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/magic_comments.h +35 -0
  172. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/node.h +94 -0
  173. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/options.h +335 -0
  174. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/parser.h +348 -0
  175. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/prettyprint.h +31 -0
  176. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/prism.h +131 -0
  177. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/serialize.h +115 -0
  178. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/source.h +155 -0
  179. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/stream.h +28 -0
  180. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/string_query.h +63 -0
  181. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/stringy.h +72 -0
  182. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/version.h +38 -0
  183. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism_compile.h +204 -0
  184. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ractor_core.h +421 -0
  185. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ruby_assert.h +14 -0
  186. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ruby_atomic.h +115 -0
  187. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/rubyparser.h +1389 -0
  188. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/shape.h +733 -0
  189. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/thread_none.h +25 -0
  190. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/thread_pthread.h +63 -0
  191. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/thread_sched.h +271 -0
  192. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_core.h +2509 -0
  193. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_debug.h +124 -0
  194. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_opts.h +65 -0
  195. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_sync.h +160 -0
  196. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/zjit.h +221 -0
  197. data/lib/datadog/ruby_core_source/version.rb +1 -1
  198. metadata +197 -4
@@ -0,0 +1,155 @@
1
+ /**
2
+ * @file source.h
3
+ *
4
+ * An opaque type representing the source code being parsed, regardless of
5
+ * origin (constant memory, file, memory-mapped file, or stream).
6
+ */
7
+ #ifndef PRISM_SOURCE_H
8
+ #define PRISM_SOURCE_H
9
+
10
+ #include "prism/compiler/exported.h"
11
+ #include "prism/compiler/filesystem.h"
12
+ #include "prism/compiler/nodiscard.h"
13
+ #include "prism/compiler/nonnull.h"
14
+
15
+ #include <stddef.h>
16
+ #include <stdint.h>
17
+
18
+ /**
19
+ * An opaque type representing source code being parsed.
20
+ */
21
+ typedef struct pm_source_t pm_source_t;
22
+
23
+ /**
24
+ * This function is used to retrieve a line of input from a stream. It closely
25
+ * mirrors that of fgets so that fgets can be used as the default
26
+ * implementation.
27
+ *
28
+ * As with fgets, implementations MUST write at most `size` bytes into
29
+ * `string`, including the terminating NUL byte (i.e. at most `size - 1` bytes
30
+ * of data followed by a '\0'). The caller relies on this bound for memory
31
+ * safety, so an implementation that reads from a source which may return more
32
+ * data than requested (for example a multi-byte-aware `gets`) is responsible
33
+ * for clamping the amount it copies. Returns `string`, or NULL on EOF.
34
+ */
35
+ typedef char * (pm_source_stream_fgets_t)(char *string, int size, void *stream);
36
+
37
+ /**
38
+ * This function is used to check whether a stream is at EOF. It closely mirrors
39
+ * that of feof so that feof can be used as the default implementation.
40
+ */
41
+ typedef int (pm_source_stream_feof_t)(void *stream);
42
+
43
+ /**
44
+ * Represents the result of initializing a source from a file.
45
+ */
46
+ typedef enum {
47
+ /** Indicates that the source was successfully initialized. */
48
+ PM_SOURCE_INIT_SUCCESS = 0,
49
+
50
+ /**
51
+ * Indicates a generic error from a source init function, where the type
52
+ * of error should be read from `errno` or `GetLastError()`.
53
+ */
54
+ PM_SOURCE_INIT_ERROR_GENERIC = 1,
55
+
56
+ /**
57
+ * Indicates that the file that was attempted to be opened was a directory.
58
+ */
59
+ PM_SOURCE_INIT_ERROR_DIRECTORY = 2,
60
+
61
+ /**
62
+ * Indicates that the file is not a regular file (e.g. a pipe or character
63
+ * device) and the caller should handle reading it.
64
+ */
65
+ PM_SOURCE_INIT_ERROR_NON_REGULAR = 3
66
+ } pm_source_init_result_t;
67
+
68
+ /**
69
+ * Create a new source that wraps existing constant memory. The memory is not
70
+ * owned and will not be freed.
71
+ *
72
+ * @param data The pointer to the source data.
73
+ * @param length The length of the source data in bytes.
74
+ * @returns A new source. Aborts on allocation failure.
75
+ */
76
+ PRISM_NODISCARD PRISM_EXPORTED_FUNCTION pm_source_t * pm_source_constant_new(const uint8_t *data, size_t length);
77
+
78
+ /**
79
+ * Create a new source that wraps existing shared memory. The memory is not
80
+ * owned and will not be freed. Semantically a "slice" of another source.
81
+ *
82
+ * @param data The pointer to the source data.
83
+ * @param length The length of the source data in bytes.
84
+ * @returns A new source. Aborts on allocation failure.
85
+ */
86
+ PRISM_NODISCARD PRISM_EXPORTED_FUNCTION pm_source_t * pm_source_shared_new(const uint8_t *data, size_t length);
87
+
88
+ /**
89
+ * Create a new source that owns its memory. The memory will be freed with
90
+ * xfree when the source is freed.
91
+ *
92
+ * @param data The pointer to the heap-allocated source data.
93
+ * @param length The length of the source data in bytes.
94
+ * @returns A new source. Aborts on allocation failure.
95
+ */
96
+ PRISM_NODISCARD PRISM_EXPORTED_FUNCTION pm_source_t * pm_source_owned_new(uint8_t *data, size_t length);
97
+
98
+ /**
99
+ * Create a new source by reading a file into a heap-allocated buffer.
100
+ *
101
+ * @param filepath The path to the file to read.
102
+ * @param result Out parameter for the result of the initialization.
103
+ * @returns A new source, or NULL on error (with result written to out param).
104
+ */
105
+ PRISM_NODISCARD PRISM_EXPORTED_FUNCTION pm_source_t * pm_source_file_new(const char *filepath, pm_source_init_result_t *result) PRISM_NONNULL(1, 2);
106
+
107
+ /**
108
+ * Create a new source by memory-mapping a file. Falls back to file reading on
109
+ * platforms without mmap support.
110
+ *
111
+ * If the file is a non-regular file (e.g. a pipe or character device),
112
+ * PM_SOURCE_INIT_ERROR_NON_REGULAR is returned, allowing the caller to handle
113
+ * it appropriately (e.g. by reading it through their own I/O layer).
114
+ *
115
+ * @param filepath The path to the file to read.
116
+ * @param open_flags Additional flags to pass to open(2) (e.g. O_NONBLOCK).
117
+ * @param result Out parameter for the result of the initialization.
118
+ * @returns A new source, or NULL on error (with result written to out param).
119
+ */
120
+ PRISM_NODISCARD PRISM_EXPORTED_FUNCTION pm_source_t * pm_source_mapped_new(const char *filepath, int open_flags, pm_source_init_result_t *result) PRISM_NONNULL(1, 3);
121
+
122
+ /**
123
+ * Create a new source by reading from a stream using the provided callbacks.
124
+ *
125
+ * @param stream The stream to read from.
126
+ * @param fgets The function to use to read from the stream.
127
+ * @param feof The function to use to check if the stream is at EOF.
128
+ * @returns A new source. Aborts on allocation failure.
129
+ */
130
+ PRISM_NODISCARD PRISM_EXPORTED_FUNCTION pm_source_t * pm_source_stream_new(void *stream, pm_source_stream_fgets_t *fgets, pm_source_stream_feof_t *feof);
131
+
132
+ /**
133
+ * Free the given source and any memory it owns.
134
+ *
135
+ * @param source The source to free.
136
+ */
137
+ PRISM_EXPORTED_FUNCTION void pm_source_free(pm_source_t *source) PRISM_NONNULL(1);
138
+
139
+ /**
140
+ * Returns the length of the source data in bytes.
141
+ *
142
+ * @param source The source to get the length of.
143
+ * @returns The length of the source data.
144
+ */
145
+ PRISM_EXPORTED_FUNCTION size_t pm_source_length(const pm_source_t *source) PRISM_NONNULL(1);
146
+
147
+ /**
148
+ * Returns a pointer to the source data.
149
+ *
150
+ * @param source The source to get the data of.
151
+ * @returns A pointer to the source data.
152
+ */
153
+ PRISM_EXPORTED_FUNCTION const uint8_t * pm_source_source(const pm_source_t *source) PRISM_NONNULL(1);
154
+
155
+ #endif
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @file stream.h
3
+ *
4
+ * Functions for parsing streams.
5
+ */
6
+ #ifndef PRISM_STREAM_H
7
+ #define PRISM_STREAM_H
8
+
9
+ #include "prism/compiler/exported.h"
10
+ #include "prism/compiler/nonnull.h"
11
+
12
+ #include "prism/arena.h"
13
+ #include "prism/options.h"
14
+ #include "prism/parser.h"
15
+ #include "prism/source.h"
16
+
17
+ /**
18
+ * Parse a stream of Ruby source and return the tree.
19
+ *
20
+ * @param parser The out parameter to write the parser to.
21
+ * @param arena The arena to use for all AST-lifetime allocations.
22
+ * @param source The source to use, created via pm_source_stream_new.
23
+ * @param options The optional options to use when parsing.
24
+ * @returns The AST representing the source.
25
+ */
26
+ PRISM_EXPORTED_FUNCTION pm_node_t * pm_parse_stream(pm_parser_t **parser, pm_arena_t *arena, pm_source_t *source, const pm_options_t *options) PRISM_NONNULL(1, 2, 3);
27
+
28
+ #endif
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @file string_query.h
3
+ *
4
+ * Functions for querying properties of strings, such as whether they are valid
5
+ * local variable names, constant names, or method names.
6
+ */
7
+ #ifndef PRISM_STRING_QUERY_H
8
+ #define PRISM_STRING_QUERY_H
9
+
10
+ #include "prism/compiler/exported.h"
11
+ #include "prism/compiler/nonnull.h"
12
+
13
+ #include <stddef.h>
14
+ #include <stdint.h>
15
+
16
+ /**
17
+ * Represents the results of a slice query.
18
+ */
19
+ typedef enum {
20
+ /** Returned if the encoding given to a slice query was invalid. */
21
+ PM_STRING_QUERY_ERROR = -1,
22
+
23
+ /** Returned if the result of the slice query is false. */
24
+ PM_STRING_QUERY_FALSE,
25
+
26
+ /** Returned if the result of the slice query is true. */
27
+ PM_STRING_QUERY_TRUE
28
+ } pm_string_query_t;
29
+
30
+ /**
31
+ * Check that the slice is a valid local variable name.
32
+ *
33
+ * @param source The source to check.
34
+ * @param length The length of the source.
35
+ * @param encoding_name The name of the encoding of the source.
36
+ * @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if
37
+ * the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid.
38
+ */
39
+ PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_local(const uint8_t *source, size_t length, const char *encoding_name) PRISM_NONNULL(1, 3);
40
+
41
+ /**
42
+ * Check that the slice is a valid constant name.
43
+ *
44
+ * @param source The source to check.
45
+ * @param length The length of the source.
46
+ * @param encoding_name The name of the encoding of the source.
47
+ * @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if
48
+ * the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid.
49
+ */
50
+ PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_constant(const uint8_t *source, size_t length, const char *encoding_name) PRISM_NONNULL(1, 3);
51
+
52
+ /**
53
+ * Check that the slice is a valid method name.
54
+ *
55
+ * @param source The source to check.
56
+ * @param length The length of the source.
57
+ * @param encoding_name The name of the encoding of the source.
58
+ * @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if
59
+ * the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid.
60
+ */
61
+ PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_method_name(const uint8_t *source, size_t length, const char *encoding_name) PRISM_NONNULL(1, 3);
62
+
63
+ #endif
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @file stringy.h
3
+ *
4
+ * A generic string type that can have various ownership semantics.
5
+ */
6
+ #ifndef PRISM_STRINGY_H
7
+ #define PRISM_STRINGY_H
8
+
9
+ #include "prism/compiler/exported.h"
10
+ #include "prism/compiler/nonnull.h"
11
+
12
+ #include <stddef.h>
13
+ #include <stdint.h>
14
+
15
+ /**
16
+ * A generic string type that can have various ownership semantics.
17
+ */
18
+ typedef struct {
19
+ /** A pointer to the start of the string. */
20
+ const uint8_t *source;
21
+
22
+ /** The length of the string in bytes of memory. */
23
+ size_t length;
24
+
25
+ /** The type of the string. This field determines how the string should be freed. */
26
+ enum {
27
+ /** This string is a constant string, and should not be freed. */
28
+ PM_STRING_CONSTANT,
29
+
30
+ /** This is a slice of another string, and should not be freed. */
31
+ PM_STRING_SHARED,
32
+
33
+ /** This string owns its memory, and should be freed internally. */
34
+ PM_STRING_OWNED
35
+ } type;
36
+ } pm_string_t;
37
+
38
+ /**
39
+ * Initialize a constant string that doesn't own its memory source.
40
+ *
41
+ * @param string The string to initialize.
42
+ * @param source The source of the string.
43
+ * @param length The length of the string.
44
+ */
45
+ PRISM_EXPORTED_FUNCTION void pm_string_constant_init(pm_string_t *string, const char *source, size_t length) PRISM_NONNULL(1);
46
+
47
+ /**
48
+ * Initialize an owned string that is responsible for freeing allocated memory.
49
+ *
50
+ * @param string The string to initialize.
51
+ * @param source The source of the string.
52
+ * @param length The length of the string.
53
+ */
54
+ PRISM_EXPORTED_FUNCTION void pm_string_owned_init(pm_string_t *string, uint8_t *source, size_t length) PRISM_NONNULL(1, 2);
55
+
56
+ /**
57
+ * Returns the length associated with the string.
58
+ *
59
+ * @param string The string to get the length of.
60
+ * @returns The length of the string.
61
+ */
62
+ PRISM_EXPORTED_FUNCTION size_t pm_string_length(const pm_string_t *string) PRISM_NONNULL(1);
63
+
64
+ /**
65
+ * Returns the start pointer associated with the string.
66
+ *
67
+ * @param string The string to get the start pointer of.
68
+ * @returns The start pointer of the string.
69
+ */
70
+ PRISM_EXPORTED_FUNCTION const uint8_t * pm_string_source(const pm_string_t *string) PRISM_NONNULL(1);
71
+
72
+ #endif
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @file version.h
3
+ *
4
+ * The version of the Prism library.
5
+ */
6
+ #ifndef PRISM_VERSION_H
7
+ #define PRISM_VERSION_H
8
+
9
+ #include "prism/compiler/exported.h"
10
+
11
+ /**
12
+ * The major version of the Prism library as an int.
13
+ */
14
+ #define PRISM_VERSION_MAJOR 1
15
+
16
+ /**
17
+ * The minor version of the Prism library as an int.
18
+ */
19
+ #define PRISM_VERSION_MINOR 9
20
+
21
+ /**
22
+ * The patch version of the Prism library as an int.
23
+ */
24
+ #define PRISM_VERSION_PATCH 0
25
+
26
+ /**
27
+ * The version of the Prism library as a constant string.
28
+ */
29
+ #define PRISM_VERSION "1.9.0"
30
+
31
+ /**
32
+ * The prism version and the serialization format.
33
+ *
34
+ * @returns The prism version as a constant string.
35
+ */
36
+ PRISM_EXPORTED_FUNCTION const char * pm_version(void);
37
+
38
+ #endif
@@ -0,0 +1,204 @@
1
+ #include "prism/prism.h"
2
+ #include "ruby/encoding.h"
3
+
4
+ /**
5
+ * the getlocal and setlocal instructions require two parameters. level is how
6
+ * many hops up the iseq stack one needs to go before finding the correct local
7
+ * table. The index is the index in that table where our variable is.
8
+ *
9
+ * Because these are always calculated and used together, we'll bind them
10
+ * together as a tuple.
11
+ */
12
+ typedef struct pm_local_index_struct {
13
+ int index, level;
14
+ } pm_local_index_t;
15
+
16
+ // A declaration for the struct that lives in compile.c.
17
+ struct iseq_link_anchor;
18
+ struct rb_code_location_struct;
19
+
20
+ /**
21
+ * A direct-indexed lookup table mapping constant IDs to local variable indices.
22
+ * Regular constant IDs (1..constants_size) index directly. Special forwarding
23
+ * parameter IDs (idMULT|FLAG, etc.) are mapped to 4 extra slots at the end.
24
+ *
25
+ * All lookups are O(1) — a single array dereference.
26
+ * The table is arena-allocated for child scopes (no explicit free needed).
27
+ */
28
+ typedef struct {
29
+ /** Array of local indices, indexed by constant_id. -1 means not present. */
30
+ int *values;
31
+
32
+ /** Total number of slots (constants_size + PM_INDEX_LOOKUP_SPECIALS). */
33
+ int capacity;
34
+
35
+ /** Whether the values array is heap-allocated and needs explicit free. */
36
+ bool owned;
37
+ } pm_index_lookup_table_t;
38
+
39
+ /** Number of extra slots for special forwarding parameter IDs. */
40
+ #define PM_INDEX_LOOKUP_SPECIALS 4
41
+
42
+ /** Slot offsets for special forwarding parameters (relative to constants_size). */
43
+ #define PM_SPECIAL_CONSTANT_FLAG ((pm_constant_id_t) (1 << 31))
44
+ #define PM_INDEX_LOOKUP_SPECIAL_MULT 0
45
+ #define PM_INDEX_LOOKUP_SPECIAL_POW 1
46
+ #define PM_INDEX_LOOKUP_SPECIAL_AND 2
47
+ #define PM_INDEX_LOOKUP_SPECIAL_DOT3 3
48
+
49
+ /**
50
+ * Special constant IDs for forwarding parameters. These use bit 31 to
51
+ * distinguish them from regular prism constant pool IDs. The lower bits
52
+ * encode which special slot (0-3) they map to in the lookup table.
53
+ */
54
+ #define PM_CONSTANT_MULT ((pm_constant_id_t) (PM_SPECIAL_CONSTANT_FLAG | PM_INDEX_LOOKUP_SPECIAL_MULT))
55
+ #define PM_CONSTANT_POW ((pm_constant_id_t) (PM_SPECIAL_CONSTANT_FLAG | PM_INDEX_LOOKUP_SPECIAL_POW))
56
+ #define PM_CONSTANT_AND ((pm_constant_id_t) (PM_SPECIAL_CONSTANT_FLAG | PM_INDEX_LOOKUP_SPECIAL_AND))
57
+ #define PM_CONSTANT_DOT3 ((pm_constant_id_t) (PM_SPECIAL_CONSTANT_FLAG | PM_INDEX_LOOKUP_SPECIAL_DOT3))
58
+
59
+ static inline int
60
+ pm_index_lookup_table_index(const pm_index_lookup_table_t *table, pm_constant_id_t key)
61
+ {
62
+ if (LIKELY(!(key & PM_SPECIAL_CONSTANT_FLAG))) {
63
+ return (int) key - 1;
64
+ }
65
+ return table->capacity - PM_INDEX_LOOKUP_SPECIALS + (int)(key & ~PM_SPECIAL_CONSTANT_FLAG);
66
+ }
67
+
68
+ static inline void
69
+ pm_index_lookup_table_insert(pm_index_lookup_table_t *table, pm_constant_id_t key, int value)
70
+ {
71
+ int idx = pm_index_lookup_table_index(table, key);
72
+ RUBY_ASSERT(idx >= 0 && idx < table->capacity);
73
+ table->values[idx] = value;
74
+ }
75
+
76
+ static inline int
77
+ pm_index_lookup_table_lookup(const pm_index_lookup_table_t *table, pm_constant_id_t key, int *value)
78
+ {
79
+ int idx = pm_index_lookup_table_index(table, key);
80
+ RUBY_ASSERT(idx >= 0 && idx < table->capacity);
81
+ if (table->values[idx] == -1) return 0;
82
+ *value = table->values[idx];
83
+ return 1;
84
+ }
85
+
86
+ static inline void
87
+ pm_index_lookup_table_init_heap(pm_index_lookup_table_t *table, int constants_size)
88
+ {
89
+ int cap = constants_size + PM_INDEX_LOOKUP_SPECIALS;
90
+ table->values = (int *) ruby_xmalloc(cap * sizeof(int));
91
+ memset(table->values, -1, cap * sizeof(int));
92
+ table->capacity = cap;
93
+ table->owned = true;
94
+ }
95
+
96
+ // ScopeNodes are helper nodes, and will never be part of the AST. We manually
97
+ // declare them here to avoid generating them.
98
+ typedef struct pm_scope_node {
99
+ pm_node_t base;
100
+ struct pm_scope_node *previous;
101
+ pm_node_t *ast_node;
102
+ pm_node_t *parameters;
103
+ pm_node_t *body;
104
+ pm_constant_id_list_t locals;
105
+
106
+ const pm_parser_t *parser;
107
+
108
+ /** The source hash of the parsed source, propagated to every iseq. */
109
+ uint64_t source_hash;
110
+ const pm_options_t *options;
111
+ const pm_line_offset_list_t *line_offsets;
112
+ int32_t start_line;
113
+ rb_encoding *encoding;
114
+
115
+ /**
116
+ * This is a pointer to the list of script lines for the ISEQs that will be
117
+ * associated with this scope node. It is only set if
118
+ * RubyVM.keep_script_lines is true. If it is set, it will be set to a
119
+ * pointer to an array that is always stack allocated (so no GC marking is
120
+ * needed by this struct). If it is not set, it will be NULL. It is
121
+ * inherited by all child scopes.
122
+ */
123
+ VALUE *script_lines;
124
+
125
+ /**
126
+ * This is the encoding of the actual filepath object that will be used when
127
+ * a __FILE__ node is compiled or when the path has to be set on a syntax
128
+ * error.
129
+ */
130
+ rb_encoding *filepath_encoding;
131
+
132
+ // The size of the local table on the iseq which includes locals and hidden
133
+ // variables.
134
+ int local_table_for_iseq_size;
135
+
136
+ ID *constants;
137
+
138
+ /**
139
+ * A flat lookup table mapping constant IDs (or special IDs) to local
140
+ * variable indices. When allocated from the compile data arena (child
141
+ * scopes), no explicit free is needed. When heap-allocated (top-level
142
+ * scope in pm_parse_process), owned is set to true so destroy can free it.
143
+ */
144
+ pm_index_lookup_table_t index_lookup_table;
145
+
146
+ // The current coverage setting, passed down through the various scopes.
147
+ int coverage_enabled;
148
+
149
+ /**
150
+ * This will only be set on the top-level scope node. It will contain all of
151
+ * the instructions pertaining to BEGIN{} nodes.
152
+ */
153
+ struct iseq_link_anchor *pre_execution_anchor;
154
+
155
+ /**
156
+ * Cached line hint for line offset list lookups. Since the compiler walks
157
+ * the AST roughly in source order, consecutive lookups tend to be for
158
+ * nearby byte offsets. This avoids repeated binary searches.
159
+ */
160
+ size_t last_line;
161
+ } pm_scope_node_t;
162
+
163
+ void pm_scope_node_init(const pm_node_t *node, pm_scope_node_t *scope, pm_scope_node_t *previous);
164
+ void pm_scope_node_destroy(pm_scope_node_t *scope_node);
165
+
166
+ typedef struct {
167
+ /** The arena allocator for AST-lifetime memory. */
168
+ pm_arena_t *arena;
169
+
170
+ /** The parser that will do the actual parsing. */
171
+ pm_parser_t *parser;
172
+
173
+ /** The options that will be passed to the parser. */
174
+ pm_options_t *options;
175
+
176
+ /** The source backing the parse (file, string, or stream). */
177
+ pm_source_t *source;
178
+
179
+ /** The resulting scope node that will hold the generated AST. */
180
+ pm_scope_node_t node;
181
+
182
+ /** Whether or not this parse result has performed its parsing yet. */
183
+ bool parsed;
184
+ } pm_parse_result_t;
185
+
186
+ void pm_parse_result_init(pm_parse_result_t *result);
187
+ VALUE pm_load_file(pm_parse_result_t *result, VALUE filepath, bool load_error);
188
+ VALUE pm_parse_file(pm_parse_result_t *result, VALUE filepath, VALUE *script_lines);
189
+ VALUE pm_load_parse_file(pm_parse_result_t *result, VALUE filepath, VALUE *script_lines);
190
+ VALUE pm_parse_string(pm_parse_result_t *result, VALUE source, VALUE filepath, VALUE *script_lines);
191
+ VALUE pm_parse_stdin(pm_parse_result_t *result);
192
+ void pm_options_version_for_current_ruby_set(pm_options_t *options);
193
+ void pm_parse_result_free(pm_parse_result_t *result);
194
+ bool pm_node_source_location(VALUE source, VALUE filepath, int start_line,
195
+ int node_id, struct rb_code_location_struct *location);
196
+
197
+ rb_iseq_t *pm_iseq_new(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, enum rb_iseq_type, int *error_state);
198
+ rb_iseq_t *pm_iseq_new_top(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, int *error_state);
199
+ rb_iseq_t *pm_iseq_new_main(pm_scope_node_t *node, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt, int *error_state);
200
+ rb_iseq_t *pm_iseq_new_eval(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth, int *error_state);
201
+ rb_iseq_t *pm_iseq_new_with_opt(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth, enum rb_iseq_type, const rb_compile_option_t *option, int *error_state);
202
+ rb_iseq_t *pm_iseq_build(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth, enum rb_iseq_type, const rb_compile_option_t *option);
203
+
204
+ VALUE pm_iseq_compile_node(rb_iseq_t *iseq, pm_scope_node_t *node);