2 Copyright (C) 2001-2007, The Perl Foundation.
7 src/pmc/multisub.pmc - A container for multi-dispatched subs
11 This class inherits from ResizablePMCArray and provides an Array of
12 Sub PMCs with the same short name, but different long names.
22 #include "parrot/parrot.h"
25 pmclass MultiSub extends ResizablePMCArray need_ext provides array {
27 void push_pmc(PMC *value) {
28 STRING * const _sub = CONST_STRING(interp, "Sub");
29 STRING * const _nci = CONST_STRING(interp, "NCI");
30 if (!VTABLE_isa(interp, value, _sub) &&
31 !VTABLE_isa(interp, value, _nci))
32 real_exception(interp, NULL, E_TypeError,
33 "attempt to push non Sub PMC");
37 VTABLE void set_pmc_keyed_int(INTVAL key, PMC *value) {
38 STRING *_sub = CONST_STRING(interp, "Sub");
39 if (!VTABLE_isa(interp, value, _sub))
40 real_exception(interp, NULL, E_TypeError,
41 "attempt to set non Sub PMC");
45 VTABLE void set_integer_keyed_int(INTVAL key, INTVAL value) {
46 real_exception(interp, NULL, E_TypeError,
47 "attempt to set non Sub PMC");
50 VTABLE void set_string_keyed_int(INTVAL key, STRING *value) {
51 real_exception(interp, NULL, E_TypeError,
52 "attempt to set non Sub PMC");
55 VTABLE void set_number_keyed_int(INTVAL key, FLOATVAL value) {
56 real_exception(interp, NULL, E_TypeError,
57 "attempt to set non Sub PMC");
60 VTABLE opcode_t *invoke(void *next) {
61 PMC * const list = Parrot_mmd_sort_candidate_list(interp, SELF);
64 if (PMC_IS_NULL(list))
65 real_exception(INTERP, NULL, 1, "No applicable methods.\n");
67 func = VTABLE_get_pmc_keyed_int(interp, list, 0);
68 return VTABLE_invoke(INTERP, func, next);
79 F<$perl6/doc/trunk/design/apo/A12.pod>,
80 F<$perl6/doc/trunk/design/syn/S12.pod>
84 Initial version - leo 14.03.2005
92 * c-file-style: "parrot"
94 * vim: expandtab shiftwidth=4: