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.
- checksums.yaml +7 -0
- data/README.md +195 -0
- data/exe/portable-mruby +6 -0
- data/lib/portable_mruby/binary_manager.rb +225 -0
- data/lib/portable_mruby/builder.rb +97 -0
- data/lib/portable_mruby/bytecode_compiler.rb +19 -0
- data/lib/portable_mruby/c_generator.rb +94 -0
- data/lib/portable_mruby/cli.rb +136 -0
- data/lib/portable_mruby/version.rb +6 -0
- data/lib/portable_mruby.rb +15 -0
- data/vendor/mruby/bin/mrbc.com +0 -0
- data/vendor/mruby/include/mrbconf.h +230 -0
- data/vendor/mruby/include/mruby/array.h +303 -0
- data/vendor/mruby/include/mruby/boxing_nan.h +169 -0
- data/vendor/mruby/include/mruby/boxing_no.h +59 -0
- data/vendor/mruby/include/mruby/boxing_word.h +251 -0
- data/vendor/mruby/include/mruby/class.h +104 -0
- data/vendor/mruby/include/mruby/common.h +118 -0
- data/vendor/mruby/include/mruby/compile.h +185 -0
- data/vendor/mruby/include/mruby/data.h +76 -0
- data/vendor/mruby/include/mruby/debug.h +75 -0
- data/vendor/mruby/include/mruby/dump.h +159 -0
- data/vendor/mruby/include/mruby/endian.h +44 -0
- data/vendor/mruby/include/mruby/error.h +132 -0
- data/vendor/mruby/include/mruby/gc.h +72 -0
- data/vendor/mruby/include/mruby/gems/mruby-dir/include/dir_hal.h +79 -0
- data/vendor/mruby/include/mruby/gems/mruby-io/include/io_hal.h +451 -0
- data/vendor/mruby/include/mruby/gems/mruby-io/include/mruby/ext/io.h +76 -0
- data/vendor/mruby/include/mruby/gems/mruby-socket/include/socket_hal.h +83 -0
- data/vendor/mruby/include/mruby/gems/mruby-time/include/mruby/time.h +27 -0
- data/vendor/mruby/include/mruby/hash.h +234 -0
- data/vendor/mruby/include/mruby/internal.h +274 -0
- data/vendor/mruby/include/mruby/irep.h +142 -0
- data/vendor/mruby/include/mruby/istruct.h +50 -0
- data/vendor/mruby/include/mruby/khash.h +455 -0
- data/vendor/mruby/include/mruby/mempool.h +19 -0
- data/vendor/mruby/include/mruby/numeric.h +174 -0
- data/vendor/mruby/include/mruby/object.h +45 -0
- data/vendor/mruby/include/mruby/opcode.h +69 -0
- data/vendor/mruby/include/mruby/ops.h +120 -0
- data/vendor/mruby/include/mruby/presym/disable.h +72 -0
- data/vendor/mruby/include/mruby/presym/enable.h +39 -0
- data/vendor/mruby/include/mruby/presym/id.h +1423 -0
- data/vendor/mruby/include/mruby/presym/scanning.h +81 -0
- data/vendor/mruby/include/mruby/presym/table.h +2847 -0
- data/vendor/mruby/include/mruby/presym.h +41 -0
- data/vendor/mruby/include/mruby/proc.h +186 -0
- data/vendor/mruby/include/mruby/range.h +77 -0
- data/vendor/mruby/include/mruby/re.h +16 -0
- data/vendor/mruby/include/mruby/string.h +428 -0
- data/vendor/mruby/include/mruby/throw.h +57 -0
- data/vendor/mruby/include/mruby/value.h +471 -0
- data/vendor/mruby/include/mruby/variable.h +108 -0
- data/vendor/mruby/include/mruby/version.h +143 -0
- data/vendor/mruby/include/mruby.h +1614 -0
- data/vendor/mruby/lib/libmruby.a +0 -0
- metadata +102 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
** @file mruby/numeric.h - Numeric, Integer, Float class
|
|
3
|
+
**
|
|
4
|
+
** See Copyright Notice in mruby.h
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#ifndef MRUBY_NUMERIC_H
|
|
8
|
+
#define MRUBY_NUMERIC_H
|
|
9
|
+
|
|
10
|
+
#include "common.h"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Numeric class and it's sub-classes.
|
|
14
|
+
*
|
|
15
|
+
* Integer and Float
|
|
16
|
+
*/
|
|
17
|
+
MRB_BEGIN_DECL
|
|
18
|
+
|
|
19
|
+
#define TYPED_POSFIXABLE(f,t) ((f) <= (t)MRB_FIXNUM_MAX)
|
|
20
|
+
#define TYPED_NEGFIXABLE(f,t) ((f) >= (t)MRB_FIXNUM_MIN)
|
|
21
|
+
#define TYPED_FIXABLE(f,t) (TYPED_POSFIXABLE(f,t) && TYPED_NEGFIXABLE(f,t))
|
|
22
|
+
#define POSFIXABLE(f) TYPED_POSFIXABLE(f,mrb_int)
|
|
23
|
+
#define NEGFIXABLE(f) TYPED_NEGFIXABLE(f,mrb_int)
|
|
24
|
+
#define FIXABLE(f) TYPED_FIXABLE(f,mrb_int)
|
|
25
|
+
#ifndef MRB_NO_FLOAT
|
|
26
|
+
#ifdef MRB_INT64
|
|
27
|
+
#define FIXABLE_FLOAT(f) ((f)>=-9223372036854775808.0 && (f)<9223372036854775808.0)
|
|
28
|
+
#else
|
|
29
|
+
#define FIXABLE_FLOAT(f) TYPED_FIXABLE(f,mrb_float)
|
|
30
|
+
#endif
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
/* utility functions */
|
|
34
|
+
MRB_API mrb_value mrb_num_add(mrb_state *mrb, mrb_value x, mrb_value y);
|
|
35
|
+
MRB_API mrb_value mrb_num_sub(mrb_state *mrb, mrb_value x, mrb_value y);
|
|
36
|
+
MRB_API mrb_value mrb_num_mul(mrb_state *mrb, mrb_value x, mrb_value y);
|
|
37
|
+
/* obsolete old names */
|
|
38
|
+
#define mrb_num_plus(mrb, x, y) mrb_num_add(mrb, x, y)
|
|
39
|
+
#define mrb_num_minus(mrb, x, y) mrb_num_sub(mrb, x, y)
|
|
40
|
+
|
|
41
|
+
MRB_API mrb_value mrb_integer_to_str(mrb_state *mrb, mrb_value x, mrb_int base);
|
|
42
|
+
MRB_API char *mrb_int_to_cstr(char *buf, size_t len, mrb_int n, mrb_int base);
|
|
43
|
+
|
|
44
|
+
/* obsolete function(s); will be removed */
|
|
45
|
+
#define mrb_fixnum_to_str(mrb, x, base) mrb_integer_to_str(mrb, x, base)
|
|
46
|
+
|
|
47
|
+
#ifndef __has_builtin
|
|
48
|
+
#define __has_builtin(x) 0
|
|
49
|
+
#endif
|
|
50
|
+
|
|
51
|
+
#if (defined(__GNUC__) && __GNUC__ >= 5) || \
|
|
52
|
+
(__has_builtin(__builtin_add_overflow) && \
|
|
53
|
+
__has_builtin(__builtin_sub_overflow) && \
|
|
54
|
+
__has_builtin(__builtin_mul_overflow))
|
|
55
|
+
# define MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
|
|
56
|
+
#endif
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
// Clang 3.8 and 3.9 have problem compiling mruby in 32-bit mode, when MRB_INT64 is set
|
|
60
|
+
// because of missing __mulodi4 and similar functions in its runtime. We need to use custom
|
|
61
|
+
// implementation for them.
|
|
62
|
+
*/
|
|
63
|
+
#ifdef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
|
|
64
|
+
#if defined(__clang__) && (__clang_major__ == 3) && (__clang_minor__ >= 8) && \
|
|
65
|
+
defined(MRB_32BIT) && defined(MRB_INT64)
|
|
66
|
+
#undef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
|
|
67
|
+
#endif
|
|
68
|
+
#endif
|
|
69
|
+
|
|
70
|
+
#ifdef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
|
|
71
|
+
|
|
72
|
+
static inline mrb_bool
|
|
73
|
+
mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum)
|
|
74
|
+
{
|
|
75
|
+
return __builtin_add_overflow(augend, addend, sum);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static inline mrb_bool
|
|
79
|
+
mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference)
|
|
80
|
+
{
|
|
81
|
+
return __builtin_sub_overflow(minuend, subtrahend, difference);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static inline mrb_bool
|
|
85
|
+
mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
|
|
86
|
+
{
|
|
87
|
+
return __builtin_mul_overflow(multiplier, multiplicand, product);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
#else
|
|
91
|
+
|
|
92
|
+
#define MRB_INT_OVERFLOW_MASK ((mrb_uint)1 << (MRB_INT_BIT - 1))
|
|
93
|
+
|
|
94
|
+
static inline mrb_bool
|
|
95
|
+
mrb_int_add_overflow(mrb_int a, mrb_int b, mrb_int *c)
|
|
96
|
+
{
|
|
97
|
+
mrb_uint x = (mrb_uint)a;
|
|
98
|
+
mrb_uint y = (mrb_uint)b;
|
|
99
|
+
mrb_uint z = (mrb_uint)(x + y);
|
|
100
|
+
*c = (mrb_int)z;
|
|
101
|
+
return !!(((x ^ z) & (y ^ z)) & MRB_INT_OVERFLOW_MASK);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static inline mrb_bool
|
|
105
|
+
mrb_int_sub_overflow(mrb_int a, mrb_int b, mrb_int *c)
|
|
106
|
+
{
|
|
107
|
+
mrb_uint x = (mrb_uint)a;
|
|
108
|
+
mrb_uint y = (mrb_uint)b;
|
|
109
|
+
mrb_uint z = (mrb_uint)(x - y);
|
|
110
|
+
*c = (mrb_int)z;
|
|
111
|
+
return !!(((x ^ z) & (~y ^ z)) & MRB_INT_OVERFLOW_MASK);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static inline mrb_bool
|
|
115
|
+
mrb_int_mul_overflow(mrb_int a, mrb_int b, mrb_int *c)
|
|
116
|
+
{
|
|
117
|
+
#ifdef MRB_INT32
|
|
118
|
+
int64_t n = (int64_t)a * b;
|
|
119
|
+
*c = (mrb_int)n;
|
|
120
|
+
return n > MRB_INT_MAX || n < MRB_INT_MIN;
|
|
121
|
+
#else /* MRB_INT64 */
|
|
122
|
+
*c = a * b;
|
|
123
|
+
if (a > 0 && b > 0 && a > MRB_INT_MAX / b) return TRUE;
|
|
124
|
+
if (a < 0 && b > 0 && a < MRB_INT_MIN / b) return TRUE;
|
|
125
|
+
if (a > 0 && b < 0 && b < MRB_INT_MIN / a) return TRUE;
|
|
126
|
+
if (a < 0 && b < 0 && (a <= MRB_INT_MIN || b <= MRB_INT_MIN || -a > MRB_INT_MAX / -b))
|
|
127
|
+
return TRUE;
|
|
128
|
+
return FALSE;
|
|
129
|
+
#endif
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
#undef MRB_INT_OVERFLOW_MASK
|
|
133
|
+
|
|
134
|
+
#endif
|
|
135
|
+
|
|
136
|
+
#ifndef MRB_NO_FLOAT
|
|
137
|
+
|
|
138
|
+
# define MRB_FLT_RADIX FLT_RADIX
|
|
139
|
+
|
|
140
|
+
# ifdef MRB_USE_FLOAT32
|
|
141
|
+
# define MRB_FLT_MANT_DIG FLT_MANT_DIG
|
|
142
|
+
# define MRB_FLT_EPSILON FLT_EPSILON
|
|
143
|
+
# define MRB_FLT_DIG FLT_DIG
|
|
144
|
+
# define MRB_FLT_MIN_EXP FLT_MIN_EXP
|
|
145
|
+
# define MRB_FLT_MIN FLT_MIN
|
|
146
|
+
# define MRB_FLT_MIN_10_EXP FLT_MIN_10_EXP
|
|
147
|
+
# define MRB_FLT_MAX_EXP FLT_MAX_EXP
|
|
148
|
+
# define MRB_FLT_MAX FLT_MAX
|
|
149
|
+
# define MRB_FLT_MAX_10_EXP FLT_MAX_10_EXP
|
|
150
|
+
|
|
151
|
+
# else /* not MRB_USE_FLOAT32 */
|
|
152
|
+
# define MRB_FLT_MANT_DIG DBL_MANT_DIG
|
|
153
|
+
# define MRB_FLT_EPSILON DBL_EPSILON
|
|
154
|
+
# define MRB_FLT_DIG DBL_DIG
|
|
155
|
+
# define MRB_FLT_MIN_EXP DBL_MIN_EXP
|
|
156
|
+
# define MRB_FLT_MIN DBL_MIN
|
|
157
|
+
# define MRB_FLT_MIN_10_EXP DBL_MIN_10_EXP
|
|
158
|
+
# define MRB_FLT_MAX_EXP DBL_MAX_EXP
|
|
159
|
+
# define MRB_FLT_MAX DBL_MAX
|
|
160
|
+
# define MRB_FLT_MAX_10_EXP DBL_MAX_10_EXP
|
|
161
|
+
# endif /* MRB_USE_FLOAT32 */
|
|
162
|
+
|
|
163
|
+
MRB_API mrb_value mrb_float_to_integer(mrb_state *mrb, mrb_value val);
|
|
164
|
+
|
|
165
|
+
/* internal functions */
|
|
166
|
+
mrb_float mrb_div_float(mrb_float x, mrb_float y);
|
|
167
|
+
mrb_value mrb_float_to_str(mrb_state *mrb, mrb_value x, const char *fmt);
|
|
168
|
+
int mrb_format_float(mrb_float f, char *buf, size_t buf_size, char fmt, int prec, char sign);
|
|
169
|
+
|
|
170
|
+
#endif /* MRB_NO_FLOAT */
|
|
171
|
+
|
|
172
|
+
MRB_END_DECL
|
|
173
|
+
|
|
174
|
+
#endif /* MRUBY_NUMERIC_H */
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
** @file mruby/object.h - mruby object definition
|
|
3
|
+
**
|
|
4
|
+
** See Copyright Notice in mruby.h
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#ifndef MRUBY_OBJECT_H
|
|
8
|
+
#define MRUBY_OBJECT_H
|
|
9
|
+
|
|
10
|
+
#define MRB_OBJECT_HEADER \
|
|
11
|
+
struct RClass *c; \
|
|
12
|
+
struct RBasic *gcnext; \
|
|
13
|
+
enum mrb_vtype tt:8; \
|
|
14
|
+
unsigned int gc_color:3; \
|
|
15
|
+
unsigned int frozen:1; \
|
|
16
|
+
uint32_t flags:20
|
|
17
|
+
|
|
18
|
+
#define MRB_FLAG_TEST(obj, flag) ((obj)->flags & (flag))
|
|
19
|
+
|
|
20
|
+
struct RBasic {
|
|
21
|
+
MRB_OBJECT_HEADER;
|
|
22
|
+
};
|
|
23
|
+
#define mrb_basic_ptr(v) ((struct RBasic*)(mrb_ptr(v)))
|
|
24
|
+
|
|
25
|
+
#define MRB_OBJ_IS_FROZEN 1
|
|
26
|
+
#define mrb_frozen_p(o) ((o)->frozen)
|
|
27
|
+
|
|
28
|
+
struct RObject {
|
|
29
|
+
MRB_OBJECT_HEADER;
|
|
30
|
+
struct iv_tbl *iv;
|
|
31
|
+
};
|
|
32
|
+
#define mrb_obj_ptr(v) ((struct RObject*)(mrb_ptr(v)))
|
|
33
|
+
|
|
34
|
+
#define mrb_special_const_p(x) mrb_immediate_p(x)
|
|
35
|
+
|
|
36
|
+
struct RFiber {
|
|
37
|
+
MRB_OBJECT_HEADER;
|
|
38
|
+
struct mrb_context *cxt;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
#define mrb_static_assert_object_size(st) \
|
|
42
|
+
mrb_static_assert(sizeof(st) <= sizeof(void*) * 6, \
|
|
43
|
+
#st " size must be within 6 words")
|
|
44
|
+
|
|
45
|
+
#endif /* MRUBY_OBJECT_H */
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
** @file mruby/opcode.h - RiteVM operation codes
|
|
3
|
+
**
|
|
4
|
+
** See Copyright Notice in mruby.h
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#ifndef MRUBY_OPCODE_H
|
|
8
|
+
#define MRUBY_OPCODE_H
|
|
9
|
+
|
|
10
|
+
enum mrb_insn {
|
|
11
|
+
#define OPCODE(x,_) OP_ ## x,
|
|
12
|
+
#include <mruby/ops.h>
|
|
13
|
+
#undef OPCODE
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
#define OP_L_STRICT 1
|
|
17
|
+
#define OP_L_CAPTURE 2
|
|
18
|
+
#define OP_L_METHOD OP_L_STRICT
|
|
19
|
+
#define OP_L_LAMBDA (OP_L_STRICT|OP_L_CAPTURE)
|
|
20
|
+
#define OP_L_BLOCK OP_L_CAPTURE
|
|
21
|
+
|
|
22
|
+
#define PEEK_B(pc) (*(pc))
|
|
23
|
+
#define PEEK_S(pc) ((pc)[0]<<8|(pc)[1])
|
|
24
|
+
#define PEEK_W(pc) ((pc)[0]<<16|(pc)[1]<<8|(pc)[2])
|
|
25
|
+
|
|
26
|
+
#define READ_B() PEEK_B(pc++)
|
|
27
|
+
#define READ_S() (pc+=2, PEEK_S(pc-2))
|
|
28
|
+
#define READ_W() (pc+=3, PEEK_W(pc-3))
|
|
29
|
+
|
|
30
|
+
#define FETCH_Z() /* nothing */
|
|
31
|
+
#define FETCH_B() do {a=READ_B();} while (0)
|
|
32
|
+
#define FETCH_BB() do {a=READ_B(); b=READ_B();} while (0)
|
|
33
|
+
#define FETCH_BBB() do {a=READ_B(); b=READ_B(); c=READ_B();} while (0)
|
|
34
|
+
#define FETCH_BS() do {a=READ_B(); b=READ_S();} while (0)
|
|
35
|
+
#define FETCH_BSS() do {a=READ_B(); b=READ_S(); c=READ_S();} while (0)
|
|
36
|
+
#define FETCH_S() do {a=READ_S();} while (0)
|
|
37
|
+
#define FETCH_W() do {a=READ_W();} while (0)
|
|
38
|
+
|
|
39
|
+
/* with OP_EXT1 (1st 16bit) */
|
|
40
|
+
#define FETCH_Z_1() FETCH_Z()
|
|
41
|
+
#define FETCH_B_1() FETCH_S()
|
|
42
|
+
#define FETCH_BB_1() do {a=READ_S(); b=READ_B();} while (0)
|
|
43
|
+
#define FETCH_BBB_1() do {a=READ_S(); b=READ_B(); c=READ_B();} while (0)
|
|
44
|
+
#define FETCH_BS_1() do {a=READ_S(); b=READ_S();} while (0)
|
|
45
|
+
#define FETCH_BSS_1() do {a=READ_S(); b=READ_S();c=READ_S();} while (0)
|
|
46
|
+
#define FETCH_S_1() FETCH_S()
|
|
47
|
+
#define FETCH_W_1() FETCH_W()
|
|
48
|
+
|
|
49
|
+
/* with OP_EXT2 (2nd 16bit) */
|
|
50
|
+
#define FETCH_Z_2() FETCH_Z()
|
|
51
|
+
#define FETCH_B_2() FETCH_B()
|
|
52
|
+
#define FETCH_BB_2() do {a=READ_B(); b=READ_S();} while (0)
|
|
53
|
+
#define FETCH_BBB_2() do {a=READ_B(); b=READ_S(); c=READ_B();} while (0)
|
|
54
|
+
#define FETCH_BS_2() FETCH_BS()
|
|
55
|
+
#define FETCH_BSS_2() FETCH_BSS()
|
|
56
|
+
#define FETCH_S_2() FETCH_S()
|
|
57
|
+
#define FETCH_W_2() FETCH_W()
|
|
58
|
+
|
|
59
|
+
/* with OP_EXT3 (1st & 2nd 16bit) */
|
|
60
|
+
#define FETCH_Z_3() FETCH_Z()
|
|
61
|
+
#define FETCH_B_3() FETCH_B()
|
|
62
|
+
#define FETCH_BB_3() do {a=READ_S(); b=READ_S();} while (0)
|
|
63
|
+
#define FETCH_BBB_3() do {a=READ_S(); b=READ_S(); c=READ_B();} while (0)
|
|
64
|
+
#define FETCH_BS_3() do {a=READ_S(); b=READ_S();} while (0)
|
|
65
|
+
#define FETCH_BSS_3() FETCH_BSS_1()
|
|
66
|
+
#define FETCH_S_3() FETCH_S()
|
|
67
|
+
#define FETCH_W_3() FETCH_W()
|
|
68
|
+
|
|
69
|
+
#endif /* MRUBY_OPCODE_H */
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/* operand types:
|
|
2
|
+
+ Z: no operand
|
|
3
|
+
+ B: 8bit
|
|
4
|
+
+ BB: 8+8bit
|
|
5
|
+
+ BBB: 8+8+8bit
|
|
6
|
+
+ BS: 8+16bit
|
|
7
|
+
+ BSS: 8+16+16bit
|
|
8
|
+
+ S: 16bit
|
|
9
|
+
+ W: 24bit
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/*-----------------------------------------------------------------------
|
|
13
|
+
operation code operands semantics
|
|
14
|
+
------------------------------------------------------------------------*/
|
|
15
|
+
OPCODE(NOP, Z) /* no operation */
|
|
16
|
+
OPCODE(MOVE, BB) /* R[a] = R[b] */
|
|
17
|
+
OPCODE(LOADL, BB) /* R[a] = Pool[b] */
|
|
18
|
+
OPCODE(LOADI8, BB) /* R[a] = mrb_int(b) */
|
|
19
|
+
OPCODE(LOADINEG, BB) /* R[a] = mrb_int(-b) */
|
|
20
|
+
OPCODE(LOADI__1, B) /* R[a] = mrb_int(-1) */
|
|
21
|
+
OPCODE(LOADI_0, B) /* R[a] = mrb_int(0) */
|
|
22
|
+
OPCODE(LOADI_1, B) /* R[a] = mrb_int(1) */
|
|
23
|
+
OPCODE(LOADI_2, B) /* R[a] = mrb_int(2) */
|
|
24
|
+
OPCODE(LOADI_3, B) /* R[a] = mrb_int(3) */
|
|
25
|
+
OPCODE(LOADI_4, B) /* R[a] = mrb_int(4) */
|
|
26
|
+
OPCODE(LOADI_5, B) /* R[a] = mrb_int(5) */
|
|
27
|
+
OPCODE(LOADI_6, B) /* R[a] = mrb_int(6) */
|
|
28
|
+
OPCODE(LOADI_7, B) /* R[a] = mrb_int(7) */
|
|
29
|
+
OPCODE(LOADI16, BS) /* R[a] = mrb_int(b) */
|
|
30
|
+
OPCODE(LOADI32, BSS) /* R[a] = mrb_int((b<<16)+c) */
|
|
31
|
+
OPCODE(LOADSYM, BB) /* R[a] = Syms[b] */
|
|
32
|
+
OPCODE(LOADNIL, B) /* R[a] = nil */
|
|
33
|
+
OPCODE(LOADSELF, B) /* R[a] = self */
|
|
34
|
+
OPCODE(LOADT, B) /* R[a] = true */
|
|
35
|
+
OPCODE(LOADF, B) /* R[a] = false */
|
|
36
|
+
OPCODE(GETGV, BB) /* R[a] = getglobal(Syms[b]) */
|
|
37
|
+
OPCODE(SETGV, BB) /* setglobal(Syms[b], R[a]) */
|
|
38
|
+
OPCODE(GETSV, BB) /* R[a] = Special[Syms[b]] */
|
|
39
|
+
OPCODE(SETSV, BB) /* Special[Syms[b]] = R[a] */
|
|
40
|
+
OPCODE(GETIV, BB) /* R[a] = ivget(Syms[b]) */
|
|
41
|
+
OPCODE(SETIV, BB) /* ivset(Syms[b],R[a]) */
|
|
42
|
+
OPCODE(GETCV, BB) /* R[a] = cvget(Syms[b]) */
|
|
43
|
+
OPCODE(SETCV, BB) /* cvset(Syms[b],R[a]) */
|
|
44
|
+
OPCODE(GETCONST, BB) /* R[a] = constget(Syms[b]) */
|
|
45
|
+
OPCODE(SETCONST, BB) /* constset(Syms[b],R[a]) */
|
|
46
|
+
OPCODE(GETMCNST, BB) /* R[a] = R[a]::Syms[b] */
|
|
47
|
+
OPCODE(SETMCNST, BB) /* R[a+1]::Syms[b] = R[a] */
|
|
48
|
+
OPCODE(GETUPVAR, BBB) /* R[a] = uvget(b,c) */
|
|
49
|
+
OPCODE(SETUPVAR, BBB) /* uvset(b,c,R[a]) */
|
|
50
|
+
OPCODE(GETIDX, B) /* R[a] = R[a][R[a+1]] */
|
|
51
|
+
OPCODE(SETIDX, B) /* R[a][R[a+1]] = R[a+2] */
|
|
52
|
+
OPCODE(JMP, S) /* pc+=a */
|
|
53
|
+
OPCODE(JMPIF, BS) /* if R[a] pc+=b */
|
|
54
|
+
OPCODE(JMPNOT, BS) /* if !R[a] pc+=b */
|
|
55
|
+
OPCODE(JMPNIL, BS) /* if R[a]==nil pc+=b */
|
|
56
|
+
OPCODE(JMPUW, S) /* unwind_and_jump_to(a) */
|
|
57
|
+
OPCODE(EXCEPT, B) /* R[a] = exc */
|
|
58
|
+
OPCODE(RESCUE, BB) /* R[b] = R[a].isa?(R[b]) */
|
|
59
|
+
OPCODE(RAISEIF, B) /* raise(R[a]) if R[a] */
|
|
60
|
+
OPCODE(SSEND, BBB) /* R[a] = self.send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..) (c=n|k<<4) */
|
|
61
|
+
OPCODE(SSENDB, BBB) /* R[a] = self.send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..,&R[a+n+2k+1]) */
|
|
62
|
+
OPCODE(SEND, BBB) /* R[a] = R[a].send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..) (c=n|k<<4) */
|
|
63
|
+
OPCODE(SENDB, BBB) /* R[a] = R[a].send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..,&R[a+n+2k+1]) */
|
|
64
|
+
OPCODE(CALL, Z) /* self.call(*, **, &) (But overlay the current call frame; tailcall) */
|
|
65
|
+
OPCODE(SUPER, BB) /* R[a] = super(R[a+1],... ,R[a+b+1]) */
|
|
66
|
+
OPCODE(ARGARY, BS) /* R[a] = argument array (16=m5:r1:m5:d1:lv4) */
|
|
67
|
+
OPCODE(ENTER, W) /* arg setup according to flags (23=m5:o5:r1:m5:k5:d1:b1) */
|
|
68
|
+
OPCODE(KEY_P, BB) /* R[a] = kdict.key?(Syms[b]) */
|
|
69
|
+
OPCODE(KEYEND, Z) /* raise unless kdict.empty? */
|
|
70
|
+
OPCODE(KARG, BB) /* R[a] = kdict[Syms[b]]; kdict.delete(Syms[b]) */
|
|
71
|
+
OPCODE(RETURN, B) /* return R[a] (normal) */
|
|
72
|
+
OPCODE(RETURN_BLK, B) /* return R[a] (in-block return) */
|
|
73
|
+
OPCODE(BREAK, B) /* break R[a] */
|
|
74
|
+
OPCODE(BLKPUSH, BS) /* R[a] = block (16=m5:r1:m5:d1:lv4) */
|
|
75
|
+
OPCODE(ADD, B) /* R[a] = R[a]+R[a+1] */
|
|
76
|
+
OPCODE(ADDI, BB) /* R[a] = R[a]+mrb_int(b) */
|
|
77
|
+
OPCODE(SUB, B) /* R[a] = R[a]-R[a+1] */
|
|
78
|
+
OPCODE(SUBI, BB) /* R[a] = R[a]-mrb_int(b) */
|
|
79
|
+
OPCODE(MUL, B) /* R[a] = R[a]*R[a+1] */
|
|
80
|
+
OPCODE(DIV, B) /* R[a] = R[a]/R[a+1] */
|
|
81
|
+
OPCODE(EQ, B) /* R[a] = R[a]==R[a+1] */
|
|
82
|
+
OPCODE(LT, B) /* R[a] = R[a]<R[a+1] */
|
|
83
|
+
OPCODE(LE, B) /* R[a] = R[a]<=R[a+1] */
|
|
84
|
+
OPCODE(GT, B) /* R[a] = R[a]>R[a+1] */
|
|
85
|
+
OPCODE(GE, B) /* R[a] = R[a]>=R[a+1] */
|
|
86
|
+
OPCODE(ARRAY, BB) /* R[a] = ary_new(R[a],R[a+1]..R[a+b]) */
|
|
87
|
+
OPCODE(ARRAY2, BBB) /* R[a] = ary_new(R[b],R[b+1]..R[b+c]) */
|
|
88
|
+
OPCODE(ARYCAT, B) /* ary_cat(R[a],R[a+1]) */
|
|
89
|
+
OPCODE(ARYPUSH, BB) /* ary_push(R[a],R[a+1]..R[a+b]) */
|
|
90
|
+
OPCODE(ARYSPLAT, B) /* R[a] = ary_splat(R[a]) */
|
|
91
|
+
OPCODE(AREF, BBB) /* R[a] = R[b][c] */
|
|
92
|
+
OPCODE(ASET, BBB) /* R[b][c] = R[a] */
|
|
93
|
+
OPCODE(APOST, BBB) /* *R[a],R[a+1]..R[a+c] = R[a][b..] */
|
|
94
|
+
OPCODE(INTERN, B) /* R[a] = intern(R[a]) */
|
|
95
|
+
OPCODE(SYMBOL, BB) /* R[a] = intern(Pool[b]) */
|
|
96
|
+
OPCODE(STRING, BB) /* R[a] = str_dup(Pool[b]) */
|
|
97
|
+
OPCODE(STRCAT, B) /* str_cat(R[a],R[a+1]) */
|
|
98
|
+
OPCODE(HASH, BB) /* R[a] = hash_new(R[a],R[a+1]..R[a+b*2-1]) */
|
|
99
|
+
OPCODE(HASHADD, BB) /* hash_push(R[a],R[a+1]..R[a+b*2]) */
|
|
100
|
+
OPCODE(HASHCAT, B) /* R[a] = hash_cat(R[a],R[a+1]) */
|
|
101
|
+
OPCODE(LAMBDA, BB) /* R[a] = lambda(Irep[b],L_LAMBDA) */
|
|
102
|
+
OPCODE(BLOCK, BB) /* R[a] = lambda(Irep[b],L_BLOCK) */
|
|
103
|
+
OPCODE(METHOD, BB) /* R[a] = lambda(Irep[b],L_METHOD) */
|
|
104
|
+
OPCODE(RANGE_INC, B) /* R[a] = range_new(R[a],R[a+1],FALSE) */
|
|
105
|
+
OPCODE(RANGE_EXC, B) /* R[a] = range_new(R[a],R[a+1],TRUE) */
|
|
106
|
+
OPCODE(OCLASS, B) /* R[a] = ::Object */
|
|
107
|
+
OPCODE(CLASS, BB) /* R[a] = newclass(R[a],Syms[b],R[a+1]) */
|
|
108
|
+
OPCODE(MODULE, BB) /* R[a] = newmodule(R[a],Syms[b]) */
|
|
109
|
+
OPCODE(EXEC, BB) /* R[a] = blockexec(R[a],Irep[b]) */
|
|
110
|
+
OPCODE(DEF, BB) /* R[a].newmethod(Syms[b],R[a+1]); R[a] = Syms[b] */
|
|
111
|
+
OPCODE(ALIAS, BB) /* alias_method(target_class,Syms[a],Syms[b]) */
|
|
112
|
+
OPCODE(UNDEF, B) /* undef_method(target_class,Syms[a]) */
|
|
113
|
+
OPCODE(SCLASS, B) /* R[a] = R[a].singleton_class */
|
|
114
|
+
OPCODE(TCLASS, B) /* R[a] = target_class */
|
|
115
|
+
OPCODE(DEBUG, BBB) /* print a,b,c */
|
|
116
|
+
OPCODE(ERR, B) /* raise(LocalJumpError, Pool[a]) */
|
|
117
|
+
OPCODE(EXT1, Z) /* make 1st operand (a) 16bit */
|
|
118
|
+
OPCODE(EXT2, Z) /* make 2nd operand (b) 16bit */
|
|
119
|
+
OPCODE(EXT3, Z) /* make 1st and 2nd operands 16bit */
|
|
120
|
+
OPCODE(STOP, Z) /* stop VM */
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
** @file mruby/presym/disable.h - Disable Preallocated Symbols
|
|
3
|
+
**
|
|
4
|
+
** See Copyright Notice in mruby.h
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#ifndef MRUBY_PRESYM_DISABLE_H
|
|
8
|
+
#define MRUBY_PRESYM_DISABLE_H
|
|
9
|
+
|
|
10
|
+
#include <string.h>
|
|
11
|
+
|
|
12
|
+
#define MRB_PRESYM_MAX 0
|
|
13
|
+
|
|
14
|
+
#define MRB_OPSYM(name) MRB_OPSYM__##name(mrb)
|
|
15
|
+
#define MRB_GVSYM(name) mrb_intern_lit(mrb, "$" #name)
|
|
16
|
+
#define MRB_CVSYM(name) mrb_intern_lit(mrb, "@@" #name)
|
|
17
|
+
#define MRB_IVSYM(name) mrb_intern_lit(mrb, "@" #name)
|
|
18
|
+
#define MRB_SYM_B(name) mrb_intern_lit(mrb, #name "!")
|
|
19
|
+
#define MRB_SYM_Q(name) mrb_intern_lit(mrb, #name "?")
|
|
20
|
+
#define MRB_SYM_E(name) mrb_intern_lit(mrb, #name "=")
|
|
21
|
+
#define MRB_SYM(name) mrb_intern_lit(mrb, #name)
|
|
22
|
+
|
|
23
|
+
#define MRB_OPSYM_2(mrb, name) MRB_OPSYM__##name(mrb)
|
|
24
|
+
#define MRB_GVSYM_2(mrb, name) mrb_intern_lit(mrb, "$" #name)
|
|
25
|
+
#define MRB_CVSYM_2(mrb, name) mrb_intern_lit(mrb, "@@" #name)
|
|
26
|
+
#define MRB_IVSYM_2(mrb, name) mrb_intern_lit(mrb, "@" #name)
|
|
27
|
+
#define MRB_SYM_B_2(mrb, name) mrb_intern_lit(mrb, #name "!")
|
|
28
|
+
#define MRB_SYM_Q_2(mrb, name) mrb_intern_lit(mrb, #name "?")
|
|
29
|
+
#define MRB_SYM_E_2(mrb, name) mrb_intern_lit(mrb, #name "=")
|
|
30
|
+
#define MRB_SYM_2(mrb, name) mrb_intern_lit(mrb, #name)
|
|
31
|
+
|
|
32
|
+
#define MRB_OPSYM__not(mrb) mrb_intern_lit(mrb, "!")
|
|
33
|
+
#define MRB_OPSYM__mod(mrb) mrb_intern_lit(mrb, "%")
|
|
34
|
+
#define MRB_OPSYM__and(mrb) mrb_intern_lit(mrb, "&")
|
|
35
|
+
#define MRB_OPSYM__mul(mrb) mrb_intern_lit(mrb, "*")
|
|
36
|
+
#define MRB_OPSYM__add(mrb) mrb_intern_lit(mrb, "+")
|
|
37
|
+
#define MRB_OPSYM__sub(mrb) mrb_intern_lit(mrb, "-")
|
|
38
|
+
#define MRB_OPSYM__div(mrb) mrb_intern_lit(mrb, "/")
|
|
39
|
+
#define MRB_OPSYM__lt(mrb) mrb_intern_lit(mrb, "<")
|
|
40
|
+
#define MRB_OPSYM__gt(mrb) mrb_intern_lit(mrb, ">")
|
|
41
|
+
#define MRB_OPSYM__xor(mrb) mrb_intern_lit(mrb, "^")
|
|
42
|
+
#define MRB_OPSYM__tick(mrb) mrb_intern_lit(mrb, "`")
|
|
43
|
+
#define MRB_OPSYM__or(mrb) mrb_intern_lit(mrb, "|")
|
|
44
|
+
#define MRB_OPSYM__neg(mrb) mrb_intern_lit(mrb, "~")
|
|
45
|
+
#define MRB_OPSYM__neq(mrb) mrb_intern_lit(mrb, "!=")
|
|
46
|
+
#define MRB_OPSYM__nmatch(mrb) mrb_intern_lit(mrb, "!~")
|
|
47
|
+
#define MRB_OPSYM__andand(mrb) mrb_intern_lit(mrb, "&&")
|
|
48
|
+
#define MRB_OPSYM__pow(mrb) mrb_intern_lit(mrb, "**")
|
|
49
|
+
#define MRB_OPSYM__plus(mrb) mrb_intern_lit(mrb, "+@")
|
|
50
|
+
#define MRB_OPSYM__minus(mrb) mrb_intern_lit(mrb, "-@")
|
|
51
|
+
#define MRB_OPSYM__lshift(mrb) mrb_intern_lit(mrb, "<<")
|
|
52
|
+
#define MRB_OPSYM__le(mrb) mrb_intern_lit(mrb, "<=")
|
|
53
|
+
#define MRB_OPSYM__eq(mrb) mrb_intern_lit(mrb, "==")
|
|
54
|
+
#define MRB_OPSYM__match(mrb) mrb_intern_lit(mrb, "=~")
|
|
55
|
+
#define MRB_OPSYM__ge(mrb) mrb_intern_lit(mrb, ">=")
|
|
56
|
+
#define MRB_OPSYM__rshift(mrb) mrb_intern_lit(mrb, ">>")
|
|
57
|
+
#define MRB_OPSYM__aref(mrb) mrb_intern_lit(mrb, "[]")
|
|
58
|
+
#define MRB_OPSYM__oror(mrb) mrb_intern_lit(mrb, "||")
|
|
59
|
+
#define MRB_OPSYM__cmp(mrb) mrb_intern_lit(mrb, "<=>")
|
|
60
|
+
#define MRB_OPSYM__eqq(mrb) mrb_intern_lit(mrb, "===")
|
|
61
|
+
#define MRB_OPSYM__aset(mrb) mrb_intern_lit(mrb, "[]=")
|
|
62
|
+
|
|
63
|
+
#define MRB_PRESYM_DEFINE_VAR_AND_INITER(name, size, ...) \
|
|
64
|
+
static mrb_sym name[size]; \
|
|
65
|
+
static void presym_init_##name(mrb_state *mrb) { \
|
|
66
|
+
mrb_sym name__[] = {__VA_ARGS__}; \
|
|
67
|
+
memcpy(name, name__, sizeof(name)); \
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#define MRB_PRESYM_INIT_SYMBOLS(mrb, name) presym_init_##name(mrb)
|
|
71
|
+
|
|
72
|
+
#endif /* MRUBY_PRESYM_DISABLE_H */
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
** @file mruby/presym/enable.h - Enable Preallocated Symbols
|
|
3
|
+
**
|
|
4
|
+
** See Copyright Notice in mruby.h
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#ifndef MRUBY_PRESYM_ENABLE_H
|
|
8
|
+
#define MRUBY_PRESYM_ENABLE_H
|
|
9
|
+
|
|
10
|
+
#include <mruby/presym/id.h>
|
|
11
|
+
|
|
12
|
+
#define MRB_OPSYM(name) MRB_OPSYM__##name
|
|
13
|
+
#define MRB_GVSYM(name) MRB_GVSYM__##name
|
|
14
|
+
#define MRB_CVSYM(name) MRB_CVSYM__##name
|
|
15
|
+
#define MRB_IVSYM(name) MRB_IVSYM__##name
|
|
16
|
+
#define MRB_SYM_B(name) MRB_SYM_B__##name
|
|
17
|
+
#define MRB_SYM_Q(name) MRB_SYM_Q__##name
|
|
18
|
+
#define MRB_SYM_E(name) MRB_SYM_E__##name
|
|
19
|
+
#define MRB_SYM(name) MRB_SYM__##name
|
|
20
|
+
|
|
21
|
+
#define MRB_OPSYM_2(mrb, name) MRB_OPSYM__##name
|
|
22
|
+
#define MRB_GVSYM_2(mrb, name) MRB_GVSYM__##name
|
|
23
|
+
#define MRB_CVSYM_2(mrb, name) MRB_CVSYM__##name
|
|
24
|
+
#define MRB_IVSYM_2(mrb, name) MRB_IVSYM__##name
|
|
25
|
+
#define MRB_SYM_B_2(mrb, name) MRB_SYM_B__##name
|
|
26
|
+
#define MRB_SYM_Q_2(mrb, name) MRB_SYM_Q__##name
|
|
27
|
+
#define MRB_SYM_E_2(mrb, name) MRB_SYM_E__##name
|
|
28
|
+
#define MRB_SYM_2(mrb, name) MRB_SYM__##name
|
|
29
|
+
|
|
30
|
+
#define MRB_PRESYM_DEFINE_VAR_AND_INITER(name, size, ...) \
|
|
31
|
+
static const mrb_sym name[] = {__VA_ARGS__};
|
|
32
|
+
|
|
33
|
+
#define MRB_PRESYM_INIT_SYMBOLS(mrb, name) (void)(mrb)
|
|
34
|
+
|
|
35
|
+
/* use MRB_SYM() for E_RUNTIME_ERROR etc. */
|
|
36
|
+
#undef MRB_ERROR_SYM
|
|
37
|
+
#define MRB_ERROR_SYM(sym) MRB_SYM(sym)
|
|
38
|
+
|
|
39
|
+
#endif /* MRUBY_PRESYM_ENABLE_H */
|