kanayago 0.1.1

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 (74) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +15 -0
  3. data/.rubocop_todo.yml +23 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +79 -0
  6. data/Rakefile +182 -0
  7. data/ext/kanayago/ccan/check_type/check_type.h +63 -0
  8. data/ext/kanayago/ccan/container_of/container_of.h +142 -0
  9. data/ext/kanayago/ccan/list/list.h +791 -0
  10. data/ext/kanayago/ccan/str/str.h +17 -0
  11. data/ext/kanayago/constant.h +53 -0
  12. data/ext/kanayago/extconf.rb +21 -0
  13. data/ext/kanayago/id.h +347 -0
  14. data/ext/kanayago/id_table.h +39 -0
  15. data/ext/kanayago/internal/array.h +151 -0
  16. data/ext/kanayago/internal/basic_operators.h +64 -0
  17. data/ext/kanayago/internal/bignum.h +244 -0
  18. data/ext/kanayago/internal/bits.h +568 -0
  19. data/ext/kanayago/internal/compile.h +34 -0
  20. data/ext/kanayago/internal/compilers.h +107 -0
  21. data/ext/kanayago/internal/complex.h +29 -0
  22. data/ext/kanayago/internal/encoding.h +36 -0
  23. data/ext/kanayago/internal/error.h +218 -0
  24. data/ext/kanayago/internal/fixnum.h +184 -0
  25. data/ext/kanayago/internal/gc.h +322 -0
  26. data/ext/kanayago/internal/hash.h +191 -0
  27. data/ext/kanayago/internal/imemo.h +261 -0
  28. data/ext/kanayago/internal/io.h +140 -0
  29. data/ext/kanayago/internal/numeric.h +274 -0
  30. data/ext/kanayago/internal/parse.h +117 -0
  31. data/ext/kanayago/internal/rational.h +71 -0
  32. data/ext/kanayago/internal/re.h +28 -0
  33. data/ext/kanayago/internal/ruby_parser.h +125 -0
  34. data/ext/kanayago/internal/sanitizers.h +297 -0
  35. data/ext/kanayago/internal/serial.h +23 -0
  36. data/ext/kanayago/internal/static_assert.h +16 -0
  37. data/ext/kanayago/internal/string.h +186 -0
  38. data/ext/kanayago/internal/symbol.h +45 -0
  39. data/ext/kanayago/internal/thread.h +79 -0
  40. data/ext/kanayago/internal/variable.h +72 -0
  41. data/ext/kanayago/internal/vm.h +137 -0
  42. data/ext/kanayago/internal/warnings.h +16 -0
  43. data/ext/kanayago/internal.h +108 -0
  44. data/ext/kanayago/kanayago.c +420 -0
  45. data/ext/kanayago/kanayago.h +21 -0
  46. data/ext/kanayago/lex.c +302 -0
  47. data/ext/kanayago/method.h +255 -0
  48. data/ext/kanayago/node.c +440 -0
  49. data/ext/kanayago/node.h +111 -0
  50. data/ext/kanayago/node_name.inc +224 -0
  51. data/ext/kanayago/parse.c +26931 -0
  52. data/ext/kanayago/parse.h +244 -0
  53. data/ext/kanayago/parse.tmp.y +16145 -0
  54. data/ext/kanayago/parser_bits.h +564 -0
  55. data/ext/kanayago/parser_node.h +32 -0
  56. data/ext/kanayago/parser_st.c +164 -0
  57. data/ext/kanayago/parser_st.h +162 -0
  58. data/ext/kanayago/parser_value.h +106 -0
  59. data/ext/kanayago/probes.h +4 -0
  60. data/ext/kanayago/ruby_assert.h +14 -0
  61. data/ext/kanayago/ruby_atomic.h +23 -0
  62. data/ext/kanayago/ruby_parser.c +1165 -0
  63. data/ext/kanayago/rubyparser.h +1391 -0
  64. data/ext/kanayago/shape.h +234 -0
  65. data/ext/kanayago/st.c +2339 -0
  66. data/ext/kanayago/symbol.h +123 -0
  67. data/ext/kanayago/thread_pthread.h +168 -0
  68. data/ext/kanayago/universal_parser.c +230 -0
  69. data/ext/kanayago/vm_core.h +2215 -0
  70. data/ext/kanayago/vm_opts.h +67 -0
  71. data/lib/kanayago/version.rb +5 -0
  72. data/lib/kanayago.rb +11 -0
  73. data/sig/kanayago.rbs +4 -0
  74. metadata +116 -0
