简体   繁体   English

将 HHVM 字节码转换为 PHP

[英]Converting HHVM bytecode to PHP

It is possible to convert HHVM bytecode to PHP?可以将 HHVM 字节码转换为 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";
 ?>

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.你绝对可以编写一个工具来自动化这个过程,尽管还没有人愿意这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM