debase-ruby_core_source 0.10.12 → 0.10.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/addr2line.h +20 -0
  3. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/builtin.h +83 -0
  4. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/ccan/build_assert/build_assert.h +40 -0
  5. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/ccan/check_type/check_type.h +63 -0
  6. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/ccan/container_of/container_of.h +142 -0
  7. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/ccan/list/list.h +788 -0
  8. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/ccan/str/str.h +16 -0
  9. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/constant.h +55 -0
  10. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/darray.h +198 -0
  11. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/debug_counter.h +467 -0
  12. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/dln.h +31 -0
  13. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/encindex.h +70 -0
  14. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/eval_intern.h +304 -0
  15. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/gc.h +142 -0
  16. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/hrtime.h +168 -0
  17. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/id.h +293 -0
  18. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/id_table.h +36 -0
  19. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/insns.inc +247 -0
  20. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/insns_info.inc +8978 -0
  21. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/array.h +113 -0
  22. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/bignum.h +246 -0
  23. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/bits.h +565 -0
  24. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/class.h +188 -0
  25. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/compar.h +49 -0
  26. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/compile.h +35 -0
  27. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/compilers.h +107 -0
  28. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/complex.h +29 -0
  29. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/cont.h +24 -0
  30. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/dir.h +16 -0
  31. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/enc.h +19 -0
  32. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/encoding.h +30 -0
  33. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/enum.h +18 -0
  34. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/enumerator.h +21 -0
  35. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/error.h +191 -0
  36. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/eval.h +32 -0
  37. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/file.h +38 -0
  38. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/fixnum.h +184 -0
  39. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/gc.h +175 -0
  40. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/hash.h +243 -0
  41. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/imemo.h +243 -0
  42. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/inits.h +50 -0
  43. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/io.h +38 -0
  44. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/load.h +18 -0
  45. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/loadpath.h +16 -0
  46. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/math.h +23 -0
  47. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/missing.h +18 -0
  48. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/numeric.h +271 -0
  49. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/object.h +83 -0
  50. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/parse.h +23 -0
  51. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/proc.h +32 -0
  52. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/process.h +137 -0
  53. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/random.h +16 -0
  54. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/range.h +40 -0
  55. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/rational.h +72 -0
  56. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/re.h +30 -0
  57. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/sanitizers.h +190 -0
  58. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/serial.h +23 -0
  59. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/signal.h +21 -0
  60. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/static_assert.h +16 -0
  61. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/string.h +141 -0
  62. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/struct.h +153 -0
  63. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/symbol.h +40 -0
  64. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/thread.h +53 -0
  65. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/time.h +34 -0
  66. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/transcode.h +20 -0
  67. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/util.h +27 -0
  68. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/variable.h +83 -0
  69. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/vm.h +132 -0
  70. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/warnings.h +16 -0
  71. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal.h +109 -0
  72. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/iseq.h +320 -0
  73. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/known_errors.inc +791 -0
  74. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/method.h +245 -0
  75. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/mjit.h +231 -0
  76. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/mjit_compile.inc +8265 -0
  77. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/node.h +499 -0
  78. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/node_name.inc +210 -0
  79. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/opt_sc.inc +107 -0
  80. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/optinsn.inc +128 -0
  81. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/optunifs.inc +43 -0
  82. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/parse.h +214 -0
  83. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/probes_helper.h +44 -0
  84. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/ractor_core.h +346 -0
  85. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/regenc.h +254 -0
  86. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/regint.h +942 -0
  87. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/regparse.h +370 -0
  88. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/revision.h +2 -0
  89. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/ruby_assert.h +14 -0
  90. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/ruby_atomic.h +23 -0
  91. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/siphash.h +48 -0
  92. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/symbol.h +119 -0
  93. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/thread_pthread.h +115 -0
  94. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/thread_win32.h +61 -0
  95. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/timev.h +57 -0
  96. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/transcode_data.h +138 -0
  97. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/transient_heap.h +65 -0
  98. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/variable.h +21 -0
  99. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/version.h +88 -0
  100. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm.inc +5415 -0
  101. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm_call_iseq_optimized.inc +244 -0
  102. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm_callinfo.h +454 -0
  103. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm_core.h +2103 -0
  104. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm_debug.h +119 -0
  105. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm_exec.h +197 -0
  106. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm_insnhelper.h +265 -0
  107. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm_opts.h +73 -0
  108. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm_sync.h +137 -0
  109. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vmtc.inc +241 -0
  110. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/yjit.h +63 -0
  111. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/yjit_asm.h +392 -0
  112. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/yjit_codegen.h +19 -0
  113. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/yjit_core.h +302 -0
  114. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/yjit_iface.h +38 -0
  115. data/lib/debase/ruby_core_source/version.rb +1 -1
  116. metadata +116 -3
@@ -0,0 +1,243 @@
1
+ #ifndef INTERNAL_HASH_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_HASH_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header for Hash.
10
+ */
11
+ #include "ruby/internal/config.h"
12
+ #include <stddef.h> /* for size_t */
13
+ #include "ruby/internal/stdbool.h" /* for bool */
14
+ #include "ruby/ruby.h" /* for struct RBasic */
15
+ #include "ruby/st.h" /* for struct st_table */
16
+
17
+ #define RHASH_AR_TABLE_MAX_SIZE SIZEOF_VALUE
18
+
19
+ struct ar_table_struct;
20
+ typedef unsigned char ar_hint_t;
21
+
22
+ enum ruby_rhash_flags {
23
+ RHASH_PASS_AS_KEYWORDS = FL_USER1, /* FL 1 */
24
+ RHASH_PROC_DEFAULT = FL_USER2, /* FL 2 */
25
+ RHASH_ST_TABLE_FLAG = FL_USER3, /* FL 3 */
26
+ RHASH_AR_TABLE_SIZE_MASK = (FL_USER4|FL_USER5|FL_USER6|FL_USER7), /* FL 4..7 */
27
+ RHASH_AR_TABLE_SIZE_SHIFT = (FL_USHIFT+4),
28
+ RHASH_AR_TABLE_BOUND_MASK = (FL_USER8|FL_USER9|FL_USER10|FL_USER11), /* FL 8..11 */
29
+ RHASH_AR_TABLE_BOUND_SHIFT = (FL_USHIFT+8),
30
+
31
+ #if USE_TRANSIENT_HEAP
32
+ RHASH_TRANSIENT_FLAG = FL_USER12, /* FL 12 */
33
+ #endif
34
+
35
+ // we can not put it in "enum" because it can exceed "int" range.
36
+ #define RHASH_LEV_MASK (FL_USER13 | FL_USER14 | FL_USER15 | /* FL 13..19 */ \
37
+ FL_USER16 | FL_USER17 | FL_USER18 | FL_USER19)
38
+
39
+ RHASH_LEV_SHIFT = (FL_USHIFT + 13),
40
+ RHASH_LEV_MAX = 127, /* 7 bits */
41
+ };
42
+
43
+ struct RHash {
44
+ struct RBasic basic;
45
+ union {
46
+ st_table *st;
47
+ struct ar_table_struct *ar; /* possibly 0 */
48
+ } as;
49
+ const VALUE ifnone;
50
+ union {
51
+ ar_hint_t ary[RHASH_AR_TABLE_MAX_SIZE];
52
+ VALUE word;
53
+ } ar_hint;
54
+ };
55
+
56
+ #define RHASH(obj) ((struct RHash *)(obj))
57
+
58
+ #ifdef RHASH_IFNONE
59
+ # undef RHASH_IFNONE
60
+ #endif
61
+
62
+ #ifdef RHASH_SIZE
63
+ # undef RHASH_SIZE
64
+ #endif
65
+
66
+ #ifdef RHASH_EMPTY_P
67
+ # undef RHASH_EMPTY_P
68
+ #endif
69
+
70
+ /* hash.c */
71
+ void rb_hash_st_table_set(VALUE hash, st_table *st);
72
+ VALUE rb_hash_default_value(VALUE hash, VALUE key);
73
+ VALUE rb_hash_set_default_proc(VALUE hash, VALUE proc);
74
+ long rb_dbl_long_hash(double d);
75
+ st_table *rb_init_identtable(void);
76
+ VALUE rb_to_hash_type(VALUE obj);
77
+ VALUE rb_hash_key_str(VALUE);
78
+ VALUE rb_hash_values(VALUE hash);
79
+ VALUE rb_hash_rehash(VALUE hash);
80
+ int rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val);
81
+ VALUE rb_hash_set_pair(VALUE hash, VALUE pair);
82
+ int rb_hash_stlike_delete(VALUE hash, st_data_t *pkey, st_data_t *pval);
83
+ int rb_hash_stlike_foreach_with_replace(VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg);
84
+ int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func *func, st_data_t arg);
85
+ extern st_table *rb_hash_st_table(VALUE hash);
86
+ VALUE rb_ident_hash_new_with_size(st_index_t size);
87
+
88
+ static inline unsigned RHASH_AR_TABLE_SIZE_RAW(VALUE h);
89
+ static inline VALUE RHASH_IFNONE(VALUE h);
90
+ static inline size_t RHASH_SIZE(VALUE h);
91
+ static inline bool RHASH_EMPTY_P(VALUE h);
92
+ static inline bool RHASH_AR_TABLE_P(VALUE h);
93
+ static inline bool RHASH_ST_TABLE_P(VALUE h);
94
+ static inline struct ar_table_struct *RHASH_AR_TABLE(VALUE h);
95
+ static inline st_table *RHASH_ST_TABLE(VALUE h);
96
+ static inline size_t RHASH_ST_SIZE(VALUE h);
97
+ static inline void RHASH_ST_CLEAR(VALUE h);
98
+ static inline bool RHASH_TRANSIENT_P(VALUE h);
99
+ static inline void RHASH_SET_TRANSIENT_FLAG(VALUE h);
100
+ static inline void RHASH_UNSET_TRANSIENT_FLAG(VALUE h);
101
+
102
+ RUBY_SYMBOL_EXPORT_BEGIN
103
+ /* hash.c (export) */
104
+ VALUE rb_hash_delete_entry(VALUE hash, VALUE key);
105
+ VALUE rb_ident_hash_new(void);
106
+ int rb_hash_stlike_foreach(VALUE hash, st_foreach_callback_func *func, st_data_t arg);
107
+ RUBY_SYMBOL_EXPORT_END
108
+
109
+ MJIT_SYMBOL_EXPORT_BEGIN
110
+ VALUE rb_hash_new_with_size(st_index_t size);
111
+ VALUE rb_hash_resurrect(VALUE hash);
112
+ int rb_hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval);
113
+ VALUE rb_hash_keys(VALUE hash);
114
+ VALUE rb_hash_has_key(VALUE hash, VALUE key);
115
+ VALUE rb_hash_compare_by_id_p(VALUE hash);
116
+
117
+ st_table *rb_hash_tbl_raw(VALUE hash, const char *file, int line);
118
+ #define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h, __FILE__, __LINE__)
119
+ MJIT_SYMBOL_EXPORT_END
120
+
121
+ VALUE rb_hash_compare_by_id(VALUE hash);
122
+
123
+ #if 0 /* for debug */
124
+
125
+ static inline bool
126
+ RHASH_AR_TABLE_P(VALUE h)
127
+ {
128
+ extern int rb_hash_ar_table_p(VALUE hash);
129
+ return rb_hash_ar_table_p(h)
130
+ }
131
+
132
+ static inline struct ar_table_struct *
133
+ RHASH_AR_TABLE(VALUE h)
134
+ {
135
+ extern struct ar_table_struct *rb_hash_ar_table(VALUE hash);
136
+ return rb_hash_ar_table(h)
137
+ }
138
+
139
+ static inline st_table *
140
+ RHASH_ST_TABLE(VALUE h)
141
+ {
142
+ return rb_hash_st_table(h)
143
+ }
144
+
145
+ #else
146
+
147
+ static inline bool
148
+ RHASH_AR_TABLE_P(VALUE h)
149
+ {
150
+ return ! FL_TEST_RAW(h, RHASH_ST_TABLE_FLAG);
151
+ }
152
+
153
+ static inline struct ar_table_struct *
154
+ RHASH_AR_TABLE(VALUE h)
155
+ {
156
+ return RHASH(h)->as.ar;
157
+ }
158
+
159
+ static inline st_table *
160
+ RHASH_ST_TABLE(VALUE h)
161
+ {
162
+ return RHASH(h)->as.st;
163
+ }
164
+
165
+ #endif
166
+
167
+ static inline VALUE
168
+ RHASH_IFNONE(VALUE h)
169
+ {
170
+ return RHASH(h)->ifnone;
171
+ }
172
+
173
+ static inline size_t
174
+ RHASH_SIZE(VALUE h)
175
+ {
176
+ if (RHASH_AR_TABLE_P(h)) {
177
+ return RHASH_AR_TABLE_SIZE_RAW(h);
178
+ }
179
+ else {
180
+ return RHASH_ST_SIZE(h);
181
+ }
182
+ }
183
+
184
+ static inline bool
185
+ RHASH_EMPTY_P(VALUE h)
186
+ {
187
+ return RHASH_SIZE(h) == 0;
188
+ }
189
+
190
+ static inline bool
191
+ RHASH_ST_TABLE_P(VALUE h)
192
+ {
193
+ return ! RHASH_AR_TABLE_P(h);
194
+ }
195
+
196
+ static inline size_t
197
+ RHASH_ST_SIZE(VALUE h)
198
+ {
199
+ return RHASH_ST_TABLE(h)->num_entries;
200
+ }
201
+
202
+ static inline void
203
+ RHASH_ST_CLEAR(VALUE h)
204
+ {
205
+ FL_UNSET_RAW(h, RHASH_ST_TABLE_FLAG);
206
+ RHASH(h)->as.ar = NULL;
207
+ }
208
+
209
+ static inline unsigned
210
+ RHASH_AR_TABLE_SIZE_RAW(VALUE h)
211
+ {
212
+ VALUE ret = FL_TEST_RAW(h, RHASH_AR_TABLE_SIZE_MASK);
213
+ ret >>= RHASH_AR_TABLE_SIZE_SHIFT;
214
+ return (unsigned)ret;
215
+ }
216
+
217
+ static inline bool
218
+ RHASH_TRANSIENT_P(VALUE h)
219
+ {
220
+ #if USE_TRANSIENT_HEAP
221
+ return FL_TEST_RAW(h, RHASH_TRANSIENT_FLAG);
222
+ #else
223
+ return false;
224
+ #endif
225
+ }
226
+
227
+ static inline void
228
+ RHASH_SET_TRANSIENT_FLAG(VALUE h)
229
+ {
230
+ #if USE_TRANSIENT_HEAP
231
+ FL_SET_RAW(h, RHASH_TRANSIENT_FLAG);
232
+ #endif
233
+ }
234
+
235
+ static inline void
236
+ RHASH_UNSET_TRANSIENT_FLAG(VALUE h)
237
+ {
238
+ #if USE_TRANSIENT_HEAP
239
+ FL_UNSET_RAW(h, RHASH_TRANSIENT_FLAG);
240
+ #endif
241
+ }
242
+
243
+ #endif /* INTERNAL_HASH_H */
@@ -0,0 +1,243 @@
1
+ #ifndef INTERNAL_IMEMO_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_IMEMO_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief IMEMO: Internal memo object.
10
+ */
11
+ #include "ruby/internal/config.h"
12
+ #include <stddef.h> /* for size_t */
13
+ #include "internal/array.h" /* for rb_ary_tmp_new_fill */
14
+ #include "internal/gc.h" /* for RB_OBJ_WRITE */
15
+ #include "ruby/internal/stdbool.h" /* for bool */
16
+ #include "ruby/ruby.h" /* for rb_block_call_func_t */
17
+
18
+ #ifndef IMEMO_DEBUG
19
+ # define IMEMO_DEBUG 0
20
+ #endif
21
+
22
+ #define IMEMO_MASK 0x0f
23
+
24
+ /* FL_USER0 to FL_USER3 is for type */
25
+ #define IMEMO_FL_USHIFT (FL_USHIFT + 4)
26
+ #define IMEMO_FL_USER0 FL_USER4
27
+ #define IMEMO_FL_USER1 FL_USER5
28
+ #define IMEMO_FL_USER2 FL_USER6
29
+ #define IMEMO_FL_USER3 FL_USER7
30
+ #define IMEMO_FL_USER4 FL_USER8
31
+ #define IMEMO_FL_USER5 FL_USER9
32
+
33
+ enum imemo_type {
34
+ imemo_env = 0,
35
+ imemo_cref = 1, /*!< class reference */
36
+ imemo_svar = 2, /*!< special variable */
37
+ imemo_throw_data = 3,
38
+ imemo_ifunc = 4, /*!< iterator function */
39
+ imemo_memo = 5,
40
+ imemo_ment = 6,
41
+ imemo_iseq = 7,
42
+ imemo_tmpbuf = 8,
43
+ imemo_ast = 9,
44
+ imemo_parser_strterm = 10,
45
+ imemo_callinfo = 11,
46
+ imemo_callcache = 12,
47
+ imemo_constcache = 13,
48
+ };
49
+
50
+ /* CREF (Class REFerence) is defined in method.h */
51
+
52
+ /*! SVAR (Special VARiable) */
53
+ struct vm_svar {
54
+ VALUE flags;
55
+ const VALUE cref_or_me; /*!< class reference or rb_method_entry_t */
56
+ const VALUE lastline;
57
+ const VALUE backref;
58
+ const VALUE others;
59
+ };
60
+
61
+ /*! THROW_DATA */
62
+ struct vm_throw_data {
63
+ VALUE flags;
64
+ VALUE reserved;
65
+ const VALUE throw_obj;
66
+ const struct rb_control_frame_struct *catch_frame;
67
+ int throw_state;
68
+ };
69
+
70
+ #define THROW_DATA_CONSUMED IMEMO_FL_USER0
71
+
72
+ /* IFUNC (Internal FUNCtion) */
73
+
74
+ struct vm_ifunc_argc {
75
+ #if SIZEOF_INT * 2 > SIZEOF_VALUE
76
+ signed int min: (SIZEOF_VALUE * CHAR_BIT) / 2;
77
+ signed int max: (SIZEOF_VALUE * CHAR_BIT) / 2;
78
+ #else
79
+ int min, max;
80
+ #endif
81
+ };
82
+
83
+ /*! IFUNC (Internal FUNCtion) */
84
+ struct vm_ifunc {
85
+ VALUE flags;
86
+ VALUE reserved;
87
+ rb_block_call_func_t func;
88
+ const void *data;
89
+ struct vm_ifunc_argc argc;
90
+ };
91
+
92
+ struct rb_imemo_tmpbuf_struct {
93
+ VALUE flags;
94
+ VALUE reserved;
95
+ VALUE *ptr; /* malloc'ed buffer */
96
+ struct rb_imemo_tmpbuf_struct *next; /* next imemo */
97
+ size_t cnt; /* buffer size in VALUE */
98
+ };
99
+
100
+ /*! MEMO
101
+ *
102
+ * @see imemo_type
103
+ * */
104
+ struct MEMO {
105
+ VALUE flags;
106
+ VALUE reserved;
107
+ const VALUE v1;
108
+ const VALUE v2;
109
+ union {
110
+ long cnt;
111
+ long state;
112
+ const VALUE value;
113
+ void (*func)(void);
114
+ } u3;
115
+ };
116
+
117
+ /* ment is in method.h */
118
+
119
+ #define THROW_DATA_P(err) imemo_throw_data_p((VALUE)err)
120
+ #define MEMO_CAST(m) ((struct MEMO *)(m))
121
+ #define MEMO_NEW(a, b, c) ((struct MEMO *)rb_imemo_new(imemo_memo, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0))
122
+ #define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
123
+ #define NEW_MEMO_FOR(type, value) \
124
+ ((value) = rb_ary_tmp_new_fill(type_roomof(type, VALUE)), MEMO_FOR(type, value))
125
+ #define NEW_PARTIAL_MEMO_FOR(type, value, member) \
126
+ ((value) = rb_ary_tmp_new_fill(type_roomof(type, VALUE)), \
127
+ rb_ary_set_len((value), offsetof(type, member) / sizeof(VALUE)), \
128
+ MEMO_FOR(type, value))
129
+
130
+ typedef struct rb_imemo_tmpbuf_struct rb_imemo_tmpbuf_t;
131
+ VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0);
132
+ rb_imemo_tmpbuf_t *rb_imemo_tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt);
133
+ struct vm_ifunc *rb_vm_ifunc_new(rb_block_call_func_t func, const void *data, int min_argc, int max_argc);
134
+ void rb_strterm_mark(VALUE obj);
135
+ static inline enum imemo_type imemo_type(VALUE imemo);
136
+ static inline int imemo_type_p(VALUE imemo, enum imemo_type imemo_type);
137
+ static inline bool imemo_throw_data_p(VALUE imemo);
138
+ static inline struct vm_ifunc *rb_vm_ifunc_proc_new(rb_block_call_func_t func, const void *data);
139
+ static inline VALUE rb_imemo_tmpbuf_auto_free_pointer(void);
140
+ static inline void *RB_IMEMO_TMPBUF_PTR(VALUE v);
141
+ static inline void *rb_imemo_tmpbuf_set_ptr(VALUE v, void *ptr);
142
+ static inline VALUE rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(VALUE str);
143
+ static inline void MEMO_V1_SET(struct MEMO *m, VALUE v);
144
+ static inline void MEMO_V2_SET(struct MEMO *m, VALUE v);
145
+
146
+ RUBY_SYMBOL_EXPORT_BEGIN
147
+ #if IMEMO_DEBUG
148
+ VALUE rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0, const char *file, int line);
149
+ #define rb_imemo_new(type, v1, v2, v3, v0) rb_imemo_new_debug(type, v1, v2, v3, v0, __FILE__, __LINE__)
150
+ #else
151
+ VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0);
152
+ #endif
153
+ const char *rb_imemo_name(enum imemo_type type);
154
+ RUBY_SYMBOL_EXPORT_END
155
+
156
+ static inline enum imemo_type
157
+ imemo_type(VALUE imemo)
158
+ {
159
+ return (RBASIC(imemo)->flags >> FL_USHIFT) & IMEMO_MASK;
160
+ }
161
+
162
+ static inline int
163
+ imemo_type_p(VALUE imemo, enum imemo_type imemo_type)
164
+ {
165
+ if (LIKELY(!RB_SPECIAL_CONST_P(imemo))) {
166
+ /* fixed at compile time if imemo_type is given. */
167
+ const VALUE mask = (IMEMO_MASK << FL_USHIFT) | RUBY_T_MASK;
168
+ const VALUE expected_type = (imemo_type << FL_USHIFT) | T_IMEMO;
169
+ /* fixed at runtime. */
170
+ return expected_type == (RBASIC(imemo)->flags & mask);
171
+ }
172
+ else {
173
+ return 0;
174
+ }
175
+ }
176
+
177
+ #define IMEMO_TYPE_P(v, t) imemo_type_p((VALUE)v, t)
178
+
179
+ static inline bool
180
+ imemo_throw_data_p(VALUE imemo)
181
+ {
182
+ return RB_TYPE_P(imemo, T_IMEMO);
183
+ }
184
+
185
+ static inline struct vm_ifunc *
186
+ rb_vm_ifunc_proc_new(rb_block_call_func_t func, const void *data)
187
+ {
188
+ return rb_vm_ifunc_new(func, data, 0, UNLIMITED_ARGUMENTS);
189
+ }
190
+
191
+ static inline VALUE
192
+ rb_imemo_tmpbuf_auto_free_pointer(void)
193
+ {
194
+ return rb_imemo_new(imemo_tmpbuf, 0, 0, 0, 0);
195
+ }
196
+
197
+ static inline void *
198
+ RB_IMEMO_TMPBUF_PTR(VALUE v)
199
+ {
200
+ const struct rb_imemo_tmpbuf_struct *p = (const void *)v;
201
+ return p->ptr;
202
+ }
203
+
204
+ static inline void *
205
+ rb_imemo_tmpbuf_set_ptr(VALUE v, void *ptr)
206
+ {
207
+ return ((rb_imemo_tmpbuf_t *)v)->ptr = ptr;
208
+ }
209
+
210
+ static inline VALUE
211
+ rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(VALUE str)
212
+ {
213
+ const void *src;
214
+ VALUE imemo;
215
+ rb_imemo_tmpbuf_t *tmpbuf;
216
+ void *dst;
217
+ size_t len;
218
+
219
+ SafeStringValue(str);
220
+ /* create tmpbuf to keep the pointer before xmalloc */
221
+ imemo = rb_imemo_tmpbuf_auto_free_pointer();
222
+ tmpbuf = (rb_imemo_tmpbuf_t *)imemo;
223
+ len = RSTRING_LEN(str);
224
+ src = RSTRING_PTR(str);
225
+ dst = ruby_xmalloc(len);
226
+ memcpy(dst, src, len);
227
+ tmpbuf->ptr = dst;
228
+ return imemo;
229
+ }
230
+
231
+ static inline void
232
+ MEMO_V1_SET(struct MEMO *m, VALUE v)
233
+ {
234
+ RB_OBJ_WRITE(m, &m->v1, v);
235
+ }
236
+
237
+ static inline void
238
+ MEMO_V2_SET(struct MEMO *m, VALUE v)
239
+ {
240
+ RB_OBJ_WRITE(m, &m->v2, v);
241
+ }
242
+
243
+ #endif /* INTERNAL_IMEMO_H */
@@ -0,0 +1,50 @@
1
+ #ifndef INTERNAL_INITS_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_INITS_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header aggregating init functions.
10
+ */
11
+
12
+ /* class.c */
13
+ void Init_class_hierarchy(void);
14
+
15
+ /* dmyext.c */
16
+ void Init_enc(void);
17
+ void Init_ext(void);
18
+
19
+ /* file.c */
20
+ void Init_File(void);
21
+
22
+ /* gc.c */
23
+ void Init_heap(void);
24
+
25
+ /* localeinit.c */
26
+ int Init_enc_set_filesystem_encoding(void);
27
+
28
+ /* newline.c */
29
+ void Init_newline(void);
30
+
31
+ /* vm.c */
32
+ void Init_BareVM(void);
33
+ void Init_vm_objects(void);
34
+
35
+ /* vm_backtrace.c */
36
+ void Init_vm_backtrace(void);
37
+
38
+ /* vm_eval.c */
39
+ void Init_vm_eval(void);
40
+
41
+ /* vm_insnhelper.c */
42
+ void Init_vm_stack_canary(void);
43
+
44
+ /* vm_method.c */
45
+ void Init_eval_method(void);
46
+
47
+ /* inits.c */
48
+ void rb_call_inits(void);
49
+
50
+ #endif /* INTERNAL_INITS_H */
@@ -0,0 +1,38 @@
1
+ #ifndef INTERNAL_IO_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_IO_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header for IO.
10
+ */
11
+ #include "ruby/ruby.h" /* for VALUE */
12
+ #include "ruby/io.h" /* for rb_io_t */
13
+
14
+ /* io.c */
15
+ void ruby_set_inplace_mode(const char *);
16
+ void rb_stdio_set_default_encoding(void);
17
+ VALUE rb_io_flush_raw(VALUE, int);
18
+ size_t rb_io_memsize(const rb_io_t *);
19
+ int rb_stderr_tty_p(void);
20
+ void rb_io_fptr_finalize_internal(void *ptr);
21
+ #ifdef rb_io_fptr_finalize
22
+ # undef rb_io_fptr_finalize
23
+ #endif
24
+ #define rb_io_fptr_finalize rb_io_fptr_finalize_internal
25
+ VALUE rb_io_popen(VALUE pname, VALUE pmode, VALUE env, VALUE opt);
26
+
27
+ VALUE rb_io_prep_stdin(void);
28
+ VALUE rb_io_prep_stdout(void);
29
+ VALUE rb_io_prep_stderr(void);
30
+
31
+ RUBY_SYMBOL_EXPORT_BEGIN
32
+ /* io.c (export) */
33
+ void rb_maygvl_fd_fix_cloexec(int fd);
34
+ int rb_gc_for_fd(int err);
35
+ void rb_write_error_str(VALUE mesg);
36
+ RUBY_SYMBOL_EXPORT_END
37
+
38
+ #endif /* INTERNAL_IO_H */
@@ -0,0 +1,18 @@
1
+ #ifndef INTERNAL_LOAD_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_LOAD_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header for require.
10
+ */
11
+ #include "ruby/ruby.h" /* for VALUE */
12
+
13
+ /* load.c */
14
+ VALUE rb_get_expanded_load_path(void);
15
+ int rb_require_internal(VALUE fname);
16
+ NORETURN(void rb_load_fail(VALUE, const char*));
17
+
18
+ #endif /* INTERNAL_LOAD_H */
@@ -0,0 +1,16 @@
1
+ #ifndef INTERNAL_LOADPATH_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_LOADPATH_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header for $LOAD_PATH.
10
+ */
11
+
12
+ /* loadpath.c */
13
+ extern const char ruby_exec_prefix[];
14
+ extern const char ruby_initial_load_paths[];
15
+
16
+ #endif /* INTERNAL_LOADPATH_H */
@@ -0,0 +1,23 @@
1
+ #ifndef INTERNAL_MATH_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_MATH_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header for Math.
10
+ */
11
+ #include "ruby/ruby.h" /* for VALUE */
12
+
13
+ /* math.c */
14
+ VALUE rb_math_atan2(VALUE, VALUE);
15
+ VALUE rb_math_cos(VALUE);
16
+ VALUE rb_math_cosh(VALUE);
17
+ VALUE rb_math_exp(VALUE);
18
+ VALUE rb_math_hypot(VALUE, VALUE);
19
+ VALUE rb_math_log(int argc, const VALUE *argv);
20
+ VALUE rb_math_sin(VALUE);
21
+ VALUE rb_math_sinh(VALUE);
22
+
23
+ #endif /* INTERNAL_MATH_H */
@@ -0,0 +1,18 @@
1
+ #ifndef INTERNAL_MISSING_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_MISSING_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header corresponding missing.
10
+ */
11
+ #include "ruby/internal/config.h" /* for HAVE_SETPROCTITLE */
12
+
13
+ /* missing/setproctitle.c */
14
+ #ifndef HAVE_SETPROCTITLE
15
+ extern void ruby_init_setproctitle(int argc, char *argv[]);
16
+ #endif
17
+
18
+ #endif /* INTERNAL_MISSING_H */