Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Second part of making IO up to spec
with S16 | S32/IO synopsis updates.

This was mostly about making IO::Path smarter: keeping the $*SPEC/$*CWD
settings at creation time for later usage.  And making sure all IO::Path
methods map to the correct $!SPEC.samemethod (or composite).
  • Loading branch information
lizmat committed Oct 2, 2014
1 parent 9814e86 commit 5870906
Show file tree
Hide file tree
Showing 13 changed files with 332 additions and 275 deletions.
11 changes: 6 additions & 5 deletions src/core/CompUnitRepo/Local/File.pm
Expand Up @@ -5,16 +5,16 @@ class CompUnitRepo::Local::File does CompUnitRepo::Locally {
Perl5 => <pm5 pm>,
NQP => <nqp>,
JVM => ();
my Str $slash := IO::Spec.rootdir;

# global cache of files seen
my %seen;

method install($source, $from?) { ... }
method files($file, :$name, :$auth, :$ver) {
my $base := $file.path.is-absolute ?? $file !! $!path ~ $slash ~ $file;
return { files => { $file => $base }, ver => Version.new('0') } if $base.IO.f;
();
my $base := $file.IO;
$base.f
?? { files => { $file => $base.path }, ver => Version.new('0') }
!! ();
}

method candidates(
Expand All @@ -28,12 +28,13 @@ class CompUnitRepo::Local::File does CompUnitRepo::Locally {
# sorry, cannot handle this one
return () unless %extensions{$from}:exists;

my $slash := $*SPEC.rootdir;
my $base := $!path ~ $slash ~ $name.subst(:g, "::", $slash) ~ '.';
if %seen{$base} -> $found {
return $found;
}

state Str $precomp-ext = $*VM.precomp-ext;
state Str $precomp-ext = $*VM.precomp-ext; # should be $?VM probably

# have extensions to check
if %extensions{$from} -> @extensions {
Expand Down
7 changes: 5 additions & 2 deletions src/core/CompUnitRepo/Local/Installation.pm
Expand Up @@ -4,8 +4,11 @@ class CompUnitRepo::Local::Installation does CompUnitRepo::Locally {

method BUILD(:$path) {
$!WHICH = self.^name ~ '|' ~ $path;
$!path = $path.path unless $!path;
%!dists{$path} = "$path/MANIFEST".IO.e ?? from-json( slurp "$path/MANIFEST" ) !! {};
$!path = $path.IO unless $!path;
my $manifest = $!path.child("MANIFEST");
%!dists{$path} = $manifest.e
?? from-json($manifest.slurp)
!! {};
%!dists{$path}<file-count> //= 0;
%!dists{$path}<dist-count> //= 0;
%!dists{$path}<dists> //= [ ];
Expand Down
9 changes: 5 additions & 4 deletions src/core/CompUnitRepo/Locally.pm
Expand Up @@ -5,13 +5,14 @@ role CompUnitRepo::Locally {

my %instances;

method new( $path ) {
return Nil unless $path.IO.e;
%instances{$path} //= self.bless(:path($path.path), :lock(Lock.new));
method new($dir) {
my $path := $dir.IO;
return Nil unless $path.d and $path.r;
%instances{$path} //= self.bless(:$path, :lock(Lock.new));
}

multi method WHICH (CompUnitRepo::Locally:D:) {
$!WHICH = self.^name ~ '|' ~ $!path;
$!WHICH //= self.^name ~ '|' ~ $!path;
}
method Str { self.DEFINITE ?? $!path.Str !! Nil }
method gist { self.DEFINITE
Expand Down
4 changes: 2 additions & 2 deletions src/core/Cool.pm
@@ -1,5 +1,5 @@
my role IO { ... }
my class IO::Path { ... }
my role IO { ... }
my class IO::Path { ... }

my class SprintfHandler {
method mine($x) { nqp::reprname($x) eq "P6opaque"; }
Expand Down
2 changes: 1 addition & 1 deletion src/core/Deprecations.pm
Expand Up @@ -78,7 +78,7 @@ sub DEPRECATED ($alternative, :$up = 1, :$what ) {
$dep = %DEPRECATIONS{$dep.WHICH} //= $dep;

# update callsite
$dep.callsites{$callsite.file}{$callsite.line}++;
$dep.callsites{$callsite.file.IO}{$callsite.line}++;
}

END {
Expand Down
4 changes: 3 additions & 1 deletion src/core/Env.pm
Expand Up @@ -13,7 +13,9 @@
}

multi sub INITIALIZE_DYNAMIC('$*CWD') {
PROCESS::<$CWD> = IO::Path.new(nqp::p6box_s(nqp::cwd()));
# PROCESS::<$CWD> = nqp::p6box_s(nqp::cwd());
my $CWD := nqp::p6box_s(nqp::cwd());
PROCESS::<$CWD> = IO::Path.new($CWD, :$CWD); # need :CWD to prevent looping
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit 5870906

Please sign in to comment.