/
Match.pir
72 lines (53 loc) · 1.52 KB
/
Match.pir
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
## $Id$
=head1 TITLE
Match - Perl 6 match objects
=head1 Description
=cut
.namespace ['Match']
.sub '' :anon :load :init
.local pmc p6meta, matchproto
p6meta = get_hll_global ['Perl6Object'], '$!P6META'
matchproto = p6meta.'new_class'('Match', 'parent'=>'PGE::Grammar Any')
$P0 = p6meta.'get_parrotclass'(matchproto)
$P1 = new 'ResizablePMCArray'
push $P1, 'of'
$P0.'resolve_method'($P1)
$P0 = get_hll_global 'Positional'
$P0 = $P0.'!select'()
p6meta.'add_role'($P0, 'to'=>matchproto)
$P0 = get_hll_global 'Associative'
$P0 = $P0.'!select'()
p6meta.'add_role'($P0, 'to'=>matchproto)
.end
=item hash, list
Currently C<Object> interposes its own C<hash> and C<list> methods
on Match objects, these force Match.hash and Match.list to
properly delegate to the underlying Capture PMC.
=cut
.sub '' :method('item')
.return (self)
.end
.sub '' :method('hash')
$P0 = getattribute self, ['Capture'], 'proxy'
$P1 = $P0.'hash'()
.return ($P1)
.end
.sub '' :method('list')
$P0 = getattribute self, ['Capture'], 'proxy'
$P1 = $P0.'list'()
.return ($P1)
.end
=item of
Returns the type of value that this Match object may store. Note: we need this
to resolve role composition collision with Positional and Associative. At some
point we may not have of there, but for now it's the best place.
=cut
.sub 'of' :method
$P0 = get_hll_global 'Object'
.return ($P0)
.end
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: