Skip to content

Commit

Permalink
RakuAST: Fix SETTING:: in v6.e still finding CORE.d
Browse files Browse the repository at this point in the history
6.e has a replacement PseudoStash class that also needed adjusting for
finding the setting frame from a RakuAST compiled comp unit. Because the
implementation differs, replace the previous solution with a more
reliable one, i.e. add another marker to the unit frame's lexpad.

This marker can be removed once we switch to RakuAST completely (with
support for the old frontend then removed from PseudoStash)
  • Loading branch information
niner committed Jan 31, 2023
1 parent 97a68d1 commit 6f1b0fe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/Raku/ast/compunit.rakumod
Expand Up @@ -206,6 +206,9 @@ class RakuAST::CompUnit
nqp::push(@decls, RakuAST::VarDeclaration::Implicit::Constant.new(
name => '!UNIT_MARKER', value => 1
));
nqp::push(@decls, RakuAST::VarDeclaration::Implicit::Constant.new(
name => '!RAKUAST_MARKER', value => 1 #TODO remove this when old frontend is gone
));
nqp::push(@decls, RakuAST::VarDeclaration::Implicit::Constant.new(
name => '!EVAL_MARKER', value => 1
)) if $!is-eval;
Expand Down
9 changes: 2 additions & 7 deletions src/core.c/PseudoStash.pm6
Expand Up @@ -199,16 +199,11 @@ my class PseudoStash is Map {
until nqp::isnull($ctx) || nqp::existskey(nqp::ctxlexpad($ctx), '!UNIT_MARKER') {
$ctx := nqp::ctxouterskipthunks($ctx);
}
my $is-rakuast := nqp::existskey(nqp::ctxlexpad($ctx), '!RAKUAST_MARKER');
nqp::if(
nqp::isnull($ctx)
|| nqp::isnull($ctx := nqp::ctxouter($ctx))
|| nqp::isnull(
nqp::if(
nqp::existskey(nqp::ctxlexpad($ctx), 'CORE-SETTING-REV'),
$ctx, # Compiled from RakuAST
($ctx := nqp::ctxouter($ctx)) # Compiled via legacy frontend
)
),
|| nqp::isnull(nqp::if($is-rakuast, $ctx, ($ctx := nqp::ctxouter($ctx)))),
Nil,
nqp::stmts(
(my $stash := nqp::create(PseudoStash)),
Expand Down
1 change: 1 addition & 0 deletions src/core.e/PseudoStash.pm6
Expand Up @@ -136,6 +136,7 @@ my class PseudoStash is CORE::v6c::PseudoStash {
}
# EVAL adds two extra contexts to EVAL'ed code.
my $outers = ($ctx && nqp::existskey(nqp::ctxlexpad($ctx), '!EVAL_MARKER')) ?? 4 !! 2;
$outers-- if nqp::existskey(nqp::ctxlexpad($ctx), '!RAKUAST_MARKER');
nqp::until(
(nqp::isnull($ctx) || !$outers),
nqp::stmts(
Expand Down

0 comments on commit 6f1b0fe

Please sign in to comment.