Skip to content

Commit

Permalink
Add Nil handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Jun 19, 2011
1 parent 33c6b6c commit a56af91
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/core/Any.pm
Expand Up @@ -5,6 +5,7 @@ my class Any {
# List-like methods for Any.
method flat() { self.list.flat }
method list() { (self,).list }
method elems() { self.list.elems }

method join($separator = ' ') {
my $list = (self,).flat.eager;
Expand Down
4 changes: 1 addition & 3 deletions src/core/ListIter.pm
@@ -1,5 +1,3 @@
class Parcel { ... }

my class ListIter {
# Attributes defined in BOOTSTRAP.pm:
# has $!reified; # return value for already-reified iterator
Expand Down Expand Up @@ -29,7 +27,7 @@ my class ListIter {
pir__perl6_unbox_rpa__PP($x),
0, 0);
}
else {
elsif !Nil.ACCEPTS($x) {
$x := $!list.STORE_AT_POS($pos, $x) if $!list.defined;
pir::push__vPP($rpa, $x);
$n = $n - 1;
Expand Down
10 changes: 9 additions & 1 deletion src/core/Parcel.pm
Expand Up @@ -31,12 +31,20 @@ my class Parcel {
$perl ~ ')';
}

method DUMP() {
multi method DUMP(Parcel:D:) {
self.DUMP-ID() ~ '(:storage(' ~ DUMP($!storage) ~ '))'
}
}


my class Nil is Parcel {
method new() { Nil }
method flat() { ().flat }
method list() { ().list }
method gist() { 'Nil' }
}


my sub infix:<,>(|$) {
# pir::perl6_box_rpa__PP(pir::perl6_current_args_rpa__P())
pir::setattribute__0PPsP(
Expand Down
2 changes: 1 addition & 1 deletion tools/build/Makefile.in
Expand Up @@ -124,6 +124,7 @@ CORE_SOURCES = \
src/core/Any.pm \
src/core/Code.pm \
src/core/Attribute.pm \
src/core/Parcel.pm \
src/core/Cool.pm \
src/core/Bool.pm \
src/core/Numeric.pm \
Expand All @@ -137,7 +138,6 @@ CORE_SOURCES = \
src/core/MapIter.pm \
src/core/GatherIter.pm \
src/core/List.pm \
src/core/Parcel.pm \
src/core/Array.pm \
src/core/RangeIter.pm \
src/core/Range.pm \
Expand Down

0 comments on commit a56af91

Please sign in to comment.