/
multisub.pmc
96 lines (69 loc) · 2.2 KB
/
multisub.pmc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
Copyright (C) 2001-2003, The Perl Foundation.
$Id$
=head1 NAME
src/pmc/multisub.pmc - A container for Perl6 multi subs
=head1 DESCRIPTION
This class inherits from ResizablePMCArray and provides an Array of
Sub PMCs with the same short name, but different long names.
=head2 Functions
=over 4
=cut
*/
#include "parrot/parrot.h"
pmclass MultiSub extends ResizablePMCArray need_ext does array {
void push_pmc(PMC *value) {
STRING * const _sub = CONST_STRING(interp, "Sub");
STRING * const _nci = CONST_STRING(interp, "NCI");
if (!VTABLE_isa(interp, value, _sub) &&
!VTABLE_isa(interp, value, _nci))
real_exception(interp, NULL, E_TypeError,
"attempt to push non Sub PMC");
SUPER(value);
}
void set_pmc_keyed_int(INTVAL key, PMC *value) {
STRING *_sub = CONST_STRING(interp, "Sub");
if (!VTABLE_isa(interp, value, _sub))
real_exception(interp, NULL, E_TypeError,
"attempt to set non Sub PMC");
SUPER(key, value);
}
void set_integer_keyed_int(INTVAL key, INTVAL value) {
real_exception(interp, NULL, E_TypeError,
"attempt to set non Sub PMC");
}
void set_string_keyed_int(INTVAL key, STRING *value) {
real_exception(interp, NULL, E_TypeError,
"attempt to set non Sub PMC");
}
void set_number_keyed_int(INTVAL key, FLOATVAL value) {
real_exception(interp, NULL, E_TypeError,
"attempt to set non Sub PMC");
}
opcode_t *invoke(void *next) {
PMC * const list = Parrot_mmd_sort_candidate_list(interp, SELF);
PMC *func;
if (PMC_IS_NULL(list)) {
real_exception(INTERP, NULL, 1,
"No applicable methods.\n");
}
func = VTABLE_get_pmc_keyed_int(interp, list, 0);
return VTABLE_invoke(INTERP, func, next);
}
}
/*
=back
=head1 SEE ALSO
F<src/mmd.c>,
F<$perl6/doc/trunk/design/apo/A12.pod>,
F<$perl6/doc/trunk/design/syn/S12.pod>
=head1 HISTORY
Initial version - leo 14.03.2005
=cut
*/
/*
* Local variables:
* c-file-style: "parrot"
* End:
* vim: expandtab shiftwidth=4:
*/