Permalink
Browse files

Fix $/ setting and $_ lookup a bit.

We "got lucky" because the callframe of the proto was magically going
missing, thanks to an optimization. This should resolve it, for now at
least, though it feels like we're missing a more real solution.
  • Loading branch information...
1 parent 23f38ed commit f81a1274ca4353075b16a2512e71de7b7fec72f6 @jnthn jnthn committed Mar 13, 2013
Showing with 23 additions and 9 deletions.
  1. +5 −1 src/core/Cool.pm
  2. +18 −8 src/core/Regex.pm
View
@@ -168,8 +168,12 @@ my class Cool {
multi method comb() { self.Str.comb() }
multi method comb(Regex $matcher, $limit = $Inf) { self.Str.comb($matcher, $limit) }
- proto method subst(|) {*}
+ proto method subst(|) {
+ $/ := nqp::getlexdyn('$/');
+ {*}
+ }
multi method subst($matcher, $replacement, *%adverbs) {
+ $/ := nqp::getlexdyn('$/');
self.Stringy.subst($matcher, $replacement, |%adverbs);
}
View
@@ -1,20 +1,25 @@
my class Regex {
multi method ACCEPTS(Regex:D \SELF: Mu \topic) {
- my $match = SELF.(Cursor."!cursor_init"(topic, :c(0))).MATCH_SAVE;
- pir::find_caller_lex__Ps('$/') = $match;
- $match
+ my $dollar_slash := pir::find_dynamic_lex_relative__PPs(
+ nqp::ctxcaller(nqp::ctxcaller(nqp::ctx())),
+ '$/');
+ $dollar_slash = SELF.(Cursor."!cursor_init"(topic, :c(0))).MATCH_SAVE;
}
multi method ACCEPTS(Regex:D \SELF: @a) {
- my $dollar_slash := pir::find_caller_lex__Ps('$/');
+ my $dollar_slash := pir::find_dynamic_lex_relative__PPs(
+ nqp::ctxcaller(nqp::ctxcaller(nqp::ctx())),
+ '$/');
for @a {
$dollar_slash = SELF.(Cursor.'!cursor_init'($_, :c(0))).MATCH_SAVE;
return $dollar_slash if $dollar_slash;
}
Nil;
}
multi method ACCEPTS(Regex:D \SELF: %h) {
- my $dollar_slash := pir::find_caller_lex__Ps('$/');
+ my $dollar_slash := pir::find_dynamic_lex_relative__PPs(
+ nqp::ctxcaller(nqp::ctxcaller(nqp::ctx())),
+ '$/');
for %h.keys {
$dollar_slash = SELF.(Cursor.'!cursor_init'($_, :c(0))).MATCH_SAVE;
return $dollar_slash if $dollar_slash;
@@ -23,8 +28,13 @@ my class Regex {
}
multi method Bool(Regex:D:) {
- my $match = pir::find_caller_lex__Ps('$_').match(self);
- pir::find_caller_lex__Ps('$/') = $match;
- $match.Bool()
+ my $dollar_slash := pir::find_dynamic_lex_relative__PPs(
+ nqp::ctxcaller(nqp::ctxcaller(nqp::ctx())),
+ '$/');
+ my $dollar_underscore := pir::find_dynamic_lex_relative__PPs(
+ nqp::ctxcaller(nqp::ctxcaller(nqp::ctx())),
+ '$_');
+ $dollar_slash = $dollar_underscore.match(self);
+ $dollar_slash.Bool()
}
}

0 comments on commit f81a127

Please sign in to comment.