Source code opcode?

Is there a way to create perl source code if I have opcode?

for instance

perl -MO=Concise -e "print 123" 

displays the operation code:

 6 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v:{ ->3 5 <@> print vK ->6 3 <0> pushmark s ->4 4 <$> const[IV 123] s ->5 

I would like to somehow cancel this.

+6
source share
1 answer

If by "operation code" you mean "have a tree of operation code"

While B :: Concise is trying to give an accurate representation of the opcode tree, B :: Deparse takes the opcode tree and outputs the source code from it.

 $ perl -MO=Deparse -e'$x && print' print $_ if $x; -e syntax OK 

This is not bad, although there are some limitations.

If in the "have opcode" section, you mean "have B :: Concise output"

Given that B :: Concise is trying to be very complete, it might be possible, but I think some information is missing. I am pretty sure that there is nothing trying to do this on CPAN, since I have never heard that pallor violates it (something that you would expect regularly).

+3
source

Source: https://habr.com/ru/post/980097/


All Articles