cast_off 0.2.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.
- data/README +578 -0
- data/README.en +256 -0
- data/bin/CastOff +145 -0
- data/cast_off.gemspec +25 -0
- data/ext/cast_off/cast_off.c.rb +1386 -0
- data/ext/cast_off/cast_off.h +24 -0
- data/ext/cast_off/depend +70 -0
- data/ext/cast_off/extconf.rb +19 -0
- data/ext/cast_off/generated_c_include/inline_api.h +507 -0
- data/ext/cast_off/generated_c_include/iter_api.h +595 -0
- data/ext/cast_off/generated_c_include/unbox_api.h.rb +76 -0
- data/ext/cast_off/generated_c_include/vm_api.h +751 -0
- data/ext/cast_off/ruby_source/atomic.h +56 -0
- data/ext/cast_off/ruby_source/constant.h +34 -0
- data/ext/cast_off/ruby_source/debug.h +41 -0
- data/ext/cast_off/ruby_source/eval_intern.h +234 -0
- data/ext/cast_off/ruby_source/gc.h +98 -0
- data/ext/cast_off/ruby_source/id.h +175 -0
- data/ext/cast_off/ruby_source/insns.inc +179 -0
- data/ext/cast_off/ruby_source/insns_info.inc +695 -0
- data/ext/cast_off/ruby_source/internal.h +227 -0
- data/ext/cast_off/ruby_source/iseq.h +125 -0
- data/ext/cast_off/ruby_source/manual_update.h +135 -0
- data/ext/cast_off/ruby_source/method.h +105 -0
- data/ext/cast_off/ruby_source/node.h +503 -0
- data/ext/cast_off/ruby_source/thread_pthread.h +51 -0
- data/ext/cast_off/ruby_source/thread_win32.h +40 -0
- data/ext/cast_off/ruby_source/vm_core.h +756 -0
- data/ext/cast_off/ruby_source/vm_exec.h +184 -0
- data/ext/cast_off/ruby_source/vm_insnhelper.c +1748 -0
- data/ext/cast_off/ruby_source/vm_insnhelper.h +220 -0
- data/ext/cast_off/ruby_source/vm_opts.h +51 -0
- data/lib/cast_off.rb +15 -0
- data/lib/cast_off/compile.rb +629 -0
- data/lib/cast_off/compile/basicblock.rb +144 -0
- data/lib/cast_off/compile/cfg.rb +391 -0
- data/lib/cast_off/compile/code_manager.rb +284 -0
- data/lib/cast_off/compile/configuration.rb +2368 -0
- data/lib/cast_off/compile/dependency.rb +240 -0
- data/lib/cast_off/compile/information.rb +775 -0
- data/lib/cast_off/compile/instruction.rb +446 -0
- data/lib/cast_off/compile/ir/call_ir.rb +2348 -0
- data/lib/cast_off/compile/ir/guard_ir.rb +423 -0
- data/lib/cast_off/compile/ir/jump_ir.rb +223 -0
- data/lib/cast_off/compile/ir/operand.rb +934 -0
- data/lib/cast_off/compile/ir/param_ir.rb +98 -0
- data/lib/cast_off/compile/ir/return_ir.rb +92 -0
- data/lib/cast_off/compile/ir/simple_ir.rb +808 -0
- data/lib/cast_off/compile/ir/sub_ir.rb +212 -0
- data/lib/cast_off/compile/iseq.rb +454 -0
- data/lib/cast_off/compile/method_information.rb +1384 -0
- data/lib/cast_off/compile/namespace/namespace.rb +556 -0
- data/lib/cast_off/compile/namespace/uuid.rb +323 -0
- data/lib/cast_off/compile/stack.rb +65 -0
- data/lib/cast_off/compile/translator.rb +1562 -0
- data/lib/cast_off/suggestion.rb +98 -0
- data/lib/cast_off/util.rb +58 -0
- metadata +107 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
#include <ruby.h>
|
2
|
+
|
3
|
+
#include "vm_core.h"
|
4
|
+
#include "eval_intern.h"
|
5
|
+
#include "iseq.h"
|
6
|
+
#include "gc.h"
|
7
|
+
#include <ruby/vm.h>
|
8
|
+
#include <ruby/encoding.h>
|
9
|
+
#include "vm_insnhelper.h"
|
10
|
+
#include "vm_insnhelper.c"
|
11
|
+
#include "vm_exec.h"
|
12
|
+
|
13
|
+
#ifdef USE_INSN_STACK_INCREASE
|
14
|
+
#undef USE_INSN_STACK_INCREASE
|
15
|
+
#endif
|
16
|
+
#define USE_INSN_STACK_INCREASE 1
|
17
|
+
|
18
|
+
#ifdef USE_INSN_RET_NUM
|
19
|
+
#undef USE_INSN_RET_NUM
|
20
|
+
#endif
|
21
|
+
#define USE_INSN_RET_NUM 1
|
22
|
+
|
23
|
+
#include "insns_info.inc"
|
24
|
+
#include "manual_update.h"
|
data/ext/cast_off/depend
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
$(srcdir)/generated_c_include/unbox_api.h: \
|
2
|
+
$(srcdir)/generated_c_include/unbox_api.h.rb
|
3
|
+
$(RUBY) -- $(srcdir)/generated_c_include/unbox_api.h.rb > $@
|
4
|
+
|
5
|
+
|
6
|
+
cast_off.c: \
|
7
|
+
$(srcdir)/ruby_source/debug.h \
|
8
|
+
$(srcdir)/ruby_source/gc.h \
|
9
|
+
$(srcdir)/ruby_source/id.h \
|
10
|
+
$(srcdir)/ruby_source/eval_intern.h \
|
11
|
+
$(srcdir)/ruby_source/iseq.h \
|
12
|
+
$(srcdir)/ruby_source/method.h \
|
13
|
+
$(srcdir)/ruby_source/node.h \
|
14
|
+
$(srcdir)/ruby_source/thread_pthread.h \
|
15
|
+
$(srcdir)/ruby_source/thread_win32.h \
|
16
|
+
$(srcdir)/ruby_source/vm_core.h \
|
17
|
+
$(srcdir)/ruby_source/vm_exec.h \
|
18
|
+
$(srcdir)/ruby_source/vm_insnhelper.c \
|
19
|
+
$(srcdir)/ruby_source/vm_insnhelper.h \
|
20
|
+
$(srcdir)/ruby_source/vm_opts.h \
|
21
|
+
$(srcdir)/ruby_source/insns_info.inc \
|
22
|
+
$(srcdir)/ruby_source/insns.inc \
|
23
|
+
$(srcdir)/ruby_source/constant.h \
|
24
|
+
$(srcdir)/ruby_source/atomic.h \
|
25
|
+
$(srcdir)/ruby_source/internal.h \
|
26
|
+
$(srcdir)/ruby_source/manual_update.h \
|
27
|
+
$(srcdir)/generated_c_include/iter_api.h \
|
28
|
+
$(srcdir)/generated_c_include/vm_api.h \
|
29
|
+
$(srcdir)/generated_c_include/inline_api.h \
|
30
|
+
$(srcdir)/generated_c_include/unbox_api.h \
|
31
|
+
$(srcdir)/generated_c_include/unbox_api.h.rb \
|
32
|
+
$(srcdir)/extconf.h \
|
33
|
+
$(srcdir)/cast_off.h \
|
34
|
+
$(srcdir)/cast_off.c.rb
|
35
|
+
$(RUBY) -- $(srcdir)/cast_off.c.rb $(srcdir)/ruby_source $(srcdir)/generated_c_include > $@
|
36
|
+
|
37
|
+
|
38
|
+
cast_off.o: \
|
39
|
+
$(arch_hdrdir)/ruby/config.h \
|
40
|
+
$(hdrdir)/ruby/defines.h \
|
41
|
+
$(hdrdir)/ruby/intern.h \
|
42
|
+
$(hdrdir)/ruby/missing.h \
|
43
|
+
$(hdrdir)/ruby/ruby.h \
|
44
|
+
$(hdrdir)/ruby/st.h \
|
45
|
+
$(srcdir)/ruby_source/eval_intern.h \
|
46
|
+
$(srcdir)/ruby_source/iseq.h \
|
47
|
+
$(srcdir)/ruby_source/method.h \
|
48
|
+
$(srcdir)/ruby_source/node.h \
|
49
|
+
$(srcdir)/ruby_source/thread_pthread.h \
|
50
|
+
$(srcdir)/ruby_source/thread_win32.h \
|
51
|
+
$(srcdir)/ruby_source/vm_core.h \
|
52
|
+
$(srcdir)/ruby_source/vm_exec.h \
|
53
|
+
$(srcdir)/ruby_source/vm_insnhelper.c \
|
54
|
+
$(srcdir)/ruby_source/vm_insnhelper.h \
|
55
|
+
$(srcdir)/ruby_source/vm_opts.h \
|
56
|
+
$(srcdir)/ruby_source/insns_info.inc \
|
57
|
+
$(srcdir)/ruby_source/insns.inc \
|
58
|
+
$(srcdir)/ruby_source/constant.h \
|
59
|
+
$(srcdir)/ruby_source/atomic.h \
|
60
|
+
$(srcdir)/ruby_source/internal.h \
|
61
|
+
$(srcdir)/ruby_source/manual_update.h \
|
62
|
+
$(srcdir)/generated_c_include/iter_api.h \
|
63
|
+
$(srcdir)/generated_c_include/vm_api.h \
|
64
|
+
$(srcdir)/generated_c_include/inline_api.h \
|
65
|
+
$(srcdir)/generated_c_include/unbox_api.h \
|
66
|
+
$(srcdir)/generated_c_include/unbox_api.h.rb \
|
67
|
+
$(srcdir)/extconf.h \
|
68
|
+
$(srcdir)/cast_off.h \
|
69
|
+
$(srcdir)/cast_off.c
|
70
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# coding=utf-8
|
2
|
+
|
3
|
+
# Ruby to C (and then, to machine executable) compiler, originally written by
|
4
|
+
# Urabe Shyouhei <shyouhei@ruby-lang.org> during 2010. See the COPYING for
|
5
|
+
# legal info.
|
6
|
+
|
7
|
+
require 'mkmf'
|
8
|
+
require 'rbconfig'
|
9
|
+
extend RbConfig
|
10
|
+
|
11
|
+
$defs.push '-DCABI_OPERANDS' if enable_config 'cabi-operands', true
|
12
|
+
$defs.push '-DCABI_PASS_CFP' if enable_config 'cabi-pass-cfp', true
|
13
|
+
|
14
|
+
$INCFLAGS << ' -I$(srcdir)/ruby_source'
|
15
|
+
$objs = %w'cast_off.o'
|
16
|
+
$srcs = %w'cast_off.c.rb'
|
17
|
+
create_header
|
18
|
+
create_makefile 'cast_off'
|
19
|
+
|
@@ -0,0 +1,507 @@
|
|
1
|
+
#define TYPE_ERROR_MESSAGE() "type mismatch"
|
2
|
+
|
3
|
+
static inline VALUE
|
4
|
+
cast_off_inline_fixnum_fixnum_plus(VALUE recv, VALUE obj)
|
5
|
+
{
|
6
|
+
#if 0
|
7
|
+
#ifdef INJECT_GUARD
|
8
|
+
if (UNLIKELY(!FIXNUM_2_P(recv, obj))) {
|
9
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
10
|
+
}
|
11
|
+
#endif
|
12
|
+
#endif
|
13
|
+
|
14
|
+
#ifndef LONG_LONG_VALUE
|
15
|
+
{
|
16
|
+
VALUE val = (recv + (obj & (~1)));
|
17
|
+
#ifdef INJECT_GUARD
|
18
|
+
if ((~(recv ^ obj) & (recv ^ val)) & ((VALUE)0x01 << ((sizeof(VALUE) * CHAR_BIT) - 1))) {
|
19
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
20
|
+
}
|
21
|
+
#endif /* INJECT_GUARD */
|
22
|
+
return val;
|
23
|
+
}
|
24
|
+
#else /* LONG_LONG_VALUE */
|
25
|
+
{
|
26
|
+
long a, b, c;
|
27
|
+
a = FIX2LONG(recv);
|
28
|
+
b = FIX2LONG(obj);
|
29
|
+
c = a + b;
|
30
|
+
#ifdef INJECT_GUARD
|
31
|
+
if (UNLIKELY(!FIXABLE(c))) {
|
32
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
33
|
+
}
|
34
|
+
#endif /* INJECT_GUARD */
|
35
|
+
return LONG2FIX(c);
|
36
|
+
}
|
37
|
+
#endif /* LONG_LONG_VALUE */
|
38
|
+
}
|
39
|
+
|
40
|
+
static inline VALUE
|
41
|
+
cast_off_inline_fixnum_float_plus(VALUE recv, VALUE obj)
|
42
|
+
{
|
43
|
+
return DBL2NUM((double)FIX2LONG(recv) + RFLOAT_VALUE(obj));
|
44
|
+
}
|
45
|
+
|
46
|
+
static inline VALUE
|
47
|
+
cast_off_inline_fixnum_fixnum_minus(VALUE recv, VALUE obj)
|
48
|
+
{
|
49
|
+
long a, b, c;
|
50
|
+
|
51
|
+
#if 0
|
52
|
+
#ifdef INJECT_GUARD
|
53
|
+
if (UNLIKELY(!FIXNUM_2_P(recv, obj))) {
|
54
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
55
|
+
}
|
56
|
+
#endif
|
57
|
+
#endif
|
58
|
+
|
59
|
+
a = FIX2LONG(recv);
|
60
|
+
b = FIX2LONG(obj);
|
61
|
+
c = a - b;
|
62
|
+
#ifdef INJECT_GUARD
|
63
|
+
if (LIKELY(FIXABLE(c))) {
|
64
|
+
#endif
|
65
|
+
return LONG2FIX(c);
|
66
|
+
#ifdef INJECT_GUARD
|
67
|
+
} else {
|
68
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
69
|
+
}
|
70
|
+
#endif
|
71
|
+
}
|
72
|
+
|
73
|
+
static inline VALUE
|
74
|
+
cast_off_inline_fixnum_float_minus(VALUE recv, VALUE obj)
|
75
|
+
{
|
76
|
+
return DBL2NUM((double)FIX2LONG(recv) - RFLOAT_VALUE(obj));
|
77
|
+
}
|
78
|
+
|
79
|
+
static inline VALUE
|
80
|
+
cast_off_inline_fixnum_fixnum_mult(VALUE recv, VALUE obj)
|
81
|
+
{
|
82
|
+
long a, b, c;
|
83
|
+
|
84
|
+
#if 0
|
85
|
+
#ifdef INJECT_GUARD
|
86
|
+
if (UNLIKELY(!FIXNUM_2_P(recv, obj))) {
|
87
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
88
|
+
}
|
89
|
+
#endif
|
90
|
+
#endif
|
91
|
+
|
92
|
+
a = FIX2LONG(recv);
|
93
|
+
b = FIX2LONG(obj);
|
94
|
+
c = a * b;
|
95
|
+
#ifdef INJECT_GUARD
|
96
|
+
if (LIKELY(FIXABLE(c))) {
|
97
|
+
#endif
|
98
|
+
return LONG2FIX(c);
|
99
|
+
#ifdef INJECT_GUARD
|
100
|
+
} else {
|
101
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
102
|
+
}
|
103
|
+
#endif
|
104
|
+
}
|
105
|
+
|
106
|
+
static inline VALUE
|
107
|
+
cast_off_inline_fixnum_float_mult(VALUE recv, VALUE obj)
|
108
|
+
{
|
109
|
+
return DBL2NUM((double)FIX2LONG(recv) * RFLOAT_VALUE(obj));
|
110
|
+
}
|
111
|
+
|
112
|
+
static inline VALUE
|
113
|
+
cast_off_inline_fixnum_le(VALUE recv, VALUE obj)
|
114
|
+
{
|
115
|
+
long a, b;
|
116
|
+
|
117
|
+
#if 0
|
118
|
+
#ifdef INJECT_GUARD
|
119
|
+
if (UNLIKELY(!FIXNUM_2_P(recv, obj))) {
|
120
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
121
|
+
}
|
122
|
+
#endif
|
123
|
+
#endif
|
124
|
+
|
125
|
+
a = FIX2LONG(recv);
|
126
|
+
b = FIX2LONG(obj);
|
127
|
+
if (a <= b) {
|
128
|
+
return Qtrue;
|
129
|
+
} else {
|
130
|
+
return Qfalse;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
static inline VALUE
|
135
|
+
cast_off_inline_fixnum_lt(VALUE recv, VALUE obj)
|
136
|
+
{
|
137
|
+
long a, b;
|
138
|
+
|
139
|
+
#if 0
|
140
|
+
#ifdef INJECT_GUARD
|
141
|
+
if (UNLIKELY(!FIXNUM_2_P(recv, obj))) {
|
142
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
143
|
+
}
|
144
|
+
#endif
|
145
|
+
#endif
|
146
|
+
|
147
|
+
a = FIX2LONG(recv);
|
148
|
+
b = FIX2LONG(obj);
|
149
|
+
if (a < b) {
|
150
|
+
return Qtrue;
|
151
|
+
} else {
|
152
|
+
return Qfalse;
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
static inline VALUE
|
157
|
+
cast_off_inline_fixnum_ge(VALUE recv, VALUE obj)
|
158
|
+
{
|
159
|
+
long a, b;
|
160
|
+
|
161
|
+
#if 0
|
162
|
+
#ifdef INJECT_GUARD
|
163
|
+
if (UNLIKELY(!FIXNUM_2_P(recv, obj))) {
|
164
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
165
|
+
}
|
166
|
+
#endif
|
167
|
+
#endif
|
168
|
+
a = FIX2LONG(recv);
|
169
|
+
b = FIX2LONG(obj);
|
170
|
+
if (a >= b) {
|
171
|
+
return Qtrue;
|
172
|
+
} else {
|
173
|
+
return Qfalse;
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
static inline VALUE
|
178
|
+
cast_off_inline_fixnum_gt(VALUE recv, VALUE obj)
|
179
|
+
{
|
180
|
+
long a, b;
|
181
|
+
|
182
|
+
#if 0
|
183
|
+
#ifdef INJECT_GUARD
|
184
|
+
if (UNLIKELY(!FIXNUM_2_P(recv, obj))) {
|
185
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
186
|
+
}
|
187
|
+
#endif
|
188
|
+
#endif
|
189
|
+
a = FIX2LONG(recv);
|
190
|
+
b = FIX2LONG(obj);
|
191
|
+
if (a > b) {
|
192
|
+
return Qtrue;
|
193
|
+
} else {
|
194
|
+
return Qfalse;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
|
198
|
+
static inline VALUE
|
199
|
+
cast_off_inline_fixnum_eq(VALUE recv, VALUE obj)
|
200
|
+
{
|
201
|
+
#if 0
|
202
|
+
#ifdef INJECT_GUARD
|
203
|
+
if (UNLIKELY(!FIXNUM_2_P(recv, obj))) {
|
204
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
205
|
+
}
|
206
|
+
#endif
|
207
|
+
#endif
|
208
|
+
if (recv == obj) {
|
209
|
+
return Qtrue;
|
210
|
+
} else {
|
211
|
+
return Qfalse;
|
212
|
+
}
|
213
|
+
}
|
214
|
+
#define cast_off_inline_fixnum_eqq(recv, obj) cast_off_inline_fixnum_eq((recv), (obj))
|
215
|
+
|
216
|
+
static inline VALUE
|
217
|
+
cast_off_inline_fixnum_neq(VALUE recv, VALUE obj)
|
218
|
+
{
|
219
|
+
#if 0
|
220
|
+
#ifdef INJECT_GUARD
|
221
|
+
if (UNLIKELY(!FIXNUM_2_P(recv, obj))) {
|
222
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
223
|
+
}
|
224
|
+
#endif
|
225
|
+
#endif
|
226
|
+
if (recv != obj) {
|
227
|
+
return Qtrue;
|
228
|
+
} else {
|
229
|
+
return Qfalse;
|
230
|
+
}
|
231
|
+
}
|
232
|
+
|
233
|
+
static inline VALUE
|
234
|
+
cast_off_inline_fixnum_and(VALUE recv, VALUE obj)
|
235
|
+
{
|
236
|
+
long val;
|
237
|
+
|
238
|
+
#if 0
|
239
|
+
#ifdef INJECT_GUARD
|
240
|
+
if (UNLIKELY(!FIXNUM_2_P(recv, obj))) {
|
241
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
242
|
+
}
|
243
|
+
#endif
|
244
|
+
#endif
|
245
|
+
|
246
|
+
val = FIX2LONG(recv) & FIX2LONG(obj);
|
247
|
+
#ifdef INJECT_GUARD
|
248
|
+
if (LIKELY(FIXABLE(val))) {
|
249
|
+
#endif
|
250
|
+
return LONG2FIX(val);
|
251
|
+
#ifdef INJECT_GUARD
|
252
|
+
} else {
|
253
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
254
|
+
}
|
255
|
+
#endif
|
256
|
+
}
|
257
|
+
|
258
|
+
static inline VALUE
|
259
|
+
cast_off_inline_array_entry(VALUE ary, VALUE index)
|
260
|
+
{
|
261
|
+
long offset;
|
262
|
+
|
263
|
+
#if 0
|
264
|
+
#ifdef INJECT_GUARD
|
265
|
+
if (UNLIKELY(rb_class_of(ary) != rb_cArray || !FIXNUM_P(index))) {
|
266
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
267
|
+
}
|
268
|
+
#endif
|
269
|
+
#endif
|
270
|
+
offset = FIX2LONG(index);
|
271
|
+
|
272
|
+
#ifdef ARRAY_CONSERVATIVE
|
273
|
+
return rb_ary_entry(ary, offset);
|
274
|
+
#else
|
275
|
+
return RARRAY_PTR(ary)[offset];
|
276
|
+
#endif
|
277
|
+
}
|
278
|
+
|
279
|
+
static inline VALUE
|
280
|
+
cast_off_inline_array_store(VALUE ary, VALUE index, VALUE val)
|
281
|
+
{
|
282
|
+
#if 0
|
283
|
+
#ifdef INJECT_GUARD
|
284
|
+
if (UNLIKELY(rb_class_of(ary) != rb_cArray || !FIXNUM_P(index))) {
|
285
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
286
|
+
}
|
287
|
+
#endif
|
288
|
+
#endif
|
289
|
+
|
290
|
+
#ifdef ARRAY_CONSERVATIVE
|
291
|
+
rb_ary_store(ary, FIX2LONG(index), val);
|
292
|
+
#else
|
293
|
+
RARRAY_PTR(ary)[FIX2LONG(index)] = val;
|
294
|
+
#endif
|
295
|
+
return val;
|
296
|
+
}
|
297
|
+
|
298
|
+
static inline VALUE
|
299
|
+
cast_off_inline_array_length(VALUE ary)
|
300
|
+
{
|
301
|
+
long len;
|
302
|
+
|
303
|
+
#if 0
|
304
|
+
#ifdef INJECT_GUARD
|
305
|
+
if (UNLIKELY(rb_class_of(ary) != rb_cArray)) {
|
306
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
307
|
+
}
|
308
|
+
#endif
|
309
|
+
#endif
|
310
|
+
|
311
|
+
len = RARRAY_LEN(ary);
|
312
|
+
|
313
|
+
#ifdef INJECT_GUARD
|
314
|
+
if (LIKELY(FIXABLE(len))) {
|
315
|
+
#endif
|
316
|
+
return LONG2FIX(len);
|
317
|
+
#ifdef INJECT_GUARD
|
318
|
+
} else {
|
319
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
320
|
+
}
|
321
|
+
#endif
|
322
|
+
}
|
323
|
+
#define cast_off_inline_array_size(ary) cast_off_inline_array_length((ary))
|
324
|
+
|
325
|
+
static inline VALUE
|
326
|
+
cast_off_inline_array_empty_p(VALUE ary)
|
327
|
+
{
|
328
|
+
#if 0
|
329
|
+
#ifdef INJECT_GUARD
|
330
|
+
if (UNLIKELY(rb_class_of(ary) != rb_cArray)) {
|
331
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
332
|
+
}
|
333
|
+
#endif
|
334
|
+
#endif
|
335
|
+
|
336
|
+
if (RARRAY_LEN(ary) == 0) {
|
337
|
+
return Qtrue;
|
338
|
+
} else {
|
339
|
+
return Qfalse;
|
340
|
+
}
|
341
|
+
}
|
342
|
+
|
343
|
+
static inline VALUE
|
344
|
+
cast_off_inline_array_first(VALUE ary)
|
345
|
+
{
|
346
|
+
#if 0
|
347
|
+
#ifdef INJECT_GUARD
|
348
|
+
if (UNLIKELY(rb_class_of(ary) != rb_cArray)) {
|
349
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
350
|
+
}
|
351
|
+
#endif
|
352
|
+
#endif
|
353
|
+
|
354
|
+
#ifdef ARRAY_CONSERVATIVE
|
355
|
+
if (RARRAY_LEN(ary) == 0) return Qnil;
|
356
|
+
#endif
|
357
|
+
return RARRAY_PTR(ary)[0];
|
358
|
+
}
|
359
|
+
|
360
|
+
static inline VALUE
|
361
|
+
cast_off_inline_array_last(VALUE ary)
|
362
|
+
{
|
363
|
+
#if 0
|
364
|
+
#ifdef INJECT_GUARD
|
365
|
+
if (UNLIKELY(rb_class_of(ary) != rb_cArray)) {
|
366
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
367
|
+
}
|
368
|
+
#endif
|
369
|
+
#endif
|
370
|
+
|
371
|
+
#ifdef ARRAY_CONSERVATIVE
|
372
|
+
if (RARRAY_LEN(ary) == 0) return Qnil;
|
373
|
+
#endif
|
374
|
+
return RARRAY_PTR(ary)[RARRAY_LEN(ary)-1];
|
375
|
+
}
|
376
|
+
|
377
|
+
static inline VALUE
|
378
|
+
cast_off_inline_string_eq(VALUE str1, VALUE str2)
|
379
|
+
{
|
380
|
+
#if 0
|
381
|
+
#ifdef INJECT_GUARD
|
382
|
+
if (UNLIKELY(rb_class_of(str1) != rb_cString || rb_class_of(str2) != rb_cString)) {
|
383
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
384
|
+
}
|
385
|
+
#endif
|
386
|
+
#endif
|
387
|
+
|
388
|
+
if (str1 == str2) return Qtrue;
|
389
|
+
if (RSTRING_LEN(str1) != RSTRING_LEN(str2)) return Qfalse;
|
390
|
+
return rb_str_equal(str1, str2);
|
391
|
+
}
|
392
|
+
#define cast_off_inline_string_eqq(str1, str2) cast_off_inline_string_eq((str1), (str2))
|
393
|
+
|
394
|
+
static inline VALUE
|
395
|
+
cast_off_inline_string_neq(VALUE str1, VALUE str2)
|
396
|
+
{
|
397
|
+
#if 0
|
398
|
+
#ifdef INJECT_GUARD
|
399
|
+
if (UNLIKELY(rb_class_of(str1) != rb_cString || rb_class_of(str2) != rb_cString)) {
|
400
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
401
|
+
}
|
402
|
+
#endif
|
403
|
+
#endif
|
404
|
+
|
405
|
+
if (str1 == str2) return Qfalse;
|
406
|
+
if (RSTRING_LEN(str1) != RSTRING_LEN(str2)) return Qtrue;
|
407
|
+
if (rb_str_equal(str1, str2) == Qtrue) {
|
408
|
+
return Qfalse;
|
409
|
+
} else {
|
410
|
+
return Qtrue;
|
411
|
+
}
|
412
|
+
}
|
413
|
+
|
414
|
+
static inline VALUE
|
415
|
+
cast_off_inline_string_empty_p(VALUE str)
|
416
|
+
{
|
417
|
+
#if 0
|
418
|
+
#ifdef INJECT_GUARD
|
419
|
+
if (UNLIKELY(rb_class_of(str) != rb_cString)) {
|
420
|
+
rb_raise(rb_eCastOffExecutionError, TYPE_ERROR_MESSAGE());
|
421
|
+
}
|
422
|
+
#endif
|
423
|
+
#endif
|
424
|
+
|
425
|
+
if (RSTRING_LEN(str) == 0) {
|
426
|
+
return Qtrue;
|
427
|
+
} else {
|
428
|
+
return Qfalse;
|
429
|
+
}
|
430
|
+
}
|
431
|
+
|
432
|
+
static inline VALUE
|
433
|
+
cast_off_inline_float_float_plus(VALUE x, VALUE y)
|
434
|
+
{
|
435
|
+
return DBL2NUM(RFLOAT_VALUE(x) + RFLOAT_VALUE(y));
|
436
|
+
}
|
437
|
+
static inline VALUE
|
438
|
+
cast_off_inline_float_fixnum_plus(VALUE x, VALUE y)
|
439
|
+
{
|
440
|
+
return DBL2NUM(RFLOAT_VALUE(x) + (double)FIX2LONG(y));
|
441
|
+
}
|
442
|
+
|
443
|
+
static inline VALUE
|
444
|
+
cast_off_inline_float_float_minus(VALUE x, VALUE y)
|
445
|
+
{
|
446
|
+
return DBL2NUM(RFLOAT_VALUE(x) - RFLOAT_VALUE(y));
|
447
|
+
}
|
448
|
+
static inline VALUE
|
449
|
+
cast_off_inline_float_fixnum_minus(VALUE x, VALUE y)
|
450
|
+
{
|
451
|
+
return DBL2NUM(RFLOAT_VALUE(x) - (double)FIX2LONG(y));
|
452
|
+
}
|
453
|
+
|
454
|
+
static inline VALUE
|
455
|
+
cast_off_inline_float_float_mult(VALUE x, VALUE y)
|
456
|
+
{
|
457
|
+
return DBL2NUM(RFLOAT_VALUE(x) * RFLOAT_VALUE(y));
|
458
|
+
}
|
459
|
+
static inline VALUE
|
460
|
+
cast_off_inline_float_fixnum_mult(VALUE x, VALUE y)
|
461
|
+
{
|
462
|
+
return DBL2NUM(RFLOAT_VALUE(x) * (double)FIX2LONG(y));
|
463
|
+
}
|
464
|
+
|
465
|
+
static inline VALUE
|
466
|
+
cast_off_inline_float_float_div(VALUE x, VALUE y)
|
467
|
+
{
|
468
|
+
return DBL2NUM(RFLOAT_VALUE(x) / RFLOAT_VALUE(y));
|
469
|
+
}
|
470
|
+
static inline VALUE
|
471
|
+
cast_off_inline_float_fixnum_div(VALUE x, VALUE y)
|
472
|
+
{
|
473
|
+
return DBL2NUM(RFLOAT_VALUE(x) / (double)FIX2LONG(y));
|
474
|
+
}
|
475
|
+
|
476
|
+
static inline VALUE
|
477
|
+
cast_off_inline_string_plus(VALUE str1, VALUE str2)
|
478
|
+
{
|
479
|
+
VALUE str3;
|
480
|
+
rb_encoding *enc;
|
481
|
+
|
482
|
+
/* StringValue(str2); */ /* str2 is always String */
|
483
|
+
enc = rb_enc_check(str1, str2);
|
484
|
+
str3 = rb_str_new(0, RSTRING_LEN(str1)+RSTRING_LEN(str2));
|
485
|
+
memcpy(RSTRING_PTR(str3), RSTRING_PTR(str1), RSTRING_LEN(str1));
|
486
|
+
memcpy(RSTRING_PTR(str3) + RSTRING_LEN(str1),
|
487
|
+
RSTRING_PTR(str2), RSTRING_LEN(str2));
|
488
|
+
RSTRING_PTR(str3)[RSTRING_LEN(str3)] = '\0';
|
489
|
+
|
490
|
+
if (OBJ_TAINTED(str1) || OBJ_TAINTED(str2))
|
491
|
+
OBJ_TAINT(str3);
|
492
|
+
ENCODING_CODERANGE_SET(str3, rb_enc_to_index(enc),
|
493
|
+
ENC_CODERANGE_AND(ENC_CODERANGE(str1), ENC_CODERANGE(str2)));
|
494
|
+
return str3;
|
495
|
+
}
|
496
|
+
|
497
|
+
static inline VALUE
|
498
|
+
cast_off_inline_string_concat(VALUE str1, VALUE str2)
|
499
|
+
{
|
500
|
+
/* StringValue(str2); */ /* str2 is always String */
|
501
|
+
if (RSTRING_LEN(str2) > 0 && STR_ASSOC_P(str1)) {
|
502
|
+
return rb_str_append(str1, str2);
|
503
|
+
} else {
|
504
|
+
return rb_str_buf_append(str1, str2);
|
505
|
+
}
|
506
|
+
}
|
507
|
+
|