Skip to content
Permalink
Browse files

Move Inline::Perl5 interpreter fetching to R:I.PERL5

This allows the removal of one more state variable and reduces the size of
the sub for the most common case.
  • Loading branch information...
lizmat committed May 20, 2019
1 parent 5b3a8ce commit 5b7870bf8f50123a821fdd0b9a7f44ca4bb93fcc
Showing with 23 additions and 16 deletions.
  1. +3 −16 src/core/ForeignCode.pm6
  2. +20 −0 src/core/Rakudo/Internals.pm6
@@ -85,26 +85,13 @@ multi sub EVAL(
Str() :$filename = Str,
Bool() :$check = False,
) {
my $eval_ctx := nqp::getattr(nqp::decont($context // CALLER::), PseudoStash, '$!ctx');
my $?FILES := $filename // 'EVAL_' ~ Rakudo::Internals::EvalIdSource.next-id;
state $p5;
unless $p5 {
{
my $compunit := $*REPO.need(CompUnit::DependencySpecification.new(:short-name<Inline::Perl5>));
GLOBAL.WHO.merge-symbols($compunit.handle.globalish-package);
CATCH {
#X::Eval::NoSuchLang.new(:$lang).throw;
note $_;
}
}
$p5 = ::("Inline::Perl5").default_perl5;
}

if $check {
X::NYI.new(feature => ":check on EVAL :from<Perl5>").throw;
}
else {
$p5.run: nqp::istype($code,Blob)
my $?FILES :=
$filename // 'EVAL_' ~ Rakudo::Internals::EvalIdSource.next-id;
Rakudo::Internals.PERL5.run: nqp::istype($code,Blob)
?? Blob.new($code).decode('utf8-c8')
!! $code.Str
}
@@ -1711,6 +1711,26 @@ implementation detail and has no serviceable parts inside"
);
nqp::iterator($keys)
}

# Return an Inline::Perl5 interpreter if possible
my $P5;
method PERL5() {
$P5 //= do {
{
my $compunit := $*REPO.need(
CompUnit::DependencySpecification.new(
:short-name<Inline::Perl5>
)
);
GLOBAL.WHO.merge-symbols($compunit.handle.globalish-package);
CATCH {
#X::Eval::NoSuchLang.new(:$lang).throw;
.note;
}
}
::("Inline::Perl5").default_perl5
}
}
}

# expose the number of bits a native int has

0 comments on commit 5b7870b

Please sign in to comment.
You can’t perform that action at this time.