}
/* }}} */
-void zend_do_resolve_class_name(znode *result, znode *class_name, int is_static TSRMLS_DC) /* {{{ */
-{
- char *lcname;
- int lctype;
- znode constant_name;
-
- lcname = zend_str_tolower_dup(Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant));
- lctype = zend_get_class_fetch_type(lcname, strlen(lcname));
- switch (lctype) {
- case ZEND_FETCH_CLASS_SELF:
- if (!CG(active_class_entry)) {
- zend_error_noreturn(E_COMPILE_ERROR, "Cannot access self::class when no class scope is active");
- }
- zval_dtor(&class_name->u.constant);
- class_name->op_type = IS_CONST;
- ZVAL_STR(&class_name->u.constant, STR_COPY(CG(active_class_entry)->name));
- *result = *class_name;
- break;
- case ZEND_FETCH_CLASS_STATIC:
- case ZEND_FETCH_CLASS_PARENT:
- if (is_static) {
- zend_error_noreturn(E_COMPILE_ERROR,
- "%s::class cannot be used for compile-time class name resolution",
- lctype == ZEND_FETCH_CLASS_STATIC ? "static" : "parent"
- );
- }
- if (!CG(active_class_entry)) {
- zend_error_noreturn(E_COMPILE_ERROR,
- "Cannot access %s::class when no class scope is active",
- lctype == ZEND_FETCH_CLASS_STATIC ? "static" : "parent"
- );
- }
- constant_name.op_type = IS_CONST;
- ZVAL_STRINGL(&constant_name.u.constant, "class", sizeof("class")-1);
- zend_do_fetch_constant(result, class_name, &constant_name, ZEND_RT, 1 TSRMLS_CC);
- break;
- case ZEND_FETCH_CLASS_DEFAULT:
- zend_resolve_class_name(class_name TSRMLS_CC);
- *result = *class_name;
- break;
- }
-
- efree(lcname);
-
-}
-/* }}} */
-
void zend_resolve_class_name(znode *class_name TSRMLS_DC) /* {{{ */
{
char *compound;
}
/* }}} */
-void zend_do_boolean_or_begin(znode *expr1, znode *op_token TSRMLS_DC) /* {{{ */
-{
- int next_op_number = get_next_op_number(CG(active_op_array));
- zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
-
- opline->opcode = ZEND_JMPNZ_EX;
- if (expr1->op_type == IS_TMP_VAR) {
- SET_NODE(opline->result, expr1);
- } else {
- opline->result.var = get_temporary_variable(CG(active_op_array));
- opline->result_type = IS_TMP_VAR;
- }
- SET_NODE(opline->op1, expr1);
- SET_UNUSED(opline->op2);
-
- op_token->u.op.opline_num = next_op_number;
-
- GET_NODE(expr1, opline->result);
-}
-/* }}} */
-
-void zend_do_boolean_or_end(znode *result, znode *expr1, znode *expr2, const znode *op_token TSRMLS_DC) /* {{{ */
-{
- zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
-
- *result = *expr1; /* we saved the original result in expr1 */
- opline->opcode = ZEND_BOOL;
- SET_NODE(opline->result, result);
- SET_NODE(opline->op1, expr2);
- SET_UNUSED(opline->op2);
-
- CG(active_op_array)->opcodes[op_token->u.op.opline_num].op2.opline_num = get_next_op_number(CG(active_op_array));
-}
-/* }}} */
-
-void zend_do_boolean_and_begin(znode *expr1, znode *op_token TSRMLS_DC) /* {{{ */
-{
- int next_op_number = get_next_op_number(CG(active_op_array));
- zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
-
- opline->opcode = ZEND_JMPZ_EX;
- if (expr1->op_type == IS_TMP_VAR) {
- SET_NODE(opline->result, expr1);
- } else {
- opline->result.var = get_temporary_variable(CG(active_op_array));
- opline->result_type = IS_TMP_VAR;
- }
- SET_NODE(opline->op1, expr1);
- SET_UNUSED(opline->op2);
-
- op_token->u.op.opline_num = next_op_number;
-
- GET_NODE(expr1, opline->result);
-}
-/* }}} */
-
-void zend_do_boolean_and_end(znode *result, znode *expr1, znode *expr2, const znode *op_token TSRMLS_DC) /* {{{ */
-{
- zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
-
- *result = *expr1; /* we saved the original result in expr1 */
- opline->opcode = ZEND_BOOL;
- SET_NODE(opline->result, result);
- SET_NODE(opline->op1, expr2);
- SET_UNUSED(opline->op2);
-
- CG(active_op_array)->opcodes[op_token->u.op.opline_num].op2.opline_num = get_next_op_number(CG(active_op_array));
-}
-/* }}} */
-
void zend_do_do_while_begin(TSRMLS_D) /* {{{ */
{
do_begin_loop(TSRMLS_C);
}
/* }}} */
-void zend_do_fetch_constant(znode *result, znode *constant_container, znode *constant_name, int mode, zend_bool check_namespace TSRMLS_DC) /* {{{ */
-{
- znode tmp;
- zend_op *opline;
- int type;
- char *compound;
- ulong fetch_type = 0;
-
- if (constant_container) {
- switch (mode) {
- case ZEND_CT:
- /* this is a class constant */
- type = zend_get_class_fetch_type(Z_STRVAL(constant_container->u.constant), Z_STRLEN(constant_container->u.constant));
-
- if (ZEND_FETCH_CLASS_STATIC == type) {
- zend_error(E_ERROR, "\"static::\" is not allowed in compile-time constants");
- } else if (ZEND_FETCH_CLASS_DEFAULT == type) {
- zend_resolve_class_name(constant_container TSRMLS_CC);
- }
- zend_do_build_full_name(NULL, constant_container, constant_name, 1 TSRMLS_CC);
- *result = *constant_container;
- Z_TYPE_INFO(result->u.constant) = IS_CONSTANT_EX;
- if (IS_INTERNED(Z_STR(result->u.constant))) {
- Z_TYPE_FLAGS(result->u.constant) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE);
- }
- Z_CONST_FLAGS(result->u.constant) = fetch_type;
- break;
- case ZEND_RT:
- if (constant_container->op_type == IS_CONST &&
- ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_STRVAL(constant_container->u.constant), Z_STRLEN(constant_container->u.constant))) {
- zend_resolve_class_name(constant_container TSRMLS_CC);
- } else {
- zend_do_fetch_class(&tmp, constant_container TSRMLS_CC);
- constant_container = &tmp;
- }
- opline = get_next_op(CG(active_op_array) TSRMLS_CC);
- opline->opcode = ZEND_FETCH_CONSTANT;
- opline->result_type = IS_TMP_VAR;
- opline->result.var = get_temporary_variable(CG(active_op_array));
- if (constant_container->op_type == IS_CONST) {
- opline->op1_type = IS_CONST;
- opline->op1.constant = zend_add_class_name_literal(CG(active_op_array), &constant_container->u.constant TSRMLS_CC);
- } else {
- SET_NODE(opline->op1, constant_container);
- }
- SET_NODE(opline->op2, constant_name);
- if (opline->op1_type == IS_CONST) {
- GET_CACHE_SLOT(opline->op2.constant);
- } else {
- GET_POLYMORPHIC_CACHE_SLOT(opline->op2.constant);
- }
- GET_NODE(result, opline->result);
- break;
- }
- return;
- }
- /* namespace constant */
- /* only one that did not contain \ from the start can be converted to string if unknown */
- switch (mode) {
- case ZEND_CT:
- compound = memchr(Z_STRVAL(constant_name->u.constant), '\\', Z_STRLEN(constant_name->u.constant));
- /* this is a namespace constant, or an unprefixed constant */
-
- if (zend_constant_ct_subst(result, &constant_name->u.constant, 0 TSRMLS_CC)) {
- break;
- }
-
- zend_resolve_const_name(constant_name, &check_namespace TSRMLS_CC);
-
- if(!compound) {
- fetch_type |= IS_CONSTANT_UNQUALIFIED;
- }
-
- *result = *constant_name;
- Z_TYPE_INFO(result->u.constant) = IS_CONSTANT_EX;
- if (IS_INTERNED(Z_STR(result->u.constant))) {
- Z_TYPE_FLAGS(result->u.constant) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE);
- }
- Z_CONST_FLAGS(result->u.constant) = fetch_type;
- break;
- case ZEND_RT:
- compound = memchr(Z_STRVAL(constant_name->u.constant), '\\', Z_STRLEN(constant_name->u.constant));
-
- zend_resolve_const_name(constant_name, &check_namespace TSRMLS_CC);
-
- if(zend_constant_ct_subst(result, &constant_name->u.constant, 1 TSRMLS_CC)) {
- break;
- }
-
- opline = get_next_op(CG(active_op_array) TSRMLS_CC);
- opline->opcode = ZEND_FETCH_CONSTANT;
- opline->result_type = IS_TMP_VAR;
- opline->result.var = get_temporary_variable(CG(active_op_array));
- GET_NODE(result, opline->result);
- SET_UNUSED(opline->op1);
- opline->op2_type = IS_CONST;
- if (compound) {
- /* the name is unambiguous */
- opline->extended_value = 0;
- opline->op2.constant = zend_add_const_name_literal(CG(active_op_array), &constant_name->u.constant, 0 TSRMLS_CC);
- } else {
- opline->extended_value = IS_CONSTANT_UNQUALIFIED;
- if (Z_TYPE(CG(current_namespace)) != IS_UNDEF) {
- opline->extended_value |= IS_CONSTANT_IN_NAMESPACE;
- opline->op2.constant = zend_add_const_name_literal(CG(active_op_array), &constant_name->u.constant, 1 TSRMLS_CC);
- } else {
- opline->op2.constant = zend_add_const_name_literal(CG(active_op_array), &constant_name->u.constant, 0 TSRMLS_CC);
- }
- }
- GET_CACHE_SLOT(opline->op2.constant);
- break;
- }
-}
-/* }}} */
-
void zend_init_list(void *result, void *item TSRMLS_DC) /* {{{ */
{
void** list = emalloc(sizeof(void*) * 2);