binding_of_caller 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +0 -0
- data/README.md +56 -0
- data/Rakefile +99 -0
- data/ext/binding_of_caller/binding_of_caller.c +124 -0
- data/ext/binding_of_caller/compat.h +57 -0
- data/ext/binding_of_caller/extconf.rb +14 -0
- data/ext/binding_of_caller/ruby_headers/192/debug.h +36 -0
- data/ext/binding_of_caller/ruby_headers/192/dln.h +41 -0
- data/ext/binding_of_caller/ruby_headers/192/eval_intern.h +232 -0
- data/ext/binding_of_caller/ruby_headers/192/gc.h +77 -0
- data/ext/binding_of_caller/ruby_headers/192/id.h +173 -0
- data/ext/binding_of_caller/ruby_headers/192/iseq.h +104 -0
- data/ext/binding_of_caller/ruby_headers/192/method.h +103 -0
- data/ext/binding_of_caller/ruby_headers/192/node.h +483 -0
- data/ext/binding_of_caller/ruby_headers/192/regenc.h +211 -0
- data/ext/binding_of_caller/ruby_headers/192/regint.h +841 -0
- data/ext/binding_of_caller/ruby_headers/192/regparse.h +354 -0
- data/ext/binding_of_caller/ruby_headers/192/thread_pthread.h +27 -0
- data/ext/binding_of_caller/ruby_headers/192/thread_win32.h +33 -0
- data/ext/binding_of_caller/ruby_headers/192/timev.h +21 -0
- data/ext/binding_of_caller/ruby_headers/192/transcode_data.h +109 -0
- data/ext/binding_of_caller/ruby_headers/192/version.h +63 -0
- data/ext/binding_of_caller/ruby_headers/192/vm_core.h +703 -0
- data/ext/binding_of_caller/ruby_headers/192/vm_exec.h +184 -0
- data/ext/binding_of_caller/ruby_headers/192/vm_insnhelper.h +208 -0
- data/ext/binding_of_caller/ruby_headers/192/vm_opts.h +51 -0
- data/ext/binding_of_caller/ruby_headers/193/addr2line.h +21 -0
- data/ext/binding_of_caller/ruby_headers/193/atomic.h +56 -0
- data/ext/binding_of_caller/ruby_headers/193/constant.h +34 -0
- data/ext/binding_of_caller/ruby_headers/193/debug.h +41 -0
- data/ext/binding_of_caller/ruby_headers/193/dln.h +50 -0
- data/ext/binding_of_caller/ruby_headers/193/encdb.h +167 -0
- data/ext/binding_of_caller/ruby_headers/193/eval_intern.h +234 -0
- data/ext/binding_of_caller/ruby_headers/193/gc.h +98 -0
- data/ext/binding_of_caller/ruby_headers/193/id.h +175 -0
- data/ext/binding_of_caller/ruby_headers/193/internal.h +227 -0
- data/ext/binding_of_caller/ruby_headers/193/iseq.h +125 -0
- data/ext/binding_of_caller/ruby_headers/193/method.h +105 -0
- data/ext/binding_of_caller/ruby_headers/193/node.h +503 -0
- data/ext/binding_of_caller/ruby_headers/193/parse.h +186 -0
- data/ext/binding_of_caller/ruby_headers/193/regenc.h +219 -0
- data/ext/binding_of_caller/ruby_headers/193/regint.h +851 -0
- data/ext/binding_of_caller/ruby_headers/193/regparse.h +362 -0
- data/ext/binding_of_caller/ruby_headers/193/revision.h +1 -0
- data/ext/binding_of_caller/ruby_headers/193/thread_pthread.h +51 -0
- data/ext/binding_of_caller/ruby_headers/193/thread_win32.h +40 -0
- data/ext/binding_of_caller/ruby_headers/193/timev.h +21 -0
- data/ext/binding_of_caller/ruby_headers/193/transcode_data.h +117 -0
- data/ext/binding_of_caller/ruby_headers/193/transdb.h +189 -0
- data/ext/binding_of_caller/ruby_headers/193/version.h +52 -0
- data/ext/binding_of_caller/ruby_headers/193/vm_core.h +755 -0
- data/ext/binding_of_caller/ruby_headers/193/vm_exec.h +184 -0
- data/ext/binding_of_caller/ruby_headers/193/vm_insnhelper.h +220 -0
- data/ext/binding_of_caller/ruby_headers/193/vm_opts.h +51 -0
- data/lib/binding_of_caller.rb +22 -0
- data/lib/binding_of_caller/version.rb +3 -0
- data/test/test.rb +12 -0
- metadata +120 -0
@@ -0,0 +1,77 @@
|
|
1
|
+
|
2
|
+
#ifndef RUBY_GC_H
|
3
|
+
#define RUBY_GC_H 1
|
4
|
+
|
5
|
+
#if defined(__x86_64__) && defined(__GNUC__)
|
6
|
+
#define SET_MACHINE_STACK_END(p) __asm__("movq\t%%rsp, %0" : "=r" (*p))
|
7
|
+
#elif defined(__i386) && defined(__GNUC__)
|
8
|
+
#define SET_MACHINE_STACK_END(p) __asm__("movl\t%%esp, %0" : "=r" (*p))
|
9
|
+
#else
|
10
|
+
NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p));
|
11
|
+
#define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p)
|
12
|
+
#define USE_CONSERVATIVE_STACK_END
|
13
|
+
#endif
|
14
|
+
|
15
|
+
/* for GC debug */
|
16
|
+
|
17
|
+
#ifndef RUBY_MARK_FREE_DEBUG
|
18
|
+
#define RUBY_MARK_FREE_DEBUG 0
|
19
|
+
#endif
|
20
|
+
|
21
|
+
#if RUBY_MARK_FREE_DEBUG
|
22
|
+
extern int ruby_gc_debug_indent;
|
23
|
+
|
24
|
+
static void
|
25
|
+
rb_gc_debug_indent(void)
|
26
|
+
{
|
27
|
+
printf("%*s", ruby_gc_debug_indent, "");
|
28
|
+
}
|
29
|
+
|
30
|
+
static void
|
31
|
+
rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr)
|
32
|
+
{
|
33
|
+
if (st == 0) {
|
34
|
+
ruby_gc_debug_indent--;
|
35
|
+
}
|
36
|
+
rb_gc_debug_indent();
|
37
|
+
printf("%s: %s %s (%p)\n", mode, st ? "->" : "<-", msg, ptr);
|
38
|
+
|
39
|
+
if (st) {
|
40
|
+
ruby_gc_debug_indent++;
|
41
|
+
}
|
42
|
+
|
43
|
+
fflush(stdout);
|
44
|
+
}
|
45
|
+
|
46
|
+
#define RUBY_MARK_ENTER(msg) rb_gc_debug_body("mark", msg, 1, ptr)
|
47
|
+
#define RUBY_MARK_LEAVE(msg) rb_gc_debug_body("mark", msg, 0, ptr)
|
48
|
+
#define RUBY_FREE_ENTER(msg) rb_gc_debug_body("free", msg, 1, ptr)
|
49
|
+
#define RUBY_FREE_LEAVE(msg) rb_gc_debug_body("free", msg, 0, ptr)
|
50
|
+
#define RUBY_GC_INFO rb_gc_debug_indent(); printf
|
51
|
+
|
52
|
+
#else
|
53
|
+
#define RUBY_MARK_ENTER(msg)
|
54
|
+
#define RUBY_MARK_LEAVE(msg)
|
55
|
+
#define RUBY_FREE_ENTER(msg)
|
56
|
+
#define RUBY_FREE_LEAVE(msg)
|
57
|
+
#define RUBY_GC_INFO if(0)printf
|
58
|
+
#endif
|
59
|
+
|
60
|
+
#define RUBY_MARK_UNLESS_NULL(ptr) if(RTEST(ptr)){rb_gc_mark(ptr);}
|
61
|
+
#define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);}
|
62
|
+
|
63
|
+
#if STACK_GROW_DIRECTION > 0
|
64
|
+
# define STACK_UPPER(x, a, b) a
|
65
|
+
#elif STACK_GROW_DIRECTION < 0
|
66
|
+
# define STACK_UPPER(x, a, b) b
|
67
|
+
#else
|
68
|
+
RUBY_EXTERN int ruby_stack_grow_direction;
|
69
|
+
int ruby_get_stack_grow_direction(volatile VALUE *addr);
|
70
|
+
# define stack_growup_p(x) ( \
|
71
|
+
(ruby_stack_grow_direction ? \
|
72
|
+
ruby_stack_grow_direction : \
|
73
|
+
ruby_get_stack_grow_direction(x)) > 0)
|
74
|
+
# define STACK_UPPER(x, a, b) (stack_growup_p(x) ? a : b)
|
75
|
+
#endif
|
76
|
+
|
77
|
+
#endif /* RUBY_GC_H */
|
@@ -0,0 +1,173 @@
|
|
1
|
+
/* DO NOT EDIT THIS FILE DIRECTLY */
|
2
|
+
/**********************************************************************
|
3
|
+
|
4
|
+
id.h -
|
5
|
+
|
6
|
+
$Author$
|
7
|
+
created at: Sun Oct 19 21:12:51 2008
|
8
|
+
|
9
|
+
Copyright (C) 2007 Koichi Sasada
|
10
|
+
|
11
|
+
**********************************************************************/
|
12
|
+
|
13
|
+
#ifndef RUBY_ID_H
|
14
|
+
#define RUBY_ID_H
|
15
|
+
|
16
|
+
#define ID_SCOPE_SHIFT 3
|
17
|
+
#define ID_SCOPE_MASK 0x07
|
18
|
+
#define ID_LOCAL 0x00
|
19
|
+
#define ID_INSTANCE 0x01
|
20
|
+
#define ID_GLOBAL 0x03
|
21
|
+
#define ID_ATTRSET 0x04
|
22
|
+
#define ID_CONST 0x05
|
23
|
+
#define ID_CLASS 0x06
|
24
|
+
#define ID_JUNK 0x07
|
25
|
+
#define ID_INTERNAL ID_JUNK
|
26
|
+
|
27
|
+
#ifdef USE_PARSE_H
|
28
|
+
#include "parse.h"
|
29
|
+
#endif
|
30
|
+
|
31
|
+
#define symIFUNC ID2SYM(idIFUNC)
|
32
|
+
#define symCFUNC ID2SYM(idCFUNC)
|
33
|
+
|
34
|
+
#if !defined tLAST_TOKEN && defined YYTOKENTYPE
|
35
|
+
#define tLAST_TOKEN tLAST_TOKEN
|
36
|
+
#endif
|
37
|
+
|
38
|
+
enum ruby_method_ids {
|
39
|
+
#ifndef tLAST_TOKEN
|
40
|
+
tUPLUS = 321,
|
41
|
+
tUMINUS = 322,
|
42
|
+
tPOW = 323,
|
43
|
+
tCMP = 324,
|
44
|
+
tEQ = 325,
|
45
|
+
tEQQ = 326,
|
46
|
+
tNEQ = 327,
|
47
|
+
tGEQ = 328,
|
48
|
+
tLEQ = 329,
|
49
|
+
tANDOP = 330,
|
50
|
+
tOROP = 331,
|
51
|
+
tMATCH = 332,
|
52
|
+
tNMATCH = 333,
|
53
|
+
tDOT2 = 334,
|
54
|
+
tDOT3 = 335,
|
55
|
+
tAREF = 336,
|
56
|
+
tASET = 337,
|
57
|
+
tLSHFT = 338,
|
58
|
+
tRSHFT = 339,
|
59
|
+
tLAMBDA = 352,
|
60
|
+
idNULL = 365,
|
61
|
+
idRespond_to = 366,
|
62
|
+
idIFUNC = 367,
|
63
|
+
idCFUNC = 368,
|
64
|
+
id_core_set_method_alias = 369,
|
65
|
+
id_core_set_variable_alias = 370,
|
66
|
+
id_core_undef_method = 371,
|
67
|
+
id_core_define_method = 372,
|
68
|
+
id_core_define_singleton_method = 373,
|
69
|
+
id_core_set_postexe = 374,
|
70
|
+
tLAST_TOKEN = 375,
|
71
|
+
#endif
|
72
|
+
idDot2 = tDOT2,
|
73
|
+
idDot3 = tDOT3,
|
74
|
+
idUPlus = tUPLUS,
|
75
|
+
idUMinus = tUMINUS,
|
76
|
+
idPow = tPOW,
|
77
|
+
idCmp = tCMP,
|
78
|
+
idPLUS = '+',
|
79
|
+
idMINUS = '-',
|
80
|
+
idMULT = '*',
|
81
|
+
idDIV = '/',
|
82
|
+
idMOD = '%',
|
83
|
+
idLT = '<',
|
84
|
+
idLTLT = tLSHFT,
|
85
|
+
idLE = tLEQ,
|
86
|
+
idGT = '>',
|
87
|
+
idGE = tGEQ,
|
88
|
+
idEq = tEQ,
|
89
|
+
idEqq = tEQQ,
|
90
|
+
idNeq = tNEQ,
|
91
|
+
idNot = '!',
|
92
|
+
idBackquote = '`',
|
93
|
+
idEqTilde = tMATCH,
|
94
|
+
idNeqTilde = tNMATCH,
|
95
|
+
idAREF = tAREF,
|
96
|
+
idASET = tASET,
|
97
|
+
idLAST_TOKEN = tLAST_TOKEN >> ID_SCOPE_SHIFT,
|
98
|
+
tIntern,
|
99
|
+
tMethodMissing,
|
100
|
+
tLength,
|
101
|
+
tSize,
|
102
|
+
tGets,
|
103
|
+
tSucc,
|
104
|
+
tEach,
|
105
|
+
tLambda,
|
106
|
+
tSend,
|
107
|
+
t__send__,
|
108
|
+
tInitialize,
|
109
|
+
tUScore,
|
110
|
+
#if SUPPORT_JOKE
|
111
|
+
tBitblt,
|
112
|
+
tAnswer,
|
113
|
+
#endif
|
114
|
+
tLAST_ID,
|
115
|
+
#define TOKEN2ID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
116
|
+
#if SUPPORT_JOKE
|
117
|
+
TOKEN2ID(Bitblt),
|
118
|
+
TOKEN2ID(Answer),
|
119
|
+
#endif
|
120
|
+
TOKEN2ID(Intern),
|
121
|
+
TOKEN2ID(MethodMissing),
|
122
|
+
TOKEN2ID(Length),
|
123
|
+
TOKEN2ID(Size),
|
124
|
+
TOKEN2ID(Gets),
|
125
|
+
TOKEN2ID(Succ),
|
126
|
+
TOKEN2ID(Each),
|
127
|
+
TOKEN2ID(Lambda),
|
128
|
+
TOKEN2ID(Send),
|
129
|
+
TOKEN2ID(__send__),
|
130
|
+
TOKEN2ID(Initialize),
|
131
|
+
TOKEN2ID(UScore),
|
132
|
+
TOKEN2ID(LAST_ID)
|
133
|
+
};
|
134
|
+
|
135
|
+
#ifdef tLAST_TOKEN
|
136
|
+
struct ruby_method_ids_check {
|
137
|
+
#define ruby_method_id_check_for(name, value) \
|
138
|
+
int checking_for_##name[name == value ? 1 : -1]
|
139
|
+
ruby_method_id_check_for(tUPLUS, 321);
|
140
|
+
ruby_method_id_check_for(tUMINUS, 322);
|
141
|
+
ruby_method_id_check_for(tPOW, 323);
|
142
|
+
ruby_method_id_check_for(tCMP, 324);
|
143
|
+
ruby_method_id_check_for(tEQ, 325);
|
144
|
+
ruby_method_id_check_for(tEQQ, 326);
|
145
|
+
ruby_method_id_check_for(tNEQ, 327);
|
146
|
+
ruby_method_id_check_for(tGEQ, 328);
|
147
|
+
ruby_method_id_check_for(tLEQ, 329);
|
148
|
+
ruby_method_id_check_for(tANDOP, 330);
|
149
|
+
ruby_method_id_check_for(tOROP, 331);
|
150
|
+
ruby_method_id_check_for(tMATCH, 332);
|
151
|
+
ruby_method_id_check_for(tNMATCH, 333);
|
152
|
+
ruby_method_id_check_for(tDOT2, 334);
|
153
|
+
ruby_method_id_check_for(tDOT3, 335);
|
154
|
+
ruby_method_id_check_for(tAREF, 336);
|
155
|
+
ruby_method_id_check_for(tASET, 337);
|
156
|
+
ruby_method_id_check_for(tLSHFT, 338);
|
157
|
+
ruby_method_id_check_for(tRSHFT, 339);
|
158
|
+
ruby_method_id_check_for(tLAMBDA, 352);
|
159
|
+
ruby_method_id_check_for(idNULL, 365);
|
160
|
+
ruby_method_id_check_for(idRespond_to, 366);
|
161
|
+
ruby_method_id_check_for(idIFUNC, 367);
|
162
|
+
ruby_method_id_check_for(idCFUNC, 368);
|
163
|
+
ruby_method_id_check_for(id_core_set_method_alias, 369);
|
164
|
+
ruby_method_id_check_for(id_core_set_variable_alias, 370);
|
165
|
+
ruby_method_id_check_for(id_core_undef_method, 371);
|
166
|
+
ruby_method_id_check_for(id_core_define_method, 372);
|
167
|
+
ruby_method_id_check_for(id_core_define_singleton_method, 373);
|
168
|
+
ruby_method_id_check_for(id_core_set_postexe, 374);
|
169
|
+
ruby_method_id_check_for(tLAST_TOKEN, 375);
|
170
|
+
};
|
171
|
+
#endif
|
172
|
+
|
173
|
+
#endif /* RUBY_ID_H */
|
@@ -0,0 +1,104 @@
|
|
1
|
+
/**********************************************************************
|
2
|
+
|
3
|
+
iseq.h -
|
4
|
+
|
5
|
+
$Author$
|
6
|
+
created at: 04/01/01 23:36:57 JST
|
7
|
+
|
8
|
+
Copyright (C) 2004-2008 Koichi Sasada
|
9
|
+
|
10
|
+
**********************************************************************/
|
11
|
+
|
12
|
+
#ifndef RUBY_COMPILE_H
|
13
|
+
#define RUBY_COMPILE_H
|
14
|
+
|
15
|
+
/* compile.c */
|
16
|
+
VALUE rb_iseq_compile_node(VALUE self, NODE *node);
|
17
|
+
int rb_iseq_translate_threaded_code(rb_iseq_t *iseq);
|
18
|
+
VALUE rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args,
|
19
|
+
VALUE exception, VALUE body);
|
20
|
+
|
21
|
+
/* iseq.c */
|
22
|
+
VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
|
23
|
+
struct st_table *ruby_insn_make_insn_table(void);
|
24
|
+
|
25
|
+
#define ISEQ_TYPE_TOP INT2FIX(1)
|
26
|
+
#define ISEQ_TYPE_METHOD INT2FIX(2)
|
27
|
+
#define ISEQ_TYPE_BLOCK INT2FIX(3)
|
28
|
+
#define ISEQ_TYPE_CLASS INT2FIX(4)
|
29
|
+
#define ISEQ_TYPE_RESCUE INT2FIX(5)
|
30
|
+
#define ISEQ_TYPE_ENSURE INT2FIX(6)
|
31
|
+
#define ISEQ_TYPE_EVAL INT2FIX(7)
|
32
|
+
#define ISEQ_TYPE_MAIN INT2FIX(8)
|
33
|
+
#define ISEQ_TYPE_DEFINED_GUARD INT2FIX(9)
|
34
|
+
|
35
|
+
#define CATCH_TYPE_RESCUE ((int)INT2FIX(1))
|
36
|
+
#define CATCH_TYPE_ENSURE ((int)INT2FIX(2))
|
37
|
+
#define CATCH_TYPE_RETRY ((int)INT2FIX(3))
|
38
|
+
#define CATCH_TYPE_BREAK ((int)INT2FIX(4))
|
39
|
+
#define CATCH_TYPE_REDO ((int)INT2FIX(5))
|
40
|
+
#define CATCH_TYPE_NEXT ((int)INT2FIX(6))
|
41
|
+
|
42
|
+
struct iseq_insn_info_entry {
|
43
|
+
unsigned short position;
|
44
|
+
unsigned short line_no;
|
45
|
+
unsigned short sp;
|
46
|
+
};
|
47
|
+
|
48
|
+
struct iseq_catch_table_entry {
|
49
|
+
VALUE type;
|
50
|
+
VALUE iseq;
|
51
|
+
unsigned long start;
|
52
|
+
unsigned long end;
|
53
|
+
unsigned long cont;
|
54
|
+
unsigned long sp;
|
55
|
+
};
|
56
|
+
|
57
|
+
#define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)
|
58
|
+
|
59
|
+
struct iseq_compile_data_storage {
|
60
|
+
struct iseq_compile_data_storage *next;
|
61
|
+
unsigned long pos;
|
62
|
+
unsigned long size;
|
63
|
+
char *buff;
|
64
|
+
};
|
65
|
+
|
66
|
+
struct iseq_compile_data {
|
67
|
+
/* GC is needed */
|
68
|
+
VALUE err_info;
|
69
|
+
VALUE mark_ary;
|
70
|
+
VALUE catch_table_ary; /* Array */
|
71
|
+
|
72
|
+
/* GC is not needed */
|
73
|
+
struct iseq_label_data *start_label;
|
74
|
+
struct iseq_label_data *end_label;
|
75
|
+
struct iseq_label_data *redo_label;
|
76
|
+
VALUE current_block;
|
77
|
+
VALUE ensure_node;
|
78
|
+
VALUE for_iseq;
|
79
|
+
struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
|
80
|
+
int loopval_popped; /* used by NODE_BREAK */
|
81
|
+
int cached_const;
|
82
|
+
struct iseq_compile_data_storage *storage_head;
|
83
|
+
struct iseq_compile_data_storage *storage_current;
|
84
|
+
int last_line;
|
85
|
+
int last_coverable_line;
|
86
|
+
int flip_cnt;
|
87
|
+
int label_no;
|
88
|
+
int node_level;
|
89
|
+
const rb_compile_option_t *option;
|
90
|
+
};
|
91
|
+
|
92
|
+
/* defined? */
|
93
|
+
#define DEFINED_IVAR INT2FIX(1)
|
94
|
+
#define DEFINED_IVAR2 INT2FIX(2)
|
95
|
+
#define DEFINED_GVAR INT2FIX(3)
|
96
|
+
#define DEFINED_CVAR INT2FIX(4)
|
97
|
+
#define DEFINED_CONST INT2FIX(5)
|
98
|
+
#define DEFINED_METHOD INT2FIX(6)
|
99
|
+
#define DEFINED_YIELD INT2FIX(7)
|
100
|
+
#define DEFINED_REF INT2FIX(8)
|
101
|
+
#define DEFINED_ZSUPER INT2FIX(9)
|
102
|
+
#define DEFINED_FUNC INT2FIX(10)
|
103
|
+
|
104
|
+
#endif /* RUBY_COMPILE_H */
|
@@ -0,0 +1,103 @@
|
|
1
|
+
/**********************************************************************
|
2
|
+
|
3
|
+
method.h -
|
4
|
+
|
5
|
+
$Author$
|
6
|
+
created at: Wed Jul 15 20:02:33 2009
|
7
|
+
|
8
|
+
Copyright (C) 2009 Koichi Sasada
|
9
|
+
|
10
|
+
**********************************************************************/
|
11
|
+
#ifndef METHOD_H
|
12
|
+
#define METHOD_H
|
13
|
+
|
14
|
+
typedef enum {
|
15
|
+
NOEX_PUBLIC = 0x00,
|
16
|
+
NOEX_NOSUPER = 0x01,
|
17
|
+
NOEX_PRIVATE = 0x02,
|
18
|
+
NOEX_PROTECTED = 0x04,
|
19
|
+
NOEX_MASK = 0x06,
|
20
|
+
NOEX_BASIC = 0x08,
|
21
|
+
NOEX_UNDEF = NOEX_NOSUPER,
|
22
|
+
NOEX_MODFUNC = 0x12,
|
23
|
+
NOEX_SUPER = 0x20,
|
24
|
+
NOEX_VCALL = 0x40,
|
25
|
+
NOEX_RESPONDS = 0x80
|
26
|
+
} rb_method_flag_t;
|
27
|
+
|
28
|
+
#define NOEX_SAFE(n) ((int)((n) >> 8) & 0x0F)
|
29
|
+
#define NOEX_WITH(n, s) ((s << 8) | (n) | (ruby_running ? 0 : NOEX_BASIC))
|
30
|
+
#define NOEX_WITH_SAFE(n) NOEX_WITH(n, rb_safe_level())
|
31
|
+
|
32
|
+
/* method data type */
|
33
|
+
|
34
|
+
typedef enum {
|
35
|
+
VM_METHOD_TYPE_ISEQ,
|
36
|
+
VM_METHOD_TYPE_CFUNC,
|
37
|
+
VM_METHOD_TYPE_ATTRSET,
|
38
|
+
VM_METHOD_TYPE_IVAR,
|
39
|
+
VM_METHOD_TYPE_BMETHOD,
|
40
|
+
VM_METHOD_TYPE_ZSUPER,
|
41
|
+
VM_METHOD_TYPE_UNDEF,
|
42
|
+
VM_METHOD_TYPE_NOTIMPLEMENTED,
|
43
|
+
VM_METHOD_TYPE_OPTIMIZED, /* Kernel#send, Proc#call, etc */
|
44
|
+
VM_METHOD_TYPE_MISSING /* wrapper for method_missing(id) */
|
45
|
+
} rb_method_type_t;
|
46
|
+
|
47
|
+
typedef struct rb_method_cfunc_struct {
|
48
|
+
VALUE (*func)(ANYARGS);
|
49
|
+
int argc;
|
50
|
+
} rb_method_cfunc_t;
|
51
|
+
|
52
|
+
typedef struct rb_method_attr_struct {
|
53
|
+
ID id;
|
54
|
+
VALUE location;
|
55
|
+
} rb_method_attr_t;
|
56
|
+
|
57
|
+
typedef struct rb_iseq_struct rb_iseq_t;
|
58
|
+
|
59
|
+
typedef struct rb_method_definition_struct {
|
60
|
+
rb_method_type_t type; /* method type */
|
61
|
+
ID original_id;
|
62
|
+
union {
|
63
|
+
rb_iseq_t *iseq; /* should be mark */
|
64
|
+
rb_method_cfunc_t cfunc;
|
65
|
+
rb_method_attr_t attr;
|
66
|
+
VALUE proc; /* should be mark */
|
67
|
+
enum method_optimized_type {
|
68
|
+
OPTIMIZED_METHOD_TYPE_SEND,
|
69
|
+
OPTIMIZED_METHOD_TYPE_CALL
|
70
|
+
} optimize_type;
|
71
|
+
} body;
|
72
|
+
int alias_count;
|
73
|
+
} rb_method_definition_t;
|
74
|
+
|
75
|
+
typedef struct rb_method_entry_struct {
|
76
|
+
rb_method_flag_t flag;
|
77
|
+
char mark;
|
78
|
+
rb_method_definition_t *def;
|
79
|
+
ID called_id;
|
80
|
+
VALUE klass; /* should be mark */
|
81
|
+
} rb_method_entry_t;
|
82
|
+
|
83
|
+
struct unlinked_method_entry_list_entry {
|
84
|
+
struct unlinked_method_entry_list_entry *next;
|
85
|
+
rb_method_entry_t *me;
|
86
|
+
};
|
87
|
+
|
88
|
+
#define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
|
89
|
+
|
90
|
+
void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex);
|
91
|
+
rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex);
|
92
|
+
rb_method_entry_t *rb_method_entry(VALUE klass, ID id);
|
93
|
+
|
94
|
+
rb_method_entry_t *rb_method_entry_get_without_cache(VALUE klass, ID id);
|
95
|
+
rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_flag_t noex);
|
96
|
+
|
97
|
+
int rb_method_entry_arity(const rb_method_entry_t *me);
|
98
|
+
|
99
|
+
void rb_mark_method_entry(const rb_method_entry_t *me);
|
100
|
+
void rb_free_method_entry(rb_method_entry_t *me);
|
101
|
+
void rb_sweep_method_entry(void *vm);
|
102
|
+
|
103
|
+
#endif /* METHOD_H */
|