Permalink
Browse files

More array-related methods and fixes. This _almost_ gets us

to passing S02-builtins/array.t, as soon as $_ within if blocks
starts working.
  • Loading branch information...
1 parent 4af0ae1 commit f5c25daafde2bc25db225af9b5ce11c864f61b18 @pmichaud pmichaud committed Jun 28, 2011
Showing with 16 additions and 7 deletions.
  1. +1 −0 src/Perl6/Actions.pm
  2. +9 −0 src/core/Any.pm
  3. +3 −6 src/core/Failure.pm
  4. +2 −0 src/core/Parcel.pm
  5. +1 −1 t/spectest.data
@@ -3426,6 +3426,7 @@ class Perl6::Actions is HLL::Actions {
add_signature_binding_code($block, $signature, @params);
my $code := $*ST.create_code_object($block, 'WhateverCode', $signature);
$past := block_closure(reference_to_code_object($code, $block));
+ $past.returns('WhateverCode');
$past.arity(+@params);
}
$past
View
@@ -41,6 +41,7 @@ my class Any {
proto method postcircumfix:<[ ]>(|$) { * }
+ multi method postcircumfix:<[ ]>() { self.list }
multi method postcircumfix:<[ ]>($pos) is rw {
fail "Cannot use negative index $pos on {self.WHAT.perl}" if $pos < 0;
self.at_pos($pos)
@@ -59,10 +60,18 @@ my class Any {
self[^self.elems]
}
+ method at_pos($pos) is rw {
+ if self.defined {
+ fail ".[$pos] out of range for type {self.perl}" if $pos != 0;
+ return self;
+ }
+ }
+
########
# Hash-like methods for Any.
########
proto method postcircumfix:<{ }>(|$) { * }
+ multi method postcircumfix:<{ }>() { self.values }
multi method postcircumfix:<{ }>($key) is rw {
self.at_key($key)
}
View
@@ -21,11 +21,8 @@ my class Failure {
}
multi method Bool(Failure:D:) { $!handled = 1; 0.Bool; }
- proto method Int(|$) {*}
- multi method Int(Failure:D:) { $!handled ?? 0 !! $!exception.rethrow; }
- proto method Num(|$) {*}
- multi method Num(Failure:D:) { $!handled ?? 0e0 !! $!exception.rethrow; }
- proto method Str(|$) {*}
+ method Int(Failure:D:) { $!handled ?? 0 !! $!exception.rethrow; }
+ method Num(Failure:D:) { $!handled ?? 0e0 !! $!exception.rethrow; }
multi method Str(Failure:D:) { $!handled ?? '' !! $!exception.rethrow; }
}
@@ -43,7 +40,7 @@ my &fail := -> *@msg {
.get_results (%r)
pop_eh
};
- my $fail = Failure.new(EXCEPTION($ex));
+ my $fail := Failure.new(EXCEPTION($ex));
my Mu $return := pir::find_caller_lex__Ps('RETURN');
$return($fail) unless nqp::isnull($return);
$fail
View
@@ -3,6 +3,8 @@ my class Parcel does Positional {
# is Cool; # parent class
# has $!storage; # RPA of Parcel's elements
+ multi method Str(Parcel:D:) { self.flat.Str }
+
method flat() {
nqp::p6list(nqp::clone($!storage), List, 1.Bool)
}
View
@@ -20,7 +20,7 @@
# See the "make quicktest" and "make stresstest" targets in
# build/Makefile.in for examples of use.
-# S02-builtin_data_types/anon_block.t
+S02-builtin_data_types/anon_block.t
S02-builtin_data_types/array_extending.t
# S02-builtin_data_types/array_ref.t
# S02-builtin_data_types/array.t

0 comments on commit f5c25da

Please sign in to comment.