Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

JVM is sensitive to where savecapture is used.

This corrects it to be used after the signature binder is called. This
fixes complex protos (those that aren't just an onlystar), which in
turn unbusts .=subst(...).
  • Loading branch information...
commit 21185446dcafbedf95e095c7405bc705acf0a77c 1 parent 9ded36c
Jonathan Worthington jnthn authored

Showing 1 changed file with 32 additions and 28 deletions. Show diff stats Hide diff stats

  1. +32 28 src/Perl6/Actions.nqp
60 src/Perl6/Actions.nqp
@@ -2017,20 +2017,6 @@ class Perl6::Actions is HLL::Actions does STDActions {
2017 2017 else {
2018 2018 $block[1] := wrap_return_handler($block[1]);
2019 2019 }
2020   - if $*MULTINESS eq 'proto' {
2021   - # Also stash the current lexical dispatcher and capture, for the {*}
2022   - # to resolve.
2023   - $block[0].push(QAST::Op.new(
2024   - :op('bind'),
2025   - QAST::Var.new( :name('CURRENT_DISPATCH_CAPTURE'), :scope('lexical'), :decl('var') ),
2026   - QAST::Op.new( :op('savecapture') )
2027   - ));
2028   - $block[0].push(QAST::Op.new(
2029   - :op('bind'),
2030   - QAST::Var.new( :name('&*CURRENT_DISPATCHER'), :scope('lexical'), :decl('var') ),
2031   - QAST::Op.new( :op('getcodeobj'), QAST::Op.new( :op('curcode') ) )
2032   - ));
2033   - }
2034 2020 }
2035 2021
2036 2022 # Obtain parameters, create signature object and generate code to
@@ -2065,6 +2051,21 @@ class Perl6::Actions is HLL::Actions does STDActions {
2065 2051 :op('takedispatcher'),
2066 2052 QAST::SVal.new( :value('$*DISPATCHER') )
2067 2053 ));
  2054 +
  2055 + # If it's a proto but not an onlystar, need some variables for the
  2056 + # {*} implementation to use.
  2057 + if $*MULTINESS eq 'proto' && !$<onlystar> {
  2058 + $block[0].push(QAST::Op.new(
  2059 + :op('bind'),
  2060 + QAST::Var.new( :name('CURRENT_DISPATCH_CAPTURE'), :scope('lexical'), :decl('var') ),
  2061 + QAST::Op.new( :op('savecapture') )
  2062 + ));
  2063 + $block[0].push(QAST::Op.new(
  2064 + :op('bind'),
  2065 + QAST::Var.new( :name('&*CURRENT_DISPATCHER'), :scope('lexical'), :decl('var') ),
  2066 + QAST::Op.new( :op('getcodeobj'), QAST::Op.new( :op('curcode') ) )
  2067 + ));
  2068 + }
2068 2069
2069 2070 # Set name.
2070 2071 if $<deflongname> {
@@ -2407,20 +2408,6 @@ class Perl6::Actions is HLL::Actions does STDActions {
2407 2408 else {
2408 2409 $past[1] := wrap_return_handler($past[1]);
2409 2410 }
2410   - if $*MULTINESS eq 'proto' {
2411   - # Also stash the current lexical dispatcher and capture, for the {*}
2412   - # to resolve.
2413   - $past[0].push(QAST::Op.new(
2414   - :op('bind'),
2415   - QAST::Var.new( :name('CURRENT_DISPATCH_CAPTURE'), :scope('lexical'), :decl('var') ),
2416   - QAST::Op.new( :op('savecapture') )
2417   - ));
2418   - $past[0].push(QAST::Op.new(
2419   - :op('bind'),
2420   - QAST::Var.new( :name('&*CURRENT_DISPATCHER'), :scope('lexical'), :decl('var') ),
2421   - QAST::Op.new( :op('getcodeobj'), QAST::Op.new( :op('curcode') ) )
2422   - ));
2423   - }
2424 2411 }
2425 2412
2426 2413 my $name;
@@ -2445,6 +2432,23 @@ class Perl6::Actions is HLL::Actions does STDActions {
2445 2432 $<longname> && $*W.is_lexical('$?CLASS') ?? '$?CLASS' !! 'Mu']);
2446 2433 my $code := methodize_block($/, $*DECLARAND, $past, %sig_info, $inv_type, :yada(is_yada($/)));
2447 2434
  2435 + # If it's a proto but not an onlystar, need some variables for the
  2436 + # {*} implementation to use.
  2437 + if $*MULTINESS eq 'proto' && !$<onlystar> {
  2438 + # Also stash the current lexical dispatcher and capture, for the {*}
  2439 + # to resolve.
  2440 + $past[0].push(QAST::Op.new(
  2441 + :op('bind'),
  2442 + QAST::Var.new( :name('CURRENT_DISPATCH_CAPTURE'), :scope('lexical'), :decl('var') ),
  2443 + QAST::Op.new( :op('savecapture') )
  2444 + ));
  2445 + $past[0].push(QAST::Op.new(
  2446 + :op('bind'),
  2447 + QAST::Var.new( :name('&*CURRENT_DISPATCHER'), :scope('lexical'), :decl('var') ),
  2448 + QAST::Op.new( :op('getcodeobj'), QAST::Op.new( :op('curcode') ) )
  2449 + ));
  2450 + }
  2451 +
2448 2452 # Document it
2449 2453 Perl6::Pod::document($/, $code, $*DOC);
2450 2454

0 comments on commit 2118544

Please sign in to comment.
Something went wrong with that request. Please try again.