Guest User

Untitled

a guest
May 26th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. diff --git a/src/core/Cool-str.pm b/src/core/Cool-str.pm
  2. index a045cd4..e231260 100644
  3. --- a/src/core/Cool-str.pm
  4. +++ b/src/core/Cool-str.pm
  5. @@ -28,8 +28,19 @@ augment class Cool {
  6. return self if @matches == 1 && !@matches[0];
  7. my $prev = 0;
  8. my $result = '';
  9. + my $caller_pad = Q:PIR{
  10. + $P0 = getinterp
  11. + %r = $P0['lexpad';1]
  12. + };
  13. for @matches -> $m {
  14. $result ~= self.substr($prev, $m.from - $prev);
  15. + Q:PIR {
  16. + $P0 = find_lex '$caller_pad'
  17. + if null $P0 goto match_set_done
  18. + $P1 = find_lex '$m'
  19. + $P0['$/'] = $P1
  20. + match_set_done:
  21. + } if $replacement ~~ Callable;
  22. $result ~= ~($replacement ~~ Callable
  23. ?? $replacement($m)
  24. !! $replacement);
  25.  
  26.  
  27. # this is how it fails:
  28.  
  29. ./perl6 -e 'my $x = "foo"; $x.=subst(/./, "F")'
  30. make: Nothing to be done for `all'.
  31. Null PMC access in can()
  32. current instr.: '&infix:<=>' pc 17802 (src/builtins/Junction.pir:198)
  33. called from Sub 'perl6;Cool;subst' pc 421821 (src/gen/core.pir:0)
  34. called from Sub '!dispatch_.=' pc 438 (src/glue/dispatch.pir:117)
  35. called from Sub '_block14' pc 29 (EVAL_1:0)
  36. called from Sub '!YOU_ARE_HERE' pc 383924 (src/gen/core.pir:29685)
  37. called from Sub '!UNIT_START' pc 1400 (src/glue/run.pir:21)
  38. called from Sub 'perl6;HLL;Compiler;_block432' pc -1 ((unknown file):-1)
  39. called from Sub 'perl6;HLL;Compiler;eval' pc 21950 (ext/nqp-rx/src/stage0/HLL-s0.pir:7074)
  40. called from Sub 'perl6;PCT;HLLCompiler;command_line' pc 1504 (compilers/pct/src/PCT/HLLCompiler.pir:801)
  41. called from Sub 'perl6;Perl6;Compiler;main' pc -1 ((unknown file):-1)
Add Comment
Please, Sign In to add comment