Skip to content

Instantly share code, notes, and snippets.

@MasterDuke17
Created June 9, 2025 19:43
Show Gist options
  • Save MasterDuke17/7c0fc7efe05ad0d334336004f424583a to your computer and use it in GitHub Desktop.
Save MasterDuke17/7c0fc7efe05ad0d334336004f424583a to your computer and use it in GitHub Desktop.
diff --git src/Raku/ast/package.rakumod src/Raku/ast/package.rakumod
index 610fdf7b0..5a86a3937 100644
--- src/Raku/ast/package.rakumod
+++ src/Raku/ast/package.rakumod
@@ -267,7 +267,7 @@ method install-extra-declarations(RakuAST::Resolver $resolver) {
# Need to install the package somewhere
method install-in-scope(RakuAST::Resolver $resolver, str $scope, RakuAST::Name $name, RakuAST::Name $full-name) {
self.IMPL-INSTALL-PACKAGE(
- $resolver, $scope, $name, $resolver.current-package, :meta-object(Mu)
+ $resolver, $scope, $full-name, $resolver.current-package, :meta-object(Mu)
) if $scope eq 'my' || $scope eq 'our';
}
@@ -588,7 +588,7 @@ method install-in-scope(RakuAST::Resolver $resolver, str $scope, RakuAST::Na
:name($group-name), :repr(self.repr)
);
self.IMPL-INSTALL-PACKAGE(
- $resolver, $scope, $name, $resolver.current-package,
+ $resolver, $scope, $full-name, $resolver.current-package,
:meta-object($group),
);
}
diff --git src/Raku/ast/resolver.rakumod src/Raku/ast/resolver.rakumod
index 75c6090c2..de42888f7 100644
--- src/Raku/ast/resolver.rakumod
+++ src/Raku/ast/resolver.rakumod
@@ -217,17 +217,58 @@ method IMPL-RESOLVE-NAME-IN-PACKAGES($Rname, :$sigil, Bool :$partial) {
# it being passed as an argument then??? XXX
# $name := $sigil ~ $name if $sigil;
- for $!packages {
- my $stash := self.IMPL-STASH-HASH($_.compile-time-value);
- return $partial
- ?? ($stash{$name}, List.new, 'global')
- !! self.external-constant($stash, $name)
- if nqp::existskey($stash,$name);
- }
+ my @parts := nqp::clone($Rname.IMPL-UNWRAP-LIST($Rname.parts));
+ my $first := nqp::shift(@parts);
+ my $fname := nqp::istype($first,RakuAST::Name::Part::Simple) ?? $first.name !! '';
+ my $packages := nqp::clone($!packages);
+ nqp::unshift($packages, $!global);
+ while $packages {
+ my $package := nqp::pop($packages);
+ nqp::note("package: " ~ $package.HOW.name($package));
+ my $stash := self.IMPL-STASH-HASH(nqp::can($package, 'compile-time-value') ?? $package.compile-time-value !! $package);
+ if nqp::existskey($stash, $fname) {
+ my $cur-package := $stash{$fname};
+ #$symbol := $cur;
+ while @parts {
+ my $part := nqp::shift(@parts);
+ my $pname := nqp::istype($part,RakuAST::Name::Part::Simple) ?? $part.name !! '';
+ my $next-package := nqp::atkey(self.IMPL-STASH-HASH($cur-package), $pname);
+ if nqp::isnull($next-package) {
+ nqp::unshift(@parts, $part);
+ return $partial
+ ?? ($next-package, $Rname.IMPL-WRAP-LIST(@parts), 'global')
+ !! Nil
+ }
+ $cur-package := $next-package;
+ }
+ return $partial
+ ?? ($cur-package, List.new, 'global')
+ !! RakuAST::Declaration::External::Constant.new(
+ lexical-name => $name, compile-time-value => $cur-package
+ );
+ }
+ }
+ return Nil;
+ #for @parts {
+ # my $pname := nqp::istype($_,RakuAST::Name::Part::Simple)
+ # ?? $_.name
+ # !! '';
+ # for $!packages {
+ # #nqp::note($_.DUMP);
+ # if !$_.has-compile-time-value {
+ # # XXX should throw
+ # last;
+ # }
+ # my $stash := self.IMPL-STASH-HASH($_.compile-time-value);
+ # return $partial
+ # ?? ($stash{$pname}, List.new, 'global')
+ # !! self.external-constant($stash, $pname)
+ # if nqp::existskey($stash,$pname);
+ # }
+ #}
my $symbol := $!global;
- my @parts := nqp::clone($Rname.IMPL-UNWRAP-LIST($Rname.parts));
- while @parts {
+ while @parts {
my $part := @parts.shift;
$name := nqp::istype($part,RakuAST::Name::Part::Simple)
?? $part.name
diff --git src/Raku/ast/scoping.rakumod src/Raku/ast/scoping.rakumod
index 7e1fc773d..a6de008c9 100644
--- src/Raku/ast/scoping.rakumod
+++ src/Raku/ast/scoping.rakumod
@@ -619,6 +619,14 @@ method generate-lookup() {
$lookup.set-resolution(self);
$lookup
}
+
+ method has-compile-time-value() {
+ $!maybe-compile-time-value ?? True !! False
+ }
+
+ method compile-time-value() {
+ $!maybe-compile-time-value
+ }
}
class RakuAST::Declaration::Mergeable {
@@ -760,6 +768,14 @@ method set-value(Mu $compile-time-value is raw) {
}
method return-type() { $!compile-time-value.WHAT }
+
+ method has-compile-time-value() {
+ True
+ }
+
+ method maybe-compile-time-value() {
+ self.compile-time-value
+ }
}
# An imported lexical declaration. Has a compile-time value. Must create a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment