cvs: ZendEngine2 / zend_execute.c zend_language_parser.y

From: Date: Mon, 14 Oct 2002 20:13:03 +0000
Subject: cvs: ZendEngine2 / zend_execute.c zend_language_parser.y
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-511@lists.php.net to get a copy of this message
andi Mon Oct 14 16:13:03 2002 EDT Modified files: /ZendEngine2 zend_execute.c zend_language_parser.y Log: - Support new classname::$class_name, e.g.: <? class foo::bar { public $hello = "Hello, World\n"; } $name = "bar"; $obj = new foo::$name; print $obj->hello; ?> Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.372 ZendEngine2/zend_execute.c:1.373 --- ZendEngine2/zend_execute.c:1.372 Wed Oct 9 10:21:40 2002 +++ ZendEngine2/zend_execute.c Mon Oct 14 16:13:03 2002 @@ -1798,14 +1798,14 @@ case ZEND_FETCH_CLASS: { zend_class_entry **pce; + zend_bool is_const; + char *class_name_strval; + zend_uint class_name_strlen; + zval *class_name; + zval tmp; + int retval; if (EX(opline)->op1.op_type == IS_UNUSED) { - zval tmp; - zval *class_name; - zend_bool is_const; - char *class_name_strval; - zend_uint class_name_strlen; - if (EX(opline)->extended_value == ZEND_FETCH_CLASS_SELF) { if (!EG(scope)) { zend_error(E_ERROR, "Cannot fetch self:: when no class scope is active"); @@ -1824,40 +1824,40 @@ } EX(Ts)[EX(opline)->result.u.var].EA.class_entry = EG(scope)->parent; NEXT_OPCODE(); - } + } + } - is_const = (EX(opline)->op2.op_type == IS_CONST); + is_const = (EX(opline)->op2.op_type == IS_CONST); - if (is_const) { - class_name_strval = EX(opline)->op2.u.constant.value.str.val; - class_name_strlen = EX(opline)->op2.u.constant.value.str.len; - } else { - class_name = get_zval_ptr(&EX(opline)->op2, EX(Ts), &EG(free_op2), BP_VAR_R); + if (is_const) { + class_name_strval = EX(opline)->op2.u.constant.value.str.val; + class_name_strlen = EX(opline)->op2.u.constant.value.str.len; + } else { + class_name = get_zval_ptr(&EX(opline)->op2, EX(Ts), &EG(free_op2), BP_VAR_R); - tmp = *class_name; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - zend_str_tolower(tmp.value.str.val, tmp.value.str.len); + tmp = *class_name; + zval_copy_ctor(&tmp); + convert_to_string(&tmp); + zend_str_tolower(tmp.value.str.val, tmp.value.str.len); - class_name_strval = tmp.value.str.val; - class_name_strlen = tmp.value.str.len; - } + class_name_strval = tmp.value.str.val; + class_name_strlen = tmp.value.str.len; + } - if (zend_lookup_class(class_name_strval, class_name_strlen, &pce TSRMLS_CC) == FAILURE) { - zend_error(E_ERROR, "Class '%s' not found", class_name_strval); - } else { - EX(Ts)[EX(opline)->result.u.var].EA.class_entry = *pce; - } - if (!is_const) { - zval_dtor(&tmp); - FREE_OP(EX(Ts), &EX(opline)->op2, EG(free_op2)); - } + if (EX(opline)->op1.op_type == IS_UNUSED) { + retval = zend_lookup_class(class_name_strval, class_name_strlen, &pce TSRMLS_CC); } else { - if (zend_hash_find(&EX(Ts)[EX(opline)->op1.u.var].EA.class_entry->class_table, EX(opline)->op2.u.constant.value.str.val, EX(opline)->op2.u.constant.value.str.len+1, (void **)&pce) == FAILURE) { - zend_error(E_ERROR, "Class '%s' not found", EX(opline)->op2.u.constant.value.str.val); - } else { - EX(Ts)[EX(opline)->result.u.var].EA.class_entry = *pce; - } + retval = zend_hash_find(&EX(Ts)[EX(opline)->op1.u.var].EA.class_entry->class_table, class_name_strval, class_name_strlen+1, (void **)&pce); + } + + if (retval == FAILURE) { + zend_error(E_ERROR, "Class '%s' not found", class_name_strval); + } else { + EX(Ts)[EX(opline)->result.u.var].EA.class_entry = *pce; + } + if (!is_const) { + zval_dtor(&tmp); + FREE_OP(EX(Ts), &EX(opline)->op2, EG(free_op2)); } NEXT_OPCODE(); } Index: ZendEngine2/zend_language_parser.y diff -u ZendEngine2/zend_language_parser.y:1.72 ZendEngine2/zend_language_parser.y:1.73 --- ZendEngine2/zend_language_parser.y:1.72 Wed Oct 9 10:21:40 2002 +++ ZendEngine2/zend_language_parser.y Mon Oct 14 16:13:03 2002 @@ -586,7 +586,7 @@ ; new_class_entry: - parse_class_entry T_STRING { do_fetch_class(&$$, &$1, &$2 TSRMLS_CC); } + parse_class_entry static_or_variable_string { do_fetch_class(&$$, &$1, &$2 TSRMLS_CC); } | static_or_variable_string { do_fetch_class(&$$, NULL, &$1 TSRMLS_CC); } ;

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