Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 149 lines (120 sloc) 4.814 kb
934b700 @nobu * method.h: properties.
nobu authored
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
2f522b9 @charliesome * class.c, compile.c, eval.c, gc.h, insns.def, internal.h, method.h,
charliesome authored
14 #include "internal.h"
15
cd9d004 @nobu * method.h (END_OF_ENUMERATION): placeholder to put last comma.
nobu authored
16 #ifndef END_OF_ENUMERATION
ec6f077 @shyouhei * vm_core.h (enum): avoid syntax error.
shyouhei authored
17 # if defined(__GNUC__) &&! defined(__STRICT_ANSI__)
cd9d004 @nobu * method.h (END_OF_ENUMERATION): placeholder to put last comma.
nobu authored
18 # define END_OF_ENUMERATION(key)
19 # else
20 # define END_OF_ENUMERATION(key) END_OF_##key##_PLACEHOLDER = 0
21 # endif
22 #endif
23
934b700 @nobu * method.h: properties.
nobu authored
24 typedef enum {
25 NOEX_PUBLIC = 0x00,
26 NOEX_NOSUPER = 0x01,
27 NOEX_PRIVATE = 0x02,
28 NOEX_PROTECTED = 0x04,
29 NOEX_MASK = 0x06,
30 NOEX_BASIC = 0x08,
31 NOEX_UNDEF = NOEX_NOSUPER,
32 NOEX_MODFUNC = 0x12,
33 NOEX_SUPER = 0x20,
e3fc29a * vm_method.c (basic_obj_respond_to): should not call
matz authored
34 NOEX_VCALL = 0x40,
3c4f8ce @nobu method.h: NOEX_SAFE_SHIFT_OFFSET
nobu authored
35 NOEX_RESPONDS = 0x80,
36
37 NOEX_BIT_WIDTH = 8,
38 NOEX_SAFE_SHIFT_OFFSET = ((NOEX_BIT_WIDTH+3)/4)*4 /* round up to nibble */
934b700 @nobu * method.h: properties.
nobu authored
39 } rb_method_flag_t;
40
3c4f8ce @nobu method.h: NOEX_SAFE_SHIFT_OFFSET
nobu authored
41 #define NOEX_SAFE(n) ((int)((n) >> NOEX_SAFE_SHIFT_OFFSET) & 0x0F)
42 #define NOEX_WITH(n, s) (((s) << NOEX_SAFE_SHIFT_OFFSET) | (n) | (ruby_running ? 0 : NOEX_BASIC))
63d5d7f @akr * method.h: parenthesize macro arguments.
akr authored
43 #define NOEX_WITH_SAFE(n) NOEX_WITH((n), rb_safe_level())
934b700 @nobu * method.h: properties.
nobu authored
44
45 /* method data type */
46
47 typedef enum {
48 VM_METHOD_TYPE_ISEQ,
49 VM_METHOD_TYPE_CFUNC,
50 VM_METHOD_TYPE_ATTRSET,
51 VM_METHOD_TYPE_IVAR,
52 VM_METHOD_TYPE_BMETHOD,
53 VM_METHOD_TYPE_ZSUPER,
54 VM_METHOD_TYPE_UNDEF,
55 VM_METHOD_TYPE_NOTIMPLEMENTED,
102918a git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25129 b2dd03c8-39d4-4d...
matz authored
56 VM_METHOD_TYPE_OPTIMIZED, /* Kernel#send, Proc#call, etc */
90a6dce @ko1 * method.h: introduce new method type VM_METHOD_TYPE_CFUNC_FAST.
ko1 authored
57 VM_METHOD_TYPE_MISSING, /* wrapper for method_missing(id) */
cd9d004 @nobu * method.h (END_OF_ENUMERATION): placeholder to put last comma.
nobu authored
58 VM_METHOD_TYPE_REFINED,
59
60 END_OF_ENUMERATION(VM_METHOD_TYPE)
934b700 @nobu * method.h: properties.
nobu authored
61 } rb_method_type_t;
62
f4dbc7a @ko1 * method.h (rb_method_cfunc_t::invoker): add new field (func ptr)
ko1 authored
63 struct rb_call_info_struct;
64
934b700 @nobu * method.h: properties.
nobu authored
65 typedef struct rb_method_cfunc_struct {
66 VALUE (*func)(ANYARGS);
0c1682b @ko1 * vm_insnhelper.c (vm_call_cfunc_with_frame): don't use ci after
ko1 authored
67 VALUE (*invoker)(VALUE (*func)(ANYARGS), VALUE recv, int argc, const VALUE *argv);
934b700 @nobu * method.h: properties.
nobu authored
68 int argc;
69 } rb_method_cfunc_t;
70
c46f713 @wanabe * proc.c (rb_method_location): return attr's location if it is setup.
wanabe authored
71 typedef struct rb_method_attr_struct {
72 ID id;
87a120f @ko1 * class.c, include/ruby/ruby.h: add write barriers for T_CLASS,
ko1 authored
73 const VALUE location;
c46f713 @wanabe * proc.c (rb_method_location): return attr's location if it is setup.
wanabe authored
74 } rb_method_attr_t;
75
934b700 @nobu * method.h: properties.
nobu authored
76 typedef struct rb_iseq_struct rb_iseq_t;
77
fcf88c1 @nobu * method.h (rb_method_definition_t): split from rb_method_entry_t
nobu authored
78 typedef struct rb_method_definition_struct {
934b700 @nobu * method.h: properties.
nobu authored
79 rb_method_type_t type; /* method type */
25daaaf @charliesome * method.h: rearrange rb_method_definition_struct to save 8 bytes in
charliesome authored
80 int alias_count;
934b700 @nobu * method.h: properties.
nobu authored
81 ID original_id;
d84f9b1 @ko1 * fix namespace issue on singleton class expressions. [Bug #10943]
ko1 authored
82
934b700 @nobu * method.h: properties.
nobu authored
83 union {
d84f9b1 @ko1 * fix namespace issue on singleton class expressions. [Bug #10943]
ko1 authored
84 struct {
85 rb_iseq_t *const iseq; /* should be mark */
8dced4d @ko1 * internal.h: define rb_cref_t and change to use it.
ko1 authored
86 rb_cref_t *cref;
d84f9b1 @ko1 * fix namespace issue on singleton class expressions. [Bug #10943]
ko1 authored
87 } iseq_body;
934b700 @nobu * method.h: properties.
nobu authored
88 rb_method_cfunc_t cfunc;
c46f713 @wanabe * proc.c (rb_method_location): return attr's location if it is setup.
wanabe authored
89 rb_method_attr_t attr;
87a120f @ko1 * class.c, include/ruby/ruby.h: add write barriers for T_CLASS,
ko1 authored
90 const VALUE proc; /* should be mark */
934b700 @nobu * method.h: properties.
nobu authored
91 enum method_optimized_type {
92 OPTIMIZED_METHOD_TYPE_SEND,
3c4f8ce @nobu method.h: NOEX_SAFE_SHIFT_OFFSET
nobu authored
93 OPTIMIZED_METHOD_TYPE_CALL,
94
95 OPTIMIZED_METHOD_TYPE__MAX
934b700 @nobu * method.h: properties.
nobu authored
96 } optimize_type;
60d6038 @shugo * revised r37993 to avoid SEGV/ILL in tests. In r37993, a method
shugo authored
97 struct rb_method_entry_struct *orig_me;
934b700 @nobu * method.h: properties.
nobu authored
98 } body;
fcf88c1 @nobu * method.h (rb_method_definition_t): split from rb_method_entry_t
nobu authored
99 } rb_method_definition_t;
100
101 typedef struct rb_method_entry_struct {
102 rb_method_flag_t flag;
833cade @ko1 * vm_method.c (rb_unlink_method_entry, rb_sweep_method_entry):
ko1 authored
103 char mark;
fcf88c1 @nobu * method.h (rb_method_definition_t): split from rb_method_entry_t
nobu authored
104 rb_method_definition_t *def;
105 ID called_id;
106 VALUE klass; /* should be mark */
934b700 @nobu * method.h: properties.
nobu authored
107 } rb_method_entry_t;
108
833cade @ko1 * vm_method.c (rb_unlink_method_entry, rb_sweep_method_entry):
ko1 authored
109 struct unlinked_method_entry_list_entry {
110 struct unlinked_method_entry_list_entry *next;
111 rb_method_entry_t *me;
112 };
113
fcf88c1 @nobu * method.h (rb_method_definition_t): split from rb_method_entry_t
nobu authored
114 #define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
a11e254 @nobu method.h: UNDEFINED_REFINED_METHOD_P
nobu authored
115 #define UNDEFINED_REFINED_METHOD_P(def) \
116 ((def)->type == VM_METHOD_TYPE_REFINED && \
117 UNDEFINED_METHOD_ENTRY_P((def)->body.orig_me))
fcf88c1 @nobu * method.h (rb_method_definition_t): split from rb_method_entry_t
nobu authored
118
934b700 @nobu * method.h: properties.
nobu authored
119 void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex);
8dced4d @ko1 * internal.h: define rb_cref_t and change to use it.
ko1 authored
120 void rb_add_method_iseq(VALUE klass, ID mid, rb_iseq_t *iseq, rb_cref_t *cref, rb_method_flag_t noex);
934b700 @nobu * method.h: properties.
nobu authored
121 rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex);
319088e @shugo * class.c, insns.def, method.h, proc.c, vm.c, vm_core.h, vm_eval.c,
shugo authored
122 rb_method_entry_t *rb_method_entry(VALUE klass, ID id, VALUE *define_class_ptr);
3048508 @nobu vm_method.c: rb_method_entry_at
nobu authored
123 rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
60d6038 @shugo * revised r37993 to avoid SEGV/ILL in tests. In r37993, a method
shugo authored
124 void rb_add_refined_method_entry(VALUE refined_class, ID mid);
125 rb_method_entry_t *rb_resolve_refined_method(VALUE refinements,
9d9dfc2 @nobu vm_method.c: constify
nobu authored
126 const rb_method_entry_t *me,
60d6038 @shugo * revised r37993 to avoid SEGV/ILL in tests. In r37993, a method
shugo authored
127 VALUE *defined_class_ptr);
128 rb_method_entry_t *rb_method_entry_with_refinements(VALUE klass, ID id,
129 VALUE *defined_class_ptr);
29756c5 @shugo * vm_insnhelper.c (vm_call_opt_send): Kernel#send should not use
shugo authored
130 rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id,
131 VALUE *defined_class_ptr);
60d6038 @shugo * revised r37993 to avoid SEGV/ILL in tests. In r37993, a method
shugo authored
132
f088828 @charliesome * class.c (class_alloc): remove mc_tbl
charliesome authored
133 rb_method_entry_t *rb_method_entry_get_without_cache(VALUE klass, ID id, VALUE *define_class_ptr);
b4d7d61 @ko1 * method.h, vm_method.c: rename some internal functions related to
ko1 authored
134 rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_flag_t noex);
135
934b700 @nobu * method.h: properties.
nobu authored
136 int rb_method_entry_arity(const rb_method_entry_t *me);
7da3ea8 @akr * method.h, internal.h iseq.h: declare internal functions.
akr authored
137 int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2);
f12c14d @marcandre * proc.c (method_hash, proc_hash): Fix {Unbound}Method#hash
marcandre authored
138 st_index_t rb_hash_method_entry(st_index_t hash, const rb_method_entry_t *me);
b4d7d61 @ko1 * method.h, vm_method.c: rename some internal functions related to
ko1 authored
139
6eb76ba @nobu vm_method.c: show respond_to location
nobu authored
140 VALUE rb_method_entry_location(rb_method_entry_t *me);
141 VALUE rb_mod_method_location(VALUE mod, ID id);
142 VALUE rb_obj_method_location(VALUE obj, ID id);
143
62d7a30 @nobu * gc.c (rb_mark_method_entry): renamed.
nobu authored
144 void rb_mark_method_entry(const rb_method_entry_t *me);
fcf88c1 @nobu * method.h (rb_method_definition_t): split from rb_method_entry_t
nobu authored
145 void rb_free_method_entry(rb_method_entry_t *me);
833cade @ko1 * vm_method.c (rb_unlink_method_entry, rb_sweep_method_entry):
ko1 authored
146 void rb_sweep_method_entry(void *vm);
934b700 @nobu * method.h: properties.
nobu authored
147
148 #endif /* METHOD_H */
Something went wrong with that request. Please try again.