portable_mruby 0.1.0

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 (57) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +195 -0
  3. data/exe/portable-mruby +6 -0
  4. data/lib/portable_mruby/binary_manager.rb +225 -0
  5. data/lib/portable_mruby/builder.rb +97 -0
  6. data/lib/portable_mruby/bytecode_compiler.rb +19 -0
  7. data/lib/portable_mruby/c_generator.rb +94 -0
  8. data/lib/portable_mruby/cli.rb +136 -0
  9. data/lib/portable_mruby/version.rb +6 -0
  10. data/lib/portable_mruby.rb +15 -0
  11. data/vendor/mruby/bin/mrbc.com +0 -0
  12. data/vendor/mruby/include/mrbconf.h +230 -0
  13. data/vendor/mruby/include/mruby/array.h +303 -0
  14. data/vendor/mruby/include/mruby/boxing_nan.h +169 -0
  15. data/vendor/mruby/include/mruby/boxing_no.h +59 -0
  16. data/vendor/mruby/include/mruby/boxing_word.h +251 -0
  17. data/vendor/mruby/include/mruby/class.h +104 -0
  18. data/vendor/mruby/include/mruby/common.h +118 -0
  19. data/vendor/mruby/include/mruby/compile.h +185 -0
  20. data/vendor/mruby/include/mruby/data.h +76 -0
  21. data/vendor/mruby/include/mruby/debug.h +75 -0
  22. data/vendor/mruby/include/mruby/dump.h +159 -0
  23. data/vendor/mruby/include/mruby/endian.h +44 -0
  24. data/vendor/mruby/include/mruby/error.h +132 -0
  25. data/vendor/mruby/include/mruby/gc.h +72 -0
  26. data/vendor/mruby/include/mruby/gems/mruby-dir/include/dir_hal.h +79 -0
  27. data/vendor/mruby/include/mruby/gems/mruby-io/include/io_hal.h +451 -0
  28. data/vendor/mruby/include/mruby/gems/mruby-io/include/mruby/ext/io.h +76 -0
  29. data/vendor/mruby/include/mruby/gems/mruby-socket/include/socket_hal.h +83 -0
  30. data/vendor/mruby/include/mruby/gems/mruby-time/include/mruby/time.h +27 -0
  31. data/vendor/mruby/include/mruby/hash.h +234 -0
  32. data/vendor/mruby/include/mruby/internal.h +274 -0
  33. data/vendor/mruby/include/mruby/irep.h +142 -0
  34. data/vendor/mruby/include/mruby/istruct.h +50 -0
  35. data/vendor/mruby/include/mruby/khash.h +455 -0
  36. data/vendor/mruby/include/mruby/mempool.h +19 -0
  37. data/vendor/mruby/include/mruby/numeric.h +174 -0
  38. data/vendor/mruby/include/mruby/object.h +45 -0
  39. data/vendor/mruby/include/mruby/opcode.h +69 -0
  40. data/vendor/mruby/include/mruby/ops.h +120 -0
  41. data/vendor/mruby/include/mruby/presym/disable.h +72 -0
  42. data/vendor/mruby/include/mruby/presym/enable.h +39 -0
  43. data/vendor/mruby/include/mruby/presym/id.h +1423 -0
  44. data/vendor/mruby/include/mruby/presym/scanning.h +81 -0
  45. data/vendor/mruby/include/mruby/presym/table.h +2847 -0
  46. data/vendor/mruby/include/mruby/presym.h +41 -0
  47. data/vendor/mruby/include/mruby/proc.h +186 -0
  48. data/vendor/mruby/include/mruby/range.h +77 -0
  49. data/vendor/mruby/include/mruby/re.h +16 -0
  50. data/vendor/mruby/include/mruby/string.h +428 -0
  51. data/vendor/mruby/include/mruby/throw.h +57 -0
  52. data/vendor/mruby/include/mruby/value.h +471 -0
  53. data/vendor/mruby/include/mruby/variable.h +108 -0
  54. data/vendor/mruby/include/mruby/version.h +143 -0
  55. data/vendor/mruby/include/mruby.h +1614 -0
  56. data/vendor/mruby/lib/libmruby.a +0 -0
  57. metadata +102 -0
