looksee 4.2.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +15 -0
- data/Rakefile +27 -0
- data/ext/extconf.rb +6 -7
- data/ext/mri/3.0.0/id_table.h +36 -0
- data/ext/mri/3.0.0/internal/array.h +119 -0
- data/ext/mri/3.0.0/internal/class.h +174 -0
- data/ext/mri/3.0.0/internal/compilers.h +108 -0
- data/ext/mri/3.0.0/internal/gc.h +161 -0
- data/ext/mri/3.0.0/internal/imemo.h +243 -0
- data/ext/mri/3.0.0/internal/serial.h +24 -0
- data/ext/mri/3.0.0/internal/static_assert.h +17 -0
- data/ext/mri/3.0.0/internal/warnings.h +17 -0
- data/ext/mri/3.0.0/internal.h +107 -0
- data/ext/mri/3.0.0/method.h +246 -0
- data/ext/mri/3.2.0/id_table.h +36 -0
- data/ext/mri/3.2.0/internal/array.h +162 -0
- data/ext/mri/3.2.0/internal/class.h +212 -0
- data/ext/mri/3.2.0/internal/compilers.h +107 -0
- data/ext/mri/3.2.0/internal/gc.h +188 -0
- data/ext/mri/3.2.0/internal/imemo.h +242 -0
- data/ext/mri/3.2.0/internal/serial.h +23 -0
- data/ext/mri/3.2.0/internal/static_assert.h +16 -0
- data/ext/mri/3.2.0/internal/warnings.h +16 -0
- data/ext/mri/3.2.0/internal.h +113 -0
- data/ext/mri/{2.3.0 → 3.2.0}/method.h +95 -55
- data/ext/mri/mri.c +7 -37
- data/lib/looksee/adapter/base.rb +17 -3
- data/lib/looksee/adapter.rb +0 -1
- data/lib/looksee/clean.rb +1 -3
- data/lib/looksee/core_ext.rb +21 -9
- data/lib/looksee/help.rb +2 -2
- data/lib/looksee/inspector.rb +11 -0
- data/lib/looksee/lookup_path.rb +1 -1
- data/lib/looksee/version.rb +1 -1
- data/spec/looksee/adapter_spec.rb +53 -47
- data/spec/looksee/core_ext_spec.rb +2 -2
- data/spec/looksee/inspector_spec.rb +42 -0
- data/spec/looksee/lookup_path_spec.rb +1 -1
- metadata +34 -20
- data/ext/mri/2.1.0/internal.h +0 -889
- data/ext/mri/2.1.0/method.h +0 -142
- data/ext/mri/2.2.0/internal.h +0 -1182
- data/ext/mri/2.2.0/method.h +0 -141
- data/ext/mri/2.3.0/internal.h +0 -1404
- data/ext/rbx/rbx.c +0 -4
- data/lib/looksee/adapter/rubinius.rb +0 -25
@@ -0,0 +1,242 @@
|
|
1
|
+
#ifndef INTERNAL_IMEMO_H /*-*-C-*-vi:se ft=c:*/
|
2
|
+
#define INTERNAL_IMEMO_H
|
3
|
+
/**
|
4
|
+
* @author Ruby developers <ruby-core@ruby-lang.org>
|
5
|
+
* @copyright This file is a part of the programming language Ruby.
|
6
|
+
* Permission is hereby granted, to either redistribute and/or
|
7
|
+
* modify this file, provided that the conditions mentioned in the
|
8
|
+
* file COPYING are met. Consult the file for details.
|
9
|
+
* @brief IMEMO: Internal memo object.
|
10
|
+
*/
|
11
|
+
#include "ruby/internal/config.h"
|
12
|
+
#include <stddef.h> /* for size_t */
|
13
|
+
#include "internal/array.h" /* for rb_ary_hidden_new_fill */
|
14
|
+
#include "internal/gc.h" /* for RB_OBJ_WRITE */
|
15
|
+
#include "ruby/internal/stdbool.h" /* for bool */
|
16
|
+
#include "ruby/ruby.h" /* for rb_block_call_func_t */
|
17
|
+
|
18
|
+
#ifndef IMEMO_DEBUG
|
19
|
+
# define IMEMO_DEBUG 0
|
20
|
+
#endif
|
21
|
+
|
22
|
+
#define IMEMO_MASK 0x0f
|
23
|
+
|
24
|
+
/* FL_USER0 to FL_USER3 is for type */
|
25
|
+
#define IMEMO_FL_USHIFT (FL_USHIFT + 4)
|
26
|
+
#define IMEMO_FL_USER0 FL_USER4
|
27
|
+
#define IMEMO_FL_USER1 FL_USER5
|
28
|
+
#define IMEMO_FL_USER2 FL_USER6
|
29
|
+
#define IMEMO_FL_USER3 FL_USER7
|
30
|
+
#define IMEMO_FL_USER4 FL_USER8
|
31
|
+
#define IMEMO_FL_USER5 FL_USER9
|
32
|
+
|
33
|
+
enum imemo_type {
|
34
|
+
imemo_env = 0,
|
35
|
+
imemo_cref = 1, /*!< class reference */
|
36
|
+
imemo_svar = 2, /*!< special variable */
|
37
|
+
imemo_throw_data = 3,
|
38
|
+
imemo_ifunc = 4, /*!< iterator function */
|
39
|
+
imemo_memo = 5,
|
40
|
+
imemo_ment = 6,
|
41
|
+
imemo_iseq = 7,
|
42
|
+
imemo_tmpbuf = 8,
|
43
|
+
imemo_ast = 9,
|
44
|
+
imemo_parser_strterm = 10,
|
45
|
+
imemo_callinfo = 11,
|
46
|
+
imemo_callcache = 12,
|
47
|
+
imemo_constcache = 13,
|
48
|
+
};
|
49
|
+
|
50
|
+
/* CREF (Class REFerence) is defined in method.h */
|
51
|
+
|
52
|
+
/*! SVAR (Special VARiable) */
|
53
|
+
struct vm_svar {
|
54
|
+
VALUE flags;
|
55
|
+
const VALUE cref_or_me; /*!< class reference or rb_method_entry_t */
|
56
|
+
const VALUE lastline;
|
57
|
+
const VALUE backref;
|
58
|
+
const VALUE others;
|
59
|
+
};
|
60
|
+
|
61
|
+
/*! THROW_DATA */
|
62
|
+
struct vm_throw_data {
|
63
|
+
VALUE flags;
|
64
|
+
VALUE reserved;
|
65
|
+
const VALUE throw_obj;
|
66
|
+
const struct rb_control_frame_struct *catch_frame;
|
67
|
+
int throw_state;
|
68
|
+
};
|
69
|
+
|
70
|
+
#define THROW_DATA_CONSUMED IMEMO_FL_USER0
|
71
|
+
|
72
|
+
/* IFUNC (Internal FUNCtion) */
|
73
|
+
|
74
|
+
struct vm_ifunc_argc {
|
75
|
+
#if SIZEOF_INT * 2 > SIZEOF_VALUE
|
76
|
+
signed int min: (SIZEOF_VALUE * CHAR_BIT) / 2;
|
77
|
+
signed int max: (SIZEOF_VALUE * CHAR_BIT) / 2;
|
78
|
+
#else
|
79
|
+
int min, max;
|
80
|
+
#endif
|
81
|
+
};
|
82
|
+
|
83
|
+
/*! IFUNC (Internal FUNCtion) */
|
84
|
+
struct vm_ifunc {
|
85
|
+
VALUE flags;
|
86
|
+
VALUE reserved;
|
87
|
+
rb_block_call_func_t func;
|
88
|
+
const void *data;
|
89
|
+
struct vm_ifunc_argc argc;
|
90
|
+
};
|
91
|
+
|
92
|
+
struct rb_imemo_tmpbuf_struct {
|
93
|
+
VALUE flags;
|
94
|
+
VALUE reserved;
|
95
|
+
VALUE *ptr; /* malloc'ed buffer */
|
96
|
+
struct rb_imemo_tmpbuf_struct *next; /* next imemo */
|
97
|
+
size_t cnt; /* buffer size in VALUE */
|
98
|
+
};
|
99
|
+
|
100
|
+
/*! MEMO
|
101
|
+
*
|
102
|
+
* @see imemo_type
|
103
|
+
* */
|
104
|
+
struct MEMO {
|
105
|
+
VALUE flags;
|
106
|
+
VALUE reserved;
|
107
|
+
const VALUE v1;
|
108
|
+
const VALUE v2;
|
109
|
+
union {
|
110
|
+
long cnt;
|
111
|
+
long state;
|
112
|
+
const VALUE value;
|
113
|
+
void (*func)(void);
|
114
|
+
} u3;
|
115
|
+
};
|
116
|
+
|
117
|
+
/* ment is in method.h */
|
118
|
+
|
119
|
+
#define THROW_DATA_P(err) imemo_throw_data_p((VALUE)err)
|
120
|
+
#define MEMO_CAST(m) ((struct MEMO *)(m))
|
121
|
+
#define MEMO_NEW(a, b, c) ((struct MEMO *)rb_imemo_new(imemo_memo, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0))
|
122
|
+
#define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
|
123
|
+
#define NEW_MEMO_FOR(type, value) \
|
124
|
+
((value) = rb_ary_hidden_new_fill(type_roomof(type, VALUE)), MEMO_FOR(type, value))
|
125
|
+
#define NEW_PARTIAL_MEMO_FOR(type, value, member) \
|
126
|
+
((value) = rb_ary_hidden_new_fill(type_roomof(type, VALUE)), \
|
127
|
+
rb_ary_set_len((value), offsetof(type, member) / sizeof(VALUE)), \
|
128
|
+
MEMO_FOR(type, value))
|
129
|
+
|
130
|
+
typedef struct rb_imemo_tmpbuf_struct rb_imemo_tmpbuf_t;
|
131
|
+
rb_imemo_tmpbuf_t *rb_imemo_tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt);
|
132
|
+
struct vm_ifunc *rb_vm_ifunc_new(rb_block_call_func_t func, const void *data, int min_argc, int max_argc);
|
133
|
+
void rb_strterm_mark(VALUE obj);
|
134
|
+
static inline enum imemo_type imemo_type(VALUE imemo);
|
135
|
+
static inline int imemo_type_p(VALUE imemo, enum imemo_type imemo_type);
|
136
|
+
static inline bool imemo_throw_data_p(VALUE imemo);
|
137
|
+
static inline struct vm_ifunc *rb_vm_ifunc_proc_new(rb_block_call_func_t func, const void *data);
|
138
|
+
static inline VALUE rb_imemo_tmpbuf_auto_free_pointer(void);
|
139
|
+
static inline void *RB_IMEMO_TMPBUF_PTR(VALUE v);
|
140
|
+
static inline void *rb_imemo_tmpbuf_set_ptr(VALUE v, void *ptr);
|
141
|
+
static inline VALUE rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(VALUE str);
|
142
|
+
static inline void MEMO_V1_SET(struct MEMO *m, VALUE v);
|
143
|
+
static inline void MEMO_V2_SET(struct MEMO *m, VALUE v);
|
144
|
+
|
145
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
146
|
+
#if IMEMO_DEBUG
|
147
|
+
VALUE rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0, const char *file, int line);
|
148
|
+
#define rb_imemo_new(type, v1, v2, v3, v0) rb_imemo_new_debug(type, v1, v2, v3, v0, __FILE__, __LINE__)
|
149
|
+
#else
|
150
|
+
VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0);
|
151
|
+
#endif
|
152
|
+
const char *rb_imemo_name(enum imemo_type type);
|
153
|
+
RUBY_SYMBOL_EXPORT_END
|
154
|
+
|
155
|
+
static inline enum imemo_type
|
156
|
+
imemo_type(VALUE imemo)
|
157
|
+
{
|
158
|
+
return (RBASIC(imemo)->flags >> FL_USHIFT) & IMEMO_MASK;
|
159
|
+
}
|
160
|
+
|
161
|
+
static inline int
|
162
|
+
imemo_type_p(VALUE imemo, enum imemo_type imemo_type)
|
163
|
+
{
|
164
|
+
if (LIKELY(!RB_SPECIAL_CONST_P(imemo))) {
|
165
|
+
/* fixed at compile time if imemo_type is given. */
|
166
|
+
const VALUE mask = (IMEMO_MASK << FL_USHIFT) | RUBY_T_MASK;
|
167
|
+
const VALUE expected_type = (imemo_type << FL_USHIFT) | T_IMEMO;
|
168
|
+
/* fixed at runtime. */
|
169
|
+
return expected_type == (RBASIC(imemo)->flags & mask);
|
170
|
+
}
|
171
|
+
else {
|
172
|
+
return 0;
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
#define IMEMO_TYPE_P(v, t) imemo_type_p((VALUE)v, t)
|
177
|
+
|
178
|
+
static inline bool
|
179
|
+
imemo_throw_data_p(VALUE imemo)
|
180
|
+
{
|
181
|
+
return RB_TYPE_P(imemo, T_IMEMO);
|
182
|
+
}
|
183
|
+
|
184
|
+
static inline struct vm_ifunc *
|
185
|
+
rb_vm_ifunc_proc_new(rb_block_call_func_t func, const void *data)
|
186
|
+
{
|
187
|
+
return rb_vm_ifunc_new(func, data, 0, UNLIMITED_ARGUMENTS);
|
188
|
+
}
|
189
|
+
|
190
|
+
static inline VALUE
|
191
|
+
rb_imemo_tmpbuf_auto_free_pointer(void)
|
192
|
+
{
|
193
|
+
return rb_imemo_new(imemo_tmpbuf, 0, 0, 0, 0);
|
194
|
+
}
|
195
|
+
|
196
|
+
static inline void *
|
197
|
+
RB_IMEMO_TMPBUF_PTR(VALUE v)
|
198
|
+
{
|
199
|
+
const struct rb_imemo_tmpbuf_struct *p = (const void *)v;
|
200
|
+
return p->ptr;
|
201
|
+
}
|
202
|
+
|
203
|
+
static inline void *
|
204
|
+
rb_imemo_tmpbuf_set_ptr(VALUE v, void *ptr)
|
205
|
+
{
|
206
|
+
return ((rb_imemo_tmpbuf_t *)v)->ptr = ptr;
|
207
|
+
}
|
208
|
+
|
209
|
+
static inline VALUE
|
210
|
+
rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(VALUE str)
|
211
|
+
{
|
212
|
+
const void *src;
|
213
|
+
VALUE imemo;
|
214
|
+
rb_imemo_tmpbuf_t *tmpbuf;
|
215
|
+
void *dst;
|
216
|
+
size_t len;
|
217
|
+
|
218
|
+
SafeStringValue(str);
|
219
|
+
/* create tmpbuf to keep the pointer before xmalloc */
|
220
|
+
imemo = rb_imemo_tmpbuf_auto_free_pointer();
|
221
|
+
tmpbuf = (rb_imemo_tmpbuf_t *)imemo;
|
222
|
+
len = RSTRING_LEN(str);
|
223
|
+
src = RSTRING_PTR(str);
|
224
|
+
dst = ruby_xmalloc(len);
|
225
|
+
memcpy(dst, src, len);
|
226
|
+
tmpbuf->ptr = dst;
|
227
|
+
return imemo;
|
228
|
+
}
|
229
|
+
|
230
|
+
static inline void
|
231
|
+
MEMO_V1_SET(struct MEMO *m, VALUE v)
|
232
|
+
{
|
233
|
+
RB_OBJ_WRITE(m, &m->v1, v);
|
234
|
+
}
|
235
|
+
|
236
|
+
static inline void
|
237
|
+
MEMO_V2_SET(struct MEMO *m, VALUE v)
|
238
|
+
{
|
239
|
+
RB_OBJ_WRITE(m, &m->v2, v);
|
240
|
+
}
|
241
|
+
|
242
|
+
#endif /* INTERNAL_IMEMO_H */
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#ifndef INTERNAL_SERIAL_H /*-*-C-*-vi:se ft=c:*/
|
2
|
+
#define INTERNAL_SERIAL_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 rb_serial_t.
|
10
|
+
*/
|
11
|
+
#include "ruby/internal/config.h" /* for HAVE_LONG_LONG */
|
12
|
+
#include "ruby/defines.h" /* for LONG_LONG */
|
13
|
+
|
14
|
+
#ifndef HAVE_LONG_LONG
|
15
|
+
# error need C99+
|
16
|
+
#endif
|
17
|
+
|
18
|
+
typedef unsigned LONG_LONG rb_serial_t;
|
19
|
+
#define SERIALT2NUM ULL2NUM
|
20
|
+
#define PRI_SERIALT_PREFIX PRI_LL_PREFIX
|
21
|
+
#define SIZEOF_SERIAL_T SIZEOF_LONG_LONG
|
22
|
+
|
23
|
+
#endif /* INTERNAL_SERIAL_H */
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#ifndef INTERNAL_STATIC_ASSERT_H /*-*-C-*-vi:se ft=c:*/
|
2
|
+
#define INTERNAL_STATIC_ASSERT_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 C11 shim for _Static_assert.
|
10
|
+
*/
|
11
|
+
#include "ruby/internal/static_assert.h"
|
12
|
+
#ifndef STATIC_ASSERT
|
13
|
+
# define STATIC_ASSERT RBIMPL_STATIC_ASSERT
|
14
|
+
#endif
|
15
|
+
|
16
|
+
#endif /* INTERNAL_STATIC_ASSERT_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,113 @@
|
|
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
|
+
#include "ruby/ruby.h"
|
29
|
+
|
30
|
+
/* Following macros were formerly defined in this header but moved to somewhere
|
31
|
+
* else. In order to detect them we undef here. */
|
32
|
+
|
33
|
+
/* internal/array.h */
|
34
|
+
#undef RARRAY_AREF
|
35
|
+
|
36
|
+
/* internal/class.h */
|
37
|
+
#undef RClass
|
38
|
+
#undef RCLASS_SUPER
|
39
|
+
|
40
|
+
/* internal/gc.h */
|
41
|
+
#undef NEWOBJ_OF
|
42
|
+
#undef RB_NEWOBJ_OF
|
43
|
+
#undef RB_OBJ_WRITE
|
44
|
+
|
45
|
+
/* internal/hash.h */
|
46
|
+
#undef RHASH_IFNONE
|
47
|
+
#undef RHASH_SIZE
|
48
|
+
#undef RHASH_TBL
|
49
|
+
#undef RHASH_EMPTY_P
|
50
|
+
|
51
|
+
/* internal/object.h */
|
52
|
+
#undef ROBJECT_IV_INDEX_TBL
|
53
|
+
|
54
|
+
/* internal/struct.h */
|
55
|
+
#undef RSTRUCT_LEN
|
56
|
+
#undef RSTRUCT_PTR
|
57
|
+
#undef RSTRUCT_SET
|
58
|
+
#undef RSTRUCT_GET
|
59
|
+
|
60
|
+
/* Also, we keep the following macros here. They are expected to be
|
61
|
+
* overridden in each headers. */
|
62
|
+
|
63
|
+
/* internal/array.h */
|
64
|
+
#define rb_ary_new_from_args(...) rb_nonexistent_symbol(__VA_ARGS__)
|
65
|
+
|
66
|
+
/* internal/io.h */
|
67
|
+
#define rb_io_fptr_finalize(...) rb_nonexistent_symbol(__VA_ARGS__)
|
68
|
+
|
69
|
+
/* internal/string.h */
|
70
|
+
#define rb_fstring_cstr(...) rb_nonexistent_symbol(__VA_ARGS__)
|
71
|
+
|
72
|
+
/* internal/symbol.h */
|
73
|
+
#define rb_sym_intern_ascii_cstr(...) rb_nonexistent_symbol(__VA_ARGS__)
|
74
|
+
|
75
|
+
/* internal/vm.h */
|
76
|
+
#define rb_funcallv(...) rb_nonexistent_symbol(__VA_ARGS__)
|
77
|
+
#define rb_method_basic_definition_p(...) rb_nonexistent_symbol(__VA_ARGS__)
|
78
|
+
|
79
|
+
|
80
|
+
/* MRI debug support */
|
81
|
+
|
82
|
+
/* gc.c */
|
83
|
+
void rb_obj_info_dump(VALUE obj);
|
84
|
+
void rb_obj_info_dump_loc(VALUE obj, const char *file, int line, const char *func);
|
85
|
+
|
86
|
+
/* debug.c */
|
87
|
+
|
88
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
89
|
+
void ruby_debug_breakpoint(void);
|
90
|
+
PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
|
91
|
+
RUBY_SYMBOL_EXPORT_END
|
92
|
+
|
93
|
+
// show obj data structure without any side-effect
|
94
|
+
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
|
95
|
+
|
96
|
+
// same as rp, but add message header
|
97
|
+
#define rp_m(msg, obj) do { \
|
98
|
+
fputs((msg), stderr); \
|
99
|
+
rb_obj_info_dump((VALUE)(obj)); \
|
100
|
+
} while (0)
|
101
|
+
|
102
|
+
// `ruby_debug_breakpoint()` does nothing,
|
103
|
+
// but breakpoint is set in run.gdb, so `make gdb` can stop here.
|
104
|
+
#define bp() ruby_debug_breakpoint()
|
105
|
+
|
106
|
+
#define RBOOL(v) ((v) ? Qtrue : Qfalse)
|
107
|
+
#define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)
|
108
|
+
|
109
|
+
#ifndef __MINGW32__
|
110
|
+
#undef memcpy
|
111
|
+
#define memcpy ruby_nonempty_memcpy
|
112
|
+
#endif
|
113
|
+
#endif /* RUBY_INTERNAL_H */
|
@@ -1,17 +1,20 @@
|
|
1
|
+
#ifndef RUBY_METHOD_H
|
2
|
+
#define RUBY_METHOD_H 1
|
1
3
|
/**********************************************************************
|
2
4
|
|
3
5
|
method.h -
|
4
6
|
|
5
|
-
$Author
|
7
|
+
$Author$
|
6
8
|
created at: Wed Jul 15 20:02:33 2009
|
7
9
|
|
8
10
|
Copyright (C) 2009 Koichi Sasada
|
9
11
|
|
10
12
|
**********************************************************************/
|
11
|
-
#ifndef RUBY_METHOD_H
|
12
|
-
#define RUBY_METHOD_H 1
|
13
13
|
|
14
14
|
#include "internal.h"
|
15
|
+
#include "internal/imemo.h"
|
16
|
+
#include "internal/compilers.h"
|
17
|
+
#include "internal/static_assert.h"
|
15
18
|
|
16
19
|
#ifndef END_OF_ENUMERATION
|
17
20
|
# if defined(__GNUC__) &&! defined(__STRICT_ANSI__)
|
@@ -33,15 +36,16 @@ typedef enum {
|
|
33
36
|
} rb_method_visibility_t;
|
34
37
|
|
35
38
|
typedef struct rb_scope_visi_struct {
|
36
|
-
rb_method_visibility_t method_visi
|
39
|
+
BITFIELD(rb_method_visibility_t, method_visi, 3);
|
37
40
|
unsigned int module_func : 1;
|
38
41
|
} rb_scope_visibility_t;
|
39
42
|
|
43
|
+
/*! CREF (Class REFerence) */
|
40
44
|
typedef struct rb_cref_struct {
|
41
45
|
VALUE flags;
|
42
|
-
|
43
|
-
|
44
|
-
struct rb_cref_struct *
|
46
|
+
VALUE refinements;
|
47
|
+
VALUE klass_or_self;
|
48
|
+
struct rb_cref_struct * next;
|
45
49
|
const rb_scope_visibility_t scope_visi;
|
46
50
|
} rb_cref_t;
|
47
51
|
|
@@ -49,10 +53,10 @@ typedef struct rb_cref_struct {
|
|
49
53
|
|
50
54
|
typedef struct rb_method_entry_struct {
|
51
55
|
VALUE flags;
|
52
|
-
|
56
|
+
VALUE defined_class;
|
53
57
|
struct rb_method_definition_struct * const def;
|
54
58
|
ID called_id;
|
55
|
-
|
59
|
+
VALUE owner;
|
56
60
|
} rb_method_entry_t;
|
57
61
|
|
58
62
|
typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_entry_t */
|
@@ -65,8 +69,12 @@ typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_e
|
|
65
69
|
|
66
70
|
#define METHOD_ENTRY_VISI(me) (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))
|
67
71
|
#define METHOD_ENTRY_BASIC(me) (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))
|
68
|
-
#define METHOD_ENTRY_COMPLEMENTED(me)
|
69
|
-
#define METHOD_ENTRY_COMPLEMENTED_SET(me)
|
72
|
+
#define METHOD_ENTRY_COMPLEMENTED(me) ((me)->flags & IMEMO_FL_USER3)
|
73
|
+
#define METHOD_ENTRY_COMPLEMENTED_SET(me) ((me)->flags |= IMEMO_FL_USER3)
|
74
|
+
#define METHOD_ENTRY_CACHED(me) ((me)->flags & IMEMO_FL_USER4)
|
75
|
+
#define METHOD_ENTRY_CACHED_SET(me) ((me)->flags |= IMEMO_FL_USER4)
|
76
|
+
#define METHOD_ENTRY_INVALIDATED(me) ((me)->flags & IMEMO_FL_USER5)
|
77
|
+
#define METHOD_ENTRY_INVALIDATED_SET(me) ((me)->flags |= IMEMO_FL_USER5)
|
70
78
|
|
71
79
|
static inline void
|
72
80
|
METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
|
@@ -87,32 +95,35 @@ METHOD_ENTRY_FLAGS_SET(rb_method_entry_t *me, rb_method_visibility_t visi, unsig
|
|
87
95
|
VM_ASSERT(basic <= 1);
|
88
96
|
me->flags =
|
89
97
|
(me->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
|
90
|
-
|
98
|
+
((visi << (IMEMO_FL_USHIFT+0)) | (basic << (IMEMO_FL_USHIFT+2)));
|
91
99
|
}
|
92
100
|
static inline void
|
93
101
|
METHOD_ENTRY_FLAGS_COPY(rb_method_entry_t *dst, const rb_method_entry_t *src)
|
94
102
|
{
|
95
103
|
dst->flags =
|
96
104
|
(dst->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
|
97
|
-
|
105
|
+
(src->flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2));
|
98
106
|
}
|
99
107
|
|
100
108
|
typedef enum {
|
101
|
-
VM_METHOD_TYPE_ISEQ,
|
102
|
-
VM_METHOD_TYPE_CFUNC,
|
103
|
-
VM_METHOD_TYPE_ATTRSET,
|
104
|
-
VM_METHOD_TYPE_IVAR,
|
109
|
+
VM_METHOD_TYPE_ISEQ, /*!< Ruby method */
|
110
|
+
VM_METHOD_TYPE_CFUNC, /*!< C method */
|
111
|
+
VM_METHOD_TYPE_ATTRSET, /*!< attr_writer or attr_accessor */
|
112
|
+
VM_METHOD_TYPE_IVAR, /*!< attr_reader or attr_accessor */
|
105
113
|
VM_METHOD_TYPE_BMETHOD,
|
106
114
|
VM_METHOD_TYPE_ZSUPER,
|
107
115
|
VM_METHOD_TYPE_ALIAS,
|
108
116
|
VM_METHOD_TYPE_UNDEF,
|
109
117
|
VM_METHOD_TYPE_NOTIMPLEMENTED,
|
110
|
-
VM_METHOD_TYPE_OPTIMIZED,
|
111
|
-
VM_METHOD_TYPE_MISSING,
|
112
|
-
VM_METHOD_TYPE_REFINED,
|
118
|
+
VM_METHOD_TYPE_OPTIMIZED, /*!< Kernel#send, Proc#call, etc */
|
119
|
+
VM_METHOD_TYPE_MISSING, /*!< wrapper for method_missing(id) */
|
120
|
+
VM_METHOD_TYPE_REFINED, /*!< refinement */
|
113
121
|
|
114
122
|
END_OF_ENUMERATION(VM_METHOD_TYPE)
|
115
123
|
} rb_method_type_t;
|
124
|
+
#define VM_METHOD_TYPE_MINIMUM_BITS 4
|
125
|
+
STATIC_ASSERT(VM_METHOD_TYPE_MINIMUM_BITS,
|
126
|
+
VM_METHOD_TYPE_REFINED <= (1<<VM_METHOD_TYPE_MINIMUM_BITS));
|
116
127
|
|
117
128
|
#ifndef rb_iseq_t
|
118
129
|
typedef struct rb_iseq_struct rb_iseq_t;
|
@@ -120,94 +131,123 @@ typedef struct rb_iseq_struct rb_iseq_t;
|
|
120
131
|
#endif
|
121
132
|
|
122
133
|
typedef struct rb_method_iseq_struct {
|
123
|
-
const rb_iseq_t *
|
124
|
-
rb_cref_t *
|
134
|
+
const rb_iseq_t * iseqptr; /*!< iseq pointer, should be separated from iseqval */
|
135
|
+
rb_cref_t * cref; /*!< class reference, should be marked */
|
125
136
|
} rb_method_iseq_t; /* check rb_add_method_iseq() when modify the fields */
|
126
137
|
|
127
138
|
typedef struct rb_method_cfunc_struct {
|
128
139
|
VALUE (*func)(ANYARGS);
|
129
|
-
VALUE (*invoker)(VALUE
|
140
|
+
VALUE (*invoker)(VALUE recv, int argc, const VALUE *argv, VALUE (*func)(ANYARGS));
|
130
141
|
int argc;
|
131
142
|
} rb_method_cfunc_t;
|
132
143
|
|
133
144
|
typedef struct rb_method_attr_struct {
|
134
145
|
ID id;
|
135
|
-
|
146
|
+
VALUE location; /* should be marked */
|
136
147
|
} rb_method_attr_t;
|
137
148
|
|
138
149
|
typedef struct rb_method_alias_struct {
|
139
|
-
|
150
|
+
struct rb_method_entry_struct * original_me; /* original_me->klass is original owner */
|
140
151
|
} rb_method_alias_t;
|
141
152
|
|
142
153
|
typedef struct rb_method_refined_struct {
|
143
|
-
|
144
|
-
|
154
|
+
struct rb_method_entry_struct * orig_me;
|
155
|
+
VALUE owner;
|
145
156
|
} rb_method_refined_t;
|
146
157
|
|
147
|
-
typedef struct
|
148
|
-
|
149
|
-
|
150
|
-
|
158
|
+
typedef struct rb_method_bmethod_struct {
|
159
|
+
VALUE proc; /* should be marked */
|
160
|
+
struct rb_hook_list_struct *hooks;
|
161
|
+
VALUE defined_ractor;
|
162
|
+
} rb_method_bmethod_t;
|
163
|
+
|
164
|
+
enum method_optimized_type {
|
165
|
+
OPTIMIZED_METHOD_TYPE_SEND,
|
166
|
+
OPTIMIZED_METHOD_TYPE_CALL,
|
167
|
+
OPTIMIZED_METHOD_TYPE_BLOCK_CALL,
|
168
|
+
OPTIMIZED_METHOD_TYPE_STRUCT_AREF,
|
169
|
+
OPTIMIZED_METHOD_TYPE_STRUCT_ASET,
|
170
|
+
OPTIMIZED_METHOD_TYPE__MAX
|
171
|
+
};
|
172
|
+
|
173
|
+
typedef struct rb_method_optimized {
|
174
|
+
enum method_optimized_type type;
|
175
|
+
unsigned int index;
|
176
|
+
} rb_method_optimized_t;
|
177
|
+
|
178
|
+
struct rb_method_definition_struct {
|
179
|
+
BITFIELD(rb_method_type_t, type, VM_METHOD_TYPE_MINIMUM_BITS);
|
180
|
+
unsigned int iseq_overload: 1;
|
181
|
+
int alias_count : 27;
|
182
|
+
int complemented_count : 28;
|
183
|
+
unsigned int no_redef_warning: 1;
|
151
184
|
|
152
185
|
union {
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
enum method_optimized_type {
|
161
|
-
OPTIMIZED_METHOD_TYPE_SEND,
|
162
|
-
OPTIMIZED_METHOD_TYPE_CALL,
|
163
|
-
|
164
|
-
OPTIMIZED_METHOD_TYPE__MAX
|
165
|
-
} optimize_type;
|
186
|
+
rb_method_iseq_t iseq;
|
187
|
+
rb_method_cfunc_t cfunc;
|
188
|
+
rb_method_attr_t attr;
|
189
|
+
rb_method_alias_t alias;
|
190
|
+
rb_method_refined_t refined;
|
191
|
+
rb_method_bmethod_t bmethod;
|
192
|
+
rb_method_optimized_t optimized;
|
166
193
|
} body;
|
167
194
|
|
168
195
|
ID original_id;
|
169
|
-
|
196
|
+
uintptr_t method_serial;
|
197
|
+
};
|
198
|
+
|
199
|
+
struct rb_id_table;
|
200
|
+
|
201
|
+
typedef struct rb_method_definition_struct rb_method_definition_t;
|
202
|
+
STATIC_ASSERT(sizeof_method_def, offsetof(rb_method_definition_t, body)==8);
|
170
203
|
|
171
204
|
#define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
|
172
205
|
#define UNDEFINED_REFINED_METHOD_P(def) \
|
173
206
|
((def)->type == VM_METHOD_TYPE_REFINED && \
|
174
207
|
UNDEFINED_METHOD_ENTRY_P((def)->body.refined.orig_me))
|
175
208
|
|
209
|
+
void rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_visibility_t visi);
|
176
210
|
void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_visibility_t visi);
|
177
211
|
void rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref, rb_method_visibility_t visi);
|
212
|
+
void rb_add_method_optimized(VALUE klass, ID mid, enum method_optimized_type, unsigned int index, rb_method_visibility_t visi);
|
178
213
|
void rb_add_refined_method_entry(VALUE refined_class, ID mid);
|
179
214
|
|
180
|
-
rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_visibility_t visi);
|
181
215
|
rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_visibility_t noex);
|
182
216
|
rb_method_entry_t *rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, const rb_method_definition_t *def);
|
183
217
|
|
184
218
|
const rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
|
185
219
|
|
186
220
|
const rb_method_entry_t *rb_method_entry(VALUE klass, ID id);
|
187
|
-
const rb_method_entry_t *rb_method_entry_with_refinements(VALUE klass, ID id);
|
188
|
-
const rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id);
|
221
|
+
const rb_method_entry_t *rb_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class);
|
222
|
+
const rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
|
189
223
|
const rb_method_entry_t *rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
|
224
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
225
|
+
const rb_method_entry_t *rb_resolve_me_location(const rb_method_entry_t *, VALUE[5]);
|
226
|
+
RUBY_SYMBOL_EXPORT_END
|
190
227
|
|
191
228
|
const rb_callable_method_entry_t *rb_callable_method_entry(VALUE klass, ID id);
|
192
|
-
const rb_callable_method_entry_t *rb_callable_method_entry_with_refinements(VALUE klass, ID id);
|
193
|
-
const rb_callable_method_entry_t *rb_callable_method_entry_without_refinements(VALUE klass, ID id);
|
194
|
-
const rb_callable_method_entry_t *rb_resolve_refined_method_callable(VALUE refinements, const rb_callable_method_entry_t *me);
|
229
|
+
const rb_callable_method_entry_t *rb_callable_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class);
|
230
|
+
const rb_callable_method_entry_t *rb_callable_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
|
195
231
|
|
196
232
|
int rb_method_entry_arity(const rb_method_entry_t *me);
|
197
233
|
int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2);
|
198
234
|
st_index_t rb_hash_method_entry(st_index_t hash, const rb_method_entry_t *me);
|
199
235
|
|
200
236
|
VALUE rb_method_entry_location(const rb_method_entry_t *me);
|
201
|
-
VALUE rb_mod_method_location(VALUE mod, ID id);
|
202
|
-
VALUE rb_obj_method_location(VALUE obj, ID id);
|
203
237
|
|
204
238
|
void rb_free_method_entry(const rb_method_entry_t *me);
|
205
|
-
void rb_sweep_method_entry(void *vm);
|
206
239
|
|
207
240
|
const rb_method_entry_t *rb_method_entry_clone(const rb_method_entry_t *me);
|
208
|
-
const rb_callable_method_entry_t *rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, VALUE defined_class);
|
241
|
+
const rb_callable_method_entry_t *rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class);
|
209
242
|
void rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src);
|
210
243
|
|
244
|
+
void rb_method_table_insert(VALUE klass, struct rb_id_table *table, ID method_id, const rb_method_entry_t *me);
|
245
|
+
|
211
246
|
void rb_scope_visibility_set(rb_method_visibility_t);
|
212
247
|
|
248
|
+
VALUE rb_unnamed_parameters(int arity);
|
249
|
+
|
250
|
+
void rb_clear_method_cache(VALUE klass_or_module, ID mid);
|
251
|
+
void rb_clear_method_cache_all(void);
|
252
|
+
|
213
253
|
#endif /* RUBY_METHOD_H */
|