Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'upstream/nom' into deleteadverbkvpkv
Conflicts:
	src/core/Any.pm
  • Loading branch information
lizmat committed May 22, 2013
2 parents 21a9579 + 267c54c commit d0ac9a7
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 26 deletions.
1 change: 1 addition & 0 deletions docs/ChangeLog
Expand Up @@ -6,6 +6,7 @@ New in 2013.05
+ implemented Cool.lines
+ renamed IO to IO::Handle; IO is now a tag role, as per spec
+ simplify timezone handling
+ .Set and .Bag methods for List and Parcel

New in 2013.04
+ add Capture.Bool()
Expand Down
2 changes: 1 addition & 1 deletion docs/release_guide.pod
Expand Up @@ -73,7 +73,7 @@ Dates are based on Parrot's expected release schedule.

2013-05-23 Rakudo #64 "Austin" FROGGS
2013-06-20 Rakudo #65 masak
2013-07-18 Rakudo #66
2013-07-18 Rakudo #66 tadzik
2013-08-22 Rakudo #67
2013-09-19 Rakudo #68
2013-10-17 Rakudo #69
Expand Down
2 changes: 1 addition & 1 deletion src/Perl6/Actions.nqp
Expand Up @@ -153,7 +153,7 @@ class Perl6::Actions is HLL::Actions does STDActions {
%info<container_base> := $*W.find_symbol(['Hash']);
%info<bind_constraint> := $*W.find_symbol(['Associative']);
if $shape {
@value_type[0] := $*W.find_symbol(['Mu']) unless +@value_type;
@value_type[0] := $*W.find_symbol(['Any']) unless +@value_type;
my $shape_ast := $shape[0].ast;
if $shape_ast.isa(QAST::Stmts) && +@($shape_ast) == 1 && $shape_ast[0].has_compile_time_value {
@value_type[1] := $shape_ast[0].compile_time_value;
Expand Down
4 changes: 4 additions & 0 deletions src/RESTRICTED.setting
Expand Up @@ -11,6 +11,10 @@ sub mkdir(|) { restricted('mkdir') }
sub rmdir(|) { restricted('rmdir') }
sub rename(|) { restricted('rename') }
sub copy(|) { restricted('copy') }
sub spurt(|) { restricted('spurt') }
sub link(|) { restricted('link') }
sub symlink(|){ restricted('symlink') }
sub chmod(|) { restricted('chmod') }

my class RESTRICTED is Mu {
method FALLBACK(|) { restricted(self.^name) } # NYI, but see S12
Expand Down
20 changes: 18 additions & 2 deletions src/core/Any.pm
Expand Up @@ -2,6 +2,7 @@ my class MapIter { ... }
my class Range { ... }
my class X::Bind::Slice { ... }
my class X::Bind::ZenSlice { ... }
my $default= []; # so that we can check passing of parameters to ".hash"

my class Any {
multi method ACCEPTS(Any:D: Mu \a) { self === a }
Expand All @@ -17,7 +18,21 @@ my class Any {
method uniq() { self.list.uniq }
method infinite() { Mu }
method flat() { nqp::p6list(nqp::list(self), List, Bool::True) }
method hash() { my %h = self }
method hash( :$type = $default, :$of = $default ) {

# your basic hash
if ( $type === $default and $of === $default ) {
my %h = self;
}

# need to add type / of info
else {
my $code= $of === $default ?? "my %h" !! "my {$of.perl} %h";
$code ~= "\{{$type.perl}}" unless $type === $default;
$code ~= " = self";
eval $code;
}
}
method list() { nqp::p6list(nqp::list(self), List, Mu) }
method lol() { MapIter.new(self.list, { .item }, Mu).list }
method pick($n = 1) { self.list.pick($n) }
Expand Down Expand Up @@ -402,7 +417,8 @@ my class Any {
SELF.delete($_)
} ).eager.Parcel;
}
multi method postcircumfix:<{ }>(\SELF: Positional \key, :$exists!) is rw {
multi method postcircumfix:<{ }>(
\SELF: Positional \key, :$exists!) is rw {
nqp::iscont(key)
?? !( SELF.exists(key) ?^ $exists )
!! key.map({ !( SELF.exists($_) ?^ $exists ) }).eager.Parcel;
Expand Down
2 changes: 2 additions & 0 deletions src/core/Bag.pm
Expand Up @@ -3,6 +3,7 @@ my role Baggy { Any }
my class Bag is Iterable does Associative does Baggy {
has %!elems; # should be UInt

method default { 0 }
method keys { %!elems.keys }
method values { %!elems.values }
method elems returns Int { [+] self.values }
Expand Down Expand Up @@ -70,6 +71,7 @@ multi sub infix:<(+)>(Bag $a, Bag $b --> Bag) { bag((set($a) (|) set($b)).map({
my class KeyBag does Associative does Baggy {
has %!elems; # should be UInt

method default { 0 }
method keys { %!elems.keys }
method values { %!elems.values }
method elems returns Int { [+] self.values }
Expand Down
4 changes: 2 additions & 2 deletions src/core/Hash.pm
Expand Up @@ -114,7 +114,7 @@ my class Hash {
}

my role TypedHash[::TValue] does Associative[TValue] {
method at_key($key is copy, TValue $v? is copy) is rw {
method at_key(::?CLASS:D: $key is copy, TValue $v? is copy) is rw {
$key = $key.Str;
self.exists($key)
?? nqp::findmethod(EnumMap, 'at_key')(self, $key)
Expand All @@ -135,7 +135,7 @@ my class Hash {
}
my role TypedHash[::TValue, ::TKey] does Associative[TValue] {
has $!keys;
method at_key(TKey \key, TValue $v? is copy) is rw {
method at_key(::?CLASS:D: TKey \key, TValue $v? is copy) is rw {
my $key_which = key.WHICH;
self.exists($key_which)
?? nqp::findmethod(EnumMap, 'at_key')(self, $key_which)
Expand Down
2 changes: 1 addition & 1 deletion src/core/IO.pm
Expand Up @@ -347,7 +347,7 @@ sub dir(Cool $path = '.', Mu :$test = none('.', '..')) {
my Mu $RSA := pir::new__PS('OS').readdir(nqp::unbox_s($path.Str));
my int $elems = nqp::elems($RSA);
my @res;
my ($directory, $volume) = IO::Spec.splitpath(~$path, :nofile);
my ($volume, $directory) = IO::Spec.splitpath(~$path, :nofile);
loop (my int $i = 0; $i < $elems; $i = $i + 1) {
my Str $file := nqp::p6box_s(pir::trans_encoding__Ssi(
nqp::atpos_s($RSA, $i),
Expand Down
10 changes: 10 additions & 0 deletions src/core/List.pm
Expand Up @@ -71,6 +71,16 @@ my class List does Positional {
nqp::p6parcel($rpa, Any);
}

proto method Set(|) {*}
multi method Set() {
set self;
}

proto method Bag(|) {*}
multi method Bag() {
bag self;
}

multi method at_pos(List:D: $pos is copy) is rw {
$pos = $pos.Int;
self.exists($pos)
Expand Down
2 changes: 1 addition & 1 deletion src/core/Mu.pm
Expand Up @@ -489,7 +489,7 @@ my class Mu {
}


proto sub defined(Mu) { * }
proto sub defined(Mu) is pure { * }
multi sub defined(Mu \x) { x.defined }

proto sub infix:<~~>(|) { * }
Expand Down
10 changes: 10 additions & 0 deletions src/core/Parcel.pm
Expand Up @@ -116,6 +116,16 @@ my class Parcel does Positional {
method fmt($format = '%s', $separator = ' ') {
self.list.fmt($format, $separator);
}

proto method Set(|) {*}
multi method Set() {
set self;
}

proto method Bag(|) {*}
multi method Bag() {
bag self;
}
}


Expand Down
2 changes: 1 addition & 1 deletion src/core/Pod.pm
Expand Up @@ -54,7 +54,7 @@ my class Pod::Block::Declarator is Pod::Block {
method Str {
~@.content
}
multi method gist(Pod::Block:D:) {
multi method gist(Pod::Block::Declarator:D:) {
self.Str
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/Set.pm
@@ -1,6 +1,7 @@
my class Set is Iterable does Associative {
has %!elems;

method default { False }
method keys { %!elems.keys }
method values { %!elems.values }
method elems returns Int { %!elems.elems }
Expand Down Expand Up @@ -103,6 +104,7 @@ multi sub infix:«(>)»(Set $a, Set $b --> Bool) { $a > $b and so $b.keys.all (e
my class KeySet is Iterable does Associative {
has %!elems;

method default { False }
method keys { %!elems.keys }
method values { %!elems.values }
method elems returns Int { %!elems.elems }
Expand Down
26 changes: 13 additions & 13 deletions src/core/Stringy.pm
Expand Up @@ -4,10 +4,10 @@ multi sub infix:<eqv>(Stringy:D $a, Stringy:D $b) {
$a.WHAT === $b.WHAT && ($a cmp $b) == 0
}

proto prefix:<~>($) { * }
proto prefix:<~>($) is pure { * }
multi prefix:<~>(\a) { a.Stringy }

proto infix:<~>($?, $?) { * }
proto infix:<~>($?, $?) is pure { * }
multi infix:<~>($x = '') { $x.Stringy }
multi infix:<~>(\a, \b) { a.Stringy ~ b.Stringy }

Expand All @@ -16,46 +16,46 @@ multi infix:<x>() { fail "No zero-arg meaning for infix:<x>" }
multi infix:<x>($x) { $x.Stringy }
multi infix:<x>($s, $n) { $s.Stringy x ($n.Int // 0) }

proto infix:<leg>($?, $?) { * }
proto infix:<leg>($?, $?) is pure { * }
multi infix:<leg>(\a, \b) { a.Stringy cmp b.Stringy }

proto infix:<eq>($?, $?) { * }
proto infix:<eq>($?, $?) is pure { * }
multi infix:<eq>($x?) { Bool::True }
multi infix:<eq>(\a, \b) { a.Stringy eq b.Stringy }

proto infix:<ne>(Mu $?, Mu $?) { * }
proto infix:<ne>(Mu $?, Mu $?) is pure { * }
multi infix:<ne>($x?) { Bool::True }
multi infix:<ne>(Mu \a, Mu \b) { a !eq b }

proto infix:<lt>($?, $?) { * }
proto infix:<lt>($?, $?) is pure { * }
multi infix:<lt>($x?) { Bool::True }
multi infix:<lt>(\a, \b) { a.Stringy lt b.Stringy }

proto infix:<le>($?, $?) { * }
proto infix:<le>($?, $?) is pure { * }
multi infix:<le>($x?) { Bool::True }
multi infix:<le>(\a, \b) { a.Stringy le b.Stringy }

proto infix:<gt>($?, $?) { * }
proto infix:<gt>($?, $?) is pure { * }
multi infix:<gt>($x?) { Bool::True }
multi infix:<gt>(\a, \b) { a.Stringy gt b.Stringy }

proto infix:<ge>($?, $?) { * }
proto infix:<ge>($?, $?) is pure { * }
multi infix:<ge>($x?) { Bool::True }
multi infix:<ge>(\a, \b) { a.Stringy ge b.Stringy }

proto infix:<~|>($?, $?) { * }
proto infix:<~|>($?, $?) is pure { * }
multi infix:<~|>($x = '') { $x.Stringy }
multi infix:<~|>(\a, \b) { a.Stringy ~| b.Stringy }

proto infix:<~^>($?, $?) { * }
proto infix:<~^>($?, $?) is pure { * }
multi infix:<~^>($x = '') { $x.Stringy }
multi infix:<~^>(\a, \b) { a.Stringy ~^ b.Stringy }

proto infix:<~&>($?, $?) { * }
proto infix:<~&>($?, $?) is pure { * }
multi infix:<~&>() { fail "No zero-arg meaning for infix:<~&>" }
multi infix:<~&>($x) { $x.Stringy }
multi infix:<~&>(\a, \b) { a.Stringy ~& b.Stringy }

proto prefix:<~^>($?, $?) { * }
proto prefix:<~^>($?, $?) is pure { * }
multi prefix:<~^>(\a) { ~^ a.Stringy }

9 changes: 6 additions & 3 deletions t/spectest.data
Expand Up @@ -56,6 +56,7 @@ S02-magicals/pid.t
S02-magicals/progname.t
S02-magicals/sub.t
S02-magicals/vm.t
S02-names/bare-sigil.t
S02-names/caller.t
S02-names/identifier.t
S02-names/indirect.t
Expand Down Expand Up @@ -307,6 +308,7 @@ S05-metasyntax/angle-brackets.t
S05-metasyntax/assertions.t
S05-metasyntax/changed.t
S05-metasyntax/charset.t
S05-metasyntax/delimiters.t
S05-metasyntax/interpolating-closure.t
S05-metasyntax/litvar.t
S05-metasyntax/longest-alternative.t
Expand Down Expand Up @@ -548,7 +550,6 @@ S16-io/getc.t
S16-io/say-and-ref.t
S16-io/say.t
S16-unfiled/rebindstdhandles.t
S16-unfiled/slurp.t
S19-command-line/dash-e.t # icu
S19-command-line/help.t
S24-testing/0-compile.t
Expand Down Expand Up @@ -595,8 +596,9 @@ S32-container/roundrobin.t
S32-container/zip.t
S32-exceptions/misc.t
S32-hash/delete.t
S32-hash/delete_adverb.t
S32-hash/delete-adverb.t
S32-hash/exists.t
S32-hash/exists-adverb.t
S32-hash/invert.t
S32-hash/keys_values.t
S32-hash/kv.t
Expand All @@ -616,6 +618,7 @@ S32-io/io-path-cygwin.t
S32-io/io-path.t
S32-io/IO-Socket-INET.t
S32-io/note.t
S32-io/slurp.t
S32-list/categorize.t
S32-list/classify.t
S32-list/create.t
Expand Down Expand Up @@ -677,7 +680,7 @@ S32-str/samecase.t # icu
S32-str/split-simple.t
S32-str/split.t
S32-str/sprintf.t
S32-str/substr.t
S32-str/substr.t # icu
S32-str/substr-rw.t
S32-str/tclc.t # icu
S32-str/trim.t
Expand Down
2 changes: 1 addition & 1 deletion tools/build/NQP_REVISION
@@ -1 +1 @@
2013.04-134-gb4ad9fc
2013.04-138-ga0808a0

0 comments on commit d0ac9a7

Please sign in to comment.