From: Andi Gutmans Date: Fri, 8 Mar 2002 10:58:24 +0000 (+0000) Subject: - Support importing constants. e.g.: X-Git-Tag: help~132 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=90f6005f5864a11c48462e2046879d1aa78d2e3d;p=php - Support importing constants. e.g.: op1.u.var].EA.class_entry; - + if (EX(opline)->op2.op_type != IS_UNUSED) { + char *const_name_strval; + int const_name_strlen; + + const_name_strval = EX(opline)->op2.u.constant.value.str.val; + const_name_strlen = EX(opline)->op2.u.constant.value.str.len; + + if (zend_hash_find(&ce->constants_table, const_name_strval, const_name_strlen + 1, (void **) &import_constant)==FAILURE) { + zend_error(E_ERROR, "Import: constant %s not found", const_name_strval); + } + c.value = **import_constant; + zval_copy_ctor(&c.value); + c.flags = CONST_CS; + c.name = zend_strndup(const_name_strval, const_name_strlen); + c.name_len = const_name_strlen + 1; + + if (zend_register_constant(&c TSRMLS_CC) == FAILURE) { + zend_error(E_ERROR, "Import: unable to register constant %s", const_name_strval); + } + } else { + HashPosition pos; + char *key; + uint key_length; + int key_type; + ulong dummy; + + zend_hash_internal_pointer_reset_ex(&ce->constants_table, &pos); + while(zend_hash_get_current_data_ex(&ce->constants_table, (void **)&import_constant, &pos) == SUCCESS) { + key_type = zend_hash_get_current_key_ex(&ce->constants_table, &key, &key_length, &dummy, 0, &pos); + + c.value = **import_constant; + zval_copy_ctor(&c.value); + c.flags = CONST_CS; + c.name = zend_strndup(key, key_length - 1); + c.name_len = key_length; + + if (zend_register_constant(&c TSRMLS_CC) == FAILURE) { + zend_error(E_ERROR, "Import: unable to register constant %s", key); + } + zend_hash_move_forward_ex(&ce->constants_table, &pos); + } + } NEXT_OPCODE(); } case ZEND_FETCH_CLASS: