summaryrefslogtreecommitdiff
path: root/ext/B/t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-12-01 22:26:33 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-12-02 14:11:26 -0800
commit429ba3b2012d512799f9533216081e1375fad0cb (patch)
treec5deef0d4cf63c5569d2d49508d2dd67149a9fb6 /ext/B/t
parent4a31a50691fe6d239cc60d9cce54883f1bfb1214 (diff)
downloadperl-429ba3b2012d512799f9533216081e1375fad0cb.tar.gz
Add B::PMOP::pmregexp
There was no way to get from a PMOP to its regexp object under non- threaded builds. The threaded pmoffset field was exposed, but not its non-threaded counterpart. I implemented pmregexp in terms of PM_GETRE (which uses op_pmoffset with threads and op_pmregexp without), so it works under threads, too. It’s easier than conditionally using the regex_padav to get at things like this: $ ./perl -Ilib -MB -e 'use O "Concise", B::regex_padav->ARRAYelt(B::svref_2object(sub {qr/(??{})/})->ROOT->first->first->sibling->pmoffset)->qr_anoncv->object_2svref' B::Concise::compile(CODE(0x7f8e9185ba08)) 2 <1> leavesub[1 ref] K/REFC,1 ->(end) 1 </> qr() P/RTIME ->2 - <@> list K ->- - <0> pushmark s ->- - <1> null sK*/1 ->- - <1> ex-scope sK ->(end) - <0> stub s ->(end) - <$> const(PV "(\077?{})") s ->- -e syntax OK With pmregexp, it is ‘only’: $ ./perl -Ilib -MB -e 'use O "Concise", B::svref_2object(sub {qr/(??{})/})->ROOT->first->first->sibling->pmregexp->qr_anoncv->object_2svref'
Diffstat (limited to 'ext/B/t')
-rw-r--r--ext/B/t/b.t5
1 files changed, 5 insertions, 0 deletions
diff --git a/ext/B/t/b.t b/ext/B/t/b.t
index fc0ac3f151..abffa3246e 100644
--- a/ext/B/t/b.t
+++ b/ext/B/t/b.t
@@ -340,6 +340,11 @@ SKIP: {
'different COP->stashoff for different stashes';
}
+my $pmop = B::svref_2object(sub{ qr/fit/ })->ROOT->first->first->sibling;
+$regexp = $pmop->pmregexp;
+is B::class($regexp), 'REGEXP', 'B::PMOP::pmregexp returns a regexp';
+is $regexp->precomp, 'fit', 'pmregexp returns the right regexp';
+
# Test $B::overlay
{