Skip to content

Commit b0cca57

Browse files
committed
Get multi-dispatcher able to work with the new NQPRoutine (but leave the original DispatcherSub PMC hanlding in for now too).
1 parent 7c8a11c commit b0cca57

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/guts/multi_dispatch.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ static candidate_info** sort_candidates(PARROT_INTERP, PMC *candidates) {
120120
num_candidates, candidate_graph_node*);
121121
INTVAL insert_pos = 0;
122122

123-
/* Ensure we know what is a 6model object and what is not. */
124-
if (!smo_id)
125-
smo_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "SixModelObject", 0));
126-
127123
for (i = 0; i < num_candidates; i++) {
128124
PMC *multi_sig_pmc, *types_list, *definedness_list;
129125
NQP_Signature *multi_sig;
@@ -250,11 +246,24 @@ static candidate_info** sort_candidates(PARROT_INTERP, PMC *candidates) {
250246
return result;
251247
}
252248

249+
/* Gets the list of possible candidates to dispatch too. */
250+
static PMC *get_dispatchees(PARROT_INTERP, PMC *dispatcher) {
251+
if (!smo_id)
252+
smo_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "SixModelObject", 0));
253+
if (dispatcher->vtable->base_type == smo_id) {
254+
NQP_Routine *r = (NQP_Routine *)PMC_data(dispatcher);
255+
return r->dispatchees;
256+
}
257+
else {
258+
return PARROT_DISPATCHERSUB(dispatcher)->dispatchees;
259+
}
260+
}
261+
253262
/* Performs a multiple dispatch using the candidates held in the passed
254-
* DispatcherSub and using the arguments in the passed capture. */
263+
* dispatcher and using the arguments in the passed capture. */
255264
PMC *nqp_multi_dispatch(PARROT_INTERP, PMC *dispatcher, PMC *capture) {
256265
/* Get list and number of dispatchees. */
257-
PMC *dispatchees = PARROT_DISPATCHERSUB(dispatcher)->dispatchees;
266+
PMC *dispatchees = get_dispatchees(interp, dispatcher);
258267
const INTVAL num_candidates = VTABLE_elements(interp, dispatchees);
259268

260269
/* Count arguments. */

0 commit comments

Comments
 (0)