@@ -120,20 +120,28 @@ pmclass RakudoObject manual_attrs dynpmc group nqp {
120
120
}
121
121
122
122
VTABLE PMC * get_pmc_keyed(PMC *key) {
123
- PMC **vt = STABLE(SELF)->parrot_vtable_mapping;
124
- PMC *meth;
125
- if (vt && !PMC_IS_NULL(meth = vt[PARROT_VTABLE_SLOT_GET_PMC_KEYED])) {
126
- PMC *old_ctx = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
127
- PMC *cappy = Parrot_pmc_new(interp, enum_class_CallContext);
128
- VTABLE_push_pmc(interp, cappy, SELF);
129
- VTABLE_push_pmc(interp, cappy, key);
130
- Parrot_pcc_invoke_from_sig_object(interp, meth, cappy);
131
- cappy = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
132
- Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
133
- return VTABLE_get_pmc_keyed_int(interp, cappy, 0);
123
+ if (key->vtable->base_type == enum_class_Key) {
124
+ if (PObj_get_FLAGS(key) & KEY_integer_FLAG)
125
+ return SELF.get_pmc_keyed_int(VTABLE_get_integer(interp, key));
126
+ else
127
+ return SELF.get_pmc_keyed_str(VTABLE_get_string(interp, key));
128
+ }
129
+ else {
130
+ PMC **vt = STABLE(SELF)->parrot_vtable_mapping;
131
+ PMC *meth;
132
+ if (vt && !PMC_IS_NULL(meth = vt[PARROT_VTABLE_SLOT_GET_PMC_KEYED])) {
133
+ PMC *old_ctx = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
134
+ PMC *cappy = Parrot_pmc_new(interp, enum_class_CallContext);
135
+ VTABLE_push_pmc(interp, cappy, SELF);
136
+ VTABLE_push_pmc(interp, cappy, key);
137
+ Parrot_pcc_invoke_from_sig_object(interp, meth, cappy);
138
+ cappy = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
139
+ Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
140
+ return VTABLE_get_pmc_keyed_int(interp, cappy, 0);
141
+ }
142
+ else
143
+ return SUPER(key);
134
144
}
135
- else
136
- return SUPER(key);
137
145
}
138
146
139
147
VTABLE PMC * get_pmc_keyed_int(INTVAL key) {
@@ -171,19 +179,27 @@ pmclass RakudoObject manual_attrs dynpmc group nqp {
171
179
}
172
180
173
181
VTABLE void set_pmc_keyed(PMC *key, PMC *value) {
174
- PMC **vt = STABLE(SELF)->parrot_vtable_mapping;
175
- PMC *meth;
176
- if (vt && !PMC_IS_NULL(meth = vt[PARROT_VTABLE_SLOT_SET_PMC_KEYED])) {
177
- PMC *old_ctx = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
178
- PMC *cappy = Parrot_pmc_new(interp, enum_class_CallContext);
179
- VTABLE_push_pmc(interp, cappy, SELF);
180
- VTABLE_push_pmc(interp, cappy, key);
181
- VTABLE_push_pmc(interp, cappy, value);
182
- Parrot_pcc_invoke_from_sig_object(interp, meth, cappy);
183
- Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
182
+ if (key->vtable->base_type == enum_class_Key) {
183
+ if (PObj_get_FLAGS(key) & KEY_integer_FLAG)
184
+ SELF.set_pmc_keyed_int(VTABLE_get_integer(interp, key), value);
185
+ else
186
+ SELF.set_pmc_keyed_str(VTABLE_get_string(interp, key), value);
187
+ }
188
+ else {
189
+ PMC **vt = STABLE(SELF)->parrot_vtable_mapping;
190
+ PMC *meth;
191
+ if (vt && !PMC_IS_NULL(meth = vt[PARROT_VTABLE_SLOT_SET_PMC_KEYED])) {
192
+ PMC *old_ctx = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
193
+ PMC *cappy = Parrot_pmc_new(interp, enum_class_CallContext);
194
+ VTABLE_push_pmc(interp, cappy, SELF);
195
+ VTABLE_push_pmc(interp, cappy, key);
196
+ VTABLE_push_pmc(interp, cappy, value);
197
+ Parrot_pcc_invoke_from_sig_object(interp, meth, cappy);
198
+ Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
199
+ }
200
+ else
201
+ SUPER(key, value);
184
202
}
185
- else
186
- SUPER(key, value);
187
203
}
188
204
189
205
VTABLE void set_pmc_keyed_int(INTVAL key, PMC *value) {
0 commit comments