Skip to content

Commit d777c90

Browse files
committed
update
1 parent c4a135e commit d777c90

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

3/function_implement.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function my_function(){
8585
return $ret;
8686
}
8787
```
88-
另外参数还有其它的信息,比如默认值、引用传递,这些信息通过`zend_arg_info`结构记录:
88+
另外参数还有其它的信息,这些信息通过`zend_arg_info`结构记录:
8989
```c
9090
typedef struct _zend_arg_info {
9191
zend_string *name; //参数名
@@ -225,7 +225,9 @@ $c = 345; //编译到zend_op_array_1
225225
>> __操作2:__ 每个参数生成一条opcode,如果是可变参数其opcode=ZEND_RECV_VARIADIC,如果有默认值则为ZEND_RECV_INIT,否则为ZEND_RECV
226226
227227
> 上面的例子中$a编号为96,$b为112,同时生成了两条opcode:ZEND_RECV、ZEND_RECV_INIT,调用的时候会根据具体传参数量跳过部分opcode,比如这个函数我们这么调用`my_function($a)`则ZEND_RECV这条opcode就直接跳过了,然后执行ZEND_RECV_INIT将默认值写到112位置,具体的编译过程在`zend_compile_params()`中,上面已经介绍过。
228-
228+
>
229+
> 参数默认值的保存与普通变量赋值相同:`$a = array()``array()`保存在literals,参数的默认值也是如此。
230+
>
229231
> __(3)__ 编译函数内部语法,这个跟普通PHP代码编译过程无异。
230232
231233
> __(4)__ pass_two(),上一篇介绍过,不再赘述。

img/func_exe_call.png

-346 Bytes
Loading

img/func_exe_init.png

-2.26 KB
Loading

img/internal_func_param.png

26.9 KB
Loading

0 commit comments

Comments
 (0)