Skip to content

Commit

Permalink
Make BOOTSTRAP JVM compatible again
Browse files Browse the repository at this point in the history
JVM doesn't implement nqp::p6capturelexwith
  • Loading branch information
vrurg committed Dec 16, 2023
1 parent 5f8cf56 commit fe40b8e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Perl6/Metamodel/ParametricRoleHOW.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ class Perl6::Metamodel::ParametricRoleHOW
my $error;
try {
my @result := $!body_block(|@pos_args, |%named_args);
nqp::scwbdisable();
$type_env := nqp::ifnull(Perl6::Metamodel::Configuration.type_env_from(@result[1]), @result[1]);
nqp::scwbenable();
CATCH {
$error := $!;
}
Expand Down Expand Up @@ -195,6 +197,8 @@ class Perl6::Metamodel::ParametricRoleHOW
}

method specialize_with($obj, $conc, $type_env, @pos_args) {
# Here we instantiate generics bound to implementation detail lexicals !INS_OF_*. Perhaps, it'd make more
# sense to move this semantics into role body, where a TypeEnv instance would eventaully be created.
my $hll-typeenv := nqp::can($type_env, 'instantiate');
my $ctx := $hll-typeenv ?? $type_env.ctx !! $type_env;
my $ctx-iter := nqp::iterator($ctx);
Expand Down
10 changes: 10 additions & 0 deletions src/Perl6/bootstrap.c/BOOTSTRAP.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,12 @@ BEGIN {
$type.HOW.instantiate_generic($type, $type_environment));
}
if nqp::isconcrete($ci) {
#?if !jvm
nqp::bindattr($ins, Attribute, '$!container_initializer', nqp::p6capturelexwhere($ci.clone()));
#?endif
#?if jvm
nqp::bindattr($ins, Attribute, '$!container_initializer', $ci.clone());
#?endif
}
my $cd_ins := $cd;
if $cd.is_generic {
Expand Down Expand Up @@ -1783,7 +1788,12 @@ BEGIN {
$pkg.HOW.instantiate_generic($pkg, $type_environment));
}
if nqp::defined($bc) {
#?if !jvm
nqp::bindattr($ins, Attribute, '$!build_closure', nqp::p6capturelexwhere($bc.clone()));
#?endif
#?if jvm
nqp::bindattr($ins, Attribute, '$!build_closure', $bc.clone());
#?endif
}
$ins
}));
Expand Down

0 comments on commit fe40b8e

Please sign in to comment.