質問

I want to get the total number of opcodes a given (user-defined) function has.

For my purpose, I'm not interested in knowing what the specific opcodes are, just how many exist.

I know of two PECL extensions that would allow me to get this information easily:

Unfortunately, vld only dumps information for a whole script/file (I just want the function). On the other hand, parsekit looks great but it (still) is incompatible with PHP 5.4, which is a shame. I know I could patch it, but I would rather not get my hands dirty and wait for the fix to be included in the main package.

So my question is, is it possible to extrapolate the number of opcodes from the source code tokens?

If yes, what tokens should I ignore / combine / count?

役に立ちましたか?

解決

After seeing this I am now 100% sure it would be a major headache to reliably extract the opcodes.

Basically, I would have to write a PHP parser in PHP, which isn't an option.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top