1. class CompUnit::Repository::AbsolutePath does CompUnit::Repository {
  2. has %!loaded;
  3. method need(CompUnit::DependencySpecification $spec,
  4. CompUnit::PrecompilationRepository $precomp = self.precomp-repository()
  5. --> CompUnit:D)
  6. {
  7. return self.next-repo.need($spec, $precomp) if self.next-repo;
  8. X::CompUnit::UnsatisfiedDependency.new(:specification($spec)).throw;
  9. }
  10. method load(IO::Path:D $file --> CompUnit:D) {
  11. if $file.is-absolute {
  12. # We have a $file when we hit: require "PATH" or use/require Foo:file<PATH>;
  13. my $precompiled =
  14. $file.Str.ends-with(Rakudo::Internals.PRECOMP-EXT);
  15. if $file.f {
  16. return %!loaded{$file} = CompUnit.new(
  17. :handle(
  18. $precompiled
  19. ?? CompUnit::Loader.load-precompilation-file($file)
  20. !! CompUnit::Loader.load-source-file($file)
  21. ),
  22. :short-name($file.Str),
  23. :repo(self),
  24. :repo-id($file.Str),
  25. :$precompiled,
  26. );
  27. }
  28. }
  29. return self.next-repo.load($file) if self.next-repo;
  30. die("Could not find $file in:\n" ~ $*REPO.repo-chain.map(*.Str).join("\n").indent(4));
  31. }
  32. method loaded(--> Iterable:D) {
  33. return %!loaded.values;
  34. }
  35. method id() {
  36. 'ap'
  37. }
  38. method path-spec() {
  39. 'ap#'
  40. }
  41. }