php5.3和php5.4

php中有个结构体znode。今天在编译扩展时候。不能通过

opcodes_dumper.cpp:250: error: ‘struct _znode’ has no member named ‘op’

opcodes_dumper.cpp:254: error: ‘struct _znode’ has no member named ‘op’

opcodes_dumper.cpp:258: error: ‘union _znode::<anonymous>’ has no member named ‘var’

找到原因了,是因为安装的php5.4.0,可以看看Zend/zend_compile.h下关于znode的定义,

以下是在php5.3以下版本中:

typedef struct _znode {
        int op_type;
        union {
                zval constant;

                zend_uint var;
                zend_uint opline_num; /*  Needs to be signed */
                zend_op_array *op_array;
                zend_op *jmp_addr;
                struct {
                        zend_uint var;  /* dummy */
                        zend_uint type;
                } EA;
        } u;
} znode;

这是在php5.3以下版本zend_op的结构

struct _zend_op {
        opcode_handler_t handler; //op的handler都定义在{PHPSRC}/Zend/zend_vm_execute.h中
        znode result;
        znode op1;
        znode op2;
        ulong extended_value;
        uint lineno;
        zend_uchar opcode;
};

临时变量:

typedef union _temp_variable {
	zval tmp_var;
	struct {
		zval **ptr_ptr;
		zval *ptr;
		zend_bool fcall_returned_reference;
	} var;
	struct {
		zval **ptr_ptr;
		zval *ptr;
		zend_bool fcall_returned_reference;
		zval *str;
		zend_uint offset;
	} str_offset;
	struct {
		zval **ptr_ptr;
		zval *ptr;
		zend_bool fcall_returned_reference;
		HashPointer fe_pos;
	} fe;
	zend_class_entry *class_entry;
} temp_variable;

以下是在php5.4以上版本中:将其中几项都独立出来了

typedef union _znode_op {
        zend_uint      constant;
        zend_uint      var;
        zend_uint      num;
        zend_ulong     hash;
        zend_uint      opline_num; /*  Needs to be signed */
        zend_op       *jmp_addr;
        zval          *zv;
        zend_literal  *literal;
  void          *ptr;        /* Used for passing pointers from the compile to execution phase, currently used for traits */
} znode_op;

typedef struct _znode { /* used only during compilation */
        int op_type;
        union {
                znode_op op;
                zval constant; /* replaced by literal/zv */
                zend_op_array *op_array;
        } u;
        zend_uint EA;      /* extended attributes */
} znode;

这是在php5.4以上版本中zend_op的结构

struct _zend_op {
        opcode_handler_t handler; //op的handler都定义在{PHPSRC}/Zend/zend_vm_execute.h中
        znode_op op1;
        znode_op op2;
        znode_op result;
        ulong extended_value;
        uint lineno;
        zend_uchar opcode;
        zend_uchar op1_type;
        zend_uchar op2_type;
        zend_uchar result_type;
};

op_array结构:

struct _zend_op_array {
	/* Common elements */
	zend_uchar type;
	const char *function_name;		
	zend_class_entry *scope;
	zend_uint fn_flags;
	union _zend_function *prototype;
	zend_uint num_args;
	zend_uint required_num_args;
	zend_arg_info *arg_info;
	/* END of common elements */

	zend_uint *refcount;

	zend_op *opcodes;
	zend_uint last;

	zend_compiled_variable *vars;
	int last_var;

	zend_uint T;

	zend_brk_cont_element *brk_cont_array;
	int last_brk_cont;

	zend_try_catch_element *try_catch_array;
	int last_try_catch;

	/* static variables support */
	HashTable *static_variables;

	zend_uint this_var;

	const char *filename;
	zend_uint line_start;
	zend_uint line_end;
	const char *doc_comment;
	zend_uint doc_comment_len;
	zend_uint early_binding; /* the linked list of delayed declarations */

	zend_literal *literals;
	int last_literal;

	void **run_time_cache;
	int  last_cache_slot;

	void *reserved[ZEND_MAX_RESERVED_RESOURCES];
};


你可能感兴趣的:(php5.3和php5.4)