@@ -0,0 +1,83 @@
1
+ /*
2
+ ** socket_hal.h - Socket HAL (Hardware Abstraction Layer) interface
3
+ **
4
+ ** See Copyright Notice in mruby.h
5
+ **
6
+ ** This header defines the platform-independent socket HAL interface.
7
+ ** Platform-specific implementations are provided by HAL gems:
8
+ ** - hal-posix-socket: POSIX socket implementation (Linux, macOS, BSD, Unix)
9
+ ** - hal-win-socket: Windows socket implementation (Windows, MinGW)
10
+ */
11
+
12
+ #ifndef MRUBY_SOCKET_HAL_H
13
+ #define MRUBY_SOCKET_HAL_H
14
+
15
+ #include <mruby.h>
16
+
17
+ #ifdef __cplusplus
18
+ extern "C" {
19
+ #endif
20
+
21
+ /*
22
+ * Socket HAL Initialization/Finalization
23
+ */
24
+
25
+ /* Initialize socket subsystem (e.g., WSAStartup on Windows) */
26
+ void mrb_hal_socket_init(mrb_state *mrb);
27
+
28
+ /* Finalize socket subsystem (e.g., WSACleanup on Windows) */
29
+ void mrb_hal_socket_final(mrb_state *mrb);
30
+
31
+ /*
32
+ * Socket Control Operations
33
+ */
34
+
35
+ /* Set non-blocking mode on socket
36
+ * Returns 0 on success, -1 on error (sets errno) */
37
+ int mrb_hal_socket_set_nonblock(mrb_state *mrb, int fd, int nonblock);
38
+
39
+ /*
40
+ * Address Conversion Functions
41
+ */
42
+
43
+ /* Convert network address to presentation format (string)
44
+ * af: address family (AF_INET, AF_INET6)
45
+ * src: network address in binary form
46
+ * dst: buffer for string result
47
+ * size: size of dst buffer
48
+ * Returns: dst on success, NULL on error */
49
+ const char* mrb_hal_socket_inet_ntop(int af, const void *src, char *dst, size_t size);
50
+
51
+ /* Convert presentation format (string) to network address
52
+ * af: address family (AF_INET, AF_INET6)
53
+ * src: string representation of address
54
+ * dst: buffer for network address result
55
+ * Returns: 1 on success, 0 if src is not valid, -1 on error */
56
+ int mrb_hal_socket_inet_pton(int af, const char *src, void *dst);
57
+
58
+ /*
59
+ * Platform-Specific Socket Features
60
+ */
61
+
62
+ /* Create Unix domain socket address structure
63
+ * path: Unix socket path
64
+ * Returns: packed sockaddr string, or raises exception if not supported */
65
+ mrb_value mrb_hal_socket_sockaddr_un(mrb_state *mrb, const char *path, size_t pathlen);
66
+
67
+ /* Create a pair of connected sockets
68
+ * domain: address family (e.g., AF_UNIX)
69
+ * type: socket type (e.g., SOCK_STREAM)
70
+ * protocol: protocol (usually 0)
71
+ * sv: array to receive the two socket descriptors
72
+ * Returns: 0 on success, -1 on error (sets errno) */
73
+ int mrb_hal_socket_socketpair(mrb_state *mrb, int domain, int type, int protocol, int sv[2]);
74
+
75
+ /* Get Unix socket path from sockaddr
76
+ * Returns: Unix socket path string, or raises exception if not supported */
77
+ mrb_value mrb_hal_socket_unix_path(mrb_state *mrb, const char *sockaddr, size_t socklen);
78
+
79
+ #ifdef __cplusplus
80
+ }
81
+ #endif
82
+
83
+ #endif /* MRUBY_SOCKET_HAL_H */
@@ -0,0 +1,27 @@
1
+ /*
2
+ ** mruby/time.h - Time class
3
+ **
4
+ ** See Copyright Notice in mruby.h
5
+ */
6
+
7
+ #ifndef MRUBY_TIME_H
8
+ #define MRUBY_TIME_H
9
+
10
+ #include <mruby/common.h>
11
+ #include <time.h>
12
+
13
+ MRB_BEGIN_DECL
14
+
15
+ typedef enum mrb_timezone {
16
+ MRB_TIMEZONE_NONE = 0,
17
+ MRB_TIMEZONE_UTC = 1,
18
+ MRB_TIMEZONE_LOCAL = 2,
19
+ MRB_TIMEZONE_LAST = 3
20
+ } mrb_timezone;
21
+
22
+ MRB_API mrb_value mrb_time_at(mrb_state *mrb, time_t sec, time_t usec, mrb_timezone timezone);
23
+ MRB_API struct tm* mrb_time_get_tm(mrb_state *mrb, mrb_value time);
24
+
25
+ MRB_END_DECL
26
+
27
+ #endif /* MRUBY_TIME_H */
@@ -0,0 +1,234 @@
1
+ /**
2
+ ** @file mruby/hash.h - Hash class
3
+ **
4
+ ** See Copyright Notice in mruby.h
5
+ */
6
+
7
+ #ifndef MRUBY_HASH_H
8
+ #define MRUBY_HASH_H
9
+
10
+ #include "common.h"
11
+
12
+ /**
13
+ * Hash class
14
+ */
15
+ MRB_BEGIN_DECL
16
+
17
+ /* offset of `iv` must be 3 words */
18
+ struct RHash {
19
+ MRB_OBJECT_HEADER;
20
+ #ifdef MRB_64BIT
21
+ uint32_t size;
22
+ struct iv_tbl *iv;
23
+ uint32_t ea_capa;
24
+ uint32_t ea_n_used;
25
+ #else
26
+ struct iv_tbl *iv;
27
+ uint32_t size;
28
+ #endif
29
+ union {
30
+ struct hash_entry *ea;
31
+ struct hash_table *ht;
32
+ } hsh;
33
+ };
34
+
35
+ #define mrb_hash_ptr(v) ((struct RHash*)(mrb_ptr(v)))
36
+ #define mrb_hash_value(p) mrb_obj_value((void*)(p))
37
+
38
+ MRB_API mrb_value mrb_hash_new_capa(mrb_state *mrb, mrb_int capa);
39
+
40
+ /*
41
+ * Initializes a new hash.
42
+ *
43
+ * Equivalent to:
44
+ *
45
+ * Hash.new
46
+ *
47
+ * @param mrb The mruby state reference.
48
+ * @return The initialized hash.
49
+ */
50
+ MRB_API mrb_value mrb_hash_new(mrb_state *mrb);
51
+
52
+ /*
53
+ * Sets a keys and values to hashes.
54
+ *
55
+ * Equivalent to:
56
+ *
57
+ * hash[key] = val
58
+ *
59
+ * @param mrb The mruby state reference.
60
+ * @param hash The target hash.
61
+ * @param key The key to set.
62
+ * @param val The value to set.
63
+ * @return The value.
64
+ */
65
+ MRB_API void mrb_hash_set(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value val);
66
+
67
+ /*
68
+ * Gets a value from a key. If the key is not found, the default of the
69
+ * hash is used.
70
+ *
71
+ * Equivalent to:
72
+ *
73
+ * hash[key]
74
+ *
75
+ * @param mrb The mruby state reference.
76
+ * @param hash The target hash.
77
+ * @param key The key to get.
78
+ * @return The found value.
79
+ */
80
+ MRB_API mrb_value mrb_hash_get(mrb_state *mrb, mrb_value hash, mrb_value key);
81
+
82
+ /*
83
+ * Gets a value from a key. If the key is not found, the default parameter is
84
+ * used.
85
+ *
86
+ * Equivalent to:
87
+ *
88
+ * hash.key?(key) ? hash[key] : def
89
+ *
90
+ * @param mrb The mruby state reference.
91
+ * @param hash The target hash.
92
+ * @param key The key to get.
93
+ * @param def The default value.
94
+ * @return The found value.
95
+ */
96
+ MRB_API mrb_value mrb_hash_fetch(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value def);
97
+
98
+ /*
99
+ * Deletes hash key and value pair.
100
+ *
101
+ * Equivalent to:
102
+ *
103
+ * hash.delete(key)
104
+ *
105
+ * @param mrb The mruby state reference.
106
+ * @param hash The target hash.
107
+ * @param key The key to delete.
108
+ * @return The deleted value. This value is not protected from GC. Use `mrb_gc_protect()` if necessary.
109
+ */
110
+ MRB_API mrb_value mrb_hash_delete_key(mrb_state *mrb, mrb_value hash, mrb_value key);
111
+
112
+ /*
113
+ * Gets an array of keys.
114
+ *
115
+ * Equivalent to:
116
+ *
117
+ * hash.keys
118
+ *
119
+ * @param mrb The mruby state reference.
120
+ * @param hash The target hash.
121
+ * @return An array with the keys of the hash.
122
+ */
123
+ MRB_API mrb_value mrb_hash_keys(mrb_state *mrb, mrb_value hash);
124
+ /*
125
+ * Check if the hash has the key.
126
+ *
127
+ * Equivalent to:
128
+ *
129
+ * hash.key?(key)
130
+ *
131
+ * @param mrb The mruby state reference.
132
+ * @param hash The target hash.
133
+ * @param key The key to check existence.
134
+ * @return True if the hash has the key
135
+ */
136
+ MRB_API mrb_bool mrb_hash_key_p(mrb_state *mrb, mrb_value hash, mrb_value key);
137
+
138
+ /*
139
+ * Check if the hash is empty
140
+ *
141
+ * Equivalent to:
142
+ *
143
+ * hash.empty?
144
+ *
145
+ * @param mrb The mruby state reference.
146
+ * @param self The target hash.
147
+ * @return True if the hash is empty, false otherwise.
148
+ */
149
+ MRB_API mrb_bool mrb_hash_empty_p(mrb_state *mrb, mrb_value self);
150
+
151
+ /*
152
+ * Gets an array of values.
153
+ *
154
+ * Equivalent to:
155
+ *
156
+ * hash.values
157
+ *
158
+ * @param mrb The mruby state reference.
159
+ * @param hash The target hash.
160
+ * @return An array with the values of the hash.
161
+ */
162
+ MRB_API mrb_value mrb_hash_values(mrb_state *mrb, mrb_value hash);
163
+
164
+ /*
165
+ * Clears the hash.
166
+ *
167
+ * Equivalent to:
168
+ *
169
+ * hash.clear
170
+ *
171
+ * @param mrb The mruby state reference.
172
+ * @param hash The target hash.
173
+ * @return The hash
174
+ */
175
+ MRB_API mrb_value mrb_hash_clear(mrb_state *mrb, mrb_value hash);
176
+
177
+ /*
178
+ * Get hash size.
179
+ *
180
+ * Equivalent to:
181
+ *
182
+ * hash.size
183
+ *
184
+ * @param mrb The mruby state reference.
185
+ * @param hash The target hash.
186
+ * @return The hash size.
187
+ */
188
+ MRB_API mrb_int mrb_hash_size(mrb_state *mrb, mrb_value hash);
189
+
190
+ /*
191
+ * Copies the hash. This function does NOT copy the instance variables
192
+ * (except for the default value). Use mrb_obj_dup() to copy the instance
193
+ * variables as well.
194
+ *
195
+ * @param mrb The mruby state reference.
196
+ * @param hash The target hash.
197
+ * @return The copy of the hash
198
+ */
199
+ MRB_API mrb_value mrb_hash_dup(mrb_state *mrb, mrb_value hash);
200
+
201
+ /*
202
+ * Merges two hashes. The first hash will be modified by the
203
+ * second hash.
204
+ *
205
+ * @param mrb The mruby state reference.
206
+ * @param hash1 The target hash.
207
+ * @param hash2 Updating hash
208
+ */
209
+ MRB_API void mrb_hash_merge(mrb_state *mrb, mrb_value hash1, mrb_value hash2);
210
+
211
+ #define RHASH(hash) ((struct RHash*)(mrb_ptr(hash)))
212
+
213
+ #define MRB_HASH_IB_BIT_BIT 5
214
+ #define MRB_HASH_AR_EA_CAPA_BIT 5
215
+ #define MRB_HASH_IB_BIT_SHIFT 0
216
+ #define MRB_HASH_AR_EA_CAPA_SHIFT 0
217
+ #define MRB_HASH_AR_EA_N_USED_SHIFT MRB_HASH_AR_EA_CAPA_BIT
218
+ #define MRB_HASH_SIZE_FLAGS_SHIFT (MRB_HASH_AR_EA_CAPA_BIT * 2)
219
+ #define MRB_HASH_IB_BIT_MASK ((1 << MRB_HASH_IB_BIT_BIT) - 1)
220
+ #define MRB_HASH_AR_EA_CAPA_MASK ((1 << MRB_HASH_AR_EA_CAPA_BIT) - 1)
221
+ #define MRB_HASH_AR_EA_N_USED_MASK (MRB_HASH_AR_EA_CAPA_MASK << MRB_HASH_AR_EA_N_USED_SHIFT)
222
+ #define MRB_HASH_DEFAULT (1 << (MRB_HASH_SIZE_FLAGS_SHIFT + 0))
223
+ #define MRB_HASH_PROC_DEFAULT (1 << (MRB_HASH_SIZE_FLAGS_SHIFT + 1))
224
+ #define MRB_HASH_HT (1 << (MRB_HASH_SIZE_FLAGS_SHIFT + 2))
225
+ #define MRB_RHASH_DEFAULT_P(hash) (RHASH(hash)->flags & MRB_HASH_DEFAULT)
226
+ #define MRB_RHASH_PROCDEFAULT_P(hash) (RHASH(hash)->flags & MRB_HASH_PROC_DEFAULT)
227
+
228
+ /* return non zero to break the loop */
229
+ typedef int (mrb_hash_foreach_func)(mrb_state *mrb, mrb_value key, mrb_value val, void *data);
230
+ MRB_API void mrb_hash_foreach(mrb_state *mrb, struct RHash *hash, mrb_hash_foreach_func *func, void *p);
231
+
232
+ MRB_END_DECL
233
+
234
+ #endif /* MRUBY_HASH_H */
@@ -0,0 +1,274 @@
1
+ /**
2
+ ** @file mruby/internal.h - Functions only called from within the library
3
+ **
4
+ ** See Copyright Notice in mruby.h
5
+ */
6
+
7
+ #ifndef MRUBY_INTERNAL_H
8
+ #define MRUBY_INTERNAL_H
9
+
10
+ #ifdef MRUBY_ARRAY_H
11
+ void mrb_ary_decref(mrb_state*, mrb_shared_array*);
12
+ mrb_value mrb_ary_subseq(mrb_state *mrb, mrb_value ary, mrb_int beg, mrb_int len);
13
+ #endif
14
+
15
+ #ifdef MRUBY_CLASS_H
16
+ struct RClass *mrb_vm_define_class(mrb_state*, mrb_value, mrb_value, mrb_sym);
17
+ struct RClass *mrb_vm_define_module(mrb_state*, mrb_value, mrb_sym);
18
+ mrb_value mrb_instance_new(mrb_state *mrb, mrb_value cv);
19
+ void mrb_class_name_class(mrb_state*, struct RClass*, struct RClass*, mrb_sym);
20
+ mrb_bool mrb_const_name_p(mrb_state*, const char*, mrb_int);
21
+ mrb_value mrb_class_find_path(mrb_state*, struct RClass*);
22
+ mrb_value mrb_mod_to_s(mrb_state *, mrb_value);
23
+ void mrb_method_added(mrb_state *mrb, struct RClass *c, mrb_sym mid);
24
+ mrb_noreturn void mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value args);
25
+ mrb_method_t mrb_vm_find_method(mrb_state *mrb, struct RClass *c, struct RClass **cp, mrb_sym mid);
26
+ mrb_value mrb_mod_const_missing(mrb_state *mrb, mrb_value mod);
27
+ mrb_value mrb_const_missing(mrb_state *mrb, mrb_value mod, mrb_sym sym);
28
+ size_t mrb_class_mt_memsize(mrb_state*, struct RClass*);
29
+ mrb_value mrb_obj_extend(mrb_state*, mrb_value obj);
30
+ #endif
31
+
32
+ mrb_value mrb_obj_equal_m(mrb_state *mrb, mrb_value);
33
+
34
+ /* debug */
35
+ size_t mrb_packed_int_len(uint32_t num);
36
+ size_t mrb_packed_int_encode(uint32_t num, uint8_t *p);
37
+ uint32_t mrb_packed_int_decode(const uint8_t *p, const uint8_t **newpos);
38
+
39
+ /* dump */
40
+ #ifdef MRUBY_IREP_H
41
+ int mrb_dump_irep(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size);
42
+ #ifndef MRB_NO_STDIO
43
+ int mrb_dump_irep_cfunc(mrb_state *mrb, const mrb_irep*, uint8_t flags, FILE *f, const char *initname);
44
+ int mrb_dump_irep_cstruct(mrb_state *mrb, const mrb_irep*, uint8_t flags, FILE *f, const char *initname);
45
+ #endif
46
+ #endif
47
+
48
+ /* codedump */
49
+ void mrb_codedump_all(mrb_state *mrb, struct RProc *proc);
50
+ #ifndef MRB_NO_STDIO
51
+ void mrb_codedump_all_file(mrb_state *mrb, struct RProc *proc, FILE *out);
52
+ #endif
53
+
54
+ /* error */
55
+ mrb_value mrb_exc_inspect(mrb_state *mrb, mrb_value exc);
56
+ mrb_value mrb_exc_backtrace(mrb_state *mrb, mrb_value exc);
57
+ mrb_value mrb_get_backtrace(mrb_state *mrb);
58
+ void mrb_exc_mesg_set(mrb_state *mrb, struct RException *exc, mrb_value mesg);
59
+ mrb_value mrb_exc_mesg_get(mrb_state *mrb, struct RException *exc);
60
+ mrb_value mrb_f_raise(mrb_state*, mrb_value);
61
+ mrb_value mrb_make_exception(mrb_state *mrb, mrb_value exc, mrb_value mesg);
62
+ mrb_value mrb_exc_get_output(mrb_state *mrb, struct RObject *exc);
63
+
64
+ struct RBacktrace {
65
+ MRB_OBJECT_HEADER;
66
+ size_t len;
67
+ struct mrb_backtrace_location *locations;
68
+ };
69
+
70
+ struct mrb_backtrace_location {
71
+ mrb_sym method_id;
72
+ int32_t idx;
73
+ const mrb_irep *irep;
74
+ };
75
+
76
+ /* gc */
77
+ size_t mrb_gc_mark_mt(mrb_state*, struct RClass*);
78
+ void mrb_gc_free_mt(mrb_state*, struct RClass*);
79
+
80
+ /* hash */
81
+ size_t mrb_hash_memsize(mrb_value obj);
82
+ size_t mrb_gc_mark_hash(mrb_state*, struct RHash*);
83
+ void mrb_gc_free_hash(mrb_state*, struct RHash*);
84
+ mrb_value mrb_hash_first_key(mrb_state*, mrb_value);
85
+ uint32_t mrb_obj_hash_code(mrb_state *mrb, mrb_value key);
86
+
87
+ /* irep */
88
+ struct mrb_insn_data mrb_decode_insn(const mrb_code *pc);
89
+ #ifdef MRUBY_IREP_H
90
+ void mrb_irep_free(mrb_state*, struct mrb_irep*);
91
+
92
+ static inline const struct mrb_irep_catch_handler *
93
+ mrb_irep_catch_handler_table(const struct mrb_irep *irep)
94
+ {
95
+ if (irep->clen > 0) {
96
+ return (const struct mrb_irep_catch_handler*)(irep->iseq + irep->ilen);
97
+ }
98
+ else {
99
+ return (const struct mrb_irep_catch_handler*)NULL;
100
+ }
101
+ }
102
+ #endif
103
+
104
+ /* numeric */
105
+ mrb_value mrb_div_int_value(mrb_state *mrb, mrb_int x, mrb_int y);
106
+ mrb_int mrb_div_int(mrb_int x, mrb_int y);
107
+ mrb_value mrb_int_add(mrb_state *mrb, mrb_value x, mrb_value y);
108
+ mrb_value mrb_int_sub(mrb_state *mrb, mrb_value x, mrb_value y);
109
+ mrb_value mrb_int_mul(mrb_state *mrb, mrb_value x, mrb_value y);
110
+ mrb_noreturn void mrb_int_zerodiv(mrb_state *mrb);
111
+ mrb_noreturn void mrb_int_overflow(mrb_state *mrb, const char *reason);
112
+ #ifndef MRB_NO_FLOAT
113
+ void mrb_check_num_exact(mrb_state *mrb, mrb_float num);
114
+ #endif
115
+
116
+ #ifdef MRB_USE_COMPLEX
117
+ mrb_value mrb_complex_new(mrb_state *mrb, mrb_float x, mrb_float y);
118
+ mrb_value mrb_complex_add(mrb_state *mrb, mrb_value x, mrb_value y);
119
+ mrb_value mrb_complex_sub(mrb_state *mrb, mrb_value x, mrb_value y);
120
+ mrb_value mrb_complex_mul(mrb_state *mrb, mrb_value x, mrb_value y);
121
+ mrb_value mrb_complex_div(mrb_state *mrb, mrb_value x, mrb_value y);
122
+ void mrb_complex_copy(mrb_state *mrb, mrb_value x, mrb_value y);
123
+ #endif
124
+ #ifdef MRB_USE_RATIONAL
125
+ mrb_value mrb_rational_new(mrb_state *mrb, mrb_int x, mrb_int y);
126
+ mrb_value mrb_rational_add(mrb_state *mrb, mrb_value x, mrb_value y);
127
+ mrb_value mrb_rational_sub(mrb_state *mrb, mrb_value x, mrb_value y);
128
+ mrb_value mrb_rational_mul(mrb_state *mrb, mrb_value x, mrb_value y);
129
+ mrb_value mrb_rational_div(mrb_state *mrb, mrb_value x, mrb_value y);
130
+ mrb_value mrb_as_rational(mrb_state *mrb, mrb_value x);
131
+ void mrb_rational_copy(mrb_state *mrb, mrb_value x, mrb_value y);
132
+ int mrb_rational_mark(mrb_state *mrb, struct RBasic *rat);
133
+ #endif
134
+ #ifdef MRB_USE_SET
135
+ size_t mrb_gc_mark_set(mrb_state *mrb, struct RBasic *set);
136
+ void mrb_gc_free_set(mrb_state *mrb, struct RBasic *set);
137
+ size_t mrb_set_memsize(mrb_value);
138
+ #endif
139
+
140
+ #ifdef MRUBY_PROC_H
141
+ struct RProc *mrb_closure_new(mrb_state*, const mrb_irep*);
142
+ void mrb_proc_copy(mrb_state *mrb, struct RProc *a, const struct RProc *b);
143
+ mrb_int mrb_proc_arity(const struct RProc *p);
144
+ struct REnv *mrb_env_new(mrb_state *mrb, struct mrb_context *c, mrb_callinfo *ci, int nstacks, mrb_value *stack, struct RClass *tc);
145
+ void mrb_proc_merge_lvar(mrb_state *mrb, mrb_irep *irep, struct REnv *env, int num, const mrb_sym *lv, const mrb_value *stack);
146
+ mrb_value mrb_proc_local_variables(mrb_state *mrb, const struct RProc *proc);
147
+ const struct RProc *mrb_proc_get_caller(mrb_state *mrb, struct REnv **env);
148
+ mrb_value mrb_proc_get_self(mrb_state *mrb, const struct RProc *p, struct RClass **target_class_p);
149
+ mrb_bool mrb_proc_eql(mrb_state *mrb, mrb_value self, mrb_value other);
150
+ #endif
151
+
152
+ /* range */
153
+ #ifdef MRUBY_RANGE_H
154
+ mrb_value mrb_get_values_at(mrb_state *mrb, mrb_value obj, mrb_int olen, mrb_int argc, const mrb_value *argv, mrb_value (*func)(mrb_state*, mrb_value, mrb_int));
155
+ size_t mrb_gc_mark_range(mrb_state *mrb, struct RRange *r);
156
+ #endif
157
+
158
+ /* string */
159
+ void mrb_gc_free_str(mrb_state*, struct RString*);
160
+ uint32_t mrb_str_hash(mrb_state *mrb, mrb_value str);
161
+ mrb_value mrb_str_dump(mrb_state *mrb, mrb_value str);
162
+ mrb_value mrb_str_inspect(mrb_state *mrb, mrb_value str);
163
+ mrb_bool mrb_str_beg_len(mrb_int str_len, mrb_int *begp, mrb_int *lenp);
164
+ mrb_value mrb_str_byte_subseq(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len);
165
+ mrb_value mrb_str_aref(mrb_state *mrb, mrb_value str, mrb_value idx, mrb_value len);
166
+ uint32_t mrb_byte_hash(const uint8_t*, mrb_int);
167
+ uint32_t mrb_byte_hash_step(const uint8_t*, mrb_int, uint32_t);
168
+
169
+ #ifdef MRB_UTF8_STRING
170
+ mrb_int mrb_utf8len(const char *str, const char *end);
171
+ mrb_int mrb_utf8_strlen(const char *str, mrb_int byte_len);
172
+ #endif
173
+
174
+ /* variable */
175
+ mrb_value mrb_vm_special_get(mrb_state*, mrb_sym);
176
+ void mrb_vm_special_set(mrb_state*, mrb_sym, mrb_value);
177
+ mrb_value mrb_vm_cv_get(mrb_state*, mrb_sym);
178
+ void mrb_vm_cv_set(mrb_state*, mrb_sym, mrb_value);
179
+ mrb_value mrb_vm_const_get(mrb_state*, mrb_sym);
180
+ size_t mrb_obj_iv_tbl_memsize(mrb_value);
181
+ void mrb_obj_iv_set_force(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v);
182
+ mrb_value mrb_mod_constants(mrb_state *mrb, mrb_value mod);
183
+ mrb_value mrb_mod_const_at(mrb_state *mrb, struct RClass *c, mrb_value ary);
184
+ mrb_value mrb_f_global_variables(mrb_state *mrb, mrb_value self);
185
+ mrb_value mrb_obj_instance_variables(mrb_state*, mrb_value);
186
+ mrb_value mrb_mod_class_variables(mrb_state*, mrb_value);
187
+ mrb_value mrb_mod_cv_get(mrb_state *mrb, struct RClass *c, mrb_sym sym);
188
+ mrb_bool mrb_mod_cv_defined(mrb_state *mrb, struct RClass *c, mrb_sym sym);
189
+ mrb_bool mrb_ident_p(const char *s, mrb_int len);
190
+ mrb_value mrb_exc_const_get(mrb_state *mrb, mrb_sym sym);
191
+
192
+ /* GC functions */
193
+ void mrb_gc_mark_gv(mrb_state*);
194
+ void mrb_gc_free_gv(mrb_state*);
195
+ size_t mrb_gc_mark_iv(mrb_state*, struct RObject*);
196
+ void mrb_gc_free_iv(mrb_state*, struct RObject*);
197
+
198
+ /* VM */
199
+ #define MRB_CI_VISIBILITY(ci) MRB_FLAGS_GET((ci)->vis, 0, 2)
200
+ #define MRB_CI_SET_VISIBILITY(ci, visi) MRB_FLAGS_SET((ci)->vis, 0, 2, visi)
201
+ #define MRB_CI_VISIBILITY_BREAK_P(ci) MRB_FLAG_CHECK((ci)->vis, 2)
202
+ #define MRB_CI_SET_VISIBILITY_BREAK(ci) MRB_FLAG_ON((ci)->vis, 2)
203
+ mrb_int mrb_ci_bidx(mrb_callinfo *ci);
204
+ mrb_int mrb_ci_nregs(mrb_callinfo *ci);
205
+ mrb_value mrb_exec_irep(mrb_state *mrb, mrb_value self, const struct RProc *p);
206
+ mrb_value mrb_obj_instance_eval(mrb_state*, mrb_value);
207
+ mrb_value mrb_object_exec(mrb_state *mrb, mrb_value self, struct RClass *target_class);
208
+ mrb_value mrb_mod_module_eval(mrb_state*, mrb_value);
209
+ mrb_value mrb_f_send(mrb_state *mrb, mrb_value self);
210
+ mrb_value mrb_f_public_send(mrb_state *mrb, mrb_value self);
211
+
212
+ #ifdef MRB_USE_BIGINT
213
+ mrb_value mrb_bint_new_int(mrb_state *mrb, mrb_int x);
214
+ #ifdef MRB_INT64
215
+ #define mrb_bint_new_int64(mrb,x) mrb_bint_new_int((mrb),(mrb_int)(x))
216
+ #else
217
+ mrb_value mrb_bint_new_int64(mrb_state *mrb, int64_t x);
218
+ #endif
219
+ mrb_value mrb_bint_new_uint64(mrb_state *mrb, uint64_t x);
220
+ mrb_value mrb_bint_new_str(mrb_state *mrb, const char *x, mrb_int len, mrb_int base);
221
+ mrb_value mrb_as_bint(mrb_state *mrb, mrb_value x);
222
+ mrb_value mrb_bint_add(mrb_state *mrb, mrb_value x, mrb_value y);
223
+ mrb_value mrb_bint_sub(mrb_state *mrb, mrb_value x, mrb_value y);
224
+ mrb_value mrb_bint_add_n(mrb_state *mrb, mrb_value x, mrb_value y);
225
+ mrb_value mrb_bint_sub_n(mrb_state *mrb, mrb_value x, mrb_value y);
226
+ mrb_value mrb_bint_mul(mrb_state *mrb, mrb_value x, mrb_value y);
227
+ mrb_value mrb_bint_div(mrb_state *mrb, mrb_value x, mrb_value y);
228
+ mrb_value mrb_bint_divmod(mrb_state *mrb, mrb_value x, mrb_value y);
229
+ mrb_value mrb_bint_add_ii(mrb_state *mrb, mrb_int x, mrb_int y);
230
+ mrb_value mrb_bint_sub_ii(mrb_state *mrb, mrb_int x, mrb_int y);
231
+ mrb_value mrb_bint_mul_ii(mrb_state *mrb, mrb_int x, mrb_int y);
232
+ mrb_value mrb_bint_mod(mrb_state *mrb, mrb_value x, mrb_value y);
233
+ mrb_value mrb_bint_rem(mrb_state *mrb, mrb_value x, mrb_value y);
234
+ mrb_value mrb_bint_pow(mrb_state *mrb, mrb_value x, mrb_value y);
235
+ mrb_value mrb_bint_powm(mrb_state *mrb, mrb_value x, mrb_value y, mrb_value z);
236
+ mrb_value mrb_bint_and(mrb_state *mrb, mrb_value x, mrb_value y);
237
+ mrb_value mrb_bint_or(mrb_state *mrb, mrb_value x, mrb_value y);
238
+ mrb_value mrb_bint_neg(mrb_state *mrb, mrb_value x);
239
+ mrb_value mrb_bint_xor(mrb_state *mrb, mrb_value x, mrb_value y);
240
+ mrb_value mrb_bint_rev(mrb_state *mrb, mrb_value x);
241
+ mrb_value mrb_bint_lshift(mrb_state *mrb, mrb_value x, mrb_int width);
242
+ mrb_value mrb_bint_rshift(mrb_state *mrb, mrb_value x, mrb_int width);
243
+ mrb_value mrb_bint_to_s(mrb_state *mrb, mrb_value x, mrb_int base);
244
+ #ifndef MRB_NO_FLOAT
245
+ mrb_value mrb_bint_new_float(mrb_state *mrb, mrb_float x);
246
+ mrb_float mrb_bint_as_float(mrb_state *mrb, mrb_value x);
247
+ #endif
248
+ mrb_int mrb_bint_as_int(mrb_state *mrb, mrb_value x);
249
+ #ifdef MRB_INT64
250
+ #define mrb_bint_as_int64(mrb, x) mrb_bint_as_int((mrb), (x))
251
+ #else
252
+ int64_t mrb_bint_as_int64(mrb_state *mrb, mrb_value x);
253
+ #endif
254
+ uint64_t mrb_bint_as_uint64(mrb_state *mrb, mrb_value x);
255
+ mrb_int mrb_bint_cmp(mrb_state *mrb, mrb_value x, mrb_value y);
256
+ void mrb_gc_free_bint(mrb_state *mrb, struct RBasic *x);
257
+ void mrb_bint_copy(mrb_state *mrb, mrb_value x, mrb_value y);
258
+ size_t mrb_bint_memsize(mrb_value x);
259
+ mrb_value mrb_bint_hash(mrb_state *mrb, mrb_value x);
260
+ mrb_value mrb_bint_sqrt(mrb_state *mrb, mrb_value x);
261
+ mrb_int mrb_bint_size(mrb_state *mrb, mrb_value bint);
262
+ mrb_value mrb_bint_from_bytes(mrb_state *mrb, const uint8_t *bytes, mrb_int len);
263
+ mrb_int mrb_bint_sign(mrb_state *mrb, mrb_value bint);
264
+ mrb_value mrb_bint_gcd(mrb_state *mrb, mrb_value x, mrb_value y);
265
+ mrb_value mrb_bint_lcm(mrb_state *mrb, mrb_value x, mrb_value y);
266
+ mrb_value mrb_bint_abs(mrb_state *mrb, mrb_value x);
267
+ #endif
268
+
269
+ #ifdef MRB_USE_TASK_SCHEDULER
270
+ /* GC marking for task scheduler */
271
+ void mrb_task_mark_all(mrb_state *mrb);
272
+ #endif
273
+
274
+ #endif /* MRUBY_INTERNAL_H */