cvs: ZendEngine2 / zend_compile.c zend_execute.c zend_language_parser.y

From: Date: Thu, 09 Oct 2003 13:44:44 +0000
Subject: cvs: ZendEngine2 / zend_compile.c zend_execute.c zend_language_parser.y
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-1899@lists.php.net to get a copy of this message
zeev Thu Oct 9 09:44:44 2003 EDT Modified files: /ZendEngine2 zend_compile.c zend_execute.c zend_language_parser.y Log: Allow foo::$bar() Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.485 ZendEngine2/zend_compile.c:1.486 --- ZendEngine2/zend_compile.c:1.485 Mon Sep 29 20:32:41 2003 +++ ZendEngine2/zend_compile.c Thu Oct 9 09:44:44 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.485 2003/09/30 00:32:41 moriyoshi Exp $ */ +/* $Id: zend_compile.c,v 1.486 2003/10/09 13:44:44 zeev Exp $ */ #include "zend_language_parser.h" #include "zend.h" @@ -1283,18 +1283,26 @@ { unsigned char *ptr = NULL; long fetch_const_op_number = get_next_op_number(CG(active_op_array)); - zend_op *opline = &CG(active_op_array)->opcodes[fetch_const_op_number-1]; + zend_op *last_op = &CG(active_op_array)->opcodes[fetch_const_op_number-1]; - /* a tmp var is leaked here */ - opline->opcode = ZEND_INIT_STATIC_METHOD_CALL; - if(opline->op2.op_type == IS_CONST && - (sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) == Z_STRLEN(opline->op2.u.constant) && - memcmp(Z_STRVAL(opline->op2.u.constant), ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) == 0) { - zval_dtor(&opline->op2.u.constant); - SET_UNUSED(opline->op2); - } else { - zend_lowercase_znode_if_const(&opline->op2); + if (last_op->opcode == ZEND_FETCH_CONSTANT) { /* regular method call */ + /* a tmp var is leaked here */ + last_op->opcode = ZEND_INIT_STATIC_METHOD_CALL; + if(last_op->op2.op_type == IS_CONST && + (sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) == Z_STRLEN(last_op->op2.u.constant) && + memcmp(Z_STRVAL(last_op->op2.u.constant), ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) == 0) { + zval_dtor(&last_op->op2.u.constant); + SET_UNUSED(last_op->op2); + } else { + zend_lowercase_znode_if_const(&last_op->op2); + } + } else { /* indirect method call */ + zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); + opline->opcode = ZEND_INIT_STATIC_METHOD_CALL; + opline->op1 = last_op->op2; + opline->op2 = last_op->result; } + zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *)); } Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.542 ZendEngine2/zend_execute.c:1.543 --- ZendEngine2/zend_execute.c:1.542 Tue Oct 7 12:04:08 2003 +++ ZendEngine2/zend_execute.c Thu Oct 9 09:44:44 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.c,v 1.542 2003/10/07 16:04:08 zeev Exp $ */ +/* $Id: zend_execute.c,v 1.543 2003/10/09 13:44:44 zeev Exp $ */ #define ZEND_INTENSIVE_DEBUGGING 0 @@ -2422,7 +2422,10 @@ function_name_strlen = EX(opline)->op2.u.constant.value.str.len; } else { function_name = get_zval_ptr(&EX(opline)->op2, EX(Ts), &EG(free_op2), BP_VAR_R); - + + if (Z_TYPE_P(function_name) != IS_STRING) { + zend_error(E_ERROR, "Function name must be a string"); + } function_name_strval = zend_str_tolower_dup(function_name->value.str.val, function_name->value.str.len); function_name_strlen = function_name->value.str.len; } Index: ZendEngine2/zend_language_parser.y diff -u ZendEngine2/zend_language_parser.y:1.125 ZendEngine2/zend_language_parser.y:1.126 --- ZendEngine2/zend_language_parser.y:1.125 Sun Aug 3 13:40:44 2003 +++ ZendEngine2/zend_language_parser.y Thu Oct 9 09:44:44 2003 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_language_parser.y,v 1.125 2003/08/03 17:40:44 zeev Exp $ */ +/* $Id: zend_language_parser.y,v 1.126 2003/10/09 13:44:44 zeev Exp $ */ /* * LALR shift/reduce conflicts and how they are resolved: @@ -592,8 +592,11 @@ function_call_parameter_list ')' { zend_do_end_function_call(&$1, &$$, &$4, 0, $2.u.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); } | class_constant '(' { zend_do_begin_class_member_function_call(TSRMLS_C); zend_do_extended_fcall_begin(TSRMLS_C); } - function_call_parameter_list - ')' { zend_do_end_function_call(NULL, &$$, &$4, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} + function_call_parameter_list + ')' { zend_do_end_function_call(NULL, &$$, &$4, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} + | static_member '(' { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call(TSRMLS_C); zend_do_extended_fcall_begin(TSRMLS_C); } + function_call_parameter_list + ')' { zend_do_end_function_call(NULL, &$$, &$4, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} | variable_without_objects '(' { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_dynamic_function_call(&$1 TSRMLS_CC); } function_call_parameter_list ')' { zend_do_end_function_call(&$1, &$$, &$4, 0, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}

« previous php.zend-engine.cvs (#1899) next »