Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 74 lines (61 sloc) 1.981 kb
741ed7b @pmichaud Switch ListIter to be an Iterator, ListIter :flat affects only Parcel fl...
pmichaud authored
1 my class Parcel {
29921e6 @pmichaud Update comments.
pmichaud authored
2 has $!storage; # RPA of Parcel's elements
4f8db8f @pmichaud Stub in Seq, add Parcel.list .
pmichaud authored
3
475b15f @pmichaud First stage of refactoring List/ListIter. Defines List generation in te...
pmichaud authored
4 method flat() {
1e514a8 @pmichaud Switch pir__perl6_(list|iter)_from_rpa from functions to opcodes.
pmichaud authored
5 pir::perl6_list_from_rpa__PPPP(List, pir::clone__PP($!storage), 1.Bool)
475b15f @pmichaud First stage of refactoring List/ListIter. Defines List generation in te...
pmichaud authored
6 }
7
4f8db8f @pmichaud Stub in Seq, add Parcel.list .
pmichaud authored
8 method list() {
1e514a8 @pmichaud Switch pir__perl6_(list|iter)_from_rpa from functions to opcodes.
pmichaud authored
9 pir::perl6_list_from_rpa__PPPP(List, pir::clone__PP($!storage), Mu)
475b15f @pmichaud First stage of refactoring List/ListIter. Defines List generation in te...
pmichaud authored
10 }
11
ba6af41 @pmichaud First cut at an implementation of 'gist' (from specs commit 669e0dd).
pmichaud authored
12 multi method gist(Parcel:D:) {
13 my @gist;
14 my Mu $rpa := pir::clone__PP($!storage);
15 @gist.push( pir::shift__PP($rpa).gist ) while $rpa;
16 @gist;
17 }
18
342f7a5 @pmichaud Improve .perl by making it a multimethod; Mu.perl now produces "Mu" ins...
pmichaud authored
19 multi method perl(Parcel:D:) {
475b15f @pmichaud First stage of refactoring List/ListIter. Defines List generation in te...
pmichaud authored
20 my Mu $rpa := pir::clone($!storage);
21 my $perl = '(';
e3fb8b7 @pmichaud Clean up .perl a bit for List/Array/Parcel.
pmichaud authored
22 if $rpa {
23 $perl = $perl ~ pir::shift__PP($rpa).perl;
24 if $rpa {
25 $perl = $perl ~ ', ' ~ pir::shift__PP($rpa).perl while $rpa;
26 }
27 else {
28 $perl = $perl ~ ',';
29 }
30 }
342f7a5 @pmichaud Improve .perl by making it a multimethod; Mu.perl now produces "Mu" ins...
pmichaud authored
31 $perl ~ ')';
ac26106 @pmichaud Initial implementation of Array, List, and Parcel.
pmichaud authored
32 }
33
a56af91 @pmichaud Add Nil handling.
pmichaud authored
34 multi method DUMP(Parcel:D:) {
8424798 @pmichaud Fix array assignment and transitive iteration. Add a &DUMP primitive fo...
pmichaud authored
35 self.DUMP-ID() ~ '(:storage(' ~ DUMP($!storage) ~ '))'
36 }
e9d014b @pmichaud Stub in Iterable and Parcel, initial infix:<,> implementation.
pmichaud authored
37 }
38
39
a56af91 @pmichaud Add Nil handling.
pmichaud authored
40 my class Nil is Parcel {
41 method new() { Nil }
42 method flat() { ().flat }
43 method list() { ().list }
44 method gist() { 'Nil' }
45 }
46
47
ac26106 @pmichaud Initial implementation of Array, List, and Parcel.
pmichaud authored
48 my sub infix:<,>(|$) {
66fe892 @pmichaud Create box/unbox functions for RPA <-> Parcel. Eventually we may
pmichaud authored
49 # pir::perl6_box_rpa__PP(pir::perl6_current_args_rpa__P())
e9d014b @pmichaud Stub in Iterable and Parcel, initial infix:<,> implementation.
pmichaud authored
50 pir::setattribute__0PPsP(
51 pir::repr_instance_of__PP(Parcel),
52 Parcel,
53 '$!storage',
54 pir::perl6_current_args_rpa__P());
55 }
56
57
66fe892 @pmichaud Create box/unbox functions for RPA <-> Parcel. Eventually we may
pmichaud authored
58 # I'm getting tired of building and unpacking Parcel RPAs by hand,
59 # so here are some pir::lookalikes to do it. Eventually we may just
60 # turn these into opcodes, since it's a common and sometimes
61 # speed-critical operation. (I'm leaving &infix:<,> alone above
62 # to avoid the extra subcall as it's very common.)
63 sub pir__perl6_box_rpa__PP(|$) {
64 pir::setattribute__0PPsP(
65 pir::repr_instance_of__PP(Parcel),
66 Parcel,
67 '$!storage',
68 pir::shift__PP(pir::perl6_current_args_rpa__P()))
69 }
70
71 sub pir__perl6_unbox_rpa__PP(\$parcel) {
72 pir::getattribute__PPPs($parcel, Parcel, '$!storage')
73 }
Something went wrong with that request. Please try again.