This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add B::PMOP::pmregexp
authorFather Chrysostomos <sprout@cpan.org>
Tue, 2 Dec 2014 06:26:33 +0000 (22:26 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 2 Dec 2014 22:11:26 +0000 (14:11 -0800)
commit429ba3b2012d512799f9533216081e1375fad0cb
treec5deef0d4cf63c5569d2d49508d2dd67149a9fb6
parent4a31a50691fe6d239cc60d9cce54883f1bfb1214
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'
ext/B/B.pm
ext/B/B.xs
ext/B/t/b.t