Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: nom
Fetching contributors…

Cannot retrieve contributors at this time

38 lines (34 sloc) 1.393 kB
my class Stash { # declared in BOOTSTRAP
# class Stash is Hash {
multi method AT-KEY(Stash:D: Str() $key, :$global_fallback) is rw {
my Mu $storage := nqp::defined(nqp::getattr(self, EnumMap, '$!storage')) ??
nqp::getattr(self, EnumMap, '$!storage') !!
nqp::bindattr(self, EnumMap, '$!storage', nqp::hash());
if nqp::existskey($storage, nqp::unbox_s($key)) {
nqp::atkey($storage, nqp::unbox_s($key))
}
elsif $global_fallback {
nqp::existskey(GLOBAL.WHO, $key)
?? GLOBAL.WHO.AT-KEY($key)
!! fail("Could not find symbol '$key'")
}
else {
nqp::p6bindattrinvres(my $v, Scalar, '$!whence',
-> { nqp::bindkey($storage, nqp::unbox_s($key), $v) } )
}
}
method package_at_key(Stash:D: str $key) {
my Mu $storage := nqp::defined(nqp::getattr(self, EnumMap, '$!storage')) ??
nqp::getattr(self, EnumMap, '$!storage') !!
nqp::bindattr(self, EnumMap, '$!storage', nqp::hash());
if nqp::existskey($storage, nqp::unbox_s($key)) {
nqp::atkey($storage, $key)
}
else {
my $pkg := Metamodel::PackageHOW.new_type(:name($key));
$pkg.^compose;
nqp::bindkey($storage, $key, $pkg)
}
}
}
# vim: ft=perl6 expandtab sw=4
Jump to Line
Something went wrong with that request. Please try again.