@@ -0,0 +1,186 @@
1
+ #ifndef INTERNAL_STRING_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_STRING_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 String.
10
+ */
11
+ #include "ruby/internal/config.h"
12
+ #include <stddef.h> /* for size_t */
13
+ #include "internal/compilers.h" /* for __has_builtin */
14
+ #include "ruby/internal/stdbool.h" /* for bool */
15
+ #include "ruby/encoding.h" /* for rb_encoding */
16
+ #include "ruby/ruby.h" /* for VALUE */
17
+
18
+ #define STR_NOEMBED FL_USER1
19
+ #define STR_SHARED FL_USER2 /* = ELTS_SHARED */
20
+ #define STR_CHILLED FL_USER3
21
+
22
+ enum ruby_rstring_private_flags {
23
+ RSTRING_CHILLED = STR_CHILLED,
24
+ };
25
+
26
+ #ifdef rb_fstring_cstr
27
+ # undef rb_fstring_cstr
28
+ #endif
29
+
30
+ /* string.c */
31
+ VALUE rb_fstring(VALUE);
32
+ VALUE rb_fstring_cstr(const char *str);
33
+ VALUE rb_fstring_enc_new(const char *ptr, long len, rb_encoding *enc);
34
+ int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p);
35
+ int rb_str_symname_p(VALUE);
36
+ VALUE rb_str_quote_unprintable(VALUE);
37
+ char *rb_str_fill_terminator(VALUE str, const int termlen);
38
+ void rb_str_change_terminator_length(VALUE str, const int oldtermlen, const int termlen);
39
+ VALUE rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg);
40
+ VALUE rb_str_chomp_string(VALUE str, VALUE chomp);
41
+ VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc);
42
+ VALUE rb_str_cat_conv_enc_opts(VALUE newstr, long ofs, const char *ptr, long len,
43
+ rb_encoding *from, int ecflags, VALUE ecopts);
44
+ VALUE rb_enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl);
45
+ VALUE rb_str_escape(VALUE str);
46
+ size_t rb_str_memsize(VALUE);
47
+ char *rb_str_to_cstr(VALUE str);
48
+ const char *ruby_escaped_char(int c);
49
+ void rb_str_make_independent(VALUE str);
50
+ int rb_enc_str_coderange_scan(VALUE str, rb_encoding *enc);
51
+ int rb_ascii8bit_appendable_encoding_index(rb_encoding *enc, unsigned int code);
52
+ VALUE rb_str_include(VALUE str, VALUE arg);
53
+ VALUE rb_str_byte_substr(VALUE str, VALUE beg, VALUE len);
54
+
55
+ static inline bool STR_EMBED_P(VALUE str);
56
+ static inline bool STR_SHARED_P(VALUE str);
57
+ static inline VALUE QUOTE(VALUE v);
58
+ static inline VALUE QUOTE_ID(ID v);
59
+ static inline bool is_ascii_string(VALUE str);
60
+ static inline bool is_broken_string(VALUE str);
61
+ static inline VALUE rb_str_eql_internal(const VALUE str1, const VALUE str2);
62
+
63
+ RUBY_SYMBOL_EXPORT_BEGIN
64
+ /* string.c (export) */
65
+ VALUE rb_str_tmp_frozen_acquire(VALUE str);
66
+ VALUE rb_str_tmp_frozen_no_embed_acquire(VALUE str);
67
+ void rb_str_tmp_frozen_release(VALUE str, VALUE tmp);
68
+ VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb_encoding *enc);
69
+ VALUE rb_str_upto_each(VALUE, VALUE, int, int (*each)(VALUE, VALUE), VALUE);
70
+ VALUE rb_str_upto_endless_each(VALUE, int (*each)(VALUE, VALUE), VALUE);
71
+ void rb_str_make_embedded(VALUE);
72
+ size_t rb_str_size_as_embedded(VALUE);
73
+ bool rb_str_reembeddable_p(VALUE);
74
+ RUBY_SYMBOL_EXPORT_END
75
+
76
+ VALUE rb_fstring_new(const char *ptr, long len);
77
+ VALUE rb_obj_as_string_result(VALUE str, VALUE obj);
78
+ VALUE rb_str_opt_plus(VALUE x, VALUE y);
79
+ VALUE rb_str_concat_literals(size_t num, const VALUE *strary);
80
+ VALUE rb_str_eql(VALUE str1, VALUE str2);
81
+ VALUE rb_id_quote_unprintable(ID);
82
+ VALUE rb_sym_proc_call(ID mid, int argc, const VALUE *argv, int kw_splat, VALUE passed_proc);
83
+ VALUE rb_enc_literal_str(const char *ptr, long len, rb_encoding *enc);
84
+
85
+ struct rb_execution_context_struct;
86
+ VALUE rb_ec_str_resurrect(struct rb_execution_context_struct *ec, VALUE str, bool chilled);
87
+
88
+ #define rb_fstring_lit(str) rb_fstring_new((str), rb_strlen_lit(str))
89
+ #define rb_fstring_literal(str) rb_fstring_lit(str)
90
+ #define rb_fstring_enc_lit(str, enc) rb_fstring_enc_new((str), rb_strlen_lit(str), (enc))
91
+ #define rb_fstring_enc_literal(str, enc) rb_fstring_enc_lit(str, enc)
92
+
93
+ static inline VALUE
94
+ QUOTE(VALUE v)
95
+ {
96
+ return rb_str_quote_unprintable(v);
97
+ }
98
+
99
+ static inline VALUE
100
+ QUOTE_ID(ID i)
101
+ {
102
+ return rb_id_quote_unprintable(i);
103
+ }
104
+
105
+ static inline bool
106
+ STR_EMBED_P(VALUE str)
107
+ {
108
+ return ! FL_TEST_RAW(str, STR_NOEMBED);
109
+ }
110
+
111
+ static inline bool
112
+ STR_SHARED_P(VALUE str)
113
+ {
114
+ return FL_ALL_RAW(str, STR_NOEMBED | STR_SHARED);
115
+ }
116
+
117
+ static inline bool
118
+ CHILLED_STRING_P(VALUE obj)
119
+ {
120
+ return RB_TYPE_P(obj, T_STRING) && FL_TEST_RAW(obj, STR_CHILLED);
121
+ }
122
+
123
+ static inline void
124
+ CHILLED_STRING_MUTATED(VALUE str)
125
+ {
126
+ FL_UNSET_RAW(str, STR_CHILLED);
127
+ rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "literal string will be frozen in the future");
128
+ }
129
+
130
+ static inline void
131
+ STR_CHILL_RAW(VALUE str)
132
+ {
133
+ FL_SET_RAW(str, STR_CHILLED);
134
+ }
135
+
136
+ static inline bool
137
+ is_ascii_string(VALUE str)
138
+ {
139
+ return rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT;
140
+ }
141
+
142
+ static inline bool
143
+ is_broken_string(VALUE str)
144
+ {
145
+ return rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN;
146
+ }
147
+
148
+ static inline bool
149
+ at_char_boundary(const char *s, const char *p, const char *e, rb_encoding *enc)
150
+ {
151
+ return rb_enc_left_char_head(s, p, e, enc) == p;
152
+ }
153
+
154
+ static inline bool
155
+ at_char_right_boundary(const char *s, const char *p, const char *e, rb_encoding *enc)
156
+ {
157
+ RUBY_ASSERT(s <= p);
158
+ RUBY_ASSERT(p <= e);
159
+
160
+ return rb_enc_right_char_head(s, p, e, enc) == p;
161
+ }
162
+
163
+ /* expect tail call optimization */
164
+ // YJIT needs this function to never allocate and never raise
165
+ static inline VALUE
166
+ rb_str_eql_internal(const VALUE str1, const VALUE str2)
167
+ {
168
+ const long len = RSTRING_LEN(str1);
169
+ const char *ptr1, *ptr2;
170
+
171
+ if (len != RSTRING_LEN(str2)) return Qfalse;
172
+ if (!rb_str_comparable(str1, str2)) return Qfalse;
173
+ if ((ptr1 = RSTRING_PTR(str1)) == (ptr2 = RSTRING_PTR(str2)))
174
+ return Qtrue;
175
+ if (memcmp(ptr1, ptr2, len) == 0)
176
+ return Qtrue;
177
+ return Qfalse;
178
+ }
179
+
180
+ #if __has_builtin(__builtin_constant_p)
181
+ # define rb_fstring_cstr(str) \
182
+ (__builtin_constant_p(str) ? \
183
+ rb_fstring_new((str), (long)strlen(str)) : \
184
+ (rb_fstring_cstr)(str))
185
+ #endif
186
+ #endif /* INTERNAL_STRING_H */
@@ -0,0 +1,45 @@
1
+ #ifndef INTERNAL_SYMBOL_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_SYMBOL_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 Symbol.
10
+ */
11
+ #include "ruby/ruby.h" /* for VALUE */
12
+ #include "ruby/encoding.h" /* for rb_encoding */
13
+ #include "internal/compilers.h" /* for __has_builtin */
14
+
15
+ #ifdef rb_sym_intern_ascii_cstr
16
+ # undef rb_sym_intern_ascii_cstr
17
+ #endif
18
+
19
+ /* symbol.c */
20
+ VALUE rb_to_symbol_type(VALUE obj);
21
+ VALUE rb_sym_intern(const char *ptr, long len, rb_encoding *enc);
22
+ VALUE rb_sym_intern_ascii(const char *ptr, long len);
23
+ VALUE rb_sym_intern_ascii_cstr(const char *ptr);
24
+ int rb_is_const_name(VALUE name);
25
+ int rb_is_class_name(VALUE name);
26
+ int rb_is_instance_name(VALUE name);
27
+ int rb_is_local_name(VALUE name);
28
+ PUREFUNC(int rb_is_const_sym(VALUE sym));
29
+ PUREFUNC(int rb_is_attrset_sym(VALUE sym));
30
+ ID rb_make_internal_id(void);
31
+ ID rb_make_temporary_id(size_t n);
32
+ void rb_gc_free_dsymbol(VALUE);
33
+ int rb_static_id_valid_p(ID id);
34
+
35
+ /* vm.c */
36
+ void rb_free_static_symid_str(void);
37
+
38
+ #if __has_builtin(__builtin_constant_p)
39
+ #define rb_sym_intern_ascii_cstr(ptr) \
40
+ (__builtin_constant_p(ptr) ? \
41
+ rb_sym_intern_ascii((ptr), (long)strlen(ptr)) : \
42
+ rb_sym_intern_ascii_cstr(ptr))
43
+ #endif
44
+
45
+ #endif /* INTERNAL_SYMBOL_H */
@@ -0,0 +1,79 @@
1
+ #ifndef INTERNAL_THREAD_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_THREAD_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 Thread.
10
+ */
11
+ #include "ruby/ruby.h" /* for VALUE */
12
+ #include "ruby/intern.h" /* for rb_blocking_function_t */
13
+ #include "ccan/list/list.h" /* for list in rb_io_close_wait_list */
14
+
15
+ struct rb_thread_struct; /* in vm_core.h */
16
+
17
+ #define RB_VM_SAVE_MACHINE_CONTEXT(th) \
18
+ do { \
19
+ FLUSH_REGISTER_WINDOWS; \
20
+ setjmp((th)->ec->machine.regs); \
21
+ SET_MACHINE_STACK_END(&(th)->ec->machine.stack_end); \
22
+ } while (0)
23
+
24
+ /* thread.c */
25
+ #define COVERAGE_INDEX_LINES 0
26
+ #define COVERAGE_INDEX_BRANCHES 1
27
+ #define COVERAGE_TARGET_LINES 1
28
+ #define COVERAGE_TARGET_BRANCHES 2
29
+ #define COVERAGE_TARGET_METHODS 4
30
+ #define COVERAGE_TARGET_ONESHOT_LINES 8
31
+ #define COVERAGE_TARGET_EVAL 16
32
+
33
+ #define RUBY_FATAL_THREAD_KILLED INT2FIX(0)
34
+ #define RUBY_FATAL_THREAD_TERMINATED INT2FIX(1)
35
+ #define RUBY_FATAL_FIBER_KILLED RB_INT2FIX(2)
36
+
37
+ VALUE rb_obj_is_mutex(VALUE obj);
38
+ VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
39
+ void rb_thread_execute_interrupts(VALUE th);
40
+ VALUE rb_get_coverages(void);
41
+ int rb_get_coverage_mode(void);
42
+ VALUE rb_default_coverage(int);
43
+ VALUE rb_thread_shield_new(void);
44
+ bool rb_thread_shield_owned(VALUE self);
45
+ VALUE rb_thread_shield_wait(VALUE self);
46
+ VALUE rb_thread_shield_release(VALUE self);
47
+ VALUE rb_thread_shield_destroy(VALUE self);
48
+ int rb_thread_to_be_killed(VALUE thread);
49
+ void rb_mutex_allow_trap(VALUE self, int val);
50
+ VALUE rb_uninterruptible(VALUE (*b_proc)(VALUE), VALUE data);
51
+ VALUE rb_mutex_owned_p(VALUE self);
52
+ VALUE rb_exec_recursive_outer_mid(VALUE (*f)(VALUE g, VALUE h, int r), VALUE g, VALUE h, ID mid);
53
+ void ruby_mn_threads_params(void);
54
+
55
+ int rb_thread_wait_for_single_fd(int fd, int events, struct timeval * timeout);
56
+
57
+ struct rb_io_close_wait_list {
58
+ struct ccan_list_head pending_fd_users;
59
+ VALUE closing_thread;
60
+ VALUE wakeup_mutex;
61
+ };
62
+ int rb_notify_fd_close(int fd, struct rb_io_close_wait_list *busy);
63
+ void rb_notify_fd_close_wait(struct rb_io_close_wait_list *busy);
64
+
65
+ RUBY_SYMBOL_EXPORT_BEGIN
66
+
67
+ /* Temporary. This API will be removed (renamed). */
68
+ VALUE rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd);
69
+ VALUE rb_thread_io_blocking_call(rb_blocking_function_t *func, void *data1, int fd, int events);
70
+
71
+ /* thread.c (export) */
72
+ int ruby_thread_has_gvl_p(void); /* for ext/fiddle/closure.c */
73
+
74
+ RUBY_SYMBOL_EXPORT_END
75
+
76
+ int rb_threadptr_execute_interrupts(struct rb_thread_struct *th, int blocking_timing);
77
+ bool rb_thread_mn_schedulable(VALUE thread);
78
+
79
+ #endif /* INTERNAL_THREAD_H */
@@ -0,0 +1,72 @@
1
+ #ifndef INTERNAL_VARIABLE_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_VARIABLE_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 variables.
10
+ */
11
+ #include "ruby/internal/config.h"
12
+ #include <stddef.h> /* for size_t */
13
+ #include "constant.h" /* for rb_const_entry_t */
14
+ #include "ruby/internal/stdbool.h" /* for bool */
15
+ #include "ruby/ruby.h" /* for VALUE */
16
+ #include "shape.h" /* for rb_shape_t */
17
+
18
+ /* variable.c */
19
+ void rb_gc_mark_global_tbl(void);
20
+ void rb_gc_update_global_tbl(void);
21
+ size_t rb_generic_ivar_memsize(VALUE);
22
+ VALUE rb_search_class_path(VALUE);
23
+ VALUE rb_attr_delete(VALUE, ID);
24
+ void rb_autoload_str(VALUE mod, ID id, VALUE file);
25
+ VALUE rb_autoload_at_p(VALUE, ID, int);
26
+ NORETURN(VALUE rb_mod_const_missing(VALUE,VALUE));
27
+ rb_gvar_getter_t *rb_gvar_getter_function_of(ID);
28
+ rb_gvar_setter_t *rb_gvar_setter_function_of(ID);
29
+ void rb_gvar_readonly_setter(VALUE v, ID id, VALUE *_);
30
+ void rb_gvar_ractor_local(const char *name);
31
+
32
+ /**
33
+ * Sets the name of a module.
34
+ *
35
+ * Non-permanently named classes can have a temporary name assigned (or
36
+ * cleared). In that case the name will be used for `#inspect` and `#to_s`, and
37
+ * nested classes/modules will be named with the temporary name as a prefix.
38
+ *
39
+ * After the module is assigned to a constant, the temporary name will be
40
+ * discarded, and the name will be computed based on the nesting.
41
+ *
42
+ * @param[in] mod An instance of ::rb_cModule.
43
+ * @param[in] name An instance of ::rb_cString.
44
+ * @retval mod
45
+ */
46
+ VALUE rb_mod_set_temporary_name(VALUE, VALUE);
47
+
48
+ struct gen_ivtbl;
49
+ int rb_gen_ivtbl_get(VALUE obj, ID id, struct gen_ivtbl **ivtbl);
50
+ void rb_obj_copy_ivs_to_hash_table(VALUE obj, st_table *table);
51
+ void rb_obj_convert_to_too_complex(VALUE obj, st_table *table);
52
+ void rb_evict_ivars_to_hash(VALUE obj);
53
+
54
+ RUBY_SYMBOL_EXPORT_BEGIN
55
+ /* variable.c (export) */
56
+ void rb_mark_generic_ivar(VALUE obj);
57
+ void rb_ref_update_generic_ivar(VALUE);
58
+ void rb_mv_generic_ivar(VALUE src, VALUE dst);
59
+ VALUE rb_const_missing(VALUE klass, VALUE name);
60
+ int rb_class_ivar_set(VALUE klass, ID vid, VALUE value);
61
+ void rb_iv_tbl_copy(VALUE dst, VALUE src);
62
+ RUBY_SYMBOL_EXPORT_END
63
+
64
+ VALUE rb_ivar_lookup(VALUE obj, ID id, VALUE undef);
65
+ VALUE rb_gvar_get(ID);
66
+ VALUE rb_gvar_set(ID, VALUE);
67
+ VALUE rb_gvar_defined(ID);
68
+ void rb_const_warn_if_deprecated(const rb_const_entry_t *, VALUE, ID);
69
+ void rb_ensure_iv_list_size(VALUE obj, uint32_t len, uint32_t newsize);
70
+ attr_index_t rb_obj_ivar_set(VALUE obj, ID id, VALUE val);
71
+
72
+ #endif /* INTERNAL_VARIABLE_H */
@@ -0,0 +1,137 @@
1
+ #ifndef INTERNAL_VM_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_VM_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 RubyVM.
10
+ */
11
+ #include "ruby/internal/stdbool.h" /* for bool */
12
+ #include "internal/serial.h" /* for rb_serial_t */
13
+ #include "internal/static_assert.h" /* for STATIC_ASSERT */
14
+ #include "ruby/ruby.h" /* for ID */
15
+ #include "ruby/st.h" /* for st_table */
16
+
17
+ #ifdef rb_funcallv
18
+ # undef rb_funcallv
19
+ #endif
20
+
21
+ #ifdef rb_method_basic_definition_p
22
+ # undef rb_method_basic_definition_p
23
+ #endif
24
+
25
+ struct rb_callable_method_entry_struct; /* in method.h */
26
+ struct rb_method_definition_struct; /* in method.h */
27
+ struct rb_execution_context_struct; /* in vm_core.h */
28
+ struct rb_control_frame_struct; /* in vm_core.h */
29
+ struct rb_callinfo; /* in vm_core.h */
30
+
31
+ enum method_missing_reason {
32
+ MISSING_NOENTRY = 0x00,
33
+ MISSING_PRIVATE = 0x01,
34
+ MISSING_PROTECTED = 0x02,
35
+ MISSING_FCALL = 0x04,
36
+ MISSING_VCALL = 0x08,
37
+ MISSING_SUPER = 0x10,
38
+ MISSING_MISSING = 0x20,
39
+ MISSING_NONE = 0x40
40
+ };
41
+
42
+ /* vm_insnhelper.h */
43
+ VALUE rb_vm_push_frame_fname(struct rb_execution_context_struct *ec, VALUE fname);
44
+
45
+ /* vm.c */
46
+ VALUE rb_obj_is_thread(VALUE obj);
47
+ void rb_vm_mark(void *ptr);
48
+ void rb_vm_register_global_object(VALUE obj);
49
+ void rb_vm_each_stack_value(void *ptr, void (*cb)(VALUE, void*), void *ctx);
50
+ PUREFUNC(VALUE rb_vm_top_self(void));
51
+ const void **rb_vm_get_insns_address_table(void);
52
+ VALUE rb_source_location(int *pline);
53
+ const char *rb_source_location_cstr(int *pline);
54
+ void rb_vm_pop_cfunc_frame(void);
55
+ void rb_vm_check_redefinition_by_prepend(VALUE klass);
56
+ int rb_vm_check_optimizable_mid(VALUE mid);
57
+ VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements);
58
+ VALUE ruby_vm_special_exception_copy(VALUE);
59
+ PUREFUNC(st_table *rb_vm_fstring_table(void));
60
+
61
+ void rb_lastline_set_up(VALUE val, unsigned int up);
62
+
63
+ /* vm_eval.c */
64
+ VALUE rb_current_realfilepath(void);
65
+ VALUE rb_check_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE);
66
+ typedef void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE);
67
+ VALUE rb_check_funcall_with_hook_kw(VALUE recv, ID mid, int argc, const VALUE *argv,
68
+ rb_check_funcall_hook *hook, VALUE arg, int kw_splat);
69
+ const char *rb_type_str(enum ruby_value_type type);
70
+ VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE);
71
+ VALUE rb_check_funcall_basic_kw(VALUE, ID, VALUE, int, const VALUE*, int);
72
+ VALUE rb_yield_1(VALUE val);
73
+ VALUE rb_yield_force_blockarg(VALUE values);
74
+ VALUE rb_lambda_call(VALUE obj, ID mid, int argc, const VALUE *argv,
75
+ rb_block_call_func_t bl_proc, int min_argc, int max_argc,
76
+ VALUE data2);
77
+ void rb_check_stack_overflow(void);
78
+ #define RB_BLOCK_NO_USE_PACKED_ARGS 2
79
+ VALUE rb_block_call2(VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t bl_proc, VALUE data2, long flags);
80
+
81
+ #if USE_YJIT
82
+ /* vm_exec.c */
83
+ extern uint64_t rb_vm_insns_count;
84
+ #endif
85
+
86
+ extern bool rb_free_at_exit;
87
+
88
+ /* miniinit.c and builtin.c */
89
+ void rb_free_loaded_builtin_table(void);
90
+
91
+ /* vm_insnhelper.c */
92
+ VALUE rb_equal_opt(VALUE obj1, VALUE obj2);
93
+ VALUE rb_eql_opt(VALUE obj1, VALUE obj2);
94
+
95
+ struct rb_iseq_struct;
96
+ const struct rb_callcache *rb_vm_search_method_slowpath(const struct rb_callinfo *ci, VALUE klass);
97
+
98
+ /* vm_method.c */
99
+ struct rb_execution_context_struct;
100
+ int rb_ec_obj_respond_to(struct rb_execution_context_struct *ec, VALUE obj, ID id, int priv);
101
+
102
+ void rb_clear_constant_cache(void);
103
+
104
+ /* vm_dump.c */
105
+ void rb_print_backtrace(FILE *);
106
+
107
+ /* vm_backtrace.c */
108
+ VALUE rb_vm_thread_backtrace(int argc, const VALUE *argv, VALUE thval);
109
+ VALUE rb_vm_thread_backtrace_locations(int argc, const VALUE *argv, VALUE thval);
110
+ VALUE rb_vm_backtrace(int argc, const VALUE * argv, struct rb_execution_context_struct * ec);
111
+ VALUE rb_vm_backtrace_locations(int argc, const VALUE * argv, struct rb_execution_context_struct * ec);
112
+ VALUE rb_make_backtrace(void);
113
+ void rb_backtrace_print_as_bugreport(FILE*);
114
+ int rb_backtrace_p(VALUE obj);
115
+ VALUE rb_backtrace_to_str_ary(VALUE obj);
116
+ VALUE rb_backtrace_to_location_ary(VALUE obj);
117
+ VALUE rb_location_ary_to_backtrace(VALUE ary);
118
+ void rb_backtrace_each(VALUE (*iter)(VALUE recv, VALUE str), VALUE output);
119
+ int rb_frame_info_p(VALUE obj);
120
+ int rb_get_node_id_from_frame_info(VALUE obj);
121
+ const struct rb_iseq_struct *rb_get_iseq_from_frame_info(VALUE obj);
122
+
123
+ VALUE rb_ec_backtrace_object(const struct rb_execution_context_struct *ec);
124
+ void rb_backtrace_use_iseq_first_lineno_for_last_location(VALUE self);
125
+
126
+ #define RUBY_DTRACE_CREATE_HOOK(name, arg) \
127
+ RUBY_DTRACE_HOOK(name##_CREATE, arg)
128
+ #define RUBY_DTRACE_HOOK(name, arg) \
129
+ do { \
130
+ if (UNLIKELY(RUBY_DTRACE_##name##_ENABLED())) { \
131
+ int dtrace_line; \
132
+ const char *dtrace_file = rb_source_location_cstr(&dtrace_line); \
133
+ if (!dtrace_file) dtrace_file = ""; \
134
+ RUBY_DTRACE_##name(arg, dtrace_file, dtrace_line); \
135
+ } \
136
+ } while (0)
137
+ #endif /* INTERNAL_VM_H */
@@ -0,0 +1,16 @@
1
+ #ifndef INTERNAL_WARNINGS_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_WARNINGS_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 to suppress / mandate warnings.
10
+ */
11
+ #include "ruby/internal/warning_push.h"
12
+ #define COMPILER_WARNING_PUSH RBIMPL_WARNING_PUSH()
13
+ #define COMPILER_WARNING_POP RBIMPL_WARNING_POP()
14
+ #define COMPILER_WARNING_ERROR(flag) RBIMPL_WARNING_ERROR(flag)
15
+ #define COMPILER_WARNING_IGNORED(flag) RBIMPL_WARNING_IGNORED(flag)
16
+ #endif /* INTERNAL_WARNINGS_H */
@@ -0,0 +1,108 @@
1
+ #ifndef RUBY_INTERNAL_H /*-*-C-*-vi:se ft=c:*/
2
+ #define RUBY_INTERNAL_H 1
3
+ /**
4
+ * @author $Author$
5
+ * @date Tue May 17 11:42:20 JST 2011
6
+ * @copyright Copyright (C) 2011 Yukihiro Matsumoto
7
+ * @copyright This file is a part of the programming language Ruby.
8
+ * Permission is hereby granted, to either redistribute and/or
9
+ * modify this file, provided that the conditions mentioned in the
10
+ * file COPYING are met. Consult the file for details.
11
+ */
12
+ #include "ruby/internal/config.h"
13
+
14
+ #ifdef __cplusplus
15
+ # error not for C++
16
+ #endif
17
+
18
+ #define LIKELY(x) RB_LIKELY(x)
19
+ #define UNLIKELY(x) RB_UNLIKELY(x)
20
+
21
+ #define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
22
+ #define roomof(x, y) (((x) + (y) - 1) / (y))
23
+ #define type_roomof(x, y) roomof(sizeof(x), sizeof(y))
24
+
25
+ /* Prevent compiler from reordering access */
26
+ #define ACCESS_ONCE(type,x) (*((volatile type *)&(x)))
27
+
28
+ #define UNDEF_P RB_UNDEF_P
29
+ #define NIL_OR_UNDEF_P RB_NIL_OR_UNDEF_P
30
+
31
+ #include "ruby/ruby.h"
32
+
33
+ /* Following macros were formerly defined in this header but moved to somewhere
34
+ * else. In order to detect them we undef here. */
35
+
36
+ /* internal/array.h */
37
+ #undef RARRAY_AREF
38
+
39
+ /* internal/class.h */
40
+ #undef RClass
41
+ #undef RCLASS_SUPER
42
+
43
+ /* internal/hash.h */
44
+ #undef RHASH_IFNONE
45
+ #undef RHASH_SIZE
46
+ #undef RHASH_TBL
47
+ #undef RHASH_EMPTY_P
48
+
49
+ /* internal/struct.h */
50
+ #undef RSTRUCT_LEN
51
+ #undef RSTRUCT_PTR
52
+ #undef RSTRUCT_SET
53
+ #undef RSTRUCT_GET
54
+
55
+ /* Also, we keep the following macros here. They are expected to be
56
+ * overridden in each headers. */
57
+
58
+ /* internal/array.h */
59
+ #define rb_ary_new_from_args(...) rb_nonexistent_symbol(__VA_ARGS__)
60
+
61
+ /* internal/io.h */
62
+ #define rb_io_fptr_finalize(...) rb_nonexistent_symbol(__VA_ARGS__)
63
+
64
+ /* internal/string.h */
65
+ #define rb_fstring_cstr(...) rb_nonexistent_symbol(__VA_ARGS__)
66
+
67
+ /* internal/symbol.h */
68
+ #define rb_sym_intern_ascii_cstr(...) rb_nonexistent_symbol(__VA_ARGS__)
69
+
70
+ /* internal/vm.h */
71
+ #define rb_funcallv(...) rb_nonexistent_symbol(__VA_ARGS__)
72
+ #define rb_method_basic_definition_p(...) rb_nonexistent_symbol(__VA_ARGS__)
73
+
74
+
75
+ /* MRI debug support */
76
+
77
+ /* gc.c */
78
+ void rb_obj_info_dump(VALUE obj);
79
+ void rb_obj_info_dump_loc(VALUE obj, const char *file, int line, const char *func);
80
+
81
+ /* debug.c */
82
+
83
+ RUBY_SYMBOL_EXPORT_BEGIN
84
+ void ruby_debug_breakpoint(void);
85
+ PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
86
+ RUBY_SYMBOL_EXPORT_END
87
+
88
+ // show obj data structure without any side-effect
89
+ #define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
90
+
91
+ // same as rp, but add message header
92
+ #define rp_m(msg, obj) do { \
93
+ fputs((msg), stderr); \
94
+ rb_obj_info_dump((VALUE)(obj)); \
95
+ } while (0)
96
+
97
+ // `ruby_debug_breakpoint()` does nothing,
98
+ // but breakpoint is set in run.gdb, so `make gdb` can stop here.
99
+ #define bp() ruby_debug_breakpoint()
100
+
101
+ #define RBOOL(v) ((v) ? Qtrue : Qfalse)
102
+ #define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)
103
+
104
+ #ifndef __MINGW32__
105
+ #undef memcpy
106
+ #define memcpy ruby_nonempty_memcpy
107
+ #endif
108
+ #endif /* RUBY_INTERNAL_H */