我试图理解一个简单代码的操作码。
代码是:
<?php
$a = TRUE;
$b = FALSE;
if($a && $b) {
echo 'done';
}
上述代码的操作码为:
php -dvld.active=1 test.php
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
Jump found. Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
Jump found. Position 1 = 7
Branch analysis from position: 7
Return found
Branch analysis from position: 7
Branch analysis from position: 4
filename: /home/starlays/learning/test.php
function name: (null)
number of ops: 8
compiled vars: !0 = $a, !1 = $b
line # * op fetch ext return operands
---------------------------------------------------------------------------------
3 0 > ASSIGN !0, true
5 1 ASSIGN !1, false
7 2 > JMPZ_EX ~2 !0, ->4
3 > BOOL ~2 !1
4 > > JMPZ ~2, ->7
8 5 > ECHO 'done'
9 6 > JMP ->7
10 7 > > RETURN 1
branch: # 0; line: 3- 7; sop: 0; eop: 2; out1: 3; out2: 4
branch: # 3; line: 7- 7; sop: 3; eop: 3; out1: 4
branch: # 4; line: 7- 7; sop: 4; eop: 4; out1: 5; out2: 7
branch: # 5; line: 8- 9; sop: 5; eop: 6; out1: 7
branch: # 7; line: 10- 10; sop: 7; eop: 7
path #1: 0, 3, 4, 5, 7,
path #2: 0, 3, 4, 7,
path #3: 0, 4, 5, 7,
path #4: 0, 4, 7,
我试图了解第 7 行发生了什么,评估是如何完成的?它在 if 的表达式中输入了多少值进行评估?它输入 3 个值,还是输入 2 个值 $a 的值和 $b 的值,然后计算 if 括号中的表达式?
我已经阅读了 JMPZ_EX的手册,我已经了解操作代码中发生的事情,直到步骤 2 之后有点混淆,我很难理解 php 正在执行的确切步骤。
我需要了解的另一件事是操作代码中的所有分支是什么,最后将使用所有分支中的哪一个?