-1

It is possible to convert HHVM bytecode to PHP?

Something like this:

Pseudo-main at 0
maxStackCells: 1
numLocals: 0
numIterators: 0
  // line 2
    0: String "123"
    5: Print
    6: PopC
    7: Int 1
   16: RetC
Pseudo-main at 0
maxStackCells: 1
numLocals: 0
numIterators: 0

converts into

<?php
 echo "123";
 ?>
Thamilhan
  • 13,040
  • 5
  • 37
  • 59

1 Answers1

1

Yes, it's possible, as you point out in your example. The bytecode repo actually contains much more information than you see in just the bytecode dump -- there's a lot of metadata including variable names, function names, and even comments in some cases. If you were sufficiently determined, you could probably recover something pretty close to the original source code.

But right now the only way to do this is by hand, which requires intimate familiarity with the bytecode format. It's not hard, the format is pretty well documented, just obscure. You could absolutely write a tool to automate this process, though no one has bothered to do it yet.

Josh Watzman
  • 7,060
  • 1
  • 18
  • 26