@@ -49,23 +49,54 @@ typedef struct rb_cref_struct {
49
49
/* method data type */
50
50
51
51
typedef struct rb_method_entry_struct {
52
- const VALUE flags ;
53
- const VALUE defined_class ;
52
+ VALUE flags ;
53
+ VALUE defined_class ;
54
54
struct rb_method_definition_struct * const def ;
55
- const ID called_id ;
56
- const VALUE owner ;
55
+ ID called_id ;
56
+ VALUE owner ;
57
57
} rb_method_entry_t ;
58
58
59
59
typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_entry_t */
60
- const VALUE flags ;
60
+ VALUE flags ;
61
61
const VALUE defined_class ;
62
62
struct rb_method_definition_struct * const def ;
63
- const ID called_id ;
63
+ ID called_id ;
64
64
const VALUE owner ;
65
65
} rb_callable_method_entry_t ;
66
66
67
67
#define METHOD_ENTRY_VISI (me ) (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))
68
68
#define METHOD_ENTRY_BASIC (me ) (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))
69
+ #define METHOD_ENTRY_COMPLEMENTED (me ) ((me)->flags & IMEMO_FL_USER3)
70
+ #define METHOD_ENTRY_COMPLEMENTED_SET (me ) ((me)->flags = (me)->flags | IMEMO_FL_USER3)
71
+
72
+ static inline void
73
+ METHOD_ENTRY_VISI_SET (rb_method_entry_t * me , rb_method_visibility_t visi )
74
+ {
75
+ VM_ASSERT ((int )visi >= 0 && visi <= 3 );
76
+ me -> flags = (me -> flags & ~(IMEMO_FL_USER0 | IMEMO_FL_USER1 )) | (visi << (IMEMO_FL_USHIFT + 0 ));
77
+ }
78
+ static inline void
79
+ METHOD_ENTRY_BASIC_SET (rb_method_entry_t * me , unsigned int basic )
80
+ {
81
+ VM_ASSERT (basic <= 1 );
82
+ me -> flags = (me -> flags & ~(IMEMO_FL_USER2 )) | (basic << (IMEMO_FL_USHIFT + 2 ));
83
+ }
84
+ static inline void
85
+ METHOD_ENTRY_FLAGS_SET (rb_method_entry_t * me , rb_method_visibility_t visi , unsigned int basic )
86
+ {
87
+ VM_ASSERT ((int )visi >= 0 && visi <= 3 );
88
+ VM_ASSERT (basic <= 1 );
89
+ me -> flags =
90
+ (me -> flags & ~(IMEMO_FL_USER0 |IMEMO_FL_USER1 |IMEMO_FL_USER2 )) |
91
+ ((visi << (IMEMO_FL_USHIFT + 0 )) | (basic << (IMEMO_FL_USHIFT + 2 )));
92
+ }
93
+ static inline void
94
+ METHOD_ENTRY_FLAGS_COPY (rb_method_entry_t * dst , const rb_method_entry_t * src )
95
+ {
96
+ dst -> flags =
97
+ (dst -> flags & ~(IMEMO_FL_USER0 |IMEMO_FL_USER1 |IMEMO_FL_USER2 )) |
98
+ (src -> flags & (IMEMO_FL_USER0 |IMEMO_FL_USER1 |IMEMO_FL_USER2 ));
99
+ }
69
100
70
101
typedef enum {
71
102
VM_METHOD_TYPE_ISEQ , /*!< Ruby method */
@@ -93,32 +124,32 @@ typedef struct rb_iseq_struct rb_iseq_t;
93
124
#endif
94
125
95
126
typedef struct rb_method_iseq_struct {
96
- const rb_iseq_t * const iseqptr ; /*!< iseq pointer, should be separated from iseqval */
97
- rb_cref_t * const cref ; /*!< class reference, should be marked */
98
- } rb_method_iseq_t ;
127
+ rb_iseq_t * iseqptr ; /*!< iseq pointer, should be separated from iseqval */
128
+ rb_cref_t * cref ; /*!< class reference, should be marked */
129
+ } rb_method_iseq_t ; /* check rb_add_method_iseq() when modify the fields */
99
130
100
131
typedef struct rb_method_cfunc_struct {
101
- VALUE (* const func )(ANYARGS );
102
- VALUE (* const invoker )(VALUE recv , int argc , const VALUE * argv , VALUE (* func )(ANYARGS ));
103
- const int argc ;
132
+ VALUE (* func )(ANYARGS );
133
+ VALUE (* invoker )(VALUE recv , int argc , const VALUE * argv , VALUE (* func )(ANYARGS ));
134
+ int argc ;
104
135
} rb_method_cfunc_t ;
105
136
106
137
typedef struct rb_method_attr_struct {
107
- const ID id ;
108
- const VALUE location ; /* should be marked */
138
+ ID id ;
139
+ VALUE location ; /* should be marked */
109
140
} rb_method_attr_t ;
110
141
111
142
typedef struct rb_method_alias_struct {
112
- const struct rb_method_entry_struct * const original_me ; /* original_me->klass is original owner */
143
+ struct rb_method_entry_struct * original_me ; /* original_me->klass is original owner */
113
144
} rb_method_alias_t ;
114
145
115
146
typedef struct rb_method_refined_struct {
116
- const struct rb_method_entry_struct * const orig_me ;
117
- const VALUE owner ;
147
+ struct rb_method_entry_struct * orig_me ;
148
+ VALUE owner ;
118
149
} rb_method_refined_t ;
119
150
120
151
typedef struct rb_method_bmethod_struct {
121
- const VALUE proc ; /* should be marked */
152
+ VALUE proc ; /* should be marked */
122
153
struct rb_hook_list_struct * hooks ;
123
154
} rb_method_bmethod_t ;
124
155
@@ -130,22 +161,22 @@ enum method_optimized_type {
130
161
};
131
162
132
163
struct rb_method_definition_struct {
133
- BITFIELD (rb_method_type_t , const type , VM_METHOD_TYPE_MINIMUM_BITS );
164
+ BITFIELD (rb_method_type_t , type , VM_METHOD_TYPE_MINIMUM_BITS );
134
165
int alias_count : 28 ;
135
166
int complemented_count : 28 ;
136
167
137
168
union {
138
- const rb_method_iseq_t iseq ;
139
- const rb_method_cfunc_t cfunc ;
140
- const rb_method_attr_t attr ;
141
- const rb_method_alias_t alias ;
142
- const rb_method_refined_t refined ;
169
+ rb_method_iseq_t iseq ;
170
+ rb_method_cfunc_t cfunc ;
171
+ rb_method_attr_t attr ;
172
+ rb_method_alias_t alias ;
173
+ rb_method_refined_t refined ;
143
174
rb_method_bmethod_t bmethod ;
144
175
145
- const enum method_optimized_type optimize_type ;
176
+ enum method_optimized_type optimize_type ;
146
177
} body ;
147
178
148
- const ID original_id ;
179
+ ID original_id ;
149
180
};
150
181
151
182
typedef struct rb_method_definition_struct rb_method_definition_t ;
@@ -161,9 +192,8 @@ void rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *c
161
192
void rb_add_refined_method_entry (VALUE refined_class , ID mid );
162
193
void rb_add_method (VALUE klass , ID mid , rb_method_type_t type , void * option , rb_method_visibility_t visi );
163
194
164
- const rb_method_entry_t * rb_method_entry_set (VALUE klass , ID mid , const rb_method_entry_t * , rb_method_visibility_t noex );
165
- const rb_method_entry_t * rb_method_entry_from_template (const rb_method_entry_t * template , const void * opts );
166
- const rb_method_entry_t * rb_method_entry_for_missing (ID mid , VALUE klass );
195
+ rb_method_entry_t * rb_method_entry_set (VALUE klass , ID mid , const rb_method_entry_t * , rb_method_visibility_t noex );
196
+ rb_method_entry_t * rb_method_entry_create (ID called_id , VALUE klass , rb_method_visibility_t visi , const rb_method_definition_t * def );
167
197
168
198
const rb_method_entry_t * rb_method_entry_at (VALUE obj , ID id );
169
199
@@ -193,6 +223,7 @@ void rb_sweep_method_entry(void *vm);
193
223
194
224
const rb_method_entry_t * rb_method_entry_clone (const rb_method_entry_t * me );
195
225
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 );
226
+ void rb_method_entry_copy (rb_method_entry_t * dst , const rb_method_entry_t * src );
196
227
197
228
void rb_scope_visibility_set (rb_method_visibility_t );
198
229
0 commit comments