In perl.git, the branch sprout/deparse has been created
<http://perl5.git.perl.org/perl.git/commitdiff/ce7b6a180723c1b89e2044d7868aa8eba334fbcd?hp=0000000000000000000000000000000000000000>
at ce7b6a180723c1b89e2044d7868aa8eba334fbcd (commit)
- Log -----------------------------------------------------------------
commit ce7b6a180723c1b89e2044d7868aa8eba334fbcd
Author: Father Chrysostomos <[email protected]>
Date: Tue Dec 2 22:25:59 2014 -0800
Deparse.pm: Fold some logic into sub code_list
Both callers were doing $op->first->sibling, so just have code_list
do that itself.
M lib/B/Deparse.pm
commit 995959adb276fc607d3920ca663532c41158d03e
Author: Father Chrysostomos <[email protected]>
Date: Tue Dec 2 22:22:25 2014 -0800
Deparse qr// and m// with code blocks and vars
Before, this:
/$a(?{ die $b; })/;
qr/$a(?{ die $b; })/;
would deparse as this:
/${a}do {
die $b
}(?{ die $b; })/;
qr/sub : lvalue {
$a, do {
die $b
}, '(?{ die $b; })'
}
->()/;
Now it deparses correctly.
M lib/B/Deparse-subclass.t
M lib/B/Deparse.pm
commit 976d7d3a1fe476b213f4f779dda40c88638db3fc
Author: Father Chrysostomos <[email protected]>
Date: Tue Dec 2 18:10:35 2014 -0800
Deparse regexp code blocks in m// and split //
The blocks themselves are now deparsed, rather than the original strings
being emitted. This fixes problems with newlines turning into \n and
here-docs missing their bodies. It only applies to compile-time patterns.
Run-time patterns (with variables interpolated outside the code blocks)
are still unfixed and deparse with do{...} embedded in the pattern.
M lib/B/Deparse.pm
M lib/B/Deparse.t
commit 0291301f952cbb304d2dfeae1dbf4ccd97af70d8
Author: Father Chrysostomos <[email protected]>
Date: Tue Dec 2 14:53:32 2014 -0800
Deparse.t: Put a line break after the test code
The line break gets removed when it is extracted from the __DATA__
section, and then it gets wrapped in sub{$input}. That breaks
here-docs.
M lib/B/Deparse.t
commit 0bb922fdd6967f5617682995fbb26a05426d40c9
Author: Father Chrysostomos <[email protected]>
Date: Tue Dec 2 09:33:38 2014 -0800
Deparse qr/(?{code_blocks})/ with no interpolation
This is a preliminary patch that only applies when there are no varia-
bles interpolated into the pattern outside of the code blocks.
The code blocks are now actually deparsed, instead of the stringified
form just being reproduced. This means the \n bug is gone:
Before:
$ ./perl -Ilib -mO=Deparse -e '{ qr/aaaaa\\\\\\(?{;' -e '$y})' -e '/}'
{
qr/aaaaa\\\\\\(?{;\n\$y})\n/;
}
-e syntax OK
After:
$ ./perl -Ilib -mO=Deparse -e '{ qr/aaaaa\\\\\\(?{;' -e '$y})' -e '/}'
{
qr/aaaaa\\\\\\(?{ $y; })\n/;
}
-e syntax OK
You can see the \n translation now happens only outside of the block.
It also means here-docs work:
Before:
$ ./perl -Ilib -mO=Deparse -e 'qr/(??{<<END})/' -efoo -eEND
qr/(??{<<END})/;
-e syntax OK
(The output is a syntax error.)
After:
$ ./perl -Ilib -mO=Deparse -e 'qr/(??{<<END})/' -efoo -eEND
qr/(??{ "foo\n"; })/;
-e syntax OK
M lib/B/Deparse.pm
commit d5bcb4c0526a47ab62d6e5bff69fee2e244b1a75
Author: Father Chrysostomos <[email protected]>
Date: Tue Dec 2 06:06:05 2014 -0800
Deparse FOO =~ y///r correctly
Apparently anything =~ y///r with the /r never deparsed properly (just
the lhs deparsed) until 05a502dc, when lexicals on the lhs started
being emitted.
M lib/B/Deparse.pm
M lib/B/Deparse.t
commit e79c2677b9b458d05ef521e4e2ed17e1946ff0a5
Author: Father Chrysostomos <[email protected]>
Date: Tue Dec 2 05:57:40 2014 -0800
Fix deparsing of $lexical =~ //
I broke this in 05a502dc.
M lib/B/Deparse.pm
M lib/B/Deparse.t
commit c3a2f9a6871f9022fb0d1415aca4d1bf49505e41
Author: Father Chrysostomos <[email protected]>
Date: Tue Dec 2 05:51:36 2014 -0800
Deparse: matchop: Remove double method+function call
M lib/B/Deparse.pm
commit c7284ed7bff623b3bbf1f38d3071155d891d4002
Author: Father Chrysostomos <[email protected]>
Date: Mon Dec 1 22:26:33 2014 -0800
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'
M ext/B/B.pm
M ext/B/B.xs
M ext/B/t/b.t
commit 7b4a18f58692ec4147ea93ab446f6af570700ca9
Author: Father Chrysostomos <[email protected]>
Date: Mon Dec 1 22:08:49 2014 -0800
b.t: Move a test
This should go with the other regexp tests.
M ext/B/t/b.t
commit be8da4a7853e04f2a57fd07773a3a866dbbe9f0f
Author: Father Chrysostomos <[email protected]>
Date: Mon Dec 1 22:32:41 2014 -0800
To-do tests for deparsing regexp code blocks
Currently we have various bugs:
⢠Line breaks often come out as \n, changing the meaning.
⢠Some blocks are doubled up with do{...} for the first instance.
⢠qr/sub { .... }/ madness
M lib/B/Deparse-subclass.t
M lib/B/Deparse.t
-----------------------------------------------------------------------
--
Perl5 Master Repository