cvs: ZendEngine2 / zend_compile.c

From: Date: Wed, 08 Jun 2005 15:01:38 +0000
Subject: cvs: ZendEngine2 / zend_compile.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-3761@lists.php.net to get a copy of this message
dmitry Wed Jun 8 11:01:38 2005 EDT Modified files: /ZendEngine2 zend_compile.c Log: Fixed lookups for previos opcodes

http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.631&r2=1.632&ty=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.631 ZendEngine2/zend_compile.c:1.632 --- ZendEngine2/zend_compile.c:1.631 Wed Jun 8 02:49:00 2005 +++ ZendEngine2/zend_compile.c Wed Jun 8 11:01:35 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.631 2005/06/08 06:49:00 dmitry Exp $ */ +/* $Id: zend_compile.c,v 1.632 2005/06/08 15:01:35 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -291,40 +291,44 @@ void zend_do_binary_assign_op(zend_uchar op, znode *result, znode *op1, znode *op2 TSRMLS_DC) { - int last_op_number = get_next_op_number(CG(active_op_array))-1; + int last_op_number = get_next_op_number(CG(active_op_array)); zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); - zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number]; - - switch (last_op->opcode) { - case ZEND_FETCH_OBJ_RW: - last_op->opcode = op; - last_op->extended_value = ZEND_ASSIGN_OBJ; - - zend_do_op_data(opline, op2 TSRMLS_CC); - SET_UNUSED(opline->result); - *result = last_op->result; - break; - case ZEND_FETCH_DIM_RW: - last_op->opcode = op; - last_op->extended_value = ZEND_ASSIGN_DIM; - zend_do_op_data(opline, op2 TSRMLS_CC); - opline->op2.u.var = get_temporary_variable(CG(active_op_array)); - opline->op2.u.EA.type = 0; - opline->op2.op_type = IS_VAR; - SET_UNUSED(opline->result); - *result = last_op->result; - break; - default: - opline->opcode = op; - opline->op1 = *op1; - opline->op2 = *op2; - opline->result.op_type = IS_VAR; - opline->result.u.EA.type = 0; - opline->result.u.var = get_temporary_variable(CG(active_op_array)); - *result = opline->result; - break; + if (last_op_number > 0) { + zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number-1]; + + switch (last_op->opcode) { + case ZEND_FETCH_OBJ_RW: + last_op->opcode = op; + last_op->extended_value = ZEND_ASSIGN_OBJ; + + zend_do_op_data(opline, op2 TSRMLS_CC); + SET_UNUSED(opline->result); + *result = last_op->result; + return; + case ZEND_FETCH_DIM_RW: + last_op->opcode = op; + last_op->extended_value = ZEND_ASSIGN_DIM; + + zend_do_op_data(opline, op2 TSRMLS_CC); + opline->op2.u.var = get_temporary_variable(CG(active_op_array)); + opline->op2.u.EA.type = 0; + opline->op2.op_type = IS_VAR; + SET_UNUSED(opline->result); + *result = last_op->result; + return; + default: + break; + } } + + opline->opcode = op; + opline->op1 = *op1; + opline->op2 = *op2; + opline->result.op_type = IS_VAR; + opline->result.u.EA.type = 0; + opline->result.u.var = get_temporary_variable(CG(active_op_array)); + *result = opline->result; } void fetch_simple_variable_ex(znode *result, znode *varname, int bp, zend_uchar op TSRMLS_DC) @@ -530,38 +534,43 @@ void zend_do_assign(znode *result, znode *variable, znode *value TSRMLS_DC) { - int last_op_number = get_next_op_number(CG(active_op_array))-1; + int last_op_number = get_next_op_number(CG(active_op_array)); zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); - zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number]; - if (last_op->opcode == ZEND_FETCH_OBJ_W) { - last_op->opcode = ZEND_ASSIGN_OBJ; + if (last_op_number > 0) { + zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number-1]; - zend_do_op_data(opline, value TSRMLS_CC); - SET_UNUSED(opline->result); - *result = last_op->result; - } else if (last_op->opcode == ZEND_FETCH_DIM_W) { - last_op->opcode = ZEND_ASSIGN_DIM; - - zend_do_op_data(opline, value TSRMLS_CC); - opline->op2.u.var = get_temporary_variable(CG(active_op_array)); - opline->op2.u.EA.type = 0; - opline->op2.op_type = IS_VAR; - SET_UNUSED(opline->result); - *result = last_op->result; - } else { - if (opline_is_fetch_this(last_op TSRMLS_CC)) { - zend_error(E_COMPILE_ERROR, "Cannot re-assign $this"); - } + if (last_op->opcode == ZEND_FETCH_OBJ_W) { + last_op->opcode = ZEND_ASSIGN_OBJ; - opline->opcode = ZEND_ASSIGN; - opline->op1 = *variable; - opline->op2 = *value; - opline->result.op_type = IS_VAR; - opline->result.u.EA.type = 0; - opline->result.u.var = get_temporary_variable(CG(active_op_array)); - *result = opline->result; + zend_do_op_data(opline, value TSRMLS_CC); + SET_UNUSED(opline->result); + *result = last_op->result; + return; + } else if (last_op->opcode == ZEND_FETCH_DIM_W) { + last_op->opcode = ZEND_ASSIGN_DIM; + + zend_do_op_data(opline, value TSRMLS_CC); + opline->op2.u.var = get_temporary_variable(CG(active_op_array)); + opline->op2.u.EA.type = 0; + opline->op2.op_type = IS_VAR; + SET_UNUSED(opline->result); + *result = last_op->result; + return; + } else { + if (opline_is_fetch_this(last_op TSRMLS_CC)) { + zend_error(E_COMPILE_ERROR, "Cannot re-assign $this"); + } + } } + + opline->opcode = ZEND_ASSIGN; + opline->op1 = *variable; + opline->op2 = *value; + opline->result.op_type = IS_VAR; + opline->result.u.EA.type = 0; + opline->result.u.var = get_temporary_variable(CG(active_op_array)); + *result = opline->result; } static inline zend_bool zend_is_function_or_method_call(znode *variable) @@ -573,14 +582,18 @@ void zend_do_assign_ref(znode *result, znode *lvar, znode *rvar TSRMLS_DC) { - int last_op_number = get_next_op_number(CG(active_op_array))-1; + int last_op_number = get_next_op_number(CG(active_op_array)); zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); - zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number]; - opline->opcode = ZEND_ASSIGN_REF; - if (opline_is_fetch_this(last_op TSRMLS_CC)) { - zend_error(E_COMPILE_ERROR, "Cannot re-assign $this"); + if (last_op_number > 0) { + zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number-1]; + + if (opline_is_fetch_this(last_op TSRMLS_CC)) { + zend_error(E_COMPILE_ERROR, "Cannot re-assign $this"); + } } + + opline->opcode = ZEND_ASSIGN_REF; if (zend_is_function_or_method_call(rvar)) { opline->extended_value = ZEND_RETURNS_FUNCTION; } else { @@ -700,22 +713,26 @@ void zend_do_pre_incdec(znode *result, znode *op1, zend_uchar op TSRMLS_DC) { - int last_op_number = get_next_op_number(CG(active_op_array))-1; - zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); - zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number]; + int last_op_number = get_next_op_number(CG(active_op_array)); + zend_op *opline; - if (last_op->opcode == ZEND_FETCH_OBJ_RW) { - opline->opcode = (op==ZEND_PRE_INC)?ZEND_PRE_INC_OBJ:ZEND_PRE_DEC_OBJ; - opline->op1 = last_op->op1; - opline->op2 = last_op->op2; - - MAKE_NOP(last_op); - } else { - opline->opcode = op; - opline->op1 = *op1; - SET_UNUSED(opline->op2); + if (last_op_number > 0) { + zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number-1]; + + if (last_op->opcode == ZEND_FETCH_OBJ_RW) { + last_op->opcode = (op==ZEND_PRE_INC)?ZEND_PRE_INC_OBJ:ZEND_PRE_DEC_OBJ; + last_op->result.op_type = IS_VAR; + last_op->result.u.EA.type = 0; + last_op->result.u.var = get_temporary_variable(CG(active_op_array)); + *result = last_op->result; + return; + } } + opline = get_next_op(CG(active_op_array) TSRMLS_CC); + opline->opcode = op; + opline->op1 = *op1; + SET_UNUSED(opline->op2); opline->result.op_type = IS_VAR; opline->result.u.EA.type = 0; opline->result.u.var = get_temporary_variable(CG(active_op_array)); @@ -725,21 +742,25 @@ void zend_do_post_incdec(znode *result, znode *op1, zend_uchar op TSRMLS_DC) { - int last_op_number = get_next_op_number(CG(active_op_array))-1; - zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); - zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number]; + int last_op_number = get_next_op_number(CG(active_op_array)); + zend_op *opline; - if (last_op->opcode == ZEND_FETCH_OBJ_RW) { - opline->opcode = (op==ZEND_POST_INC)?ZEND_POST_INC_OBJ:ZEND_POST_DEC_OBJ; - opline->op1 = last_op->op1; - opline->op2 = last_op->op2; - - MAKE_NOP(last_op); - } else { - opline->opcode = op; - opline->op1 = *op1; - SET_UNUSED(opline->op2); + if (last_op_number > 0) { + zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number-1]; + + if (last_op->opcode == ZEND_FETCH_OBJ_RW) { + last_op->opcode = (op==ZEND_POST_INC)?ZEND_POST_INC_OBJ:ZEND_POST_DEC_OBJ; + last_op->result.op_type = IS_TMP_VAR; + last_op->result.u.var = get_temporary_variable(CG(active_op_array)); + *result = last_op->result; + return; + } } + + opline = get_next_op(CG(active_op_array) TSRMLS_CC); + opline->opcode = op; + opline->op1 = *op1; + SET_UNUSED(opline->op2); opline->result.op_type = IS_TMP_VAR; opline->result.u.var = get_temporary_variable(CG(active_op_array)); *result = opline->result;
« previous php.zend-engine.cvs (#3761) next »