Skip to content
Newer
Older
100644 130 lines (109 sloc) 4.01 KB
dbdb675 @jnthn Add empty Associative and Positional roles; make List/Parcel/EnumMap …
jnthn authored Jun 26, 2011
1 my class Parcel does Positional {
8812718 @pmichaud Create an opcode for building Parcels; the opcode also handles replacing
pmichaud authored Jun 26, 2011
2 # declared in BOOTSTRAP.pm:
3 # is Cool; # parent class
4 # has $!storage; # RPA of Parcel's elements
4f8db8f @pmichaud Stub in Seq, add Parcel.list .
pmichaud authored Jun 9, 2011
5
7d55a9f @pmichaud ?() should return False (jnthn++).
pmichaud authored Aug 7, 2011
6 multi method Bool(Parcel:D:) { nqp::p6bool($!storage) }
120d3be @pmichaud Make sure .Numeric is properly multied.
pmichaud authored Aug 3, 2011
7 multi method Numeric(Parcel:D:) { self.flat.elems }
8 multi method Str(Parcel:D:) { self.flat.Str }
0447cac @moritz implement capitalize
moritz authored Aug 14, 2011
9 # multi method Int(Parcel:D:) { self.flat.elems }
c47b816 @moritz simplistic List.ACCEPTS, fix Array.push to return self
moritz authored Jul 13, 2011
10 multi method ACCEPTS(Parcel:D: $topic) { self.list.ACCEPTS($topic) }
120d3be @pmichaud Make sure .Numeric is properly multied.
pmichaud authored Aug 3, 2011
11
08e1061 @moritz .perl methods for Match and EnumMap
moritz authored Sep 28, 2011
12 method Parcel() { self }
855106b @jnthn Fix Parcel.Capture.
jnthn authored Aug 5, 2011
13 method Capture() {
14 my $cap := nqp::create(Capture);
d032415 @jnthn Improve Parcel.Capture.
jnthn authored Jan 16, 2012
15 my Mu $list := nqp::list();
16 my Mu $hash := nqp::hash();
17 my int $c = nqp::elems($!storage);
18 my int $i = 0;
19 while $i < $c {
20 my $v := nqp::atpos($!storage, $i);
21 nqp::istype($v, Pair) ??
22 nqp::bindkey($hash, nqp::unbox_s($v.key), $v.value) !!
23 nqp::push($list, $v);
24 $i = $i + 1;
25 }
26 nqp::bindattr($cap, Capture, '$!list', $list);
27 nqp::bindattr($cap, Capture, '$!hash', $hash);
855106b @jnthn Fix Parcel.Capture.
jnthn authored Aug 5, 2011
28 $cap
29 }
f5c25da @pmichaud More array-related methods and fixes. This _almost_ gets us
pmichaud authored Jun 28, 2011
30
475b15f @pmichaud First stage of refactoring List/ListIter. Defines List generation in …
pmichaud authored Jun 17, 2011
31 method flat() {
7019642 @pmichaud Convert instances of 1.Bool into Bool::True.
pmichaud authored Jul 5, 2011
32 nqp::p6list(nqp::clone($!storage), List, Bool::True)
475b15f @pmichaud First stage of refactoring List/ListIter. Defines List generation in …
pmichaud authored Jun 17, 2011
33 }
34
16c2f0d @pmichaud Clean up for -> map translation, add Parcel.item.
pmichaud authored Jun 26, 2011
35 method item() { my $v = self; }
36
4f8db8f @pmichaud Stub in Seq, add Parcel.list .
pmichaud authored Jun 9, 2011
37 method list() {
ab1dda5 @pmichaud Convert some more pir:: opcodes to nqp:: .
pmichaud authored Jun 26, 2011
38 nqp::p6list(nqp::clone($!storage), List, Mu)
475b15f @pmichaud First stage of refactoring List/ListIter. Defines List generation in …
pmichaud authored Jun 17, 2011
39 }
40
457b5e7 @pmichaud First cut at zip and cross operators and metaoperators.
pmichaud authored Jul 1, 2011
41 method lol() {
42 nqp::p6list(nqp::clone($!storage), LoL, Mu)
43 }
44
f621500 @pmichaud Refactor handling of dispatch:<hyper> (>>.foo) to preserve structure.
pmichaud authored Aug 9, 2011
45 method at_pos(Parcel:D: \$x) is rw { self.flat.at_pos($x); }
ead83d4 @pmichaud Let Parcels participate in postcircumfix:<[ ]>.
pmichaud authored Jun 24, 2011
46
cfe49f0 @jnthn Fix incorrect proto signature introduced yesterday.
jnthn authored Jan 7, 2012
47 proto method postcircumfix:<[ ]>(|$) { * }
975b6bb @jnthn Fix zen slice on a Parcel.
jnthn authored Jan 6, 2012
48 multi method postcircumfix:<[ ]>() { self.flat }
49 multi method postcircumfix:<[ ]>(Parcel:D: \$x) { self.flat.[$x] }
ead83d4 @pmichaud Let Parcels participate in postcircumfix:<[ ]>.
pmichaud authored Jun 24, 2011
50
ba6af41 @pmichaud First cut at an implementation of 'gist' (from specs commit 669e0dd).
pmichaud authored Jun 18, 2011
51 multi method gist(Parcel:D:) {
0cde9b8 @pmichaud Update gist/.gist/say with latest specifics from TimToady++.
pmichaud authored Jun 25, 2011
52 my Mu $gist := nqp::list();
53 my Mu $iter := nqp::iterator($!storage);
54 nqp::push($gist, nqp::unbox_s(nqp::shift($iter).gist)) while $iter;
55 nqp::p6box_s(nqp::join(' ', $gist))
ba6af41 @pmichaud First cut at an implementation of 'gist' (from specs commit 669e0dd).
pmichaud authored Jun 18, 2011
56 }
57
342f7a5 @pmichaud Improve .perl by making it a multimethod; Mu.perl now produces "Mu" i…
pmichaud authored Jun 17, 2011
58 multi method perl(Parcel:D:) {
ab1dda5 @pmichaud Convert some more pir:: opcodes to nqp:: .
pmichaud authored Jun 27, 2011
59 my Mu $rpa := nqp::clone($!storage);
475b15f @pmichaud First stage of refactoring List/ListIter. Defines List generation in …
pmichaud authored Jun 17, 2011
60 my $perl = '(';
e3fb8b7 @pmichaud Clean up .perl a bit for List/Array/Parcel.
pmichaud authored Jun 18, 2011
61 if $rpa {
b54894d Substitute several more pir ops by their nqp op counterparts.
kristof authored Jun 22, 2011
62 $perl = $perl ~ nqp::shift($rpa).perl;
e3fb8b7 @pmichaud Clean up .perl a bit for List/Array/Parcel.
pmichaud authored Jun 18, 2011
63 if $rpa {
b54894d Substitute several more pir ops by their nqp op counterparts.
kristof authored Jun 22, 2011
64 $perl = $perl ~ ', ' ~ nqp::shift($rpa).perl while $rpa;
e3fb8b7 @pmichaud Clean up .perl a bit for List/Array/Parcel.
pmichaud authored Jun 18, 2011
65 }
66 else {
67 $perl = $perl ~ ',';
68 }
69 }
342f7a5 @pmichaud Improve .perl by making it a multimethod; Mu.perl now produces "Mu" i…
pmichaud authored Jun 17, 2011
70 $perl ~ ')';
ac26106 @pmichaud Initial implementation of Array, List, and Parcel.
pmichaud authored Jun 10, 2011
71 }
72
4923896 @pmichaud Re-enable list (Parcel) assignment, although my() declarations still …
pmichaud authored Jun 25, 2011
73 method STORE(|$) {
74 # get the list of rvalues to store and lhs containers
75 my Mu $args := pir::perl6_current_args_rpa__P();
76 nqp::shift($args);
7019642 @pmichaud Convert instances of 1.Bool into Bool::True.
pmichaud authored Jul 5, 2011
77 my $rhs := nqp::p6list($args, List, Bool::True); # XXX this might need to be Seq
4923896 @pmichaud Re-enable list (Parcel) assignment, although my() declarations still …
pmichaud authored Jun 25, 2011
78
79 # first pass -- scan lhs containers and pick out
80 # scalar versus list assignment. This also reifies
81 # the rhs values
82 my Mu $lhs := nqp::clone($!storage);
83 my Mu $tv := nqp::list();
84 while ($lhs) {
85 my Mu $x := $lhs.shift;
86 if nqp::iscont($x) {
87 # container: scalar assignment
88 nqp::push($tv, $x);
18dea93 @jnthn Add an nqp::p6decont and eliminate pir::perl6_decontainerize in the s…
jnthn authored Oct 23, 2011
89 nqp::push($tv, $rhs.gimme(1) ?? nqp::p6decont($rhs.shift) !! Nil);
4923896 @pmichaud Re-enable list (Parcel) assignment, although my() declarations still …
pmichaud authored Jun 25, 2011
90 }
91 elsif nqp::istype($x, Whatever) {
92 # Whatever: skip assigning value
93 $rhs.shift;
94 }
95 elsif nqp::istype($x, Parcel) {
96 # Parcel: splice into current lhs
97 nqp::splice($lhs, nqp::getattr($x, Parcel, '$!storage'), 0, 0)
98 }
99 else {
100 # store entire rhs
101 nqp::push($tv, $x);
102 nqp::push($tv, $rhs);
103 $rhs := ().list;
104 }
105 }
106
107 # second pass, perform the assignments
108 while ($tv) { my $x := nqp::shift($tv); $x = nqp::shift($tv); }
109 self
110 }
111
a56af91 @pmichaud Add Nil handling.
pmichaud authored Jun 18, 2011
112 multi method DUMP(Parcel:D:) {
8424798 @pmichaud Fix array assignment and transitive iteration. Add a &DUMP primitive …
pmichaud authored Jun 17, 2011
113 self.DUMP-ID() ~ '(:storage(' ~ DUMP($!storage) ~ '))'
114 }
bf8a6af @jnthn Allow | to work on a Parcel.
jnthn authored Jul 8, 2011
115
029c30f @jnthn Refactor of flattening and better handling of duplicate named paramet…
jnthn authored Sep 18, 2011
116 method FLATTENABLE_LIST() { $!storage }
117 method FLATTENABLE_HASH() { nqp::hash() }
ecce797 @moritz Parcel.fmt
moritz authored Sep 13, 2011
118
119 method fmt($format = '%s', $separator = ' ') {
120 self.list.fmt($format, $separator);
121 }
e9d014b @pmichaud Stub in Iterable and Parcel, initial infix:<,> implementation.
pmichaud authored Jun 9, 2011
122 }
123
124
ac26106 @pmichaud Initial implementation of Array, List, and Parcel.
pmichaud authored Jun 10, 2011
125 my sub infix:<,>(|$) {
ab1dda5 @pmichaud Convert some more pir:: opcodes to nqp:: .
pmichaud authored Jun 27, 2011
126 nqp::p6parcel(pir::perl6_current_args_rpa__P(), nqp::null());
e9d014b @pmichaud Stub in Iterable and Parcel, initial infix:<,> implementation.
pmichaud authored Jun 9, 2011
127 }
128
129
Something went wrong with that request. Please try again.