~ubuntu-branches/ubuntu/precise/rakudo/precise

« back to all changes in this revision

Viewing changes to src/classes/Capture.pir

  • Committer: Bazaar Package Importer
  • Author(s): Ryan Niebur
  • Date: 2009-10-04 14:31:57 UTC
  • Revision ID: james.westby@ubuntu.com-20091004143157-ubq3wu0grk0f1e6a
Tags: upstream-0.1~2009.09
ImportĀ upstreamĀ versionĀ 0.1~2009.09

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
## $Id$
 
2
 
 
3
=head1 TITLE
 
4
 
 
5
Capture - Perl 6 Capture class
 
6
 
 
7
=head1 DESCRIPTION
 
8
 
 
9
This file sets up the Perl 6 C<Capture> class.
 
10
 
 
11
=cut
 
12
 
 
13
.namespace ['Perl6Capture']
 
14
 
 
15
.sub 'onload' :anon :init :load
 
16
    .local pmc p6meta, captureproto
 
17
    p6meta = get_hll_global ['Perl6Object'], '$!P6META'
 
18
    captureproto = p6meta.'new_class'('Perl6Capture', 'parent'=>'parrot;Capture Any', 'name'=>'Capture')
 
19
    captureproto.'!IMMUTABLE'()
 
20
.end
 
21
 
 
22
 
 
23
=head2 Methods
 
24
 
 
25
=over 4
 
26
 
 
27
=item get_string()   (vtable)
 
28
 
 
29
=cut
 
30
 
 
31
.sub '' :vtable('get_string') :method
 
32
    $S0 = self.'item'()
 
33
    .return ($S0)
 
34
.end
 
35
 
 
36
.sub '' :vtable('get_number') :method
 
37
    $N0 = self.'item'()
 
38
    .return ($N0)
 
39
.end
 
40
 
 
41
.sub 'item' :method
 
42
    $P0 = self[0]
 
43
    unless null $P0 goto end
 
44
    $P0 = 'undef'()
 
45
  end:
 
46
    .return ($P0)
 
47
.end
 
48
 
 
49
 
 
50
=back
 
51
 
 
52
=head2 Operators
 
53
 
 
54
=over 4
 
55
 
 
56
=item prefix:<\\>
 
57
 
 
58
Build a capture from its argument(s).
 
59
 
 
60
=cut
 
61
 
 
62
.namespace []
 
63
.sub "prefix:\\"
 
64
    .param pmc arg
 
65
    $I0 = isa arg, 'Perl6Scalar'
 
66
    if $I0 goto have_ref
 
67
    arg = root_new ['parrot';'Perl6Scalar'], arg
 
68
  have_ref:
 
69
    .return (arg)
 
70
.end
 
71
 
 
72
# Local Variables:
 
73
#   mode: pir
 
74
#   fill-column: 100
 
75
# End:
 
76
# vim: expandtab shiftwidth=4 ft=pir: