为什么不调用回调?
Why callback is not called?
我有来自 B::OPCheck module with modified PL_op_name
to padsv
的示例脚本
use B::Generate;
use B::OPCheck padsv => check => sub {
my $op = shift;
print "HERE";
};
my $x;
1;
但是没有调用回调。
在解析这个程序时我可以看到这个OP
:
$perl -Ilib -Iblib/arch -MO=Terse ~/tmp/xs.pl
LISTOP (0x19828f0) leave [1]
OP (0x1c27ef0) enter
COP (0x1982938) nextstate
OP (0x1982998) padsv [1] <<<< HERE IT IS
COP (0x1c27f38) nextstate
OP (0x1c27f98) null [5]
为什么不调用回调?
UPD
似乎 here 是答案:
For most (but not all) types of op, once the op has been initially built and populated with child ops it will be filtered through the check function referenced by the appropriate element of this array
但是在哪里可以找到将通过检查功能过滤的操作列表?
接下来我已经知道了。我应该做
wrap_op_checker(OP_PADANY, my_check, &old_checker);
而不是:
wrap_op_checker(OP_PADSV, my_check, &old_checker);
因为没有创建这种类型的OP。在那一步,它是 OP_PADANY
并且 在 Perl_newSVREF
处被转换 为 OP_PADSV
,这是从 Perl_yyparse+0x1834
.[=20= 的某处调用的]
所以因为这个转换我们不能挂钩OP_PADSV
UPD
此行为不符合 DOC
A check routine is called when the node is fully constructed
我有来自 B::OPCheck module with modified PL_op_name
to padsv
use B::Generate;
use B::OPCheck padsv => check => sub {
my $op = shift;
print "HERE";
};
my $x;
1;
但是没有调用回调。
在解析这个程序时我可以看到这个OP
:
$perl -Ilib -Iblib/arch -MO=Terse ~/tmp/xs.pl
LISTOP (0x19828f0) leave [1]
OP (0x1c27ef0) enter
COP (0x1982938) nextstate
OP (0x1982998) padsv [1] <<<< HERE IT IS
COP (0x1c27f38) nextstate
OP (0x1c27f98) null [5]
为什么不调用回调?
UPD
似乎 here 是答案:
For most (but not all) types of op, once the op has been initially built and populated with child ops it will be filtered through the check function referenced by the appropriate element of this array
但是在哪里可以找到将通过检查功能过滤的操作列表?
接下来我已经知道了。我应该做
wrap_op_checker(OP_PADANY, my_check, &old_checker);
而不是:
wrap_op_checker(OP_PADSV, my_check, &old_checker);
因为没有创建这种类型的OP。在那一步,它是 OP_PADANY
并且 在 Perl_newSVREF
处被转换 为 OP_PADSV
,这是从 Perl_yyparse+0x1834
.[=20= 的某处调用的]
所以因为这个转换我们不能挂钩OP_PADSV
UPD
此行为不符合 DOC
A check routine is called when the node is fully constructed