2018-07-06 php internal - zend_stack zend_stack 定义 12345678910111213141516typedef struct _zend_stack {// size为栈中最大元素的大小 int size, top, max; void *elements;} zend_stack;#define ZEND_STACK_ELEMENT(stack, n) ((void *)((char *) (stack)->elements + (stack)->size * (n)))+--------+ +- size -+|size | +--------+|top | +----->| ||max | | | ||elments +-----+ | |+--------+ | | +--------+ 栈的常用API 123456789101112ZEND_API int zend_stack_init(zend_stack *stack, int size);ZEND_API int zend_stack_push(zend_stack *stack, const void *element);ZEND_API void *zend_stack_top(const zend_stack *stack);ZEND_API int zend_stack_del_top(zend_stack *stack);ZEND_API int zend_stack_int_top(const zend_stack *stack);ZEND_API int zend_stack_is_empty(const zend_stack *stack);ZEND_API int zend_stack_destroy(zend_stack *stack);ZEND_API void *zend_stack_base(const zend_stack *stack);ZEND_API int zend_stack_count(const zend_stack *stack);ZEND_API void zend_stack_apply(zend_stack *stack, int type, int (*apply_function)(void *element));ZEND_API void zend_stack_apply_with_argument(zend_stack *stack, int type, int (*apply_function)(void *element, void *arg), void *arg);ZEND_API void zend_stack_clean(zend_stack *stack, void (*func)(void *), zend_bool free_elements); zend_stack的应用 词法分析 注册错误和异常处理函数 Newer php internal - zend_string Older php internal - 数据类型