Annotation of embedaddon/php/Zend/zend_compile.c, revision 1.1

1.1     ! misho       1: /*
        !             2:    +----------------------------------------------------------------------+
        !             3:    | Zend Engine                                                          |
        !             4:    +----------------------------------------------------------------------+
        !             5:    | Copyright (c) 1998-2012 Zend Technologies Ltd. (http://www.zend.com) |
        !             6:    +----------------------------------------------------------------------+
        !             7:    | This source file is subject to version 2.00 of the Zend license,     |
        !             8:    | that is bundled with this package in the file LICENSE, and is        | 
        !             9:    | available through the world-wide-web at the following url:           |
        !            10:    | http://www.zend.com/license/2_00.txt.                                |
        !            11:    | If you did not receive a copy of the Zend license and are unable to  |
        !            12:    | obtain it through the world-wide-web, please send a note to          |
        !            13:    | license@zend.com so we can mail you a copy immediately.              |
        !            14:    +----------------------------------------------------------------------+
        !            15:    | Authors: Andi Gutmans <andi@zend.com>                                |
        !            16:    |          Zeev Suraski <zeev@zend.com>                                |
        !            17:    +----------------------------------------------------------------------+
        !            18: */
        !            19: 
        !            20: /* $Id: zend_compile.c 321634 2012-01-01 13:15:04Z felipe $ */
        !            21: 
        !            22: #include <zend_language_parser.h>
        !            23: #include "zend.h"
        !            24: #include "zend_compile.h"
        !            25: #include "zend_constants.h"
        !            26: #include "zend_llist.h"
        !            27: #include "zend_API.h"
        !            28: #include "zend_exceptions.h"
        !            29: #include "tsrm_virtual_cwd.h"
        !            30: 
        !            31: #ifdef ZEND_MULTIBYTE
        !            32: #include "zend_multibyte.h"
        !            33: #endif /* ZEND_MULTIBYTE */
        !            34: 
        !            35: ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
        !            36: ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, char *filename TSRMLS_DC);
        !            37: 
        !            38: #ifndef ZTS
        !            39: ZEND_API zend_compiler_globals compiler_globals;
        !            40: ZEND_API zend_executor_globals executor_globals;
        !            41: #endif
        !            42: 
        !            43: static void zend_duplicate_property_info(zend_property_info *property_info) /* {{{ */
        !            44: {
        !            45:        property_info->name = estrndup(property_info->name, property_info->name_length);
        !            46:        if (property_info->doc_comment) {
        !            47:                property_info->doc_comment = estrndup(property_info->doc_comment, property_info->doc_comment_len);
        !            48:        }
        !            49: }
        !            50: /* }}} */
        !            51: 
        !            52: 
        !            53: static void zend_duplicate_property_info_internal(zend_property_info *property_info) /* {{{ */
        !            54: {
        !            55:        property_info->name = zend_strndup(property_info->name, property_info->name_length);
        !            56: }
        !            57: /* }}} */
        !            58: 
        !            59: 
        !            60: static void zend_destroy_property_info(zend_property_info *property_info) /* {{{ */
        !            61: {
        !            62:        efree(property_info->name);
        !            63:        if (property_info->doc_comment) {
        !            64:                efree(property_info->doc_comment);
        !            65:        }
        !            66: }
        !            67: /* }}} */
        !            68: 
        !            69: 
        !            70: static void zend_destroy_property_info_internal(zend_property_info *property_info) /* {{{ */
        !            71: {
        !            72:        free(property_info->name);
        !            73: }
        !            74: /* }}} */
        !            75: 
        !            76: #if SUHOSIN_PATCH
        !            77: void *suhosin_zend_destroy_property_info_internal = zend_destroy_property_info_internal;
        !            78: void *suhosin_zend_destroy_property_info = zend_destroy_property_info;
        !            79: #endif
        !            80: 
        !            81: static void build_runtime_defined_function_key(zval *result, const char *name, int name_length TSRMLS_DC) /* {{{ */
        !            82: {
        !            83:        char char_pos_buf[32];
        !            84:        uint char_pos_len;
        !            85:        char *filename;
        !            86: 
        !            87:        char_pos_len = zend_sprintf(char_pos_buf, "%p", LANG_SCNG(yy_text));
        !            88:        if (CG(active_op_array)->filename) {
        !            89:                filename = CG(active_op_array)->filename;
        !            90:        } else {
        !            91:                filename = "-";
        !            92:        }
        !            93: 
        !            94:        /* NULL, name length, filename length, last accepting char position length */
        !            95:        result->value.str.len = 1+name_length+strlen(filename)+char_pos_len;
        !            96: #ifdef ZEND_MULTIBYTE
        !            97:        /* must be binary safe */
        !            98:        result->value.str.val = (char *) safe_emalloc(result->value.str.len, 1, 1);
        !            99:        result->value.str.val[0] = '\0';
        !           100:        sprintf(result->value.str.val+1, "%s%s%s", name, filename, char_pos_buf);
        !           101: #else
        !           102:        zend_spprintf(&result->value.str.val, 0, "%c%s%s%s", '\0', name, filename, char_pos_buf);
        !           103: #endif /* ZEND_MULTIBYTE */
        !           104:        result->type = IS_STRING;
        !           105:        Z_SET_REFCOUNT_P(result, 1);
        !           106: }
        !           107: /* }}} */
        !           108: 
        !           109: 
        !           110: int zend_auto_global_arm(zend_auto_global *auto_global TSRMLS_DC) /* {{{ */
        !           111: {
        !           112:        auto_global->armed = (auto_global->auto_global_callback ? 1 : 0);
        !           113:        return 0;
        !           114: }
        !           115: /* }}} */
        !           116: 
        !           117: 
        !           118: ZEND_API int zend_auto_global_disable_jit(const char *varname, zend_uint varname_length TSRMLS_DC) /* {{{ */
        !           119: {
        !           120:        zend_auto_global *auto_global;
        !           121: 
        !           122:        if (zend_hash_find(CG(auto_globals), varname, varname_length+1, (void **) &auto_global)==FAILURE) {
        !           123:                return FAILURE;
        !           124:        }
        !           125:        auto_global->armed = 0;
        !           126:        return SUCCESS;
        !           127: }
        !           128: /* }}} */
        !           129: 
        !           130: 
        !           131: static void init_compiler_declarables(TSRMLS_D) /* {{{ */
        !           132: {
        !           133:        Z_TYPE(CG(declarables).ticks) = IS_LONG;
        !           134:        Z_LVAL(CG(declarables).ticks) = 0;
        !           135: }
        !           136: /* }}} */
        !           137: 
        !           138: 
        !           139: void zend_init_compiler_data_structures(TSRMLS_D) /* {{{ */
        !           140: {
        !           141:        zend_stack_init(&CG(bp_stack));
        !           142:        zend_stack_init(&CG(function_call_stack));
        !           143:        zend_stack_init(&CG(switch_cond_stack));
        !           144:        zend_stack_init(&CG(foreach_copy_stack));
        !           145:        zend_stack_init(&CG(object_stack));
        !           146:        zend_stack_init(&CG(declare_stack));
        !           147:        CG(active_class_entry) = NULL;
        !           148:        zend_llist_init(&CG(list_llist), sizeof(list_llist_element), NULL, 0);
        !           149:        zend_llist_init(&CG(dimension_llist), sizeof(int), NULL, 0);
        !           150:        zend_stack_init(&CG(list_stack));
        !           151:        CG(in_compilation) = 0;
        !           152:        CG(start_lineno) = 0;
        !           153:        CG(current_namespace) = NULL;
        !           154:        CG(in_namespace) = 0;
        !           155:        CG(has_bracketed_namespaces) = 0;
        !           156:        CG(current_import) = NULL;
        !           157:        init_compiler_declarables(TSRMLS_C);
        !           158:        zend_hash_apply(CG(auto_globals), (apply_func_t) zend_auto_global_arm TSRMLS_CC);
        !           159:        zend_stack_init(&CG(labels_stack));
        !           160:        CG(labels) = NULL;
        !           161: 
        !           162: #ifdef ZEND_MULTIBYTE
        !           163:        CG(script_encoding_list) = NULL;
        !           164:        CG(script_encoding_list_size) = 0;
        !           165:        CG(internal_encoding) = NULL;
        !           166:        CG(encoding_detector) = NULL;
        !           167:        CG(encoding_converter) = NULL;
        !           168:        CG(encoding_oddlen) = NULL;
        !           169:        CG(encoding_declared) = 0;
        !           170: #endif /* ZEND_MULTIBYTE */
        !           171: }
        !           172: /* }}} */
        !           173: 
        !           174: 
        !           175: ZEND_API void file_handle_dtor(zend_file_handle *fh) /* {{{ */
        !           176: {
        !           177:        TSRMLS_FETCH();
        !           178: 
        !           179:        zend_file_handle_dtor(fh TSRMLS_CC);
        !           180: }
        !           181: /* }}} */
        !           182: 
        !           183: 
        !           184: void init_compiler(TSRMLS_D) /* {{{ */
        !           185: {
        !           186:        CG(active_op_array) = NULL;
        !           187:        zend_init_compiler_data_structures(TSRMLS_C);
        !           188:        zend_init_rsrc_list(TSRMLS_C);
        !           189:        zend_hash_init(&CG(filenames_table), 5, NULL, (dtor_func_t) free_estring, 0);
        !           190:        zend_llist_init(&CG(open_files), sizeof(zend_file_handle), (void (*)(void *)) file_handle_dtor, 0);
        !           191:        CG(unclean_shutdown) = 0;
        !           192: }
        !           193: /* }}} */
        !           194: 
        !           195: 
        !           196: void shutdown_compiler(TSRMLS_D) /* {{{ */
        !           197: {
        !           198:        zend_stack_destroy(&CG(bp_stack));
        !           199:        zend_stack_destroy(&CG(function_call_stack));
        !           200:        zend_stack_destroy(&CG(switch_cond_stack));
        !           201:        zend_stack_destroy(&CG(foreach_copy_stack));
        !           202:        zend_stack_destroy(&CG(object_stack));
        !           203:        zend_stack_destroy(&CG(declare_stack));
        !           204:        zend_stack_destroy(&CG(list_stack));
        !           205:        zend_hash_destroy(&CG(filenames_table));
        !           206:        zend_llist_destroy(&CG(open_files));
        !           207:        zend_stack_destroy(&CG(labels_stack));
        !           208: 
        !           209: #ifdef ZEND_MULTIBYTE
        !           210:        if (CG(script_encoding_list)) {
        !           211:                efree(CG(script_encoding_list));
        !           212:        }
        !           213: #endif /* ZEND_MULTIBYTE */
        !           214: }
        !           215: /* }}} */
        !           216: 
        !           217: 
        !           218: ZEND_API char *zend_set_compiled_filename(const char *new_compiled_filename TSRMLS_DC) /* {{{ */
        !           219: {
        !           220:        char **pp, *p;
        !           221:        int length = strlen(new_compiled_filename);
        !           222: 
        !           223:        if (zend_hash_find(&CG(filenames_table), new_compiled_filename, length+1, (void **) &pp) == SUCCESS) {
        !           224:                CG(compiled_filename) = *pp;
        !           225:                return *pp;
        !           226:        }
        !           227:        p = estrndup(new_compiled_filename, length);
        !           228:        zend_hash_update(&CG(filenames_table), new_compiled_filename, length+1, &p, sizeof(char *), (void **) &pp);
        !           229:        CG(compiled_filename) = p;
        !           230:        return p;
        !           231: }
        !           232: /* }}} */
        !           233: 
        !           234: 
        !           235: ZEND_API void zend_restore_compiled_filename(char *original_compiled_filename TSRMLS_DC) /* {{{ */
        !           236: {
        !           237:        CG(compiled_filename) = original_compiled_filename;
        !           238: }
        !           239: /* }}} */
        !           240: 
        !           241: 
        !           242: ZEND_API char *zend_get_compiled_filename(TSRMLS_D) /* {{{ */
        !           243: {
        !           244:        return CG(compiled_filename);
        !           245: }
        !           246: /* }}} */
        !           247: 
        !           248: 
        !           249: ZEND_API int zend_get_compiled_lineno(TSRMLS_D) /* {{{ */
        !           250: {
        !           251:        return CG(zend_lineno);
        !           252: }
        !           253: /* }}} */
        !           254: 
        !           255: 
        !           256: ZEND_API zend_bool zend_is_compiling(TSRMLS_D) /* {{{ */
        !           257: {
        !           258:        return CG(in_compilation);
        !           259: }
        !           260: /* }}} */
        !           261: 
        !           262: 
        !           263: static zend_uint get_temporary_variable(zend_op_array *op_array) /* {{{ */
        !           264: {
        !           265:        return (op_array->T)++ * ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable));
        !           266: }
        !           267: /* }}} */
        !           268: 
        !           269: static int lookup_cv(zend_op_array *op_array, char* name, int name_len) /* {{{ */
        !           270: {
        !           271:        int i = 0;
        !           272:        ulong hash_value = zend_inline_hash_func(name, name_len+1);
        !           273: 
        !           274:        while (i < op_array->last_var) {
        !           275:                if (op_array->vars[i].hash_value == hash_value &&
        !           276:                    op_array->vars[i].name_len == name_len &&
        !           277:                    strcmp(op_array->vars[i].name, name) == 0) {
        !           278:                  efree(name);
        !           279:                  return i;
        !           280:                }
        !           281:                i++;
        !           282:        }
        !           283:        i = op_array->last_var;
        !           284:        op_array->last_var++;
        !           285:        if (op_array->last_var > op_array->size_var) {
        !           286:                op_array->size_var += 16; /* FIXME */
        !           287:                op_array->vars = erealloc(op_array->vars, op_array->size_var*sizeof(zend_compiled_variable));
        !           288:        }
        !           289:        op_array->vars[i].name = name; /* estrndup(name, name_len); */
        !           290:        op_array->vars[i].name_len = name_len;
        !           291:        op_array->vars[i].hash_value = hash_value;
        !           292:        return i;
        !           293: }
        !           294: /* }}} */
        !           295: 
        !           296: 
        !           297: void zend_do_binary_op(zend_uchar op, znode *result, const znode *op1, const znode *op2 TSRMLS_DC) /* {{{ */
        !           298: {
        !           299:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           300: 
        !           301:        opline->opcode = op;
        !           302:        opline->result.op_type = IS_TMP_VAR;
        !           303:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !           304:        opline->op1 = *op1;
        !           305:        opline->op2 = *op2;
        !           306:        *result = opline->result;
        !           307: }
        !           308: /* }}} */
        !           309: 
        !           310: void zend_do_unary_op(zend_uchar op, znode *result, const znode *op1 TSRMLS_DC) /* {{{ */
        !           311: {
        !           312:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           313: 
        !           314:        opline->opcode = op;
        !           315:        opline->result.op_type = IS_TMP_VAR;
        !           316:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !           317:        opline->op1 = *op1;
        !           318:        *result = opline->result;
        !           319:        SET_UNUSED(opline->op2);
        !           320: }
        !           321: /* }}} */
        !           322: 
        !           323: #define MAKE_NOP(opline)       { opline->opcode = ZEND_NOP;  memset(&opline->result,0,sizeof(znode)); memset(&opline->op1,0,sizeof(znode)); memset(&opline->op2,0,sizeof(znode)); opline->result.op_type=opline->op1.op_type=opline->op2.op_type=IS_UNUSED;  }
        !           324: 
        !           325: 
        !           326: static void zend_do_op_data(zend_op *data_op, const znode *value TSRMLS_DC) /* {{{ */
        !           327: {
        !           328:        data_op->opcode = ZEND_OP_DATA;
        !           329:        data_op->op1 = *value;
        !           330:        SET_UNUSED(data_op->op2);
        !           331: }
        !           332: /* }}} */
        !           333: 
        !           334: void zend_do_binary_assign_op(zend_uchar op, znode *result, const znode *op1, const znode *op2 TSRMLS_DC) /* {{{ */
        !           335: {
        !           336:        int last_op_number = get_next_op_number(CG(active_op_array));
        !           337:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           338: 
        !           339:        if (last_op_number > 0) {
        !           340:                zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number-1];
        !           341: 
        !           342:                switch (last_op->opcode) {
        !           343:                        case ZEND_FETCH_OBJ_RW:
        !           344:                                last_op->opcode = op;
        !           345:                                last_op->extended_value = ZEND_ASSIGN_OBJ;
        !           346: 
        !           347:                                zend_do_op_data(opline, op2 TSRMLS_CC);
        !           348:                                SET_UNUSED(opline->result);
        !           349:                                *result = last_op->result;
        !           350:                                return;
        !           351:                        case ZEND_FETCH_DIM_RW:
        !           352:                                last_op->opcode = op;
        !           353:                                last_op->extended_value = ZEND_ASSIGN_DIM;
        !           354: 
        !           355:                                zend_do_op_data(opline, op2 TSRMLS_CC);
        !           356:                                opline->op2.u.var = get_temporary_variable(CG(active_op_array));
        !           357:                                opline->op2.u.EA.type = 0;
        !           358:                                opline->op2.op_type = IS_VAR;
        !           359:                                SET_UNUSED(opline->result);
        !           360:                                *result = last_op->result;
        !           361:                                return;
        !           362:                        default:
        !           363:                                break;
        !           364:                }
        !           365:        }
        !           366: 
        !           367:        opline->opcode = op;
        !           368:        opline->op1 = *op1;
        !           369:        opline->op2 = *op2;
        !           370:        opline->result.op_type = IS_VAR;
        !           371:        opline->result.u.EA.type = 0;
        !           372:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !           373:        *result = opline->result;
        !           374: }
        !           375: /* }}} */
        !           376: 
        !           377: void fetch_simple_variable_ex(znode *result, znode *varname, int bp, zend_uchar op TSRMLS_DC) /* {{{ */
        !           378: {
        !           379:        zend_op opline;
        !           380:        zend_op *opline_ptr;
        !           381:        zend_llist *fetch_list_ptr;
        !           382: 
        !           383:        if (varname->op_type == IS_CONST) {
        !           384:                if (Z_TYPE(varname->u.constant) != IS_STRING) {
        !           385:                        convert_to_string(&varname->u.constant);
        !           386:                }
        !           387:                if (!zend_is_auto_global(varname->u.constant.value.str.val, varname->u.constant.value.str.len TSRMLS_CC) &&
        !           388:                    !(varname->u.constant.value.str.len == (sizeof("this")-1) &&
        !           389:                      !memcmp(varname->u.constant.value.str.val, "this", sizeof("this"))) &&
        !           390:                    (CG(active_op_array)->last == 0 ||
        !           391:                     CG(active_op_array)->opcodes[CG(active_op_array)->last-1].opcode != ZEND_BEGIN_SILENCE)) {
        !           392:                        result->op_type = IS_CV;
        !           393:                        result->u.var = lookup_cv(CG(active_op_array), varname->u.constant.value.str.val, varname->u.constant.value.str.len);
        !           394:                        result->u.EA.type = 0;
        !           395:                        varname->u.constant.value.str.val = CG(active_op_array)->vars[result->u.var].name;
        !           396:                        return;
        !           397:                }
        !           398:        }
        !           399: 
        !           400:        if (bp) {
        !           401:                opline_ptr = &opline;
        !           402:                init_op(opline_ptr TSRMLS_CC);
        !           403:        } else {
        !           404:                opline_ptr = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           405:        }
        !           406: 
        !           407:        opline_ptr->opcode = op;
        !           408:        opline_ptr->result.op_type = IS_VAR;
        !           409:        opline_ptr->result.u.EA.type = 0;
        !           410:        opline_ptr->result.u.var = get_temporary_variable(CG(active_op_array));
        !           411:        opline_ptr->op1 = *varname;
        !           412:        *result = opline_ptr->result;
        !           413:        SET_UNUSED(opline_ptr->op2);
        !           414: 
        !           415:        opline_ptr->op2.u.EA.type = ZEND_FETCH_LOCAL;
        !           416:        if (varname->op_type == IS_CONST && varname->u.constant.type == IS_STRING) {
        !           417:                if (zend_is_auto_global(varname->u.constant.value.str.val, varname->u.constant.value.str.len TSRMLS_CC)) {
        !           418:                        opline_ptr->op2.u.EA.type = ZEND_FETCH_GLOBAL;
        !           419:                }
        !           420:        }
        !           421: 
        !           422:        if (bp) {
        !           423:                zend_stack_top(&CG(bp_stack), (void **) &fetch_list_ptr);
        !           424:                zend_llist_add_element(fetch_list_ptr, opline_ptr);
        !           425:        }
        !           426: }
        !           427: /* }}} */
        !           428: 
        !           429: void fetch_simple_variable(znode *result, znode *varname, int bp TSRMLS_DC) /* {{{ */
        !           430: {
        !           431:        /* the default mode must be Write, since fetch_simple_variable() is used to define function arguments */
        !           432:        fetch_simple_variable_ex(result, varname, bp, ZEND_FETCH_W TSRMLS_CC);
        !           433: }
        !           434: /* }}} */
        !           435: 
        !           436: void zend_do_fetch_static_member(znode *result, znode *class_name TSRMLS_DC) /* {{{ */
        !           437: {
        !           438:        znode class_node;
        !           439:        zend_llist *fetch_list_ptr;
        !           440:        zend_llist_element *le;
        !           441:        zend_op *opline_ptr;
        !           442:        zend_op opline;
        !           443: 
        !           444:        zend_do_fetch_class(&class_node, class_name TSRMLS_CC);
        !           445:        zend_stack_top(&CG(bp_stack), (void **) &fetch_list_ptr);
        !           446:        if (result->op_type == IS_CV) {
        !           447:                init_op(&opline TSRMLS_CC);
        !           448: 
        !           449:                opline.opcode = ZEND_FETCH_W;
        !           450:                opline.result.op_type = IS_VAR;
        !           451:                opline.result.u.EA.type = 0;
        !           452:                opline.result.u.var = get_temporary_variable(CG(active_op_array));
        !           453:                opline.op1.op_type = IS_CONST;
        !           454:                opline.op1.u.constant.type = IS_STRING;
        !           455:                opline.op1.u.constant.value.str.val = estrdup(CG(active_op_array)->vars[result->u.var].name);
        !           456:                opline.op1.u.constant.value.str.len = CG(active_op_array)->vars[result->u.var].name_len;
        !           457:                SET_UNUSED(opline.op2);
        !           458:                opline.op2 = class_node;
        !           459:                opline.op2.u.EA.type = ZEND_FETCH_STATIC_MEMBER;
        !           460:                *result = opline.result;
        !           461: 
        !           462:                zend_llist_add_element(fetch_list_ptr, &opline);
        !           463:        } else {
        !           464:                le = fetch_list_ptr->head;
        !           465: 
        !           466:                opline_ptr = (zend_op *)le->data;
        !           467:                if (opline_ptr->opcode != ZEND_FETCH_W && opline_ptr->op1.op_type == IS_CV) {
        !           468:                        init_op(&opline TSRMLS_CC);
        !           469:                        opline.opcode = ZEND_FETCH_W;
        !           470:                        opline.result.op_type = IS_VAR;
        !           471:                        opline.result.u.EA.type = 0;
        !           472:                        opline.result.u.var = get_temporary_variable(CG(active_op_array));
        !           473:                        opline.op1.op_type = IS_CONST;
        !           474:                        opline.op1.u.constant.type = IS_STRING;
        !           475:                        opline.op1.u.constant.value.str.val = estrdup(CG(active_op_array)->vars[opline_ptr->op1.u.var].name);
        !           476:                        opline.op1.u.constant.value.str.len = CG(active_op_array)->vars[opline_ptr->op1.u.var].name_len;
        !           477:                        SET_UNUSED(opline.op2);
        !           478:                        opline.op2 = class_node;
        !           479:                        opline.op2.u.EA.type = ZEND_FETCH_STATIC_MEMBER;
        !           480:                        opline_ptr->op1 = opline.result;
        !           481: 
        !           482:                        zend_llist_prepend_element(fetch_list_ptr, &opline);
        !           483:                } else {
        !           484:                        opline_ptr->op2 = class_node;
        !           485:                        opline_ptr->op2.u.EA.type = ZEND_FETCH_STATIC_MEMBER;
        !           486:                }
        !           487:        }
        !           488: }
        !           489: /* }}} */
        !           490: 
        !           491: void fetch_array_begin(znode *result, znode *varname, znode *first_dim TSRMLS_DC) /* {{{ */
        !           492: {
        !           493:        fetch_simple_variable(result, varname, 1 TSRMLS_CC);
        !           494: 
        !           495:        fetch_array_dim(result, result, first_dim TSRMLS_CC);
        !           496: }
        !           497: /* }}} */
        !           498: 
        !           499: void fetch_array_dim(znode *result, const znode *parent, const znode *dim TSRMLS_DC) /* {{{ */
        !           500: {
        !           501:        zend_op opline;
        !           502:        zend_llist *fetch_list_ptr;
        !           503: 
        !           504:        init_op(&opline TSRMLS_CC);
        !           505:        opline.opcode = ZEND_FETCH_DIM_W;       /* the backpatching routine assumes W */
        !           506:        opline.result.op_type = IS_VAR;
        !           507:        opline.result.u.EA.type = 0;
        !           508:        opline.result.u.var = get_temporary_variable(CG(active_op_array));
        !           509:        opline.op1 = *parent;
        !           510:        opline.op2 = *dim;
        !           511:        opline.extended_value = ZEND_FETCH_STANDARD;
        !           512:        *result = opline.result;
        !           513: 
        !           514:        zend_stack_top(&CG(bp_stack), (void **) &fetch_list_ptr);
        !           515:        zend_llist_add_element(fetch_list_ptr, &opline);
        !           516: }
        !           517: /* }}} */
        !           518: 
        !           519: void fetch_string_offset(znode *result, const znode *parent, const znode *offset TSRMLS_DC) /* {{{ */
        !           520: {
        !           521:        fetch_array_dim(result, parent, offset TSRMLS_CC);
        !           522: }
        !           523: /* }}} */
        !           524: 
        !           525: void zend_do_print(znode *result, const znode *arg TSRMLS_DC) /* {{{ */
        !           526: {
        !           527:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           528: 
        !           529:        opline->result.op_type = IS_TMP_VAR;
        !           530:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !           531:        opline->opcode = ZEND_PRINT;
        !           532:        opline->op1 = *arg;
        !           533:        SET_UNUSED(opline->op2);
        !           534:        *result = opline->result;
        !           535: }
        !           536: /* }}} */
        !           537: 
        !           538: void zend_do_echo(const znode *arg TSRMLS_DC) /* {{{ */
        !           539: {
        !           540:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           541: 
        !           542:        opline->opcode = ZEND_ECHO;
        !           543:        opline->op1 = *arg;
        !           544:        SET_UNUSED(opline->op2);
        !           545: }
        !           546: /* }}} */
        !           547: 
        !           548: void zend_do_abstract_method(const znode *function_name, znode *modifiers, const znode *body TSRMLS_DC) /* {{{ */
        !           549: {
        !           550:        char *method_type;
        !           551: 
        !           552:        if (CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE) {
        !           553:                Z_LVAL(modifiers->u.constant) |= ZEND_ACC_ABSTRACT;
        !           554:                method_type = "Interface";
        !           555:        } else {
        !           556:                method_type = "Abstract";
        !           557:        }
        !           558: 
        !           559:        if (modifiers->u.constant.value.lval & ZEND_ACC_ABSTRACT) {
        !           560:                if(modifiers->u.constant.value.lval & ZEND_ACC_PRIVATE) {
        !           561:                        zend_error(E_COMPILE_ERROR, "%s function %s::%s() cannot be declared private", method_type, CG(active_class_entry)->name, function_name->u.constant.value.str.val);
        !           562:                }
        !           563:                if (Z_LVAL(body->u.constant) == ZEND_ACC_ABSTRACT) {
        !           564:                        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           565: 
        !           566:                        opline->opcode = ZEND_RAISE_ABSTRACT_ERROR;
        !           567:                        SET_UNUSED(opline->op1);
        !           568:                        SET_UNUSED(opline->op2);
        !           569:                } else {
        !           570:                        /* we had code in the function body */
        !           571:                        zend_error(E_COMPILE_ERROR, "%s function %s::%s() cannot contain body", method_type, CG(active_class_entry)->name, function_name->u.constant.value.str.val);
        !           572:                }
        !           573:        } else {
        !           574:                if (body->u.constant.value.lval == ZEND_ACC_ABSTRACT) {
        !           575:                        zend_error(E_COMPILE_ERROR, "Non-abstract method %s::%s() must contain body", CG(active_class_entry)->name, function_name->u.constant.value.str.val);
        !           576:                }
        !           577:        }
        !           578: }
        !           579: /* }}} */
        !           580: 
        !           581: static zend_bool opline_is_fetch_this(const zend_op *opline TSRMLS_DC) /* {{{ */
        !           582: {
        !           583:        if ((opline->opcode == ZEND_FETCH_W) && (opline->op1.op_type == IS_CONST)
        !           584:                && (opline->op1.u.constant.type == IS_STRING)
        !           585:                && (opline->op1.u.constant.value.str.len == (sizeof("this")-1))
        !           586:                && !memcmp(opline->op1.u.constant.value.str.val, "this", sizeof("this"))) {
        !           587:                return 1;
        !           588:        } else {
        !           589:                return 0;
        !           590:        }
        !           591: }
        !           592: /* }}} */
        !           593: 
        !           594: void zend_do_assign(znode *result, znode *variable, const znode *value TSRMLS_DC) /* {{{ */
        !           595: {
        !           596:        int last_op_number;
        !           597:        zend_op *opline;
        !           598: 
        !           599:        if (value->op_type == IS_CV) {
        !           600:                zend_llist *fetch_list_ptr;
        !           601: 
        !           602:                zend_stack_top(&CG(bp_stack), (void **) &fetch_list_ptr);
        !           603:                if (fetch_list_ptr && fetch_list_ptr->head) {
        !           604:                        opline = (zend_op *)fetch_list_ptr->head->data;
        !           605: 
        !           606:                        if (opline->opcode == ZEND_FETCH_DIM_W &&
        !           607:                            opline->op1.op_type == IS_CV &&
        !           608:                            opline->op1.u.var == value->u.var) {
        !           609: 
        !           610:                                opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           611:                                opline->opcode = ZEND_FETCH_R;
        !           612:                                opline->result.op_type = IS_VAR;
        !           613:                                opline->result.u.EA.type = 0;
        !           614:                                opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !           615:                                opline->op1.op_type = IS_CONST;
        !           616:                                ZVAL_STRINGL(&opline->op1.u.constant,
        !           617:                                        CG(active_op_array)->vars[value->u.var].name, 
        !           618:                                        CG(active_op_array)->vars[value->u.var].name_len, 1);
        !           619:                                SET_UNUSED(opline->op2);
        !           620:                                opline->op2.u.EA.type = ZEND_FETCH_LOCAL;
        !           621:                                value = &opline->result;
        !           622:                        }
        !           623:                }
        !           624:        }
        !           625: 
        !           626:        zend_do_end_variable_parse(variable, BP_VAR_W, 0 TSRMLS_CC);
        !           627: 
        !           628:        last_op_number = get_next_op_number(CG(active_op_array));
        !           629:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           630: 
        !           631:        if (variable->op_type == IS_CV) {
        !           632:                if (variable->u.var == CG(active_op_array)->this_var) {
        !           633:                        zend_error(E_COMPILE_ERROR, "Cannot re-assign $this");
        !           634:                }
        !           635:        } else if (variable->op_type == IS_VAR) {
        !           636:                int n = 0;
        !           637: 
        !           638:                while (last_op_number - n > 0) {
        !           639:                        zend_op *last_op;
        !           640: 
        !           641:                        last_op = &CG(active_op_array)->opcodes[last_op_number-n-1];
        !           642: 
        !           643:                        if (last_op->result.op_type == IS_VAR &&
        !           644:                            last_op->result.u.var == variable->u.var) {
        !           645:                                if (last_op->opcode == ZEND_FETCH_OBJ_W) {
        !           646:                                        if (n > 0) {
        !           647:                                                int opline_no = (opline-CG(active_op_array)->opcodes)/sizeof(*opline);
        !           648:                                                *opline = *last_op;
        !           649:                                                MAKE_NOP(last_op);
        !           650:                                                /* last_op = opline; */
        !           651:                                                opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           652:                                                /* get_next_op can realloc, we need to move last_op */
        !           653:                                                last_op = &CG(active_op_array)->opcodes[opline_no];
        !           654:                                        }
        !           655:                                        last_op->opcode = ZEND_ASSIGN_OBJ;
        !           656:                                        zend_do_op_data(opline, value TSRMLS_CC);
        !           657:                                        SET_UNUSED(opline->result);
        !           658:                                        *result = last_op->result;
        !           659:                                        return;
        !           660:                                } else if (last_op->opcode == ZEND_FETCH_DIM_W) {
        !           661:                                        if (n > 0) {
        !           662:                                                int opline_no = (opline-CG(active_op_array)->opcodes)/sizeof(*opline);
        !           663:                                                *opline = *last_op;
        !           664:                                                MAKE_NOP(last_op);
        !           665:                                                /* last_op = opline; */
        !           666:                                                /* TBFixed: this can realloc opcodes, leaving last_op pointing wrong */
        !           667:                                                opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           668:                                                /* get_next_op can realloc, we need to move last_op */
        !           669:                                                last_op = &CG(active_op_array)->opcodes[opline_no];
        !           670:                                        }
        !           671:                                        last_op->opcode = ZEND_ASSIGN_DIM;
        !           672:                                        zend_do_op_data(opline, value TSRMLS_CC);
        !           673:                                        opline->op2.u.var = get_temporary_variable(CG(active_op_array));
        !           674:                                        opline->op2.u.EA.type = 0;
        !           675:                                        opline->op2.op_type = IS_VAR;
        !           676:                                        SET_UNUSED(opline->result);
        !           677:                                        *result = last_op->result;
        !           678:                                        return;
        !           679:                                } else if (opline_is_fetch_this(last_op TSRMLS_CC)) {
        !           680:                                        zend_error(E_COMPILE_ERROR, "Cannot re-assign $this");
        !           681:                                } else {
        !           682:                                        break;
        !           683:                                }
        !           684:                        }
        !           685:                        n++;
        !           686:                }
        !           687:        }
        !           688: 
        !           689:        opline->opcode = ZEND_ASSIGN;
        !           690:        opline->op1 = *variable;
        !           691:        opline->op2 = *value;
        !           692:        opline->result.op_type = IS_VAR;
        !           693:        opline->result.u.EA.type = 0;
        !           694:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !           695:        *result = opline->result;
        !           696: }
        !           697: /* }}} */
        !           698: 
        !           699: static inline zend_bool zend_is_function_or_method_call(const znode *variable) /* {{{ */
        !           700: {
        !           701:        zend_uint type = variable->u.EA.type;
        !           702: 
        !           703:        return  ((type & ZEND_PARSED_METHOD_CALL) || (type == ZEND_PARSED_FUNCTION_CALL));
        !           704: }
        !           705: /* }}} */
        !           706: 
        !           707: void zend_do_assign_ref(znode *result, const znode *lvar, const znode *rvar TSRMLS_DC) /* {{{ */
        !           708: {
        !           709:        zend_op *opline;
        !           710: 
        !           711:        if (lvar->op_type == IS_CV) {
        !           712:                if (lvar->u.var == CG(active_op_array)->this_var) {
        !           713:                        zend_error(E_COMPILE_ERROR, "Cannot re-assign $this");
        !           714:                }
        !           715:        } else if (lvar->op_type == IS_VAR) {
        !           716:                int last_op_number = get_next_op_number(CG(active_op_array));
        !           717: 
        !           718:                if (last_op_number > 0) {
        !           719:                        opline = &CG(active_op_array)->opcodes[last_op_number-1];
        !           720:                        if (opline_is_fetch_this(opline TSRMLS_CC)) {
        !           721:                                zend_error(E_COMPILE_ERROR, "Cannot re-assign $this");
        !           722:                        }
        !           723:                }
        !           724:        }
        !           725: 
        !           726:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           727:        opline->opcode = ZEND_ASSIGN_REF;
        !           728:        if (zend_is_function_or_method_call(rvar)) {
        !           729:                opline->extended_value = ZEND_RETURNS_FUNCTION;
        !           730:        } else if (rvar->u.EA.type & ZEND_PARSED_NEW) {
        !           731:                opline->extended_value = ZEND_RETURNS_NEW;
        !           732:        } else {
        !           733:                opline->extended_value = 0;
        !           734:        }
        !           735:        if (result) {
        !           736:                opline->result.op_type = IS_VAR;
        !           737:                opline->result.u.EA.type = 0;
        !           738:                opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !           739:                *result = opline->result;
        !           740:        } else {
        !           741:                /* SET_UNUSED(opline->result); */
        !           742:                opline->result.u.EA.type |= EXT_TYPE_UNUSED;
        !           743:        }
        !           744:        opline->op1 = *lvar;
        !           745:        opline->op2 = *rvar;
        !           746: }
        !           747: /* }}} */
        !           748: 
        !           749: static inline void do_begin_loop(TSRMLS_D) /* {{{ */
        !           750: {
        !           751:        zend_brk_cont_element *brk_cont_element;
        !           752:        int parent;
        !           753: 
        !           754:        parent = CG(active_op_array)->current_brk_cont;
        !           755:        CG(active_op_array)->current_brk_cont = CG(active_op_array)->last_brk_cont;
        !           756:        brk_cont_element = get_next_brk_cont_element(CG(active_op_array));
        !           757:        brk_cont_element->start = get_next_op_number(CG(active_op_array));
        !           758:        brk_cont_element->parent = parent;
        !           759: }
        !           760: /* }}} */
        !           761: 
        !           762: static inline void do_end_loop(int cont_addr, int has_loop_var TSRMLS_DC) /* {{{ */
        !           763: {
        !           764:        if (!has_loop_var) {
        !           765:                /* The start fileld is used to free temporary variables in case of exceptions.
        !           766:                 * We won't try to free something of we don't have loop variable.
        !           767:                 */
        !           768:                CG(active_op_array)->brk_cont_array[CG(active_op_array)->current_brk_cont].start = -1;
        !           769:        }
        !           770:        CG(active_op_array)->brk_cont_array[CG(active_op_array)->current_brk_cont].cont = cont_addr;
        !           771:        CG(active_op_array)->brk_cont_array[CG(active_op_array)->current_brk_cont].brk = get_next_op_number(CG(active_op_array));
        !           772:        CG(active_op_array)->current_brk_cont = CG(active_op_array)->brk_cont_array[CG(active_op_array)->current_brk_cont].parent;
        !           773: }
        !           774: /* }}} */
        !           775: 
        !           776: void zend_do_while_cond(const znode *expr, znode *close_bracket_token TSRMLS_DC) /* {{{ */
        !           777: {
        !           778:        int while_cond_op_number = get_next_op_number(CG(active_op_array));
        !           779:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           780: 
        !           781:        opline->opcode = ZEND_JMPZ;
        !           782:        opline->op1 = *expr;
        !           783:        close_bracket_token->u.opline_num = while_cond_op_number;
        !           784:        SET_UNUSED(opline->op2);
        !           785: 
        !           786:        do_begin_loop(TSRMLS_C);
        !           787:        INC_BPC(CG(active_op_array));
        !           788: }
        !           789: /* }}} */
        !           790: 
        !           791: void zend_do_while_end(const znode *while_token, const znode *close_bracket_token TSRMLS_DC) /* {{{ */
        !           792: {
        !           793:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           794: 
        !           795:        /* add unconditional jump */
        !           796:        opline->opcode = ZEND_JMP;
        !           797:        opline->op1.u.opline_num = while_token->u.opline_num;
        !           798:        SET_UNUSED(opline->op1);
        !           799:        SET_UNUSED(opline->op2);
        !           800: 
        !           801:        /* update while's conditional jmp */
        !           802:        CG(active_op_array)->opcodes[close_bracket_token->u.opline_num].op2.u.opline_num = get_next_op_number(CG(active_op_array));
        !           803: 
        !           804:        do_end_loop(while_token->u.opline_num, 0 TSRMLS_CC);
        !           805: 
        !           806:        DEC_BPC(CG(active_op_array));
        !           807: }
        !           808: /* }}} */
        !           809: 
        !           810: void zend_do_for_cond(const znode *expr, znode *second_semicolon_token TSRMLS_DC) /* {{{ */
        !           811: {
        !           812:        int for_cond_op_number = get_next_op_number(CG(active_op_array));
        !           813:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           814: 
        !           815:        opline->opcode = ZEND_JMPZNZ;
        !           816:        opline->op1 = *expr;  /* the conditional expression */
        !           817:        second_semicolon_token->u.opline_num = for_cond_op_number;
        !           818:        SET_UNUSED(opline->op2);
        !           819: }
        !           820: /* }}} */
        !           821: 
        !           822: void zend_do_for_before_statement(const znode *cond_start, const znode *second_semicolon_token TSRMLS_DC) /* {{{ */
        !           823: {
        !           824:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           825: 
        !           826:        opline->opcode = ZEND_JMP;
        !           827:        opline->op1.u.opline_num = cond_start->u.opline_num;
        !           828:        CG(active_op_array)->opcodes[second_semicolon_token->u.opline_num].extended_value = get_next_op_number(CG(active_op_array));
        !           829:        SET_UNUSED(opline->op1);
        !           830:        SET_UNUSED(opline->op2);
        !           831: 
        !           832:        do_begin_loop(TSRMLS_C);
        !           833: 
        !           834:        INC_BPC(CG(active_op_array));
        !           835: }
        !           836: /* }}} */
        !           837: 
        !           838: void zend_do_for_end(const znode *second_semicolon_token TSRMLS_DC) /* {{{ */
        !           839: {
        !           840:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           841: 
        !           842:        opline->opcode = ZEND_JMP;
        !           843:        opline->op1.u.opline_num = second_semicolon_token->u.opline_num+1;
        !           844:        CG(active_op_array)->opcodes[second_semicolon_token->u.opline_num].op2.u.opline_num = get_next_op_number(CG(active_op_array));
        !           845:        SET_UNUSED(opline->op1);
        !           846:        SET_UNUSED(opline->op2);
        !           847: 
        !           848:        do_end_loop(second_semicolon_token->u.opline_num+1, 0 TSRMLS_CC);
        !           849: 
        !           850:        DEC_BPC(CG(active_op_array));
        !           851: }
        !           852: /* }}} */
        !           853: 
        !           854: void zend_do_pre_incdec(znode *result, const znode *op1, zend_uchar op TSRMLS_DC) /* {{{ */
        !           855: {
        !           856:        int last_op_number = get_next_op_number(CG(active_op_array));
        !           857:        zend_op *opline;
        !           858: 
        !           859:        if (last_op_number > 0) {
        !           860:                zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number-1];
        !           861: 
        !           862:                if (last_op->opcode == ZEND_FETCH_OBJ_RW) {
        !           863:                        last_op->opcode = (op==ZEND_PRE_INC)?ZEND_PRE_INC_OBJ:ZEND_PRE_DEC_OBJ;
        !           864:                        last_op->result.op_type = IS_VAR;
        !           865:                        last_op->result.u.EA.type = 0;
        !           866:                        last_op->result.u.var = get_temporary_variable(CG(active_op_array));
        !           867:                        *result = last_op->result;
        !           868:                        return;
        !           869:                }
        !           870:        }
        !           871: 
        !           872:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           873:        opline->opcode = op;
        !           874:        opline->op1 = *op1;
        !           875:        SET_UNUSED(opline->op2);
        !           876:        opline->result.op_type = IS_VAR;
        !           877:        opline->result.u.EA.type = 0;
        !           878:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !           879:        *result = opline->result;
        !           880: }
        !           881: /* }}} */
        !           882: 
        !           883: void zend_do_post_incdec(znode *result, const znode *op1, zend_uchar op TSRMLS_DC) /* {{{ */
        !           884: {
        !           885:        int last_op_number = get_next_op_number(CG(active_op_array));
        !           886:        zend_op *opline;
        !           887: 
        !           888:        if (last_op_number > 0) {
        !           889:                zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number-1];
        !           890: 
        !           891:                if (last_op->opcode == ZEND_FETCH_OBJ_RW) {
        !           892:                        last_op->opcode = (op==ZEND_POST_INC)?ZEND_POST_INC_OBJ:ZEND_POST_DEC_OBJ;
        !           893:                        last_op->result.op_type = IS_TMP_VAR;
        !           894:                        last_op->result.u.var = get_temporary_variable(CG(active_op_array));
        !           895:                        *result = last_op->result;
        !           896:                        return;
        !           897:                }
        !           898:        }
        !           899: 
        !           900:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           901:        opline->opcode = op;
        !           902:        opline->op1 = *op1;
        !           903:        SET_UNUSED(opline->op2);
        !           904:        opline->result.op_type = IS_TMP_VAR;
        !           905:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !           906:        *result = opline->result;
        !           907: }
        !           908: /* }}} */
        !           909: 
        !           910: void zend_do_if_cond(const znode *cond, znode *closing_bracket_token TSRMLS_DC) /* {{{ */
        !           911: {
        !           912:        int if_cond_op_number = get_next_op_number(CG(active_op_array));
        !           913:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           914: 
        !           915:        opline->opcode = ZEND_JMPZ;
        !           916:        opline->op1 = *cond;
        !           917:        closing_bracket_token->u.opline_num = if_cond_op_number;
        !           918:        SET_UNUSED(opline->op2);
        !           919:        INC_BPC(CG(active_op_array));
        !           920: }
        !           921: /* }}} */
        !           922: 
        !           923: void zend_do_if_after_statement(const znode *closing_bracket_token, unsigned char initialize TSRMLS_DC) /* {{{ */
        !           924: {
        !           925:        int if_end_op_number = get_next_op_number(CG(active_op_array));
        !           926:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !           927:        zend_llist *jmp_list_ptr;
        !           928: 
        !           929:        opline->opcode = ZEND_JMP;
        !           930:        /* save for backpatching */
        !           931:        if (initialize) {
        !           932:                zend_llist jmp_list;
        !           933: 
        !           934:                zend_llist_init(&jmp_list, sizeof(int), NULL, 0);
        !           935:                zend_stack_push(&CG(bp_stack), (void *) &jmp_list, sizeof(zend_llist));
        !           936:        }
        !           937:        zend_stack_top(&CG(bp_stack), (void **) &jmp_list_ptr);
        !           938:        zend_llist_add_element(jmp_list_ptr, &if_end_op_number);
        !           939: 
        !           940:        CG(active_op_array)->opcodes[closing_bracket_token->u.opline_num].op2.u.opline_num = if_end_op_number+1;
        !           941:        SET_UNUSED(opline->op1);
        !           942:        SET_UNUSED(opline->op2);
        !           943: }
        !           944: /* }}} */
        !           945: 
        !           946: void zend_do_if_end(TSRMLS_D) /* {{{ */
        !           947: {
        !           948:        int next_op_number = get_next_op_number(CG(active_op_array));
        !           949:        zend_llist *jmp_list_ptr;
        !           950:        zend_llist_element *le;
        !           951: 
        !           952:        zend_stack_top(&CG(bp_stack), (void **) &jmp_list_ptr);
        !           953:        for (le=jmp_list_ptr->head; le; le = le->next) {
        !           954:                CG(active_op_array)->opcodes[*((int *) le->data)].op1.u.opline_num = next_op_number;
        !           955:        }
        !           956:        zend_llist_destroy(jmp_list_ptr);
        !           957:        zend_stack_del_top(&CG(bp_stack));
        !           958:        DEC_BPC(CG(active_op_array));
        !           959: }
        !           960: /* }}} */
        !           961: 
        !           962: void zend_check_writable_variable(const znode *variable) /* {{{ */
        !           963: {
        !           964:        zend_uint type = variable->u.EA.type;
        !           965: 
        !           966:        if (type & ZEND_PARSED_METHOD_CALL) {
        !           967:                zend_error(E_COMPILE_ERROR, "Can't use method return value in write context");
        !           968:        }
        !           969:        if (type == ZEND_PARSED_FUNCTION_CALL) {
        !           970:                zend_error(E_COMPILE_ERROR, "Can't use function return value in write context");
        !           971:        }
        !           972: }
        !           973: /* }}} */
        !           974: 
        !           975: void zend_do_begin_variable_parse(TSRMLS_D) /* {{{ */
        !           976: {
        !           977:        zend_llist fetch_list;
        !           978: 
        !           979:        zend_llist_init(&fetch_list, sizeof(zend_op), NULL, 0);
        !           980:        zend_stack_push(&CG(bp_stack), (void *) &fetch_list, sizeof(zend_llist));
        !           981: }
        !           982: /* }}} */
        !           983: 
        !           984: void zend_do_end_variable_parse(znode *variable, int type, int arg_offset TSRMLS_DC) /* {{{ */
        !           985: {
        !           986:        zend_llist *fetch_list_ptr;
        !           987:        zend_llist_element *le;
        !           988:        zend_op *opline = NULL;
        !           989:        zend_op *opline_ptr;
        !           990:        zend_uint this_var = -1;
        !           991: 
        !           992:        zend_stack_top(&CG(bp_stack), (void **) &fetch_list_ptr);
        !           993: 
        !           994:        le = fetch_list_ptr->head;
        !           995: 
        !           996:        /* TODO: $foo->x->y->z = 1 should fetch "x" and "y" for R or RW, not just W */
        !           997: 
        !           998:        if (le) {
        !           999:                opline_ptr = (zend_op *)le->data;
        !          1000:                if (opline_is_fetch_this(opline_ptr TSRMLS_CC)) {
        !          1001:                        /* convert to FETCH_?(this) into IS_CV */
        !          1002:                        if (CG(active_op_array)->last == 0 ||
        !          1003:                            CG(active_op_array)->opcodes[CG(active_op_array)->last-1].opcode != ZEND_BEGIN_SILENCE) {
        !          1004: 
        !          1005:                                this_var = opline_ptr->result.u.var;
        !          1006:                                if (CG(active_op_array)->this_var == -1) {
        !          1007:                                        CG(active_op_array)->this_var = lookup_cv(CG(active_op_array), Z_STRVAL(opline_ptr->op1.u.constant), Z_STRLEN(opline_ptr->op1.u.constant));
        !          1008:                                } else {
        !          1009:                                        efree(Z_STRVAL(opline_ptr->op1.u.constant));
        !          1010:                                }
        !          1011:                                le = le->next;
        !          1012:                                if (variable->op_type == IS_VAR &&
        !          1013:                                    variable->u.var == this_var) {
        !          1014:                                        variable->op_type = IS_CV;
        !          1015:                                        variable->u.var = CG(active_op_array)->this_var;
        !          1016:                                }
        !          1017:                        } else if (CG(active_op_array)->this_var == -1) {
        !          1018:                                CG(active_op_array)->this_var = lookup_cv(CG(active_op_array), estrndup("this", sizeof("this")-1), sizeof("this")-1);
        !          1019:                        }
        !          1020:                }
        !          1021: 
        !          1022:                while (le) {
        !          1023:                        opline_ptr = (zend_op *)le->data;
        !          1024:                        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          1025:                        memcpy(opline, opline_ptr, sizeof(zend_op));
        !          1026:                        if (opline->op1.op_type == IS_VAR &&
        !          1027:                            opline->op1.u.var == this_var) {
        !          1028:                                opline->op1.op_type = IS_CV;
        !          1029:                                opline->op1.u.var = CG(active_op_array)->this_var;
        !          1030:                        }
        !          1031:                        switch (type) {
        !          1032:                                case BP_VAR_R:
        !          1033:                                        if (opline->opcode == ZEND_FETCH_DIM_W && opline->op2.op_type == IS_UNUSED) {
        !          1034:                                                zend_error(E_COMPILE_ERROR, "Cannot use [] for reading");
        !          1035:                                        }
        !          1036:                                        opline->opcode -= 3;
        !          1037:                                        break;
        !          1038:                                case BP_VAR_W:
        !          1039:                                        break;
        !          1040:                                case BP_VAR_RW:
        !          1041:                                        opline->opcode += 3;
        !          1042:                                        break;
        !          1043:                                case BP_VAR_IS:
        !          1044:                                        if (opline->opcode == ZEND_FETCH_DIM_W && opline->op2.op_type == IS_UNUSED) {
        !          1045:                                                zend_error(E_COMPILE_ERROR, "Cannot use [] for reading");
        !          1046:                                        }
        !          1047:                                        opline->opcode += 6; /* 3+3 */
        !          1048:                                        break;
        !          1049:                                case BP_VAR_FUNC_ARG:
        !          1050:                                        opline->opcode += 9; /* 3+3+3 */
        !          1051:                                        opline->extended_value = arg_offset;
        !          1052:                                        break;
        !          1053:                                case BP_VAR_UNSET:
        !          1054:                                        if (opline->opcode == ZEND_FETCH_DIM_W && opline->op2.op_type == IS_UNUSED) {
        !          1055:                                                zend_error(E_COMPILE_ERROR, "Cannot use [] for unsetting");
        !          1056:                                        }
        !          1057:                                        opline->opcode += 12; /* 3+3+3+3 */
        !          1058:                                        break;
        !          1059:                        }
        !          1060:                        le = le->next;
        !          1061:                }
        !          1062:                if (opline && type == BP_VAR_W && arg_offset) {
        !          1063:                        opline->extended_value = ZEND_FETCH_MAKE_REF;
        !          1064:                }
        !          1065:        }
        !          1066:        zend_llist_destroy(fetch_list_ptr);
        !          1067:        zend_stack_del_top(&CG(bp_stack));
        !          1068: }
        !          1069: /* }}} */
        !          1070: 
        !          1071: void zend_do_add_string(znode *result, const znode *op1, znode *op2 TSRMLS_DC) /* {{{ */
        !          1072: {
        !          1073:        zend_op *opline;
        !          1074: 
        !          1075:        if (Z_STRLEN(op2->u.constant) > 1) {
        !          1076:                opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          1077:                opline->opcode = ZEND_ADD_STRING;
        !          1078:        } else if (Z_STRLEN(op2->u.constant) == 1) {
        !          1079:                int ch = *Z_STRVAL(op2->u.constant);
        !          1080: 
        !          1081:                /* Free memory and use ZEND_ADD_CHAR in case of 1 character strings */
        !          1082:                efree(Z_STRVAL(op2->u.constant));
        !          1083:                ZVAL_LONG(&op2->u.constant, ch);
        !          1084:                opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          1085:                opline->opcode = ZEND_ADD_CHAR;
        !          1086:        } else { /* String can be empty after a variable at the end of a heredoc */
        !          1087:                efree(Z_STRVAL(op2->u.constant));
        !          1088:                return;
        !          1089:        }
        !          1090: 
        !          1091:        if (op1) {
        !          1092:                opline->op1 = *op1;
        !          1093:                opline->result = *op1;
        !          1094:        } else {
        !          1095:                SET_UNUSED(opline->op1);
        !          1096:                opline->result.op_type = IS_TMP_VAR;
        !          1097:                opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          1098:        }
        !          1099:        opline->op2 = *op2;
        !          1100:        *result = opline->result;
        !          1101: }
        !          1102: /* }}} */
        !          1103: 
        !          1104: void zend_do_add_variable(znode *result, const znode *op1, const znode *op2 TSRMLS_DC) /* {{{ */
        !          1105: {
        !          1106:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          1107: 
        !          1108:        opline->opcode = ZEND_ADD_VAR;
        !          1109: 
        !          1110:        if (op1) {
        !          1111:                opline->op1 = *op1;
        !          1112:                opline->result = *op1;
        !          1113:        } else {
        !          1114:                SET_UNUSED(opline->op1);
        !          1115:                opline->result.op_type = IS_TMP_VAR;
        !          1116:                opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          1117:        }
        !          1118:        opline->op2 = *op2;
        !          1119:        *result = opline->result;
        !          1120: }
        !          1121: /* }}} */
        !          1122: 
        !          1123: void zend_do_free(znode *op1 TSRMLS_DC) /* {{{ */
        !          1124: {
        !          1125:        if (op1->op_type==IS_TMP_VAR) {
        !          1126:                zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          1127: 
        !          1128:                opline->opcode = ZEND_FREE;
        !          1129:                opline->op1 = *op1;
        !          1130:                SET_UNUSED(opline->op2);
        !          1131:        } else if (op1->op_type==IS_VAR) {
        !          1132:                zend_op *opline = &CG(active_op_array)->opcodes[CG(active_op_array)->last-1];
        !          1133: 
        !          1134:                while (opline->opcode == ZEND_END_SILENCE || opline->opcode == ZEND_EXT_FCALL_END || opline->opcode == ZEND_OP_DATA) {
        !          1135:                        opline--;
        !          1136:                }
        !          1137:                if (opline->result.op_type == IS_VAR
        !          1138:                        && opline->result.u.var == op1->u.var) {
        !          1139:                        opline->result.u.EA.type |= EXT_TYPE_UNUSED;
        !          1140:                } else {
        !          1141:                        while (opline>CG(active_op_array)->opcodes) {
        !          1142:                                if (opline->opcode == ZEND_FETCH_DIM_R
        !          1143:                                    && opline->op1.op_type == IS_VAR
        !          1144:                                    && opline->op1.u.var == op1->u.var) {
        !          1145:                                        /* This should the end of a list() construct
        !          1146:                                         * Mark its result as unused
        !          1147:                                         */
        !          1148:                                        opline->extended_value = ZEND_FETCH_STANDARD;
        !          1149:                                        break;
        !          1150:                                } else if (opline->result.op_type==IS_VAR
        !          1151:                                        && opline->result.u.var == op1->u.var) {
        !          1152:                                        if (opline->opcode == ZEND_NEW) {
        !          1153:                                                opline->result.u.EA.type |= EXT_TYPE_UNUSED;
        !          1154:                                        }
        !          1155:                                        break;
        !          1156:                                }
        !          1157:                                opline--;
        !          1158:                        }
        !          1159:                }
        !          1160:        } else if (op1->op_type == IS_CONST) {
        !          1161:                zval_dtor(&op1->u.constant);
        !          1162:        }
        !          1163: }
        !          1164: /* }}} */
        !          1165: 
        !          1166: int zend_do_verify_access_types(const znode *current_access_type, const znode *new_modifier) /* {{{ */
        !          1167: {
        !          1168:        if ((Z_LVAL(current_access_type->u.constant) & ZEND_ACC_PPP_MASK)
        !          1169:                && (Z_LVAL(new_modifier->u.constant) & ZEND_ACC_PPP_MASK)) {
        !          1170:                zend_error(E_COMPILE_ERROR, "Multiple access type modifiers are not allowed");
        !          1171:        }
        !          1172:        if ((Z_LVAL(current_access_type->u.constant) & ZEND_ACC_ABSTRACT)
        !          1173:                && (Z_LVAL(new_modifier->u.constant) & ZEND_ACC_ABSTRACT)) {
        !          1174:                zend_error(E_COMPILE_ERROR, "Multiple abstract modifiers are not allowed");
        !          1175:        }
        !          1176:        if ((Z_LVAL(current_access_type->u.constant) & ZEND_ACC_STATIC)
        !          1177:                && (Z_LVAL(new_modifier->u.constant) & ZEND_ACC_STATIC)) {
        !          1178:                zend_error(E_COMPILE_ERROR, "Multiple static modifiers are not allowed");
        !          1179:        }
        !          1180:        if ((Z_LVAL(current_access_type->u.constant) & ZEND_ACC_FINAL)
        !          1181:                && (Z_LVAL(new_modifier->u.constant) & ZEND_ACC_FINAL)) {
        !          1182:                zend_error(E_COMPILE_ERROR, "Multiple final modifiers are not allowed");
        !          1183:        }
        !          1184:        if (((Z_LVAL(current_access_type->u.constant) | Z_LVAL(new_modifier->u.constant)) & (ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL)) == (ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL)) {
        !          1185:                zend_error(E_COMPILE_ERROR, "Cannot use the final modifier on an abstract class member");
        !          1186:        }
        !          1187:        return (Z_LVAL(current_access_type->u.constant) | Z_LVAL(new_modifier->u.constant));
        !          1188: }
        !          1189: /* }}} */
        !          1190: 
        !          1191: void zend_do_begin_function_declaration(znode *function_token, znode *function_name, int is_method, int return_reference, znode *fn_flags_znode TSRMLS_DC) /* {{{ */
        !          1192: {
        !          1193:        zend_op_array op_array;
        !          1194:        char *name = function_name->u.constant.value.str.val;
        !          1195:        int name_len = function_name->u.constant.value.str.len;
        !          1196:        int function_begin_line = function_token->u.opline_num;
        !          1197:        zend_uint fn_flags;
        !          1198:        char *lcname;
        !          1199:        zend_bool orig_interactive;
        !          1200:        ALLOCA_FLAG(use_heap)
        !          1201: 
        !          1202:        if (is_method) {
        !          1203:                if (CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE) {
        !          1204:                        if ((Z_LVAL(fn_flags_znode->u.constant) & ~(ZEND_ACC_STATIC|ZEND_ACC_PUBLIC))) {
        !          1205:                                zend_error(E_COMPILE_ERROR, "Access type for interface method %s::%s() must be omitted", CG(active_class_entry)->name, function_name->u.constant.value.str.val);
        !          1206:                        }
        !          1207:                        Z_LVAL(fn_flags_znode->u.constant) |= ZEND_ACC_ABSTRACT; /* propagates to the rest of the parser */
        !          1208:                }
        !          1209:                fn_flags = Z_LVAL(fn_flags_znode->u.constant); /* must be done *after* the above check */
        !          1210:        } else {
        !          1211:                fn_flags = 0;
        !          1212:        }
        !          1213:        if ((fn_flags & ZEND_ACC_STATIC) && (fn_flags & ZEND_ACC_ABSTRACT) && !(CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE)) {
        !          1214:                zend_error(E_STRICT, "Static function %s%s%s() should not be abstract", is_method ? CG(active_class_entry)->name : "", is_method ? "::" : "", Z_STRVAL(function_name->u.constant));
        !          1215:        }
        !          1216: 
        !          1217:        function_token->u.op_array = CG(active_op_array);
        !          1218:        lcname = zend_str_tolower_dup(name, name_len);
        !          1219: 
        !          1220:        orig_interactive = CG(interactive);
        !          1221:        CG(interactive) = 0;
        !          1222:        init_op_array(&op_array, ZEND_USER_FUNCTION, INITIAL_OP_ARRAY_SIZE TSRMLS_CC);
        !          1223:        CG(interactive) = orig_interactive;
        !          1224: 
        !          1225:        op_array.function_name = name;
        !          1226:        op_array.return_reference = return_reference;
        !          1227:        op_array.fn_flags |= fn_flags;
        !          1228:        op_array.pass_rest_by_reference = 0;
        !          1229: 
        !          1230:        op_array.scope = is_method?CG(active_class_entry):NULL;
        !          1231:        op_array.prototype = NULL;
        !          1232: 
        !          1233:        op_array.line_start = zend_get_compiled_lineno(TSRMLS_C);
        !          1234: 
        !          1235:        if (is_method) {
        !          1236:                if (zend_hash_add(&CG(active_class_entry)->function_table, lcname, name_len+1, &op_array, sizeof(zend_op_array), (void **) &CG(active_op_array)) == FAILURE) {
        !          1237:                        zend_error(E_COMPILE_ERROR, "Cannot redeclare %s::%s()", CG(active_class_entry)->name, name);
        !          1238:                }
        !          1239: 
        !          1240:                if (fn_flags & ZEND_ACC_ABSTRACT) {
        !          1241:                        CG(active_class_entry)->ce_flags |= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS;
        !          1242:                }
        !          1243: 
        !          1244:                if (!(fn_flags & ZEND_ACC_PPP_MASK)) {
        !          1245:                        fn_flags |= ZEND_ACC_PUBLIC;
        !          1246:                }
        !          1247: 
        !          1248:                if (CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE) {
        !          1249:                        if ((name_len == sizeof(ZEND_CALL_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)-1))) {
        !          1250:                                if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
        !          1251:                                        zend_error(E_WARNING, "The magic method __call() must have public visibility and cannot be static");
        !          1252:                                }
        !          1253:                        } else if ((name_len == sizeof(ZEND_CALLSTATIC_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_CALLSTATIC_FUNC_NAME, sizeof(ZEND_CALLSTATIC_FUNC_NAME)-1))) {
        !          1254:                                if ((fn_flags & (ZEND_ACC_PPP_MASK ^ ZEND_ACC_PUBLIC)) || (fn_flags & ZEND_ACC_STATIC) == 0) {
        !          1255:                                        zend_error(E_WARNING, "The magic method __callStatic() must have public visibility and be static");
        !          1256:                                }
        !          1257:                        } else if ((name_len == sizeof(ZEND_GET_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_GET_FUNC_NAME, sizeof(ZEND_GET_FUNC_NAME)-1))) {
        !          1258:                                if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
        !          1259:                                        zend_error(E_WARNING, "The magic method __get() must have public visibility and cannot be static");
        !          1260:                                }
        !          1261:                        } else if ((name_len == sizeof(ZEND_SET_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME)-1))) {
        !          1262:                                if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
        !          1263:                                        zend_error(E_WARNING, "The magic method __set() must have public visibility and cannot be static");
        !          1264:                                }
        !          1265:                        } else if ((name_len == sizeof(ZEND_UNSET_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_UNSET_FUNC_NAME, sizeof(ZEND_UNSET_FUNC_NAME)-1))) {
        !          1266:                                if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
        !          1267:                                        zend_error(E_WARNING, "The magic method __unset() must have public visibility and cannot be static");
        !          1268:                                }
        !          1269:                        } else if ((name_len == sizeof(ZEND_ISSET_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_ISSET_FUNC_NAME, sizeof(ZEND_ISSET_FUNC_NAME)-1))) {
        !          1270:                                if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
        !          1271:                                        zend_error(E_WARNING, "The magic method __isset() must have public visibility and cannot be static");
        !          1272:                                }
        !          1273:                        } else if ((name_len == sizeof(ZEND_TOSTRING_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_TOSTRING_FUNC_NAME, sizeof(ZEND_TOSTRING_FUNC_NAME)-1))) {
        !          1274:                                if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
        !          1275:                                        zend_error(E_WARNING, "The magic method __toString() must have public visibility and cannot be static");
        !          1276:                                }
        !          1277:                        }
        !          1278:                } else {
        !          1279:                        char *class_lcname;
        !          1280:                        
        !          1281:                        class_lcname = do_alloca(CG(active_class_entry)->name_length + 1, use_heap);
        !          1282:                        zend_str_tolower_copy(class_lcname, CG(active_class_entry)->name, CG(active_class_entry)->name_length);
        !          1283:                        /* Improve after RC: cache the lowercase class name */
        !          1284: 
        !          1285:                        if ((CG(active_class_entry)->name_length == name_len) && (!memcmp(class_lcname, lcname, name_len))) {
        !          1286:                                if (!CG(active_class_entry)->constructor) {
        !          1287:                                        CG(active_class_entry)->constructor = (zend_function *) CG(active_op_array);
        !          1288:                                }
        !          1289:                        } else if ((name_len == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)))) {
        !          1290:                                if (CG(active_class_entry)->constructor) {
        !          1291:                                        zend_error(E_STRICT, "Redefining already defined constructor for class %s", CG(active_class_entry)->name);
        !          1292:                                }
        !          1293:                                CG(active_class_entry)->constructor = (zend_function *) CG(active_op_array);
        !          1294:                        } else if ((name_len == sizeof(ZEND_DESTRUCTOR_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_DESTRUCTOR_FUNC_NAME, sizeof(ZEND_DESTRUCTOR_FUNC_NAME)-1))) {
        !          1295:                                CG(active_class_entry)->destructor = (zend_function *) CG(active_op_array);
        !          1296:                        } else if ((name_len == sizeof(ZEND_CLONE_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_CLONE_FUNC_NAME, sizeof(ZEND_CLONE_FUNC_NAME)-1))) {
        !          1297:                                CG(active_class_entry)->clone = (zend_function *) CG(active_op_array);
        !          1298:                        } else if ((name_len == sizeof(ZEND_CALL_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)-1))) {
        !          1299:                                if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
        !          1300:                                        zend_error(E_WARNING, "The magic method __call() must have public visibility and cannot be static");
        !          1301:                                }
        !          1302:                                CG(active_class_entry)->__call = (zend_function *) CG(active_op_array);
        !          1303:                        } else if ((name_len == sizeof(ZEND_CALLSTATIC_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_CALLSTATIC_FUNC_NAME, sizeof(ZEND_CALLSTATIC_FUNC_NAME)-1))) {
        !          1304:                                if ((fn_flags & (ZEND_ACC_PPP_MASK ^ ZEND_ACC_PUBLIC)) || (fn_flags & ZEND_ACC_STATIC) == 0) {
        !          1305:                                        zend_error(E_WARNING, "The magic method __callStatic() must have public visibility and be static");
        !          1306:                                }
        !          1307:                                CG(active_class_entry)->__callstatic = (zend_function *) CG(active_op_array);
        !          1308:                        } else if ((name_len == sizeof(ZEND_GET_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_GET_FUNC_NAME, sizeof(ZEND_GET_FUNC_NAME)-1))) {
        !          1309:                                if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
        !          1310:                                        zend_error(E_WARNING, "The magic method __get() must have public visibility and cannot be static");
        !          1311:                                }
        !          1312:                                CG(active_class_entry)->__get = (zend_function *) CG(active_op_array);
        !          1313:                        } else if ((name_len == sizeof(ZEND_SET_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME)-1))) {
        !          1314:                                if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
        !          1315:                                        zend_error(E_WARNING, "The magic method __set() must have public visibility and cannot be static");
        !          1316:                                }
        !          1317:                                CG(active_class_entry)->__set = (zend_function *) CG(active_op_array);
        !          1318:                        } else if ((name_len == sizeof(ZEND_UNSET_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_UNSET_FUNC_NAME, sizeof(ZEND_UNSET_FUNC_NAME)-1))) {
        !          1319:                                if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
        !          1320:                                        zend_error(E_WARNING, "The magic method __unset() must have public visibility and cannot be static");
        !          1321:                                }
        !          1322:                                CG(active_class_entry)->__unset = (zend_function *) CG(active_op_array);
        !          1323:                        } else if ((name_len == sizeof(ZEND_ISSET_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_ISSET_FUNC_NAME, sizeof(ZEND_ISSET_FUNC_NAME)-1))) {
        !          1324:                                if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
        !          1325:                                        zend_error(E_WARNING, "The magic method __isset() must have public visibility and cannot be static");
        !          1326:                                }
        !          1327:                                CG(active_class_entry)->__isset = (zend_function *) CG(active_op_array);
        !          1328:                        } else if ((name_len == sizeof(ZEND_TOSTRING_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_TOSTRING_FUNC_NAME, sizeof(ZEND_TOSTRING_FUNC_NAME)-1))) {
        !          1329:                                if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
        !          1330:                                        zend_error(E_WARNING, "The magic method __toString() must have public visibility and cannot be static");
        !          1331:                                }                               
        !          1332:                                CG(active_class_entry)->__tostring = (zend_function *) CG(active_op_array);
        !          1333:                        } else if (!(fn_flags & ZEND_ACC_STATIC)) {
        !          1334:                                CG(active_op_array)->fn_flags |= ZEND_ACC_ALLOW_STATIC;
        !          1335:                        }
        !          1336:                        free_alloca(class_lcname, use_heap);
        !          1337:                }
        !          1338: 
        !          1339:                efree(lcname);
        !          1340:        } else {
        !          1341:                zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          1342: 
        !          1343:                if (CG(current_namespace)) {
        !          1344:                        /* Prefix function name with current namespcae name */
        !          1345:                        znode tmp;
        !          1346: 
        !          1347:                        tmp.u.constant = *CG(current_namespace);
        !          1348:                        zval_copy_ctor(&tmp.u.constant);
        !          1349:                        zend_do_build_namespace_name(&tmp, &tmp, function_name TSRMLS_CC);
        !          1350:                        op_array.function_name = Z_STRVAL(tmp.u.constant);
        !          1351:                        efree(lcname);
        !          1352:                        name_len = Z_STRLEN(tmp.u.constant);
        !          1353:                        lcname = zend_str_tolower_dup(Z_STRVAL(tmp.u.constant), name_len);
        !          1354:                }
        !          1355: 
        !          1356:                opline->opcode = ZEND_DECLARE_FUNCTION;
        !          1357:                opline->op1.op_type = IS_CONST;
        !          1358:                build_runtime_defined_function_key(&opline->op1.u.constant, lcname, name_len TSRMLS_CC);
        !          1359:                opline->op2.op_type = IS_CONST;
        !          1360:                opline->op2.u.constant.type = IS_STRING;
        !          1361:                opline->op2.u.constant.value.str.val = lcname;
        !          1362:                opline->op2.u.constant.value.str.len = name_len;
        !          1363:                Z_SET_REFCOUNT(opline->op2.u.constant, 1);
        !          1364:                opline->extended_value = ZEND_DECLARE_FUNCTION;
        !          1365:                zend_hash_update(CG(function_table), opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len, &op_array, sizeof(zend_op_array), (void **) &CG(active_op_array));
        !          1366:        }
        !          1367: 
        !          1368:        if (CG(compiler_options) & ZEND_COMPILE_EXTENDED_INFO) {
        !          1369:                zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          1370: 
        !          1371:                opline->opcode = ZEND_EXT_NOP;
        !          1372:                opline->lineno = function_begin_line;
        !          1373:                SET_UNUSED(opline->op1);
        !          1374:                SET_UNUSED(opline->op2);
        !          1375:        }
        !          1376: 
        !          1377:        {
        !          1378:                /* Push a seperator to the switch and foreach stacks */
        !          1379:                zend_switch_entry switch_entry;
        !          1380: 
        !          1381:                switch_entry.cond.op_type = IS_UNUSED;
        !          1382:                switch_entry.default_case = 0;
        !          1383:                switch_entry.control_var = 0;
        !          1384: 
        !          1385:                zend_stack_push(&CG(switch_cond_stack), (void *) &switch_entry, sizeof(switch_entry));
        !          1386: 
        !          1387:                {
        !          1388:                        /* Foreach stack separator */
        !          1389:                        zend_op dummy_opline;
        !          1390: 
        !          1391:                        dummy_opline.result.op_type = IS_UNUSED;
        !          1392:                        dummy_opline.op1.op_type = IS_UNUSED;
        !          1393: 
        !          1394:                        zend_stack_push(&CG(foreach_copy_stack), (void *) &dummy_opline, sizeof(zend_op));
        !          1395:                }
        !          1396:        }
        !          1397: 
        !          1398:        if (CG(doc_comment)) {
        !          1399:                CG(active_op_array)->doc_comment = CG(doc_comment);
        !          1400:                CG(active_op_array)->doc_comment_len = CG(doc_comment_len);
        !          1401:                CG(doc_comment) = NULL;
        !          1402:                CG(doc_comment_len) = 0;
        !          1403:        }
        !          1404: 
        !          1405:        zend_stack_push(&CG(labels_stack), (void *) &CG(labels), sizeof(HashTable*));
        !          1406:        CG(labels) = NULL;
        !          1407: }
        !          1408: /* }}} */
        !          1409: 
        !          1410: void zend_do_begin_lambda_function_declaration(znode *result, znode *function_token, int return_reference TSRMLS_DC) /* {{{ */
        !          1411: {
        !          1412:        znode          function_name;
        !          1413:        zend_op_array *current_op_array = CG(active_op_array);
        !          1414:        int            current_op_number = get_next_op_number(CG(active_op_array));
        !          1415:        zend_op       *current_op;
        !          1416: 
        !          1417:        function_name.op_type = IS_CONST;
        !          1418:        ZVAL_STRINGL(&function_name.u.constant, "{closure}", sizeof("{closure}")-1, 1);
        !          1419: 
        !          1420:        zend_do_begin_function_declaration(function_token, &function_name, 0, return_reference, NULL TSRMLS_CC);
        !          1421: 
        !          1422:        result->op_type = IS_TMP_VAR;
        !          1423:        result->u.var = get_temporary_variable(current_op_array);
        !          1424: 
        !          1425:        current_op = &current_op_array->opcodes[current_op_number];
        !          1426:        current_op->opcode = ZEND_DECLARE_LAMBDA_FUNCTION;
        !          1427:        zval_dtor(&current_op->op2.u.constant);
        !          1428:        ZVAL_LONG(&current_op->op2.u.constant, zend_hash_func(Z_STRVAL(current_op->op1.u.constant), Z_STRLEN(current_op->op1.u.constant)));
        !          1429:        current_op->result = *result;
        !          1430:        CG(active_op_array)->fn_flags |= ZEND_ACC_CLOSURE;
        !          1431: }
        !          1432: /* }}} */
        !          1433: 
        !          1434: void zend_do_handle_exception(TSRMLS_D) /* {{{ */
        !          1435: {
        !          1436:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          1437: 
        !          1438:        opline->opcode = ZEND_HANDLE_EXCEPTION;
        !          1439:        SET_UNUSED(opline->op1);
        !          1440:        SET_UNUSED(opline->op2);
        !          1441: }
        !          1442: /* }}} */
        !          1443: 
        !          1444: void zend_do_end_function_declaration(const znode *function_token TSRMLS_DC) /* {{{ */
        !          1445: {
        !          1446:        char lcname[16];
        !          1447:        int name_len;
        !          1448: 
        !          1449:        zend_do_extended_info(TSRMLS_C);
        !          1450:        zend_do_return(NULL, 0 TSRMLS_CC);
        !          1451: 
        !          1452:        pass_two(CG(active_op_array) TSRMLS_CC);
        !          1453:        zend_release_labels(TSRMLS_C);
        !          1454: 
        !          1455:        if (CG(active_class_entry)) {
        !          1456:                zend_check_magic_method_implementation(CG(active_class_entry), (zend_function*)CG(active_op_array), E_COMPILE_ERROR TSRMLS_CC);
        !          1457:        } else {
        !          1458:                /* we don't care if the function name is longer, in fact lowercasing only 
        !          1459:                 * the beginning of the name speeds up the check process */
        !          1460:                name_len = strlen(CG(active_op_array)->function_name);
        !          1461:                zend_str_tolower_copy(lcname, CG(active_op_array)->function_name, MIN(name_len, sizeof(lcname)-1));
        !          1462:                lcname[sizeof(lcname)-1] = '\0'; /* zend_str_tolower_copy won't necessarily set the zero byte */
        !          1463:                if (name_len == sizeof(ZEND_AUTOLOAD_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_AUTOLOAD_FUNC_NAME, sizeof(ZEND_AUTOLOAD_FUNC_NAME)) && CG(active_op_array)->num_args != 1) {
        !          1464:                        zend_error(E_COMPILE_ERROR, "%s() must take exactly 1 argument", ZEND_AUTOLOAD_FUNC_NAME);
        !          1465:                }               
        !          1466:        }
        !          1467: 
        !          1468:        CG(active_op_array)->line_end = zend_get_compiled_lineno(TSRMLS_C);
        !          1469:        CG(active_op_array) = function_token->u.op_array;
        !          1470: 
        !          1471: 
        !          1472:        /* Pop the switch and foreach seperators */
        !          1473:        zend_stack_del_top(&CG(switch_cond_stack));
        !          1474:        zend_stack_del_top(&CG(foreach_copy_stack));
        !          1475: }
        !          1476: /* }}} */
        !          1477: 
        !          1478: void zend_do_receive_arg(zend_uchar op, const znode *var, const znode *offset, const znode *initialization, znode *class_type, const znode *varname, zend_uchar pass_by_reference TSRMLS_DC) /* {{{ */
        !          1479: {
        !          1480:        zend_op *opline;
        !          1481:        zend_arg_info *cur_arg_info;
        !          1482: 
        !          1483:        if (class_type->op_type == IS_CONST &&
        !          1484:            Z_TYPE(class_type->u.constant) == IS_STRING &&
        !          1485:            Z_STRLEN(class_type->u.constant) == 0) {
        !          1486:                /* Usage of namespace as class name not in namespace */
        !          1487:                zval_dtor(&class_type->u.constant);
        !          1488:                zend_error(E_COMPILE_ERROR, "Cannot use 'namespace' as a class name");
        !          1489:                return;
        !          1490:        }
        !          1491: 
        !          1492:        if (var->op_type == IS_CV &&
        !          1493:            var->u.var == CG(active_op_array)->this_var &&
        !          1494:            (CG(active_op_array)->fn_flags & ZEND_ACC_STATIC) == 0) {
        !          1495:                zend_error(E_COMPILE_ERROR, "Cannot re-assign $this");
        !          1496:        } else if (var->op_type == IS_VAR &&
        !          1497:            CG(active_op_array)->scope &&
        !          1498:                ((CG(active_op_array)->fn_flags & ZEND_ACC_STATIC) == 0) &&
        !          1499:                (Z_TYPE(varname->u.constant) == IS_STRING) &&
        !          1500:                (Z_STRLEN(varname->u.constant) == sizeof("this")-1) &&
        !          1501:                (memcmp(Z_STRVAL(varname->u.constant), "this", sizeof("this")) == 0)) {
        !          1502:                zend_error(E_COMPILE_ERROR, "Cannot re-assign $this");
        !          1503:        }
        !          1504: 
        !          1505:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          1506:        CG(active_op_array)->num_args++;
        !          1507:        opline->opcode = op;
        !          1508:        opline->result = *var;
        !          1509:        opline->op1 = *offset;
        !          1510:        if (op == ZEND_RECV_INIT) {
        !          1511:                opline->op2 = *initialization;
        !          1512:        } else {
        !          1513:                CG(active_op_array)->required_num_args = CG(active_op_array)->num_args;
        !          1514:                SET_UNUSED(opline->op2);
        !          1515:        }
        !          1516:        CG(active_op_array)->arg_info = erealloc(CG(active_op_array)->arg_info, sizeof(zend_arg_info)*(CG(active_op_array)->num_args));
        !          1517:        cur_arg_info = &CG(active_op_array)->arg_info[CG(active_op_array)->num_args-1];
        !          1518:        cur_arg_info->name = estrndup(varname->u.constant.value.str.val, varname->u.constant.value.str.len);
        !          1519:        cur_arg_info->name_len = varname->u.constant.value.str.len;
        !          1520:        cur_arg_info->array_type_hint = 0;
        !          1521:        cur_arg_info->allow_null = 1;
        !          1522:        cur_arg_info->pass_by_reference = pass_by_reference;
        !          1523:        cur_arg_info->class_name = NULL;
        !          1524:        cur_arg_info->class_name_len = 0;
        !          1525: 
        !          1526:        if (class_type->op_type != IS_UNUSED) {
        !          1527:                cur_arg_info->allow_null = 0;
        !          1528:                if (class_type->u.constant.type == IS_STRING) {
        !          1529:                        if (ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_STRVAL(class_type->u.constant), Z_STRLEN(class_type->u.constant))) {
        !          1530:                                zend_resolve_class_name(class_type, &opline->extended_value, 1 TSRMLS_CC);
        !          1531:                        }
        !          1532:                        cur_arg_info->class_name = class_type->u.constant.value.str.val;
        !          1533:                        cur_arg_info->class_name_len = class_type->u.constant.value.str.len;
        !          1534:                        if (op == ZEND_RECV_INIT) {
        !          1535:                                if (Z_TYPE(initialization->u.constant) == IS_NULL || (Z_TYPE(initialization->u.constant) == IS_CONSTANT && !strcasecmp(Z_STRVAL(initialization->u.constant), "NULL"))) {
        !          1536:                                        cur_arg_info->allow_null = 1;
        !          1537:                                } else {
        !          1538:                                        zend_error(E_COMPILE_ERROR, "Default value for parameters with a class type hint can only be NULL");
        !          1539:                                }
        !          1540:                        }
        !          1541:                } else {
        !          1542:                        cur_arg_info->array_type_hint = 1;
        !          1543:                        cur_arg_info->class_name = NULL;
        !          1544:                        cur_arg_info->class_name_len = 0;
        !          1545:                        if (op == ZEND_RECV_INIT) {
        !          1546:                                if (Z_TYPE(initialization->u.constant) == IS_NULL || (Z_TYPE(initialization->u.constant) == IS_CONSTANT && !strcasecmp(Z_STRVAL(initialization->u.constant), "NULL"))) {
        !          1547:                                        cur_arg_info->allow_null = 1;
        !          1548:                                } else if (Z_TYPE(initialization->u.constant) != IS_ARRAY && Z_TYPE(initialization->u.constant) != IS_CONSTANT_ARRAY) {
        !          1549:                                        zend_error(E_COMPILE_ERROR, "Default value for parameters with array type hint can only be an array or NULL");
        !          1550:                                }
        !          1551:                        }
        !          1552:                }
        !          1553:        }
        !          1554:        opline->result.u.EA.type |= EXT_TYPE_UNUSED;
        !          1555: }
        !          1556: /* }}} */
        !          1557: 
        !          1558: int zend_do_begin_function_call(znode *function_name, zend_bool check_namespace TSRMLS_DC) /* {{{ */
        !          1559: {
        !          1560:        zend_function *function;
        !          1561:        char *lcname;
        !          1562:        char *is_compound = memchr(Z_STRVAL(function_name->u.constant), '\\', Z_STRLEN(function_name->u.constant));
        !          1563: 
        !          1564:        zend_resolve_non_class_name(function_name, check_namespace TSRMLS_CC);
        !          1565: 
        !          1566:        if (check_namespace && CG(current_namespace) && !is_compound) {
        !          1567:                        /* We assume we call function from the current namespace
        !          1568:                        if it is not prefixed. */
        !          1569: 
        !          1570:                        /* In run-time PHP will check for function with full name and
        !          1571:                        internal function with short name */
        !          1572:                        zend_do_begin_dynamic_function_call(function_name, 1 TSRMLS_CC);
        !          1573:                        return 1;
        !          1574:        } 
        !          1575: 
        !          1576:        lcname = zend_str_tolower_dup(function_name->u.constant.value.str.val, function_name->u.constant.value.str.len);
        !          1577:        if ((zend_hash_find(CG(function_table), lcname, function_name->u.constant.value.str.len+1, (void **) &function)==FAILURE) ||
        !          1578:                ((CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS) &&
        !          1579:                (function->type == ZEND_INTERNAL_FUNCTION))) {
        !          1580:                        zend_do_begin_dynamic_function_call(function_name, 0 TSRMLS_CC);
        !          1581:                        efree(lcname);
        !          1582:                        return 1; /* Dynamic */
        !          1583:        } 
        !          1584:        efree(function_name->u.constant.value.str.val);
        !          1585:        function_name->u.constant.value.str.val = lcname;
        !          1586:        
        !          1587:        zend_stack_push(&CG(function_call_stack), (void *) &function, sizeof(zend_function *));
        !          1588:        zend_do_extended_fcall_begin(TSRMLS_C);
        !          1589:        return 0;
        !          1590: }
        !          1591: /* }}} */
        !          1592: 
        !          1593: void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC) /* {{{ */
        !          1594: {
        !          1595:        zend_op *last_op;
        !          1596:        int last_op_number;
        !          1597:        unsigned char *ptr = NULL;
        !          1598: 
        !          1599:        zend_do_end_variable_parse(left_bracket, BP_VAR_R, 0 TSRMLS_CC);
        !          1600:        zend_do_begin_variable_parse(TSRMLS_C);
        !          1601: 
        !          1602:        last_op_number = get_next_op_number(CG(active_op_array))-1;
        !          1603:        last_op = &CG(active_op_array)->opcodes[last_op_number];
        !          1604: 
        !          1605:        if ((last_op->op2.op_type == IS_CONST) && (last_op->op2.u.constant.type == IS_STRING) && (last_op->op2.u.constant.value.str.len == sizeof(ZEND_CLONE_FUNC_NAME)-1)
        !          1606:                && !zend_binary_strcasecmp(last_op->op2.u.constant.value.str.val, last_op->op2.u.constant.value.str.len, ZEND_CLONE_FUNC_NAME, sizeof(ZEND_CLONE_FUNC_NAME)-1)) {
        !          1607:                zend_error(E_COMPILE_ERROR, "Cannot call __clone() method on objects - use 'clone $obj' instead");
        !          1608:        }
        !          1609: 
        !          1610:        if (last_op->opcode == ZEND_FETCH_OBJ_R) {
        !          1611:                last_op->opcode = ZEND_INIT_METHOD_CALL;
        !          1612:                SET_UNUSED(last_op->result);
        !          1613:                Z_LVAL(left_bracket->u.constant) = ZEND_INIT_FCALL_BY_NAME;
        !          1614:        } else {
        !          1615:                zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          1616:                opline->opcode = ZEND_INIT_FCALL_BY_NAME;
        !          1617:                opline->op2 = *left_bracket;
        !          1618:                if (opline->op2.op_type == IS_CONST) {
        !          1619:                        opline->op1.op_type = IS_CONST;
        !          1620:                        Z_TYPE(opline->op1.u.constant) = IS_STRING;
        !          1621:                        Z_STRVAL(opline->op1.u.constant) = zend_str_tolower_dup(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant));
        !          1622:                        Z_STRLEN(opline->op1.u.constant) = Z_STRLEN(opline->op2.u.constant);
        !          1623:                        opline->extended_value = zend_hash_func(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant) + 1);
        !          1624:                } else {
        !          1625:                        opline->extended_value = 0;
        !          1626:                        SET_UNUSED(opline->op1);
        !          1627:                }
        !          1628:        }
        !          1629: 
        !          1630:        zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *));
        !          1631:        zend_do_extended_fcall_begin(TSRMLS_C);
        !          1632: }
        !          1633: /* }}} */
        !          1634: 
        !          1635: void zend_do_clone(znode *result, const znode *expr TSRMLS_DC) /* {{{ */
        !          1636: {
        !          1637:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          1638: 
        !          1639:        opline->opcode = ZEND_CLONE;
        !          1640:        opline->op1 = *expr;
        !          1641:        SET_UNUSED(opline->op2);
        !          1642:        opline->result.op_type = IS_VAR;
        !          1643:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          1644:        *result = opline->result;
        !          1645: }
        !          1646: /* }}} */
        !          1647: 
        !          1648: void zend_do_begin_dynamic_function_call(znode *function_name, int ns_call TSRMLS_DC) /* {{{ */
        !          1649: {
        !          1650:        unsigned char *ptr = NULL;
        !          1651:        zend_op *opline, *opline2;
        !          1652: 
        !          1653:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          1654:        if (ns_call) {
        !          1655:                char *slash;
        !          1656:                int prefix_len, name_len;
        !          1657:                /* In run-time PHP will check for function with full name and
        !          1658:                   internal function with short name */
        !          1659:                opline->opcode = ZEND_INIT_NS_FCALL_BY_NAME;
        !          1660:                opline->op2 = *function_name;
        !          1661:                opline->extended_value = 0;
        !          1662:                opline->op1.op_type = IS_CONST;
        !          1663:                Z_TYPE(opline->op1.u.constant) = IS_STRING;
        !          1664:                Z_STRVAL(opline->op1.u.constant) = zend_str_tolower_dup(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant));
        !          1665:                Z_STRLEN(opline->op1.u.constant) = Z_STRLEN(opline->op2.u.constant);
        !          1666:                opline->extended_value = zend_hash_func(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant) + 1);
        !          1667:                slash = zend_memrchr(Z_STRVAL(opline->op1.u.constant), '\\', Z_STRLEN(opline->op1.u.constant));
        !          1668:                prefix_len = slash-Z_STRVAL(opline->op1.u.constant)+1;
        !          1669:                name_len = Z_STRLEN(opline->op1.u.constant)-prefix_len;
        !          1670:                opline2 = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          1671:                opline2->opcode = ZEND_OP_DATA;
        !          1672:                opline2->op1.op_type = IS_CONST;
        !          1673:                Z_TYPE(opline2->op1.u.constant) = IS_LONG;
        !          1674:                if(!slash) {
        !          1675:                        zend_error(E_CORE_ERROR, "Namespaced name %s should contain slash", Z_STRVAL(opline->op1.u.constant));
        !          1676:                }
        !          1677:                /* this is the length of namespace prefix */
        !          1678:                Z_LVAL(opline2->op1.u.constant) = prefix_len;
        !          1679:                /* this is the hash of the non-prefixed part, lowercased */
        !          1680:                opline2->extended_value = zend_hash_func(slash+1, name_len+1);
        !          1681:                SET_UNUSED(opline2->op2);
        !          1682:        } else {
        !          1683:                opline->opcode = ZEND_INIT_FCALL_BY_NAME;
        !          1684:                opline->op2 = *function_name;
        !          1685:                if (opline->op2.op_type == IS_CONST) {
        !          1686:                        opline->op1.op_type = IS_CONST;
        !          1687:                        Z_TYPE(opline->op1.u.constant) = IS_STRING;
        !          1688:                        Z_STRVAL(opline->op1.u.constant) = zend_str_tolower_dup(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant));
        !          1689:                        Z_STRLEN(opline->op1.u.constant) = Z_STRLEN(opline->op2.u.constant);
        !          1690:                        opline->extended_value = zend_hash_func(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant) + 1);
        !          1691:                } else {
        !          1692:                        opline->extended_value = 0;
        !          1693:                        SET_UNUSED(opline->op1);
        !          1694:                }
        !          1695:        }
        !          1696: 
        !          1697:        zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *));
        !          1698:        zend_do_extended_fcall_begin(TSRMLS_C);
        !          1699: }
        !          1700: /* }}} */
        !          1701: 
        !          1702: void zend_resolve_non_class_name(znode *element_name, zend_bool check_namespace TSRMLS_DC) /* {{{ */
        !          1703: {
        !          1704:        znode tmp;
        !          1705:        int len;
        !          1706:        zval **ns;
        !          1707:        char *lcname, *compound = memchr(Z_STRVAL(element_name->u.constant), '\\', Z_STRLEN(element_name->u.constant));
        !          1708: 
        !          1709:        if (Z_STRVAL(element_name->u.constant)[0] == '\\') {
        !          1710:                /* name starts with \ so it is known and unambiguos, nothing to do here but shorten it */
        !          1711:                memmove(Z_STRVAL(element_name->u.constant), Z_STRVAL(element_name->u.constant)+1, Z_STRLEN(element_name->u.constant));
        !          1712:                --Z_STRLEN(element_name->u.constant);
        !          1713:                return;
        !          1714:        }
        !          1715: 
        !          1716:        if(!check_namespace) {
        !          1717:                return;
        !          1718:        }
        !          1719: 
        !          1720:        if (compound && CG(current_import)) {
        !          1721:                len = compound - Z_STRVAL(element_name->u.constant);
        !          1722:                lcname = zend_str_tolower_dup(Z_STRVAL(element_name->u.constant), len);
        !          1723:                /* Check if first part of compound name is an import name */
        !          1724:                if (zend_hash_find(CG(current_import), lcname, len+1, (void**)&ns) == SUCCESS) {
        !          1725:                        /* Substitute import name */
        !          1726:                        tmp.op_type = IS_CONST;
        !          1727:                        tmp.u.constant = **ns;
        !          1728:                        zval_copy_ctor(&tmp.u.constant);
        !          1729:                        len += 1;
        !          1730:                        Z_STRLEN(element_name->u.constant) -= len;
        !          1731:                        memmove(Z_STRVAL(element_name->u.constant), Z_STRVAL(element_name->u.constant)+len, Z_STRLEN(element_name->u.constant)+1);
        !          1732:                        zend_do_build_namespace_name(&tmp, &tmp, element_name TSRMLS_CC);
        !          1733:                        *element_name = tmp;
        !          1734:                        efree(lcname);
        !          1735:                        return;
        !          1736:                }
        !          1737:                efree(lcname);
        !          1738:        }
        !          1739: 
        !          1740:        if (CG(current_namespace)) {
        !          1741:                tmp = *element_name;
        !          1742:                Z_STRLEN(tmp.u.constant) = sizeof("\\")-1 + Z_STRLEN(element_name->u.constant) + Z_STRLEN_P(CG(current_namespace));
        !          1743:                Z_STRVAL(tmp.u.constant) = (char *) emalloc(Z_STRLEN(tmp.u.constant)+1);
        !          1744:                memcpy(Z_STRVAL(tmp.u.constant), Z_STRVAL_P(CG(current_namespace)), Z_STRLEN_P(CG(current_namespace)));
        !          1745:                memcpy(&(Z_STRVAL(tmp.u.constant)[Z_STRLEN_P(CG(current_namespace))]), "\\", sizeof("\\")-1);
        !          1746:                memcpy(&(Z_STRVAL(tmp.u.constant)[Z_STRLEN_P(CG(current_namespace)) + sizeof("\\")-1]), Z_STRVAL(element_name->u.constant), Z_STRLEN(element_name->u.constant)+1);
        !          1747:                STR_FREE(Z_STRVAL(element_name->u.constant));
        !          1748:                *element_name = tmp;
        !          1749:        }
        !          1750: }
        !          1751: /* }}} */
        !          1752: 
        !          1753: void zend_resolve_class_name(znode *class_name, ulong *fetch_type, int check_ns_name TSRMLS_DC) /* {{{ */
        !          1754: {
        !          1755:        char *compound;
        !          1756:        char *lcname;
        !          1757:        zval **ns;
        !          1758:        znode tmp;
        !          1759:        int len;
        !          1760: 
        !          1761:        compound = memchr(Z_STRVAL(class_name->u.constant), '\\', Z_STRLEN(class_name->u.constant));
        !          1762:        if (compound) {
        !          1763:                /* This is a compound class name that contains namespace prefix */
        !          1764:                if (Z_STRVAL(class_name->u.constant)[0] == '\\') {
        !          1765:                    /* The STRING name has "\" prefix */
        !          1766:                    Z_STRLEN(class_name->u.constant) -= 1;
        !          1767:                    memmove(Z_STRVAL(class_name->u.constant), Z_STRVAL(class_name->u.constant)+1, Z_STRLEN(class_name->u.constant)+1);
        !          1768:                        Z_STRVAL(class_name->u.constant) = erealloc(
        !          1769:                                Z_STRVAL(class_name->u.constant),
        !          1770:                                Z_STRLEN(class_name->u.constant) + 1);
        !          1771: 
        !          1772:                        if (ZEND_FETCH_CLASS_DEFAULT != zend_get_class_fetch_type(Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant))) {
        !          1773:                                zend_error(E_COMPILE_ERROR, "'\\%s' is an invalid class name", Z_STRVAL(class_name->u.constant));
        !          1774:                        }
        !          1775:                } else { 
        !          1776:                        if (CG(current_import)) {
        !          1777:                                len = compound - Z_STRVAL(class_name->u.constant);
        !          1778:                                lcname = zend_str_tolower_dup(Z_STRVAL(class_name->u.constant), len);
        !          1779:                                /* Check if first part of compound name is an import name */
        !          1780:                                if (zend_hash_find(CG(current_import), lcname, len+1, (void**)&ns) == SUCCESS) {
        !          1781:                                        /* Substitute import name */
        !          1782:                                        tmp.op_type = IS_CONST;
        !          1783:                                        tmp.u.constant = **ns;
        !          1784:                                        zval_copy_ctor(&tmp.u.constant);
        !          1785:                                        len += 1;
        !          1786:                                        Z_STRLEN(class_name->u.constant) -= len;
        !          1787:                                        memmove(Z_STRVAL(class_name->u.constant), Z_STRVAL(class_name->u.constant)+len, Z_STRLEN(class_name->u.constant)+1);
        !          1788:                                        zend_do_build_namespace_name(&tmp, &tmp, class_name TSRMLS_CC);
        !          1789:                                        *class_name = tmp;
        !          1790:                                        efree(lcname);
        !          1791:                                        return;
        !          1792:                                }
        !          1793:                                efree(lcname);
        !          1794:                        }
        !          1795:                        /* Here name is not prefixed with \ and not imported */
        !          1796:                        if (CG(current_namespace)) {
        !          1797:                                tmp.op_type = IS_CONST;
        !          1798:                                tmp.u.constant = *CG(current_namespace);
        !          1799:                                zval_copy_ctor(&tmp.u.constant);
        !          1800:                                zend_do_build_namespace_name(&tmp, &tmp, class_name TSRMLS_CC);
        !          1801:                                *class_name = tmp;
        !          1802:                        }
        !          1803:                }
        !          1804:        } else if (CG(current_import) || CG(current_namespace)) {
        !          1805:                /* this is a plain name (without \) */
        !          1806:                lcname = zend_str_tolower_dup(Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant));
        !          1807: 
        !          1808:                if (CG(current_import) &&
        !          1809:                    zend_hash_find(CG(current_import), lcname, Z_STRLEN(class_name->u.constant)+1, (void**)&ns) == SUCCESS) {
        !          1810:                    /* The given name is an import name. Substitute it. */
        !          1811:                        zval_dtor(&class_name->u.constant);
        !          1812:                        class_name->u.constant = **ns;
        !          1813:                        zval_copy_ctor(&class_name->u.constant);
        !          1814:                } else if (CG(current_namespace)) {
        !          1815:                        /* plain name, no import - prepend current namespace to it */
        !          1816:                        tmp.op_type = IS_CONST;
        !          1817:                        tmp.u.constant = *CG(current_namespace);
        !          1818:                        zval_copy_ctor(&tmp.u.constant);
        !          1819:                        zend_do_build_namespace_name(&tmp, &tmp, class_name TSRMLS_CC);
        !          1820:                        *class_name = tmp;
        !          1821:                }
        !          1822:                efree(lcname);
        !          1823:        }
        !          1824: }
        !          1825: /* }}} */
        !          1826: 
        !          1827: void zend_do_fetch_class(znode *result, znode *class_name TSRMLS_DC) /* {{{ */
        !          1828: {
        !          1829:        long fetch_class_op_number;
        !          1830:        zend_op *opline;
        !          1831: 
        !          1832:        if (class_name->op_type == IS_CONST &&
        !          1833:            Z_TYPE(class_name->u.constant) == IS_STRING &&
        !          1834:            Z_STRLEN(class_name->u.constant) == 0) {
        !          1835:                /* Usage of namespace as class name not in namespace */
        !          1836:                zval_dtor(&class_name->u.constant);
        !          1837:                zend_error(E_COMPILE_ERROR, "Cannot use 'namespace' as a class name");
        !          1838:                return;
        !          1839:        }
        !          1840: 
        !          1841:        fetch_class_op_number = get_next_op_number(CG(active_op_array));
        !          1842:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          1843: 
        !          1844:        opline->opcode = ZEND_FETCH_CLASS;
        !          1845:        SET_UNUSED(opline->op1);
        !          1846:        opline->extended_value = ZEND_FETCH_CLASS_GLOBAL;
        !          1847:        CG(catch_begin) = fetch_class_op_number;
        !          1848:        if (class_name->op_type == IS_CONST) {
        !          1849:                int fetch_type;
        !          1850: 
        !          1851:                fetch_type = zend_get_class_fetch_type(class_name->u.constant.value.str.val, class_name->u.constant.value.str.len);
        !          1852:                switch (fetch_type) {
        !          1853:                        case ZEND_FETCH_CLASS_SELF:
        !          1854:                        case ZEND_FETCH_CLASS_PARENT:
        !          1855:                        case ZEND_FETCH_CLASS_STATIC:
        !          1856:                                SET_UNUSED(opline->op2);
        !          1857:                                opline->extended_value = fetch_type;
        !          1858:                                zval_dtor(&class_name->u.constant);
        !          1859:                                break;
        !          1860:                        default:
        !          1861:                                zend_resolve_class_name(class_name, &opline->extended_value, 0 TSRMLS_CC);
        !          1862:                                opline->op2 = *class_name;
        !          1863:                                break;
        !          1864:                }
        !          1865:        } else {
        !          1866:                opline->op2 = *class_name;
        !          1867:        }
        !          1868:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          1869:        opline->result.u.EA.type = opline->extended_value;
        !          1870:        opline->result.op_type = IS_VAR; /* FIXME: Hack so that INIT_FCALL_BY_NAME still knows this is a class */
        !          1871:        *result = opline->result;
        !          1872: }
        !          1873: /* }}} */
        !          1874: 
        !          1875: void zend_do_label(znode *label TSRMLS_DC) /* {{{ */
        !          1876: {
        !          1877:        zend_op_array *oparray = CG(active_op_array);
        !          1878:        zend_label dest;
        !          1879: 
        !          1880:        if (!CG(labels)) {
        !          1881:                ALLOC_HASHTABLE(CG(labels));
        !          1882:                zend_hash_init(CG(labels), 4, NULL, NULL, 0);
        !          1883:        }
        !          1884: 
        !          1885:        dest.brk_cont = oparray->current_brk_cont;
        !          1886:        dest.opline_num = get_next_op_number(oparray);
        !          1887: 
        !          1888:        if (zend_hash_add(CG(labels), Z_STRVAL(label->u.constant), Z_STRLEN(label->u.constant) + 1, (void**)&dest, sizeof(zend_label), NULL) == FAILURE) {
        !          1889:                zend_error(E_COMPILE_ERROR, "Label '%s' already defined", Z_STRVAL(label->u.constant));
        !          1890:        }
        !          1891: 
        !          1892:        /* Done with label now */
        !          1893:        zval_dtor(&label->u.constant);
        !          1894: }
        !          1895: /* }}} */
        !          1896: 
        !          1897: void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline, int pass2 TSRMLS_DC) /* {{{ */
        !          1898: {
        !          1899:        zend_label *dest;
        !          1900:        long current, distance;
        !          1901: 
        !          1902:        if (CG(labels) == NULL ||
        !          1903:                zend_hash_find(CG(labels), Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant)+1, (void**)&dest) == FAILURE) {
        !          1904: 
        !          1905:                if (pass2) {
        !          1906:                        CG(in_compilation) = 1;
        !          1907:                        CG(active_op_array) = op_array;
        !          1908:                        CG(zend_lineno) = opline->lineno;
        !          1909:                        zend_error(E_COMPILE_ERROR, "'goto' to undefined label '%s'", Z_STRVAL(opline->op2.u.constant));
        !          1910:                } else {
        !          1911:                        /* Label is not defined. Delay to pass 2. */
        !          1912:                        INC_BPC(op_array);
        !          1913:                        return;
        !          1914:                }
        !          1915:        }
        !          1916: 
        !          1917:        opline->op1.u.opline_num = dest->opline_num;
        !          1918:        zval_dtor(&opline->op2.u.constant);
        !          1919: 
        !          1920:        /* Check that we are not moving into loop or switch */
        !          1921:        current = opline->extended_value;
        !          1922:        for (distance = 0; current != dest->brk_cont; distance++) {
        !          1923:                if (current == -1) {
        !          1924:                        if (pass2) {
        !          1925:                                CG(in_compilation) = 1;
        !          1926:                                CG(active_op_array) = op_array;
        !          1927:                                CG(zend_lineno) = opline->lineno;
        !          1928:                        }
        !          1929:                        zend_error(E_COMPILE_ERROR, "'goto' into loop or switch statement is disallowed");
        !          1930:                }
        !          1931:                current = op_array->brk_cont_array[current].parent;
        !          1932:        }
        !          1933: 
        !          1934:        if (distance == 0) {
        !          1935:                /* Nothing to break out of, optimize to ZEND_JMP */
        !          1936:                opline->opcode = ZEND_JMP;
        !          1937:                opline->extended_value = 0;
        !          1938:                SET_UNUSED(opline->op2);
        !          1939:        } else {
        !          1940:                /* Set real break distance */
        !          1941:                ZVAL_LONG(&opline->op2.u.constant, distance);
        !          1942:        }
        !          1943: 
        !          1944:        if (pass2) {
        !          1945:                DEC_BPC(op_array);
        !          1946:        }
        !          1947: }
        !          1948: /* }}} */
        !          1949: 
        !          1950: void zend_do_goto(const znode *label TSRMLS_DC) /* {{{ */
        !          1951: {
        !          1952:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          1953: 
        !          1954:        opline->opcode = ZEND_GOTO;
        !          1955:        opline->extended_value = CG(active_op_array)->current_brk_cont;
        !          1956:        SET_UNUSED(opline->op1);
        !          1957:        opline->op2 = *label;
        !          1958:        zend_resolve_goto_label(CG(active_op_array), opline, 0 TSRMLS_CC);
        !          1959: }
        !          1960: /* }}} */
        !          1961: 
        !          1962: void zend_release_labels(TSRMLS_D) /* {{{ */
        !          1963: {
        !          1964:        if (CG(labels)) {
        !          1965:                zend_hash_destroy(CG(labels));
        !          1966:                FREE_HASHTABLE(CG(labels));
        !          1967:        }
        !          1968:        if (!zend_stack_is_empty(&CG(labels_stack))) {
        !          1969:                HashTable **pht;
        !          1970: 
        !          1971:                zend_stack_top(&CG(labels_stack), (void**)&pht);
        !          1972:                CG(labels) = *pht;
        !          1973:                zend_stack_del_top(&CG(labels_stack));
        !          1974:        } else {
        !          1975:                CG(labels) = NULL;
        !          1976:        }
        !          1977: }
        !          1978: /* }}} */
        !          1979: 
        !          1980: void zend_do_build_full_name(znode *result, znode *prefix, znode *name, int is_class_member TSRMLS_DC) /* {{{ */
        !          1981: {
        !          1982:        zend_uint length;
        !          1983: 
        !          1984:        if (!result) {
        !          1985:                result = prefix;
        !          1986:        } else {
        !          1987:                *result = *prefix;
        !          1988:        }
        !          1989: 
        !          1990:        if (is_class_member) {
        !          1991:                length = sizeof("::")-1 + result->u.constant.value.str.len + name->u.constant.value.str.len;
        !          1992:                result->u.constant.value.str.val = erealloc(result->u.constant.value.str.val, length+1);
        !          1993:                memcpy(&result->u.constant.value.str.val[result->u.constant.value.str.len], "::", sizeof("::")-1);
        !          1994:                memcpy(&result->u.constant.value.str.val[result->u.constant.value.str.len + sizeof("::")-1], name->u.constant.value.str.val, name->u.constant.value.str.len+1);
        !          1995:                STR_FREE(name->u.constant.value.str.val);
        !          1996:                result->u.constant.value.str.len = length;
        !          1997:        } else {
        !          1998:                length = sizeof("\\")-1 + result->u.constant.value.str.len + name->u.constant.value.str.len;
        !          1999:                result->u.constant.value.str.val = erealloc(result->u.constant.value.str.val, length+1);
        !          2000:                memcpy(&result->u.constant.value.str.val[result->u.constant.value.str.len], "\\", sizeof("\\")-1);
        !          2001:                memcpy(&result->u.constant.value.str.val[result->u.constant.value.str.len + sizeof("\\")-1], name->u.constant.value.str.val, name->u.constant.value.str.len+1);
        !          2002:                STR_FREE(name->u.constant.value.str.val);
        !          2003:                result->u.constant.value.str.len = length;
        !          2004:        }
        !          2005: }
        !          2006: /* }}} */
        !          2007: 
        !          2008: int zend_do_begin_class_member_function_call(znode *class_name, znode *method_name TSRMLS_DC) /* {{{ */
        !          2009: {
        !          2010:        znode class_node;
        !          2011:        unsigned char *ptr = NULL;
        !          2012:        zend_op *opline;
        !          2013:        ulong fetch_type = 0;
        !          2014: 
        !          2015:        if (method_name->op_type == IS_CONST) {
        !          2016:                char *lcname = zend_str_tolower_dup(Z_STRVAL(method_name->u.constant), Z_STRLEN(method_name->u.constant));
        !          2017:                if ((sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) == Z_STRLEN(method_name->u.constant) &&
        !          2018:                        memcmp(lcname, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) == 0) {
        !          2019:                        zval_dtor(&method_name->u.constant);
        !          2020:                        SET_UNUSED(*method_name);
        !          2021:                }
        !          2022:                efree(lcname);
        !          2023:        }
        !          2024: 
        !          2025:        if (class_name->op_type == IS_CONST &&
        !          2026:                        ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant))) {
        !          2027:                fetch_type = ZEND_FETCH_CLASS_GLOBAL;
        !          2028:                zend_resolve_class_name(class_name, &fetch_type, 1 TSRMLS_CC);
        !          2029:                class_node = *class_name;
        !          2030:        } else {
        !          2031:                zend_do_fetch_class(&class_node, class_name TSRMLS_CC);
        !          2032:        }
        !          2033:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          2034:        opline->opcode = ZEND_INIT_STATIC_METHOD_CALL;
        !          2035:        opline->op1 = class_node;
        !          2036:        opline->op2 = *method_name;
        !          2037: 
        !          2038:        zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *));
        !          2039:        zend_do_extended_fcall_begin(TSRMLS_C);
        !          2040:        return 1; /* Dynamic */
        !          2041: }
        !          2042: /* }}} */
        !          2043: 
        !          2044: void zend_do_end_function_call(znode *function_name, znode *result, const znode *argument_list, int is_method, int is_dynamic_fcall TSRMLS_DC) /* {{{ */
        !          2045: {
        !          2046:        zend_op *opline;
        !          2047: 
        !          2048:        if (is_method && function_name && function_name->op_type == IS_UNUSED) {
        !          2049:                /* clone */
        !          2050:                if (Z_LVAL(argument_list->u.constant) != 0) {
        !          2051:                        zend_error(E_WARNING, "Clone method does not require arguments");
        !          2052:                }
        !          2053:                opline = &CG(active_op_array)->opcodes[Z_LVAL(function_name->u.constant)];
        !          2054:        } else {
        !          2055:                opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          2056:                if (!is_method && !is_dynamic_fcall && function_name->op_type==IS_CONST) {
        !          2057:                        opline->opcode = ZEND_DO_FCALL;
        !          2058:                        opline->op1 = *function_name;
        !          2059:                        ZVAL_LONG(&opline->op2.u.constant, zend_hash_func(Z_STRVAL(function_name->u.constant), Z_STRLEN(function_name->u.constant) + 1));
        !          2060:                } else {
        !          2061:                        opline->opcode = ZEND_DO_FCALL_BY_NAME;
        !          2062:                        SET_UNUSED(opline->op1);
        !          2063:                }
        !          2064:        }
        !          2065: 
        !          2066:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          2067:        opline->result.op_type = IS_VAR;
        !          2068:        *result = opline->result;
        !          2069:        SET_UNUSED(opline->op2);
        !          2070: 
        !          2071:        zend_stack_del_top(&CG(function_call_stack));
        !          2072:        opline->extended_value = Z_LVAL(argument_list->u.constant);
        !          2073: }
        !          2074: /* }}} */
        !          2075: 
        !          2076: void zend_do_pass_param(znode *param, zend_uchar op, int offset TSRMLS_DC) /* {{{ */
        !          2077: {
        !          2078:        zend_op *opline;
        !          2079:        int original_op=op;
        !          2080:        zend_function **function_ptr_ptr, *function_ptr;
        !          2081:        int send_by_reference;
        !          2082:        int send_function = 0;
        !          2083: 
        !          2084:        zend_stack_top(&CG(function_call_stack), (void **) &function_ptr_ptr);
        !          2085:        function_ptr = *function_ptr_ptr;
        !          2086: 
        !          2087:        if (original_op == ZEND_SEND_REF && !CG(allow_call_time_pass_reference)) {
        !          2088:                if (function_ptr &&
        !          2089:                                function_ptr->common.function_name &&
        !          2090:                                function_ptr->common.type == ZEND_USER_FUNCTION &&
        !          2091:                                !ARG_SHOULD_BE_SENT_BY_REF(function_ptr, (zend_uint) offset)) {
        !          2092:                        zend_error(E_DEPRECATED,
        !          2093:                                                "Call-time pass-by-reference has been deprecated; "
        !          2094:                                                "If you would like to pass it by reference, modify the declaration of %s().  "
        !          2095:                                                "If you would like to enable call-time pass-by-reference, you can set "
        !          2096:                                                "allow_call_time_pass_reference to true in your INI file", function_ptr->common.function_name);
        !          2097:                } else {
        !          2098:                        zend_error(E_DEPRECATED, "Call-time pass-by-reference has been deprecated");
        !          2099:                }
        !          2100:        }
        !          2101: 
        !          2102:        if (function_ptr) {
        !          2103:                if (ARG_MAY_BE_SENT_BY_REF(function_ptr, (zend_uint) offset)) {
        !          2104:                        if (param->op_type & (IS_VAR|IS_CV)) {
        !          2105:                                send_by_reference = 1;
        !          2106:                                if (op == ZEND_SEND_VAR && zend_is_function_or_method_call(param)) {
        !          2107:                                        /* Method call */
        !          2108:                                        op = ZEND_SEND_VAR_NO_REF;
        !          2109:                                        send_function = ZEND_ARG_SEND_FUNCTION | ZEND_ARG_SEND_SILENT;
        !          2110:                                }
        !          2111:                        } else {
        !          2112:                                op = ZEND_SEND_VAL;
        !          2113:                                send_by_reference = 0;
        !          2114:                        }
        !          2115:                } else {
        !          2116:                        send_by_reference = ARG_SHOULD_BE_SENT_BY_REF(function_ptr, (zend_uint) offset) ? ZEND_ARG_SEND_BY_REF : 0;
        !          2117:                }
        !          2118:        } else {
        !          2119:                send_by_reference = 0;
        !          2120:        }
        !          2121: 
        !          2122:        if (op == ZEND_SEND_VAR && zend_is_function_or_method_call(param)) {
        !          2123:                /* Method call */
        !          2124:                op = ZEND_SEND_VAR_NO_REF;
        !          2125:                send_function = ZEND_ARG_SEND_FUNCTION;
        !          2126:        } else if (op == ZEND_SEND_VAL && (param->op_type & (IS_VAR|IS_CV))) {
        !          2127:                op = ZEND_SEND_VAR_NO_REF;
        !          2128:        }
        !          2129: 
        !          2130:        if (op!=ZEND_SEND_VAR_NO_REF && send_by_reference==ZEND_ARG_SEND_BY_REF) {
        !          2131:                /* change to passing by reference */
        !          2132:                switch (param->op_type) {
        !          2133:                        case IS_VAR:
        !          2134:                        case IS_CV:
        !          2135:                                op = ZEND_SEND_REF;
        !          2136:                                break;
        !          2137:                        default:
        !          2138:                                zend_error(E_COMPILE_ERROR, "Only variables can be passed by reference");
        !          2139:                                break;
        !          2140:                }
        !          2141:        }
        !          2142: 
        !          2143:        if (original_op == ZEND_SEND_VAR) {
        !          2144:                switch (op) {
        !          2145:                        case ZEND_SEND_VAR_NO_REF:
        !          2146:                                zend_do_end_variable_parse(param, BP_VAR_R, 0 TSRMLS_CC);
        !          2147:                                break;
        !          2148:                        case ZEND_SEND_VAR:
        !          2149:                                if (function_ptr) {
        !          2150:                                        zend_do_end_variable_parse(param, BP_VAR_R, 0 TSRMLS_CC);
        !          2151:                                } else {
        !          2152:                                        zend_do_end_variable_parse(param, BP_VAR_FUNC_ARG, offset TSRMLS_CC);
        !          2153:                                }
        !          2154:                                break;
        !          2155:                        case ZEND_SEND_REF:
        !          2156:                                zend_do_end_variable_parse(param, BP_VAR_W, 0 TSRMLS_CC);
        !          2157:                                break;
        !          2158:                }
        !          2159:        }
        !          2160: 
        !          2161:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          2162: 
        !          2163:        if (op == ZEND_SEND_VAR_NO_REF) {
        !          2164:                if (function_ptr) {
        !          2165:                        opline->extended_value = ZEND_ARG_COMPILE_TIME_BOUND | send_by_reference | send_function;
        !          2166:                } else {
        !          2167:                        opline->extended_value = send_function;
        !          2168:                }
        !          2169:        } else {
        !          2170:                if (function_ptr) {
        !          2171:                        opline->extended_value = ZEND_DO_FCALL;
        !          2172:                } else {
        !          2173:                        opline->extended_value = ZEND_DO_FCALL_BY_NAME;
        !          2174:                }
        !          2175:        }
        !          2176:        opline->opcode = op;
        !          2177:        opline->op1 = *param;
        !          2178:        opline->op2.u.opline_num = offset;
        !          2179:        SET_UNUSED(opline->op2);
        !          2180: }
        !          2181: /* }}} */
        !          2182: 
        !          2183: static int generate_free_switch_expr(const zend_switch_entry *switch_entry TSRMLS_DC) /* {{{ */
        !          2184: {
        !          2185:        zend_op *opline;
        !          2186: 
        !          2187:        if (switch_entry->cond.op_type != IS_VAR && switch_entry->cond.op_type != IS_TMP_VAR) {
        !          2188:                return (switch_entry->cond.op_type == IS_UNUSED);
        !          2189:        }
        !          2190: 
        !          2191:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          2192: 
        !          2193:        opline->opcode = (switch_entry->cond.op_type == IS_TMP_VAR) ? ZEND_FREE : ZEND_SWITCH_FREE;
        !          2194:        opline->op1 = switch_entry->cond;
        !          2195:        SET_UNUSED(opline->op2);
        !          2196:        opline->extended_value = 0;
        !          2197:        return 0;
        !          2198: }
        !          2199: /* }}} */
        !          2200: 
        !          2201: static int generate_free_foreach_copy(const zend_op *foreach_copy TSRMLS_DC) /* {{{ */
        !          2202: {
        !          2203:        zend_op *opline;
        !          2204: 
        !          2205:        /* If we reach the seperator then stop applying the stack */
        !          2206:        if (foreach_copy->result.op_type == IS_UNUSED && foreach_copy->op1.op_type == IS_UNUSED) {
        !          2207:                return 1;
        !          2208:        }
        !          2209: 
        !          2210:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          2211: 
        !          2212:        opline->opcode = (foreach_copy->result.op_type == IS_TMP_VAR) ? ZEND_FREE : ZEND_SWITCH_FREE;
        !          2213:        opline->op1 = foreach_copy->result;
        !          2214:        SET_UNUSED(opline->op2);
        !          2215:        opline->extended_value = 1;
        !          2216: 
        !          2217:        if (foreach_copy->op1.op_type != IS_UNUSED) {
        !          2218:                opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          2219: 
        !          2220:                opline->opcode = (foreach_copy->op1.op_type == IS_TMP_VAR) ? ZEND_FREE : ZEND_SWITCH_FREE;
        !          2221:                opline->op1 = foreach_copy->op1;
        !          2222:                SET_UNUSED(opline->op2);
        !          2223:                opline->extended_value = 0;
        !          2224:        }
        !          2225: 
        !          2226:        return 0;
        !          2227: }
        !          2228: /* }}} */
        !          2229: 
        !          2230: void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC) /* {{{ */
        !          2231: {
        !          2232:        zend_op *opline;
        !          2233:        int start_op_number, end_op_number;
        !          2234: 
        !          2235:        if (do_end_vparse) {
        !          2236:                if (CG(active_op_array)->return_reference && !zend_is_function_or_method_call(expr)) {
        !          2237:                        zend_do_end_variable_parse(expr, BP_VAR_W, 0 TSRMLS_CC);
        !          2238:                } else {
        !          2239:                        zend_do_end_variable_parse(expr, BP_VAR_R, 0 TSRMLS_CC);
        !          2240:                }
        !          2241:        }
        !          2242: 
        !          2243:        start_op_number = get_next_op_number(CG(active_op_array));
        !          2244: 
        !          2245: #ifdef ZTS
        !          2246:        zend_stack_apply_with_argument(&CG(switch_cond_stack), ZEND_STACK_APPLY_TOPDOWN, (int (*)(void *element, void *)) generate_free_switch_expr TSRMLS_CC);
        !          2247:        zend_stack_apply_with_argument(&CG(foreach_copy_stack), ZEND_STACK_APPLY_TOPDOWN, (int (*)(void *element, void *)) generate_free_foreach_copy TSRMLS_CC);
        !          2248: #else
        !          2249:        zend_stack_apply(&CG(switch_cond_stack), ZEND_STACK_APPLY_TOPDOWN, (int (*)(void *element)) generate_free_switch_expr);
        !          2250:        zend_stack_apply(&CG(foreach_copy_stack), ZEND_STACK_APPLY_TOPDOWN, (int (*)(void *element)) generate_free_foreach_copy);
        !          2251: #endif
        !          2252: 
        !          2253:        end_op_number = get_next_op_number(CG(active_op_array));
        !          2254:        while (start_op_number < end_op_number) {
        !          2255:                CG(active_op_array)->opcodes[start_op_number].op1.u.EA.type = EXT_TYPE_FREE_ON_RETURN;
        !          2256:                start_op_number++;
        !          2257:        }
        !          2258: 
        !          2259:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          2260: 
        !          2261:        opline->opcode = ZEND_RETURN;
        !          2262: 
        !          2263:        if (expr) {
        !          2264:                opline->op1 = *expr;
        !          2265: 
        !          2266:                if (do_end_vparse && zend_is_function_or_method_call(expr)) {
        !          2267:                        opline->extended_value = ZEND_RETURNS_FUNCTION;
        !          2268:                }
        !          2269:        } else {
        !          2270:                opline->op1.op_type = IS_CONST;
        !          2271:                INIT_ZVAL(opline->op1.u.constant);
        !          2272:        }
        !          2273: 
        !          2274:        SET_UNUSED(opline->op2);
        !          2275: }
        !          2276: /* }}} */
        !          2277: 
        !          2278: static int zend_add_try_element(zend_uint try_op TSRMLS_DC) /* {{{ */
        !          2279: {
        !          2280:        int try_catch_offset = CG(active_op_array)->last_try_catch++;
        !          2281: 
        !          2282:        CG(active_op_array)->try_catch_array = erealloc(CG(active_op_array)->try_catch_array, sizeof(zend_try_catch_element)*CG(active_op_array)->last_try_catch);
        !          2283:        CG(active_op_array)->try_catch_array[try_catch_offset].try_op = try_op;
        !          2284:        return try_catch_offset;
        !          2285: }
        !          2286: /* }}} */
        !          2287: 
        !          2288: static void zend_add_catch_element(int offset, zend_uint catch_op TSRMLS_DC) /* {{{ */
        !          2289: {
        !          2290:        CG(active_op_array)->try_catch_array[offset].catch_op = catch_op;
        !          2291: }
        !          2292: /* }}} */
        !          2293: 
        !          2294: void zend_do_first_catch(znode *open_parentheses TSRMLS_DC) /* {{{ */
        !          2295: {
        !          2296:        open_parentheses->u.opline_num = get_next_op_number(CG(active_op_array));
        !          2297: }
        !          2298: /* }}} */
        !          2299: 
        !          2300: void zend_initialize_try_catch_element(const znode *try_token TSRMLS_DC) /* {{{ */
        !          2301: {
        !          2302:        int jmp_op_number = get_next_op_number(CG(active_op_array));
        !          2303:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          2304:        zend_llist jmp_list;
        !          2305:        zend_llist *jmp_list_ptr;
        !          2306: 
        !          2307:        opline->opcode = ZEND_JMP;
        !          2308:        SET_UNUSED(opline->op1);
        !          2309:        SET_UNUSED(opline->op2);
        !          2310:        /* save for backpatching */
        !          2311: 
        !          2312:        zend_llist_init(&jmp_list, sizeof(int), NULL, 0);
        !          2313:        zend_stack_push(&CG(bp_stack), (void *) &jmp_list, sizeof(zend_llist));
        !          2314:        zend_stack_top(&CG(bp_stack), (void **) &jmp_list_ptr);
        !          2315:        zend_llist_add_element(jmp_list_ptr, &jmp_op_number);
        !          2316: 
        !          2317:        zend_add_catch_element(try_token->u.opline_num, get_next_op_number(CG(active_op_array)) TSRMLS_CC);
        !          2318: }
        !          2319: /* }}} */
        !          2320: 
        !          2321: void zend_do_mark_last_catch(const znode *first_catch, const znode *last_additional_catch TSRMLS_DC) /* {{{ */
        !          2322: {
        !          2323:        CG(active_op_array)->last--;
        !          2324:        zend_do_if_end(TSRMLS_C);
        !          2325:        if (last_additional_catch->u.opline_num == -1) {
        !          2326:                CG(active_op_array)->opcodes[first_catch->u.opline_num].op1.u.EA.type = 1;
        !          2327:                CG(active_op_array)->opcodes[first_catch->u.opline_num].extended_value = get_next_op_number(CG(active_op_array));
        !          2328:        } else {
        !          2329:                CG(active_op_array)->opcodes[last_additional_catch->u.opline_num].op1.u.EA.type = 1;
        !          2330:                CG(active_op_array)->opcodes[last_additional_catch->u.opline_num].extended_value = get_next_op_number(CG(active_op_array));
        !          2331:        }
        !          2332:        DEC_BPC(CG(active_op_array));
        !          2333: }
        !          2334: /* }}} */
        !          2335: 
        !          2336: void zend_do_try(znode *try_token TSRMLS_DC) /* {{{ */
        !          2337: {
        !          2338:        try_token->u.opline_num = zend_add_try_element(get_next_op_number(CG(active_op_array)) TSRMLS_CC);
        !          2339:        INC_BPC(CG(active_op_array));
        !          2340: }
        !          2341: /* }}} */
        !          2342: 
        !          2343: void zend_do_begin_catch(znode *try_token, znode *class_name, const znode *catch_var, znode *first_catch TSRMLS_DC) /* {{{ */
        !          2344: {
        !          2345:        long catch_op_number;
        !          2346:        zend_op *opline;
        !          2347:        znode catch_class;
        !          2348: 
        !          2349:        zend_do_fetch_class(&catch_class, class_name TSRMLS_CC);
        !          2350: 
        !          2351:        catch_op_number = get_next_op_number(CG(active_op_array));
        !          2352:        if (catch_op_number > 0) {
        !          2353:                opline = &CG(active_op_array)->opcodes[catch_op_number-1];
        !          2354:                if (opline->opcode == ZEND_FETCH_CLASS) {
        !          2355:                        opline->extended_value |= ZEND_FETCH_CLASS_NO_AUTOLOAD;
        !          2356:                }
        !          2357:        }
        !          2358: 
        !          2359:        if (first_catch) {
        !          2360:                first_catch->u.opline_num = catch_op_number;
        !          2361:        }
        !          2362: 
        !          2363:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          2364:        opline->opcode = ZEND_CATCH;
        !          2365:        opline->op1 = catch_class;
        !          2366: /*     SET_UNUSED(opline->op1); */ /* FIXME: Define IS_CLASS or something like that */
        !          2367:        opline->op2.op_type = IS_CV;
        !          2368:        opline->op2.u.var = lookup_cv(CG(active_op_array), catch_var->u.constant.value.str.val, catch_var->u.constant.value.str.len);
        !          2369:        opline->op2.u.EA.type = 0;
        !          2370:        opline->op1.u.EA.type = 0; /* 1 means it's the last catch in the block */
        !          2371: 
        !          2372:        try_token->u.opline_num = catch_op_number;
        !          2373: }
        !          2374: /* }}} */
        !          2375: 
        !          2376: void zend_do_end_catch(const znode *try_token TSRMLS_DC) /* {{{ */
        !          2377: {
        !          2378:        int jmp_op_number = get_next_op_number(CG(active_op_array));
        !          2379:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          2380:        zend_llist *jmp_list_ptr;
        !          2381: 
        !          2382:        opline->opcode = ZEND_JMP;
        !          2383:        SET_UNUSED(opline->op1);
        !          2384:        SET_UNUSED(opline->op2);
        !          2385:        /* save for backpatching */
        !          2386: 
        !          2387:        zend_stack_top(&CG(bp_stack), (void **) &jmp_list_ptr);
        !          2388:        zend_llist_add_element(jmp_list_ptr, &jmp_op_number);
        !          2389: 
        !          2390:        CG(active_op_array)->opcodes[try_token->u.opline_num].extended_value = get_next_op_number(CG(active_op_array));
        !          2391: }
        !          2392: /* }}} */
        !          2393: 
        !          2394: void zend_do_throw(const znode *expr TSRMLS_DC) /* {{{ */
        !          2395: {
        !          2396:        zend_op *opline;
        !          2397: 
        !          2398:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          2399:        opline->opcode = ZEND_THROW;
        !          2400:        opline->op1 = *expr;
        !          2401:        SET_UNUSED(opline->op2);
        !          2402: }
        !          2403: /* }}} */
        !          2404: 
        !          2405: ZEND_API void function_add_ref(zend_function *function) /* {{{ */
        !          2406: {
        !          2407:        if (function->type == ZEND_USER_FUNCTION) {
        !          2408:                zend_op_array *op_array = &function->op_array;
        !          2409: 
        !          2410:                (*op_array->refcount)++;
        !          2411:                if (op_array->static_variables) {
        !          2412:                        HashTable *static_variables = op_array->static_variables;
        !          2413:                        zval *tmp_zval;
        !          2414: 
        !          2415:                        ALLOC_HASHTABLE(op_array->static_variables);
        !          2416:                        zend_hash_init(op_array->static_variables, zend_hash_num_elements(static_variables), NULL, ZVAL_PTR_DTOR, 0);
        !          2417:                        zend_hash_copy(op_array->static_variables, static_variables, (copy_ctor_func_t) zval_add_ref, (void *) &tmp_zval, sizeof(zval *));
        !          2418:                }
        !          2419:        }
        !          2420: }
        !          2421: /* }}} */
        !          2422: 
        !          2423: static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */
        !          2424: {
        !          2425:        zend_function *function;
        !          2426: 
        !          2427:        if (!ce->parent) {
        !          2428:                return;
        !          2429:        }
        !          2430: 
        !          2431:        /* You cannot change create_object */
        !          2432:        ce->create_object = ce->parent->create_object;
        !          2433: 
        !          2434:        /* Inherit special functions if needed */
        !          2435:        if (!ce->get_iterator) {
        !          2436:                ce->get_iterator = ce->parent->get_iterator;
        !          2437:        }
        !          2438:        if (!ce->iterator_funcs.funcs) {
        !          2439:                ce->iterator_funcs.funcs = ce->parent->iterator_funcs.funcs;
        !          2440:        }
        !          2441:        if (!ce->__get) {
        !          2442:                ce->__get   = ce->parent->__get;
        !          2443:        }
        !          2444:        if (!ce->__set) {
        !          2445:                ce->__set = ce->parent->__set;
        !          2446:        }
        !          2447:        if (!ce->__unset) {
        !          2448:                ce->__unset = ce->parent->__unset;
        !          2449:        }
        !          2450:        if (!ce->__isset) {
        !          2451:                ce->__isset = ce->parent->__isset;
        !          2452:        }
        !          2453:        if (!ce->__call) {
        !          2454:                ce->__call = ce->parent->__call;
        !          2455:        }
        !          2456:        if (!ce->__callstatic) {
        !          2457:                ce->__callstatic = ce->parent->__callstatic;
        !          2458:        }
        !          2459:        if (!ce->__tostring) {
        !          2460:                ce->__tostring = ce->parent->__tostring;
        !          2461:        }
        !          2462:        if (!ce->clone) {
        !          2463:                ce->clone = ce->parent->clone;
        !          2464:        }
        !          2465:        if(!ce->serialize) {
        !          2466:                ce->serialize = ce->parent->serialize;
        !          2467:        }
        !          2468:        if(!ce->unserialize) {
        !          2469:                ce->unserialize = ce->parent->unserialize;
        !          2470:        }
        !          2471:        if (!ce->destructor) {
        !          2472:                ce->destructor   = ce->parent->destructor;
        !          2473:        }
        !          2474:        if (ce->constructor) {
        !          2475:                if (ce->parent->constructor && ce->parent->constructor->common.fn_flags & ZEND_ACC_FINAL) {
        !          2476:                        zend_error(E_ERROR, "Cannot override final %s::%s() with %s::%s()",
        !          2477:                                ce->parent->name, ce->parent->constructor->common.function_name,
        !          2478:                                ce->name, ce->constructor->common.function_name
        !          2479:                                );
        !          2480:                }
        !          2481:                return;
        !          2482:        }
        !          2483: 
        !          2484:        if (zend_hash_find(&ce->parent->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), (void **)&function)==SUCCESS) {
        !          2485:                /* inherit parent's constructor */
        !          2486:                zend_hash_update(&ce->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), function, sizeof(zend_function), NULL);
        !          2487:                function_add_ref(function);
        !          2488:        } else {
        !          2489:                /* Don't inherit the old style constructor if we already have the new style constructor */
        !          2490:                char *lc_class_name;
        !          2491:                char *lc_parent_class_name;
        !          2492: 
        !          2493:                lc_class_name = zend_str_tolower_dup(ce->name, ce->name_length);
        !          2494:                if (!zend_hash_exists(&ce->function_table, lc_class_name, ce->name_length+1)) {
        !          2495:                        lc_parent_class_name = zend_str_tolower_dup(ce->parent->name, ce->parent->name_length);
        !          2496:                        if (!zend_hash_exists(&ce->function_table, lc_parent_class_name, ce->parent->name_length+1) && 
        !          2497:                                        zend_hash_find(&ce->parent->function_table, lc_parent_class_name, ce->parent->name_length+1, (void **)&function)==SUCCESS) {
        !          2498:                                if (function->common.fn_flags & ZEND_ACC_CTOR) {
        !          2499:                                        /* inherit parent's constructor */
        !          2500:                                        zend_hash_update(&ce->function_table, lc_parent_class_name, ce->parent->name_length+1, function, sizeof(zend_function), NULL);
        !          2501:                                        function_add_ref(function);
        !          2502:                                }
        !          2503:                        }
        !          2504:                        efree(lc_parent_class_name);
        !          2505:                }
        !          2506:                efree(lc_class_name);
        !          2507:        }
        !          2508:        ce->constructor = ce->parent->constructor;
        !          2509: }
        !          2510: /* }}} */
        !          2511: 
        !          2512: char *zend_visibility_string(zend_uint fn_flags) /* {{{ */
        !          2513: {
        !          2514:        if (fn_flags & ZEND_ACC_PRIVATE) {
        !          2515:                return "private";
        !          2516:        }
        !          2517:        if (fn_flags & ZEND_ACC_PROTECTED) {
        !          2518:                return "protected";
        !          2519:        }
        !          2520:        if (fn_flags & ZEND_ACC_PUBLIC) {
        !          2521:                return "public";
        !          2522:        }
        !          2523:        return "";
        !          2524: }
        !          2525: /* }}} */
        !          2526: 
        !          2527: static void do_inherit_method(zend_function *function) /* {{{ */
        !          2528: {
        !          2529:        /* The class entry of the derived function intentionally remains the same
        !          2530:         * as that of the parent class.  That allows us to know in which context
        !          2531:         * we're running, and handle private method calls properly.
        !          2532:         */
        !          2533:        function_add_ref(function);
        !          2534: }
        !          2535: /* }}} */
        !          2536: 
        !          2537: static zend_bool zend_do_perform_implementation_check(const zend_function *fe, const zend_function *proto TSRMLS_DC) /* {{{ */
        !          2538: {
        !          2539:        zend_uint i;
        !          2540: 
        !          2541:        /* If it's a user function then arg_info == NULL means we don't have any parameters but
        !          2542:         * we still need to do the arg number checks.  We are only willing to ignore this for internal
        !          2543:         * functions because extensions don't always define arg_info.
        !          2544:         */
        !          2545:        if (!proto || (!proto->common.arg_info && proto->common.type != ZEND_USER_FUNCTION)) {
        !          2546:                return 1;
        !          2547:        }
        !          2548: 
        !          2549:        /* Checks for constructors only if they are declared in an interface */
        !          2550:        if ((fe->common.fn_flags & ZEND_ACC_CTOR) && (proto->common.scope->ce_flags & ZEND_ACC_INTERFACE) == 0) {
        !          2551:                return 1;
        !          2552:        }
        !          2553: 
        !          2554:        /* check number of arguments */
        !          2555:        if (proto->common.required_num_args < fe->common.required_num_args
        !          2556:                || proto->common.num_args > fe->common.num_args) {
        !          2557:                return 0;
        !          2558:        }
        !          2559: 
        !          2560:        if (fe->common.type != ZEND_USER_FUNCTION
        !          2561:                && proto->common.pass_rest_by_reference
        !          2562:                && !fe->common.pass_rest_by_reference) {
        !          2563:                return 0;
        !          2564:        }
        !          2565: 
        !          2566:        /* by-ref constraints on return values are covariant */
        !          2567:        if (proto->common.return_reference && !fe->common.return_reference) {
        !          2568:                return 0;
        !          2569:        }
        !          2570: 
        !          2571:        for (i=0; i < proto->common.num_args; i++) {
        !          2572:                if (ZEND_LOG_XOR(fe->common.arg_info[i].class_name, proto->common.arg_info[i].class_name)) {
        !          2573:                        /* Only one has a type hint and the other one doesn't */
        !          2574:                        return 0;
        !          2575:                }
        !          2576:                if (fe->common.arg_info[i].class_name
        !          2577:                        && strcasecmp(fe->common.arg_info[i].class_name, proto->common.arg_info[i].class_name)!=0) {
        !          2578:                        char *colon;
        !          2579: 
        !          2580:                        if (fe->common.type != ZEND_USER_FUNCTION) {
        !          2581:                                return 0;
        !          2582:                        } else if (strchr(proto->common.arg_info[i].class_name, '\\') != NULL ||
        !          2583:                            (colon = zend_memrchr(fe->common.arg_info[i].class_name, '\\', fe->common.arg_info[i].class_name_len)) == NULL ||
        !          2584:                            strcasecmp(colon+1, proto->common.arg_info[i].class_name) != 0) {
        !          2585:                                zend_class_entry **fe_ce, **proto_ce;
        !          2586:                                int found, found2;
        !          2587:                                
        !          2588:                                found = zend_lookup_class(fe->common.arg_info[i].class_name, fe->common.arg_info[i].class_name_len, &fe_ce TSRMLS_CC);
        !          2589:                                found2 = zend_lookup_class(proto->common.arg_info[i].class_name, proto->common.arg_info[i].class_name_len, &proto_ce TSRMLS_CC);
        !          2590:                                
        !          2591:                                /* Check for class alias */
        !          2592:                                if (found != SUCCESS || found2 != SUCCESS ||
        !          2593:                                        (*fe_ce)->type == ZEND_INTERNAL_CLASS ||
        !          2594:                                        (*proto_ce)->type == ZEND_INTERNAL_CLASS ||
        !          2595:                                        *fe_ce != *proto_ce) {
        !          2596:                                        return 0;
        !          2597:                                }
        !          2598:                        }
        !          2599:                }
        !          2600:                if (fe->common.arg_info[i].array_type_hint != proto->common.arg_info[i].array_type_hint) {
        !          2601:                        /* Only one has an array type hint and the other one doesn't */
        !          2602:                        return 0;
        !          2603:                }
        !          2604: 
        !          2605:                /* by-ref constraints on arguments are invariant */
        !          2606:                if (fe->common.arg_info[i].pass_by_reference != proto->common.arg_info[i].pass_by_reference) {
        !          2607:                        return 0;
        !          2608:                }
        !          2609:        }
        !          2610: 
        !          2611:        if (proto->common.pass_rest_by_reference) {
        !          2612:                for (i=proto->common.num_args; i < fe->common.num_args; i++) {
        !          2613:                        if (!fe->common.arg_info[i].pass_by_reference) {
        !          2614:                                return 0;
        !          2615:                        }
        !          2616:                }
        !          2617:        }
        !          2618:        return 1;
        !          2619: }
        !          2620: /* }}} */
        !          2621: 
        !          2622: static zend_bool do_inherit_method_check(HashTable *child_function_table, zend_function *parent, const zend_hash_key *hash_key, zend_class_entry *child_ce) /* {{{ */
        !          2623: {
        !          2624:        zend_uint child_flags;
        !          2625:        zend_uint parent_flags = parent->common.fn_flags;
        !          2626:        zend_function *child;
        !          2627:        TSRMLS_FETCH();
        !          2628: 
        !          2629:        if (zend_hash_quick_find(child_function_table, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **) &child)==FAILURE) {
        !          2630:                if (parent_flags & (ZEND_ACC_ABSTRACT)) {
        !          2631:                        child_ce->ce_flags |= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS;
        !          2632:                }
        !          2633:                return 1; /* method doesn't exist in child, copy from parent */
        !          2634:        }
        !          2635: 
        !          2636:        if ((parent->common.scope->ce_flags & ZEND_ACC_INTERFACE) == 0
        !          2637:                && parent->common.fn_flags & ZEND_ACC_ABSTRACT
        !          2638:                && parent->common.scope != (child->common.prototype ? child->common.prototype->common.scope : child->common.scope)
        !          2639:                && child->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_IMPLEMENTED_ABSTRACT)) {
        !          2640:                zend_error(E_COMPILE_ERROR, "Can't inherit abstract function %s::%s() (previously declared abstract in %s)", 
        !          2641:                        parent->common.scope->name,
        !          2642:                        child->common.function_name,
        !          2643:                        child->common.prototype ? child->common.prototype->common.scope->name : child->common.scope->name);
        !          2644:        }
        !          2645: 
        !          2646:        if (parent_flags & ZEND_ACC_FINAL) {
        !          2647:                zend_error(E_COMPILE_ERROR, "Cannot override final method %s::%s()", ZEND_FN_SCOPE_NAME(parent), child->common.function_name);
        !          2648:        }
        !          2649: 
        !          2650:        child_flags     = child->common.fn_flags;
        !          2651:        /* You cannot change from static to non static and vice versa.
        !          2652:         */
        !          2653:        if ((child_flags & ZEND_ACC_STATIC) != (parent_flags & ZEND_ACC_STATIC)) {
        !          2654:                if (child->common.fn_flags & ZEND_ACC_STATIC) {
        !          2655:                        zend_error(E_COMPILE_ERROR, "Cannot make non static method %s::%s() static in class %s", ZEND_FN_SCOPE_NAME(parent), child->common.function_name, ZEND_FN_SCOPE_NAME(child));
        !          2656:                } else {
        !          2657:                        zend_error(E_COMPILE_ERROR, "Cannot make static method %s::%s() non static in class %s", ZEND_FN_SCOPE_NAME(parent), child->common.function_name, ZEND_FN_SCOPE_NAME(child));
        !          2658:                }
        !          2659:        }
        !          2660: 
        !          2661:        /* Disallow making an inherited method abstract. */
        !          2662:        if ((child_flags & ZEND_ACC_ABSTRACT) && !(parent_flags & ZEND_ACC_ABSTRACT)) {
        !          2663:                zend_error(E_COMPILE_ERROR, "Cannot make non abstract method %s::%s() abstract in class %s", ZEND_FN_SCOPE_NAME(parent), child->common.function_name, ZEND_FN_SCOPE_NAME(child));
        !          2664:        }
        !          2665: 
        !          2666:        if (parent_flags & ZEND_ACC_CHANGED) {
        !          2667:                child->common.fn_flags |= ZEND_ACC_CHANGED;
        !          2668:        } else {
        !          2669:                /* Prevent derived classes from restricting access that was available in parent classes
        !          2670:                 */
        !          2671:                if ((child_flags & ZEND_ACC_PPP_MASK) > (parent_flags & ZEND_ACC_PPP_MASK)) {
        !          2672:                        zend_error(E_COMPILE_ERROR, "Access level to %s::%s() must be %s (as in class %s)%s", ZEND_FN_SCOPE_NAME(child), child->common.function_name, zend_visibility_string(parent_flags), ZEND_FN_SCOPE_NAME(parent), (parent_flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
        !          2673:                } else if (((child_flags & ZEND_ACC_PPP_MASK) < (parent_flags & ZEND_ACC_PPP_MASK))
        !          2674:                        && ((parent_flags & ZEND_ACC_PPP_MASK) & ZEND_ACC_PRIVATE)) {
        !          2675:                        child->common.fn_flags |= ZEND_ACC_CHANGED;
        !          2676:                }
        !          2677:        }
        !          2678: 
        !          2679:        if (parent_flags & ZEND_ACC_PRIVATE) {
        !          2680:                child->common.prototype = NULL;         
        !          2681:        } else if (parent_flags & ZEND_ACC_ABSTRACT) {
        !          2682:                child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT;
        !          2683:                child->common.prototype = parent;
        !          2684:        } else if (!(parent->common.fn_flags & ZEND_ACC_CTOR) || (parent->common.prototype && (parent->common.prototype->common.scope->ce_flags & ZEND_ACC_INTERFACE))) {
        !          2685:                /* ctors only have a prototype if it comes from an interface */
        !          2686:                child->common.prototype = parent->common.prototype ? parent->common.prototype : parent;
        !          2687:        }
        !          2688: 
        !          2689:        if (child->common.prototype && (child->common.prototype->common.fn_flags & ZEND_ACC_ABSTRACT)) {
        !          2690:                if (!zend_do_perform_implementation_check(child, child->common.prototype TSRMLS_CC)) {
        !          2691:                        zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be compatible with that of %s::%s()", ZEND_FN_SCOPE_NAME(child), child->common.function_name, ZEND_FN_SCOPE_NAME(child->common.prototype), child->common.prototype->common.function_name);
        !          2692:                }
        !          2693:        } else if (EG(error_reporting) & E_STRICT || EG(user_error_handler)) { /* Check E_STRICT (or custom error handler) before the check so that we save some time */
        !          2694:                if (!zend_do_perform_implementation_check(child, parent TSRMLS_CC)) {
        !          2695:                        zend_error(E_STRICT, "Declaration of %s::%s() should be compatible with that of %s::%s()", ZEND_FN_SCOPE_NAME(child), child->common.function_name, ZEND_FN_SCOPE_NAME(parent), parent->common.function_name);
        !          2696:                }
        !          2697:        }
        !          2698: 
        !          2699:        return 0;
        !          2700: }
        !          2701: /* }}} */
        !          2702: 
        !          2703: static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_property_info *parent_info, const zend_hash_key *hash_key, zend_class_entry *ce) /* {{{ */
        !          2704: {
        !          2705:        zend_property_info *child_info;
        !          2706:        zend_class_entry *parent_ce = ce->parent;
        !          2707: 
        !          2708:        if (parent_info->flags & (ZEND_ACC_PRIVATE|ZEND_ACC_SHADOW)) {
        !          2709:                if (zend_hash_quick_find(&ce->properties_info, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **) &child_info)==SUCCESS) {
        !          2710:                        child_info->flags |= ZEND_ACC_CHANGED;
        !          2711:                } else {
        !          2712:                        zend_hash_quick_update(&ce->properties_info, hash_key->arKey, hash_key->nKeyLength, hash_key->h, parent_info, sizeof(zend_property_info), (void **) &child_info);
        !          2713:                        if(ce->type & ZEND_INTERNAL_CLASS) {
        !          2714:                                zend_duplicate_property_info_internal(child_info);
        !          2715:                        } else {
        !          2716:                                zend_duplicate_property_info(child_info);
        !          2717:                        }
        !          2718:                        child_info->flags &= ~ZEND_ACC_PRIVATE; /* it's not private anymore */
        !          2719:                        child_info->flags |= ZEND_ACC_SHADOW; /* but it's a shadow of private */
        !          2720:                }
        !          2721:                return 0; /* don't copy access information to child */
        !          2722:        }
        !          2723: 
        !          2724:        if (zend_hash_quick_find(&ce->properties_info, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **) &child_info)==SUCCESS) {
        !          2725:                if ((parent_info->flags & ZEND_ACC_STATIC) != (child_info->flags & ZEND_ACC_STATIC)) {
        !          2726:                        zend_error(E_COMPILE_ERROR, "Cannot redeclare %s%s::$%s as %s%s::$%s",
        !          2727:                                (parent_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", parent_ce->name, hash_key->arKey,
        !          2728:                                (child_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", ce->name, hash_key->arKey);
        !          2729:                                
        !          2730:                }
        !          2731: 
        !          2732:                if(parent_info->flags & ZEND_ACC_CHANGED) {
        !          2733:                        child_info->flags |= ZEND_ACC_CHANGED;
        !          2734:                }
        !          2735: 
        !          2736:                if ((child_info->flags & ZEND_ACC_PPP_MASK) > (parent_info->flags & ZEND_ACC_PPP_MASK)) {
        !          2737:                        zend_error(E_COMPILE_ERROR, "Access level to %s::$%s must be %s (as in class %s)%s", ce->name, hash_key->arKey, zend_visibility_string(parent_info->flags), parent_ce->name, (parent_info->flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
        !          2738:                } else if (child_info->flags & ZEND_ACC_IMPLICIT_PUBLIC) {
        !          2739:                        if (!(parent_info->flags & ZEND_ACC_IMPLICIT_PUBLIC)) {
        !          2740:                                /* Explicitly copy the default value from the parent (if it has one) */
        !          2741:                                zval **pvalue;
        !          2742:        
        !          2743:                                if (zend_hash_quick_find(&parent_ce->default_properties, parent_info->name, parent_info->name_length+1, parent_info->h, (void **) &pvalue) == SUCCESS) {
        !          2744:                                        Z_ADDREF_PP(pvalue);
        !          2745:                                        zend_hash_quick_del(&ce->default_properties, child_info->name, child_info->name_length+1, parent_info->h);
        !          2746:                                        zend_hash_quick_update(&ce->default_properties, parent_info->name, parent_info->name_length+1, parent_info->h, pvalue, sizeof(zval *), NULL);
        !          2747:                                }
        !          2748:                        }
        !          2749:                        return 1; /* Inherit from the parent */
        !          2750:                } else if ((child_info->flags & ZEND_ACC_PUBLIC) && (parent_info->flags & ZEND_ACC_PROTECTED)) {
        !          2751:                        char *prot_name;
        !          2752:                        int prot_name_length;
        !          2753: 
        !          2754:                        zend_mangle_property_name(&prot_name, &prot_name_length, "*", 1, child_info->name, child_info->name_length, ce->type & ZEND_INTERNAL_CLASS);
        !          2755:                        if (child_info->flags & ZEND_ACC_STATIC) {
        !          2756:                                zval **prop;
        !          2757:                                HashTable *ht;
        !          2758: 
        !          2759:                                if (parent_ce->type != ce->type) {
        !          2760:                                        /* User class extends internal class */
        !          2761:                                        TSRMLS_FETCH();
        !          2762: 
        !          2763:                                        ht = CE_STATIC_MEMBERS(parent_ce);
        !          2764:                                } else {
        !          2765:                                        ht = &parent_ce->default_static_members;
        !          2766:                                }
        !          2767:                                if (zend_hash_find(ht, prot_name, prot_name_length+1, (void**)&prop) == SUCCESS) {
        !          2768:                                        zend_hash_del(&ce->default_static_members, prot_name, prot_name_length+1);
        !          2769:                                }
        !          2770:                        } else {
        !          2771:                                zend_hash_del(&ce->default_properties, prot_name, prot_name_length+1);
        !          2772:                        }
        !          2773:                        pefree(prot_name, ce->type & ZEND_INTERNAL_CLASS);
        !          2774:                }
        !          2775:                return 0;       /* Don't copy from parent */
        !          2776:        } else {
        !          2777:                return 1;       /* Copy from parent */
        !          2778:        }
        !          2779: }
        !          2780: /* }}} */
        !          2781: 
        !          2782: static inline void do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC) /* {{{ */
        !          2783: {
        !          2784:        if (!(ce->ce_flags & ZEND_ACC_INTERFACE) && iface->interface_gets_implemented && iface->interface_gets_implemented(iface, ce TSRMLS_CC) == FAILURE) {
        !          2785:                zend_error(E_CORE_ERROR, "Class %s could not implement interface %s", ce->name, iface->name);
        !          2786:        }
        !          2787:        if (ce == iface) {
        !          2788:                zend_error(E_ERROR, "Interface %s cannot implement itself", ce->name);
        !          2789:        }
        !          2790: }
        !          2791: /* }}} */
        !          2792: 
        !          2793: ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_entry *iface TSRMLS_DC) /* {{{ */
        !          2794: {
        !          2795:        /* expects interface to be contained in ce's interface list already */
        !          2796:        zend_uint i, ce_num, if_num = iface->num_interfaces;
        !          2797:        zend_class_entry *entry;
        !          2798: 
        !          2799:        if (if_num==0) {
        !          2800:                return;
        !          2801:        }
        !          2802:        ce_num = ce->num_interfaces;
        !          2803: 
        !          2804:        if (ce->type == ZEND_INTERNAL_CLASS) {
        !          2805:                ce->interfaces = (zend_class_entry **) realloc(ce->interfaces, sizeof(zend_class_entry *) * (ce_num + if_num));
        !          2806:        } else {
        !          2807:                ce->interfaces = (zend_class_entry **) erealloc(ce->interfaces, sizeof(zend_class_entry *) * (ce_num + if_num));
        !          2808:        }
        !          2809: 
        !          2810:        /* Inherit the interfaces, only if they're not already inherited by the class */
        !          2811:        while (if_num--) {
        !          2812:                entry = iface->interfaces[if_num];
        !          2813:                for (i = 0; i < ce_num; i++) {
        !          2814:                        if (ce->interfaces[i] == entry) {
        !          2815:                                break;
        !          2816:                        }
        !          2817:                }
        !          2818:                if (i == ce_num) {
        !          2819:                        ce->interfaces[ce->num_interfaces++] = entry;
        !          2820:                }
        !          2821:        }
        !          2822: 
        !          2823:        /* and now call the implementing handlers */
        !          2824:        while (ce_num < ce->num_interfaces) {
        !          2825:                do_implement_interface(ce, ce->interfaces[ce_num++] TSRMLS_CC);
        !          2826:        }
        !          2827: }
        !          2828: /* }}} */
        !          2829: 
        !          2830: static int inherit_static_prop(zval **p TSRMLS_DC, int num_args, va_list args, const zend_hash_key *key) /* {{{ */
        !          2831: {
        !          2832:        HashTable *target = va_arg(args, HashTable*);
        !          2833: 
        !          2834:        if (!zend_hash_quick_exists(target, key->arKey, key->nKeyLength, key->h)) {
        !          2835:                SEPARATE_ZVAL_TO_MAKE_IS_REF(p);
        !          2836:                if (zend_hash_quick_add(target, key->arKey, key->nKeyLength, key->h, p, sizeof(zval*), NULL) == SUCCESS) {
        !          2837:                        Z_ADDREF_PP(p);
        !          2838:                }
        !          2839:        }
        !          2840:        return ZEND_HASH_APPLY_KEEP;
        !          2841: }
        !          2842: /* }}} */
        !          2843: 
        !          2844: #define zval_property_ctor(parent_ce, ce) \
        !          2845:        ((copy_ctor_func_t) (((parent_ce)->type != (ce)->type) ? zval_shared_property_ctor : zval_add_ref))
        !          2846: 
        !          2847: ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce TSRMLS_DC) /* {{{ */
        !          2848: {
        !          2849:        if ((ce->ce_flags & ZEND_ACC_INTERFACE)
        !          2850:                && !(parent_ce->ce_flags & ZEND_ACC_INTERFACE)) {
        !          2851:                zend_error(E_COMPILE_ERROR, "Interface %s may not inherit from class (%s)", ce->name, parent_ce->name);
        !          2852:        }
        !          2853:        if (parent_ce->ce_flags & ZEND_ACC_FINAL_CLASS) {
        !          2854:                zend_error(E_COMPILE_ERROR, "Class %s may not inherit from final class (%s)", ce->name, parent_ce->name);
        !          2855:        }
        !          2856: 
        !          2857:        ce->parent = parent_ce;
        !          2858:        /* Copy serialize/unserialize callbacks */
        !          2859:        if (!ce->serialize) {
        !          2860:                ce->serialize   = parent_ce->serialize;
        !          2861:        }
        !          2862:        if (!ce->unserialize) {
        !          2863:                ce->unserialize = parent_ce->unserialize;
        !          2864:        }
        !          2865: 
        !          2866:        /* Inherit interfaces */
        !          2867:        zend_do_inherit_interfaces(ce, parent_ce TSRMLS_CC);
        !          2868: 
        !          2869:        /* Inherit properties */
        !          2870:        zend_hash_merge(&ce->default_properties, &parent_ce->default_properties, zval_property_ctor(parent_ce, ce), NULL, sizeof(zval *), 0);
        !          2871:        if (parent_ce->type != ce->type) {
        !          2872:                /* User class extends internal class */
        !          2873:                zend_update_class_constants(parent_ce  TSRMLS_CC);
        !          2874:                zend_hash_apply_with_arguments(CE_STATIC_MEMBERS(parent_ce) TSRMLS_CC, (apply_func_args_t)inherit_static_prop, 1, &ce->default_static_members);
        !          2875:        } else {
        !          2876:                zend_hash_apply_with_arguments(&parent_ce->default_static_members TSRMLS_CC, (apply_func_args_t)inherit_static_prop, 1, &ce->default_static_members);
        !          2877:        }
        !          2878:        zend_hash_merge_ex(&ce->properties_info, &parent_ce->properties_info, (copy_ctor_func_t) (ce->type & ZEND_INTERNAL_CLASS ? zend_duplicate_property_info_internal : zend_duplicate_property_info), sizeof(zend_property_info), (merge_checker_func_t) do_inherit_property_access_check, ce);
        !          2879: 
        !          2880:        zend_hash_merge(&ce->constants_table, &parent_ce->constants_table, zval_property_ctor(parent_ce, ce), NULL, sizeof(zval *), 0);
        !          2881:        zend_hash_merge_ex(&ce->function_table, &parent_ce->function_table, (copy_ctor_func_t) do_inherit_method, sizeof(zend_function), (merge_checker_func_t) do_inherit_method_check, ce);
        !          2882:        do_inherit_parent_constructor(ce);
        !          2883: 
        !          2884:        if (ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS && ce->type == ZEND_INTERNAL_CLASS) {
        !          2885:                ce->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;
        !          2886:        } else if (!(ce->ce_flags & ZEND_ACC_IMPLEMENT_INTERFACES)) {
        !          2887:                /* The verification will be done in runtime by ZEND_VERIFY_ABSTRACT_CLASS */
        !          2888:                zend_verify_abstract_class(ce TSRMLS_CC);
        !          2889:        }
        !          2890: }
        !          2891: /* }}} */
        !          2892: 
        !          2893: static zend_bool do_inherit_constant_check(HashTable *child_constants_table, const zval **parent_constant, const zend_hash_key *hash_key, const zend_class_entry *iface) /* {{{ */
        !          2894: {
        !          2895:        zval **old_constant;
        !          2896: 
        !          2897:        if (zend_hash_quick_find(child_constants_table, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void**)&old_constant) == SUCCESS) {
        !          2898:                if (*old_constant != *parent_constant) {
        !          2899:                        zend_error(E_COMPILE_ERROR, "Cannot inherit previously-inherited or override constant %s from interface %s", hash_key->arKey, iface->name);
        !          2900:                }
        !          2901:                return 0;
        !          2902:        }
        !          2903:        return 1;
        !          2904: }
        !          2905: /* }}} */
        !          2906: 
        !          2907: static int do_interface_constant_check(zval **val TSRMLS_DC, int num_args, va_list args, const zend_hash_key *key) /* {{{ */
        !          2908: {
        !          2909:        zend_class_entry **iface = va_arg(args, zend_class_entry**);
        !          2910: 
        !          2911:        do_inherit_constant_check(&(*iface)->constants_table, (const zval **) val, key, *iface);
        !          2912: 
        !          2913:        return ZEND_HASH_APPLY_KEEP;
        !          2914: }
        !          2915: /* }}} */
        !          2916: 
        !          2917: ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC) /* {{{ */
        !          2918: {
        !          2919:        zend_uint i, ignore = 0;
        !          2920:        zend_uint current_iface_num = ce->num_interfaces;
        !          2921:        zend_uint parent_iface_num  = ce->parent ? ce->parent->num_interfaces : 0;
        !          2922: 
        !          2923:        for (i = 0; i < ce->num_interfaces; i++) {
        !          2924:                if (ce->interfaces[i] == NULL) {
        !          2925:                        memmove(ce->interfaces + i, ce->interfaces + i + 1, sizeof(zend_class_entry*) * (--ce->num_interfaces - i));
        !          2926:                        i--;
        !          2927:                } else if (ce->interfaces[i] == iface) {
        !          2928:                        if (i < parent_iface_num) {
        !          2929:                                ignore = 1;
        !          2930:                        } else {
        !          2931:                                zend_error(E_COMPILE_ERROR, "Class %s cannot implement previously implemented interface %s", ce->name, iface->name);
        !          2932:                        }
        !          2933:                }
        !          2934:        }
        !          2935:        if (ignore) {
        !          2936:                /* Check for attempt to redeclare interface constants */
        !          2937:                zend_hash_apply_with_arguments(&ce->constants_table TSRMLS_CC, (apply_func_args_t) do_interface_constant_check, 1, &iface);
        !          2938:        } else {
        !          2939:                if (ce->num_interfaces >= current_iface_num) {
        !          2940:                        if (ce->type == ZEND_INTERNAL_CLASS) {
        !          2941:                                ce->interfaces = (zend_class_entry **) realloc(ce->interfaces, sizeof(zend_class_entry *) * (++current_iface_num));
        !          2942:                        } else {
        !          2943:                                ce->interfaces = (zend_class_entry **) erealloc(ce->interfaces, sizeof(zend_class_entry *) * (++current_iface_num));
        !          2944:                        }
        !          2945:                }
        !          2946:                ce->interfaces[ce->num_interfaces++] = iface;
        !          2947:        
        !          2948:                zend_hash_merge_ex(&ce->constants_table, &iface->constants_table, (copy_ctor_func_t) zval_add_ref, sizeof(zval *), (merge_checker_func_t) do_inherit_constant_check, iface);
        !          2949:                zend_hash_merge_ex(&ce->function_table, &iface->function_table, (copy_ctor_func_t) do_inherit_method, sizeof(zend_function), (merge_checker_func_t) do_inherit_method_check, ce);
        !          2950:        
        !          2951:                do_implement_interface(ce, iface TSRMLS_CC);
        !          2952:                zend_do_inherit_interfaces(ce, iface TSRMLS_CC);
        !          2953:        }
        !          2954: }
        !          2955: /* }}} */
        !          2956: 
        !          2957: ZEND_API int do_bind_function(zend_op *opline, HashTable *function_table, zend_bool compile_time) /* {{{ */
        !          2958: {
        !          2959:        zend_function *function;
        !          2960: 
        !          2961:        zend_hash_find(function_table, opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len, (void *) &function);
        !          2962:        if (zend_hash_add(function_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, function, sizeof(zend_function), NULL)==FAILURE) {
        !          2963:                int error_level = compile_time ? E_COMPILE_ERROR : E_ERROR;
        !          2964:                zend_function *old_function;
        !          2965: 
        !          2966:                if (zend_hash_find(function_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, (void *) &old_function)==SUCCESS
        !          2967:                        && old_function->type == ZEND_USER_FUNCTION
        !          2968:                        && old_function->op_array.last > 0) {
        !          2969:                        zend_error(error_level, "Cannot redeclare %s() (previously declared in %s:%d)",
        !          2970:                                                function->common.function_name,
        !          2971:                                                old_function->op_array.filename,
        !          2972:                                                old_function->op_array.opcodes[0].lineno);
        !          2973:                } else {
        !          2974:                        zend_error(error_level, "Cannot redeclare %s()", function->common.function_name);
        !          2975:                }
        !          2976:                return FAILURE;
        !          2977:        } else {
        !          2978:                (*function->op_array.refcount)++;
        !          2979:                function->op_array.static_variables = NULL; /* NULL out the unbound function */
        !          2980:                return SUCCESS;
        !          2981:        }
        !          2982: }
        !          2983: /* }}} */
        !          2984: 
        !          2985: ZEND_API zend_class_entry *do_bind_class(const zend_op *opline, HashTable *class_table, zend_bool compile_time TSRMLS_DC) /* {{{ */
        !          2986: {
        !          2987:        zend_class_entry *ce, **pce;
        !          2988: 
        !          2989:        if (zend_hash_find(class_table, opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len, (void **) &pce)==FAILURE) {
        !          2990:                zend_error(E_COMPILE_ERROR, "Internal Zend error - Missing class information for %s", opline->op1.u.constant.value.str.val);
        !          2991:                return NULL;
        !          2992:        } else {
        !          2993:                ce = *pce;
        !          2994:        }
        !          2995:        ce->refcount++;
        !          2996:        if (zend_hash_add(class_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, &ce, sizeof(zend_class_entry *), NULL)==FAILURE) {
        !          2997:                ce->refcount--;
        !          2998:                if (!compile_time) {
        !          2999:                        /* If we're in compile time, in practice, it's quite possible
        !          3000:                         * that we'll never reach this class declaration at runtime,
        !          3001:                         * so we shut up about it.  This allows the if (!defined('FOO')) { return; }
        !          3002:                         * approach to work.
        !          3003:                         */
        !          3004:                        zend_error(E_COMPILE_ERROR, "Cannot redeclare class %s", ce->name);
        !          3005:                }
        !          3006:                return NULL;
        !          3007:        } else {
        !          3008:                if (!(ce->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_IMPLEMENT_INTERFACES))) {
        !          3009:                        zend_verify_abstract_class(ce TSRMLS_CC);
        !          3010:                }
        !          3011:                return ce;
        !          3012:        }
        !          3013: }
        !          3014: /* }}} */
        !          3015: 
        !          3016: ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op *opline, HashTable *class_table, zend_class_entry *parent_ce, zend_bool compile_time TSRMLS_DC) /* {{{ */
        !          3017: {
        !          3018:        zend_class_entry *ce, **pce;
        !          3019:        int found_ce;
        !          3020: 
        !          3021:        found_ce = zend_hash_find(class_table, opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len, (void **) &pce);
        !          3022: 
        !          3023:        if (found_ce == FAILURE) {
        !          3024:                if (!compile_time) {
        !          3025:                        /* If we're in compile time, in practice, it's quite possible
        !          3026:                         * that we'll never reach this class declaration at runtime,
        !          3027:                         * so we shut up about it.  This allows the if (!defined('FOO')) { return; }
        !          3028:                         * approach to work.
        !          3029:                         */
        !          3030:                        zend_error(E_COMPILE_ERROR, "Cannot redeclare class %s", opline->op2.u.constant.value.str.val);
        !          3031:                }
        !          3032:                return NULL;
        !          3033:        } else {
        !          3034:                ce = *pce;
        !          3035:        }
        !          3036: 
        !          3037:        if (parent_ce->ce_flags & ZEND_ACC_INTERFACE) {
        !          3038:                zend_error(E_COMPILE_ERROR, "Class %s cannot extend from interface %s", ce->name, parent_ce->name);
        !          3039:        }
        !          3040: 
        !          3041:        zend_do_inheritance(ce, parent_ce TSRMLS_CC);
        !          3042: 
        !          3043:        ce->refcount++;
        !          3044: 
        !          3045:        /* Register the derived class */
        !          3046:        if (zend_hash_add(class_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, pce, sizeof(zend_class_entry *), NULL)==FAILURE) {
        !          3047:                zend_error(E_COMPILE_ERROR, "Cannot redeclare class %s", ce->name);
        !          3048:        }
        !          3049:        return ce;
        !          3050: }
        !          3051: /* }}} */
        !          3052: 
        !          3053: void zend_do_early_binding(TSRMLS_D) /* {{{ */
        !          3054: {
        !          3055:        zend_op *opline = &CG(active_op_array)->opcodes[CG(active_op_array)->last-1];
        !          3056:        HashTable *table;
        !          3057: 
        !          3058:        while (opline->opcode == ZEND_TICKS && opline > CG(active_op_array)->opcodes) {
        !          3059:                opline--;
        !          3060:        }
        !          3061: 
        !          3062:        switch (opline->opcode) {
        !          3063:                case ZEND_DECLARE_FUNCTION:
        !          3064:                        if (do_bind_function(opline, CG(function_table), 1) == FAILURE) {
        !          3065:                                return;
        !          3066:                        }
        !          3067:                        table = CG(function_table);
        !          3068:                        break;
        !          3069:                case ZEND_DECLARE_CLASS:
        !          3070:                        if (do_bind_class(opline, CG(class_table), 1 TSRMLS_CC) == NULL) {
        !          3071:                                return;
        !          3072:                        }
        !          3073:                        table = CG(class_table);
        !          3074:                        break;
        !          3075:                case ZEND_DECLARE_INHERITED_CLASS:
        !          3076:                        {
        !          3077:                                zend_op *fetch_class_opline = opline-1;
        !          3078:                                zval *parent_name = &fetch_class_opline->op2.u.constant;
        !          3079:                                zend_class_entry **pce;
        !          3080: 
        !          3081:                                if ((zend_lookup_class(Z_STRVAL_P(parent_name), Z_STRLEN_P(parent_name), &pce TSRMLS_CC) == FAILURE) ||
        !          3082:                                                ((CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_CLASSES) &&
        !          3083:                                                ((*pce)->type == ZEND_INTERNAL_CLASS))) {
        !          3084:                                        if (CG(compiler_options) & ZEND_COMPILE_DELAYED_BINDING) {
        !          3085:                                                zend_uint *opline_num = &CG(active_op_array)->early_binding;
        !          3086: 
        !          3087:                                                while (*opline_num != -1) {
        !          3088:                                                        opline_num = &CG(active_op_array)->opcodes[*opline_num].result.u.opline_num;
        !          3089:                                                }
        !          3090:                                                *opline_num = opline - CG(active_op_array)->opcodes;
        !          3091:                                                opline->opcode = ZEND_DECLARE_INHERITED_CLASS_DELAYED;
        !          3092:                                                opline->result.op_type = IS_UNUSED;
        !          3093:                                                opline->result.u.opline_num = -1;
        !          3094:                                        }
        !          3095:                                        return;
        !          3096:                                }
        !          3097:                                if (do_bind_inherited_class(opline, CG(class_table), *pce, 1 TSRMLS_CC) == NULL) {
        !          3098:                                        return;
        !          3099:                                }
        !          3100:                                /* clear unnecessary ZEND_FETCH_CLASS opcode */
        !          3101:                                zval_dtor(&fetch_class_opline->op2.u.constant);
        !          3102:                                MAKE_NOP(fetch_class_opline);
        !          3103: 
        !          3104:                                table = CG(class_table);
        !          3105:                                break;
        !          3106:                        }
        !          3107:                case ZEND_VERIFY_ABSTRACT_CLASS:
        !          3108:                case ZEND_ADD_INTERFACE:
        !          3109:                        /* We currently don't early-bind classes that implement interfaces */
        !          3110:                        return;
        !          3111:                default:
        !          3112:                        zend_error(E_COMPILE_ERROR, "Invalid binding type");
        !          3113:                        return;
        !          3114:        }
        !          3115: 
        !          3116:        zend_hash_del(table, opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len);
        !          3117:        zval_dtor(&opline->op1.u.constant);
        !          3118:        zval_dtor(&opline->op2.u.constant);
        !          3119:        MAKE_NOP(opline);
        !          3120: }
        !          3121: /* }}} */
        !          3122: 
        !          3123: ZEND_API void zend_do_delayed_early_binding(const zend_op_array *op_array TSRMLS_DC) /* {{{ */
        !          3124: {
        !          3125:        if (op_array->early_binding != -1) {
        !          3126:                zend_bool orig_in_compilation = CG(in_compilation);
        !          3127:                zend_uint opline_num = op_array->early_binding;
        !          3128:                zend_class_entry **pce;
        !          3129: 
        !          3130:                CG(in_compilation) = 1;
        !          3131:                while (opline_num != -1) {
        !          3132:                        if (zend_lookup_class(Z_STRVAL(op_array->opcodes[opline_num-1].op2.u.constant), Z_STRLEN(op_array->opcodes[opline_num-1].op2.u.constant), &pce TSRMLS_CC) == SUCCESS) {
        !          3133:                                do_bind_inherited_class(&op_array->opcodes[opline_num], EG(class_table), *pce, 1 TSRMLS_CC);
        !          3134:                        }
        !          3135:                        opline_num = op_array->opcodes[opline_num].result.u.opline_num;
        !          3136:                }
        !          3137:                CG(in_compilation) = orig_in_compilation;
        !          3138:        }
        !          3139: }
        !          3140: /* }}} */
        !          3141: 
        !          3142: void zend_do_boolean_or_begin(znode *expr1, znode *op_token TSRMLS_DC) /* {{{ */
        !          3143: {
        !          3144:        int next_op_number = get_next_op_number(CG(active_op_array));
        !          3145:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3146: 
        !          3147:        opline->opcode = ZEND_JMPNZ_EX;
        !          3148:        if (expr1->op_type == IS_TMP_VAR) {
        !          3149:                opline->result = *expr1;
        !          3150:        } else {
        !          3151:                opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          3152:                opline->result.op_type = IS_TMP_VAR;
        !          3153:        }
        !          3154:        opline->op1 = *expr1;
        !          3155:        SET_UNUSED(opline->op2);
        !          3156: 
        !          3157:        op_token->u.opline_num = next_op_number;
        !          3158: 
        !          3159:        *expr1 = opline->result;
        !          3160: }
        !          3161: /* }}} */
        !          3162: 
        !          3163: void zend_do_boolean_or_end(znode *result, const znode *expr1, const znode *expr2, znode *op_token TSRMLS_DC) /* {{{ */
        !          3164: {
        !          3165:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3166: 
        !          3167:        *result = *expr1; /* we saved the original result in expr1 */
        !          3168:        opline->opcode = ZEND_BOOL;
        !          3169:        opline->result = *result;
        !          3170:        opline->op1 = *expr2;
        !          3171:        SET_UNUSED(opline->op2);
        !          3172: 
        !          3173:        CG(active_op_array)->opcodes[op_token->u.opline_num].op2.u.opline_num = get_next_op_number(CG(active_op_array));
        !          3174: }
        !          3175: /* }}} */
        !          3176: 
        !          3177: void zend_do_boolean_and_begin(znode *expr1, znode *op_token TSRMLS_DC) /* {{{ */
        !          3178: {
        !          3179:        int next_op_number = get_next_op_number(CG(active_op_array));
        !          3180:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3181: 
        !          3182:        opline->opcode = ZEND_JMPZ_EX;
        !          3183:        if (expr1->op_type == IS_TMP_VAR) {
        !          3184:                opline->result = *expr1;
        !          3185:        } else {
        !          3186:                opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          3187:                opline->result.op_type = IS_TMP_VAR;
        !          3188:        }
        !          3189:        opline->op1 = *expr1;
        !          3190:        SET_UNUSED(opline->op2);
        !          3191: 
        !          3192:        op_token->u.opline_num = next_op_number;
        !          3193: 
        !          3194:        *expr1 = opline->result;
        !          3195: }
        !          3196: /* }}} */
        !          3197: 
        !          3198: void zend_do_boolean_and_end(znode *result, const znode *expr1, const znode *expr2, const znode *op_token TSRMLS_DC) /* {{{ */
        !          3199: {
        !          3200:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3201: 
        !          3202:        *result = *expr1; /* we saved the original result in expr1 */
        !          3203:        opline->opcode = ZEND_BOOL;
        !          3204:        opline->result = *result;
        !          3205:        opline->op1 = *expr2;
        !          3206:        SET_UNUSED(opline->op2);
        !          3207: 
        !          3208:        CG(active_op_array)->opcodes[op_token->u.opline_num].op2.u.opline_num = get_next_op_number(CG(active_op_array));
        !          3209: }
        !          3210: /* }}} */
        !          3211: 
        !          3212: void zend_do_do_while_begin(TSRMLS_D) /* {{{ */
        !          3213: {
        !          3214:        do_begin_loop(TSRMLS_C);
        !          3215:        INC_BPC(CG(active_op_array));
        !          3216: }
        !          3217: /* }}} */
        !          3218: 
        !          3219: void zend_do_do_while_end(const znode *do_token, const znode *expr_open_bracket, const znode *expr TSRMLS_DC) /* {{{ */
        !          3220: {
        !          3221:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3222: 
        !          3223:        opline->opcode = ZEND_JMPNZ;
        !          3224:        opline->op1 = *expr;
        !          3225:        opline->op2.u.opline_num = do_token->u.opline_num;
        !          3226:        SET_UNUSED(opline->op2);
        !          3227: 
        !          3228:        do_end_loop(expr_open_bracket->u.opline_num, 0 TSRMLS_CC);
        !          3229: 
        !          3230:        DEC_BPC(CG(active_op_array));
        !          3231: }
        !          3232: /* }}} */
        !          3233: 
        !          3234: void zend_do_brk_cont(zend_uchar op, const znode *expr TSRMLS_DC) /* {{{ */
        !          3235: {
        !          3236:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3237: 
        !          3238:        opline->opcode = op;
        !          3239:        opline->op1.u.opline_num = CG(active_op_array)->current_brk_cont;
        !          3240:        SET_UNUSED(opline->op1);
        !          3241:        if (expr) {
        !          3242:                opline->op2 = *expr;
        !          3243:        } else {
        !          3244:                Z_TYPE(opline->op2.u.constant) = IS_LONG;
        !          3245:                Z_LVAL(opline->op2.u.constant) = 1;
        !          3246:                INIT_PZVAL(&opline->op2.u.constant);
        !          3247:                opline->op2.op_type = IS_CONST;
        !          3248:        }
        !          3249: }
        !          3250: /* }}} */
        !          3251: 
        !          3252: void zend_do_switch_cond(const znode *cond TSRMLS_DC) /* {{{ */
        !          3253: {
        !          3254:        zend_switch_entry switch_entry;
        !          3255: 
        !          3256:        switch_entry.cond = *cond;
        !          3257:        switch_entry.default_case = -1;
        !          3258:        switch_entry.control_var = -1;
        !          3259:        zend_stack_push(&CG(switch_cond_stack), (void *) &switch_entry, sizeof(switch_entry));
        !          3260: 
        !          3261:        do_begin_loop(TSRMLS_C);
        !          3262: 
        !          3263:        INC_BPC(CG(active_op_array));
        !          3264: }
        !          3265: /* }}} */
        !          3266: 
        !          3267: void zend_do_switch_end(const znode *case_list TSRMLS_DC) /* {{{ */
        !          3268: {
        !          3269:        zend_op *opline;
        !          3270:        zend_switch_entry *switch_entry_ptr;
        !          3271: 
        !          3272:        zend_stack_top(&CG(switch_cond_stack), (void **) &switch_entry_ptr);
        !          3273: 
        !          3274:        /* add code to jmp to default case */
        !          3275:        if (switch_entry_ptr->default_case != -1) {
        !          3276:                opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3277:                opline->opcode = ZEND_JMP;
        !          3278:                SET_UNUSED(opline->op1);
        !          3279:                SET_UNUSED(opline->op2);
        !          3280:                opline->op1.u.opline_num = switch_entry_ptr->default_case;
        !          3281:        }
        !          3282: 
        !          3283:        if (case_list->op_type != IS_UNUSED) { /* non-empty switch */
        !          3284:                int next_op_number = get_next_op_number(CG(active_op_array));
        !          3285: 
        !          3286:                CG(active_op_array)->opcodes[case_list->u.opline_num].op1.u.opline_num = next_op_number;
        !          3287:        }
        !          3288: 
        !          3289:        /* remember break/continue loop information */
        !          3290:        CG(active_op_array)->brk_cont_array[CG(active_op_array)->current_brk_cont].cont = CG(active_op_array)->brk_cont_array[CG(active_op_array)->current_brk_cont].brk = get_next_op_number(CG(active_op_array));
        !          3291:        CG(active_op_array)->current_brk_cont = CG(active_op_array)->brk_cont_array[CG(active_op_array)->current_brk_cont].parent;
        !          3292: 
        !          3293:        if (switch_entry_ptr->cond.op_type==IS_VAR || switch_entry_ptr->cond.op_type==IS_TMP_VAR) {
        !          3294:                /* emit free for the switch condition*/
        !          3295:                opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3296:                opline->opcode = (switch_entry_ptr->cond.op_type == IS_TMP_VAR) ? ZEND_FREE : ZEND_SWITCH_FREE;
        !          3297:                opline->op1 = switch_entry_ptr->cond;
        !          3298:                SET_UNUSED(opline->op2);
        !          3299:        }
        !          3300:        if (switch_entry_ptr->cond.op_type == IS_CONST) {
        !          3301:                zval_dtor(&switch_entry_ptr->cond.u.constant);
        !          3302:        }
        !          3303: 
        !          3304:        zend_stack_del_top(&CG(switch_cond_stack));
        !          3305: 
        !          3306:        DEC_BPC(CG(active_op_array));
        !          3307: }
        !          3308: /* }}} */
        !          3309: 
        !          3310: void zend_do_case_before_statement(const znode *case_list, znode *case_token, const znode *case_expr TSRMLS_DC) /* {{{ */
        !          3311: {
        !          3312:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3313:        int next_op_number;
        !          3314:        zend_switch_entry *switch_entry_ptr;
        !          3315:        znode result;
        !          3316: 
        !          3317:        zend_stack_top(&CG(switch_cond_stack), (void **) &switch_entry_ptr);
        !          3318: 
        !          3319:        if (switch_entry_ptr->control_var == -1) {
        !          3320:                switch_entry_ptr->control_var = get_temporary_variable(CG(active_op_array));
        !          3321:        }
        !          3322:        opline->opcode = ZEND_CASE;
        !          3323:        opline->result.u.var = switch_entry_ptr->control_var;
        !          3324:        opline->result.op_type = IS_TMP_VAR;
        !          3325:        opline->op1 = switch_entry_ptr->cond;
        !          3326:        opline->op2 = *case_expr;
        !          3327:        if (opline->op1.op_type == IS_CONST) {
        !          3328:                zval_copy_ctor(&opline->op1.u.constant);
        !          3329:        }
        !          3330:        result = opline->result;
        !          3331: 
        !          3332:        next_op_number = get_next_op_number(CG(active_op_array));
        !          3333:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3334:        opline->opcode = ZEND_JMPZ;
        !          3335:        opline->op1 = result;
        !          3336:        SET_UNUSED(opline->op2);
        !          3337:        case_token->u.opline_num = next_op_number;
        !          3338: 
        !          3339:        if (case_list->op_type==IS_UNUSED) {
        !          3340:                return;
        !          3341:        }
        !          3342:        next_op_number = get_next_op_number(CG(active_op_array));
        !          3343:        CG(active_op_array)->opcodes[case_list->u.opline_num].op1.u.opline_num = next_op_number;
        !          3344: }
        !          3345: /* }}} */
        !          3346: 
        !          3347: void zend_do_case_after_statement(znode *result, const znode *case_token TSRMLS_DC) /* {{{ */
        !          3348: {
        !          3349:        int next_op_number = get_next_op_number(CG(active_op_array));
        !          3350:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3351: 
        !          3352:        opline->opcode = ZEND_JMP;
        !          3353:        SET_UNUSED(opline->op1);
        !          3354:        SET_UNUSED(opline->op2);
        !          3355:        result->u.opline_num = next_op_number;
        !          3356: 
        !          3357:        switch (CG(active_op_array)->opcodes[case_token->u.opline_num].opcode) {
        !          3358:                case ZEND_JMP:
        !          3359:                        CG(active_op_array)->opcodes[case_token->u.opline_num].op1.u.opline_num = get_next_op_number(CG(active_op_array));
        !          3360:                        break;
        !          3361:                case ZEND_JMPZ:
        !          3362:                        CG(active_op_array)->opcodes[case_token->u.opline_num].op2.u.opline_num = get_next_op_number(CG(active_op_array));
        !          3363:                        break;
        !          3364:        }
        !          3365: }
        !          3366: /* }}} */
        !          3367: 
        !          3368: void zend_do_default_before_statement(const znode *case_list, znode *default_token TSRMLS_DC) /* {{{ */
        !          3369: {
        !          3370:        int next_op_number = get_next_op_number(CG(active_op_array));
        !          3371:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3372:        zend_switch_entry *switch_entry_ptr;
        !          3373: 
        !          3374:        zend_stack_top(&CG(switch_cond_stack), (void **) &switch_entry_ptr);
        !          3375: 
        !          3376:        opline->opcode = ZEND_JMP;
        !          3377:        SET_UNUSED(opline->op1);
        !          3378:        SET_UNUSED(opline->op2);
        !          3379:        default_token->u.opline_num = next_op_number;
        !          3380: 
        !          3381:        next_op_number = get_next_op_number(CG(active_op_array));
        !          3382:        switch_entry_ptr->default_case = next_op_number;
        !          3383: 
        !          3384:        if (case_list->op_type==IS_UNUSED) {
        !          3385:                return;
        !          3386:        }
        !          3387:        CG(active_op_array)->opcodes[case_list->u.opline_num].op1.u.opline_num = next_op_number;
        !          3388: }
        !          3389: /* }}} */
        !          3390: 
        !          3391: void zend_do_begin_class_declaration(const znode *class_token, znode *class_name, const znode *parent_class_name TSRMLS_DC) /* {{{ */
        !          3392: {
        !          3393:        zend_op *opline;
        !          3394:        int doing_inheritance = 0;
        !          3395:        zend_class_entry *new_class_entry;
        !          3396:        char *lcname;
        !          3397:        int error = 0;
        !          3398:        zval **ns_name;
        !          3399: 
        !          3400:        if (CG(active_class_entry)) {
        !          3401:                zend_error(E_COMPILE_ERROR, "Class declarations may not be nested");
        !          3402:                return;
        !          3403:        }
        !          3404: 
        !          3405:        lcname = zend_str_tolower_dup(class_name->u.constant.value.str.val, class_name->u.constant.value.str.len);
        !          3406: 
        !          3407:        if (!(strcmp(lcname, "self") && strcmp(lcname, "parent"))) {
        !          3408:                efree(lcname);
        !          3409:                zend_error(E_COMPILE_ERROR, "Cannot use '%s' as class name as it is reserved", class_name->u.constant.value.str.val);
        !          3410:        }
        !          3411: 
        !          3412:        /* Class name must not conflict with import names */
        !          3413:        if (CG(current_import) &&
        !          3414:                        zend_hash_find(CG(current_import), lcname, Z_STRLEN(class_name->u.constant)+1, (void**)&ns_name) == SUCCESS) {
        !          3415:                error = 1;
        !          3416:        }
        !          3417: 
        !          3418:        if (CG(current_namespace)) {
        !          3419:                /* Prefix class name with name of current namespace */
        !          3420:                znode tmp;
        !          3421: 
        !          3422:                tmp.u.constant = *CG(current_namespace);
        !          3423:                zval_copy_ctor(&tmp.u.constant);
        !          3424:                zend_do_build_namespace_name(&tmp, &tmp, class_name TSRMLS_CC);
        !          3425:                class_name = &tmp;
        !          3426:                efree(lcname);
        !          3427:                lcname = zend_str_tolower_dup(Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant));
        !          3428:        }
        !          3429: 
        !          3430:        if (error) {
        !          3431:                char *tmp = zend_str_tolower_dup(Z_STRVAL_PP(ns_name), Z_STRLEN_PP(ns_name));
        !          3432: 
        !          3433:                if (Z_STRLEN_PP(ns_name) != Z_STRLEN(class_name->u.constant) ||
        !          3434:                        memcmp(tmp, lcname, Z_STRLEN(class_name->u.constant))) {
        !          3435:                        zend_error(E_COMPILE_ERROR, "Cannot declare class %s because the name is already in use", Z_STRVAL(class_name->u.constant));
        !          3436:                }
        !          3437:                efree(tmp);
        !          3438:        }
        !          3439: 
        !          3440:        new_class_entry = emalloc(sizeof(zend_class_entry));
        !          3441:        new_class_entry->type = ZEND_USER_CLASS;
        !          3442:        new_class_entry->name = class_name->u.constant.value.str.val;
        !          3443:        new_class_entry->name_length = class_name->u.constant.value.str.len;
        !          3444: 
        !          3445:        zend_initialize_class_data(new_class_entry, 1 TSRMLS_CC);
        !          3446:        new_class_entry->filename = zend_get_compiled_filename(TSRMLS_C);
        !          3447:        new_class_entry->line_start = class_token->u.opline_num;
        !          3448:        new_class_entry->ce_flags |= class_token->u.EA.type;
        !          3449: 
        !          3450:        if (parent_class_name && parent_class_name->op_type != IS_UNUSED) {
        !          3451:                switch (parent_class_name->u.EA.type) {
        !          3452:                        case ZEND_FETCH_CLASS_SELF:
        !          3453:                                zend_error(E_COMPILE_ERROR, "Cannot use 'self' as class name as it is reserved");
        !          3454:                                break;
        !          3455:                        case ZEND_FETCH_CLASS_PARENT:
        !          3456:                                zend_error(E_COMPILE_ERROR, "Cannot use 'parent' as class name as it is reserved");
        !          3457:                                break;
        !          3458:                        case ZEND_FETCH_CLASS_STATIC:
        !          3459:                                zend_error(E_COMPILE_ERROR, "Cannot use 'static' as class name as it is reserved");
        !          3460:                                break;
        !          3461:                        default:
        !          3462:                                break;
        !          3463:                }
        !          3464:                doing_inheritance = 1;
        !          3465:        }
        !          3466: 
        !          3467:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3468:        opline->op1.op_type = IS_CONST;
        !          3469:        build_runtime_defined_function_key(&opline->op1.u.constant, lcname, new_class_entry->name_length TSRMLS_CC);
        !          3470:        
        !          3471:        opline->op2.op_type = IS_CONST;
        !          3472:        opline->op2.u.constant.type = IS_STRING;
        !          3473:        Z_SET_REFCOUNT(opline->op2.u.constant, 1);
        !          3474: 
        !          3475:        if (doing_inheritance) {
        !          3476:                opline->extended_value = parent_class_name->u.var;
        !          3477:                opline->opcode = ZEND_DECLARE_INHERITED_CLASS;
        !          3478:        } else {
        !          3479:                opline->opcode = ZEND_DECLARE_CLASS;
        !          3480:        }
        !          3481: 
        !          3482:        opline->op2.u.constant.value.str.val = lcname;
        !          3483:        opline->op2.u.constant.value.str.len = new_class_entry->name_length;
        !          3484:        
        !          3485:        zend_hash_update(CG(class_table), opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len, &new_class_entry, sizeof(zend_class_entry *), NULL);
        !          3486:        CG(active_class_entry) = new_class_entry;
        !          3487: 
        !          3488:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          3489:        opline->result.op_type = IS_VAR;
        !          3490:        CG(implementing_class) = opline->result;
        !          3491: 
        !          3492:        if (CG(doc_comment)) {
        !          3493:                CG(active_class_entry)->doc_comment = CG(doc_comment);
        !          3494:                CG(active_class_entry)->doc_comment_len = CG(doc_comment_len);
        !          3495:                CG(doc_comment) = NULL;
        !          3496:                CG(doc_comment_len) = 0;
        !          3497:        }
        !          3498: }
        !          3499: /* }}} */
        !          3500: 
        !          3501: static void do_verify_abstract_class(TSRMLS_D) /* {{{ */
        !          3502: {
        !          3503:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3504: 
        !          3505:        opline->opcode = ZEND_VERIFY_ABSTRACT_CLASS;
        !          3506:        opline->op1 = CG(implementing_class);
        !          3507:        SET_UNUSED(opline->op2);
        !          3508: }
        !          3509: /* }}} */
        !          3510: 
        !          3511: void zend_do_end_class_declaration(const znode *class_token, const znode *parent_token TSRMLS_DC) /* {{{ */
        !          3512: {
        !          3513:        zend_class_entry *ce = CG(active_class_entry);
        !          3514: 
        !          3515:        if (ce->constructor) {
        !          3516:                ce->constructor->common.fn_flags |= ZEND_ACC_CTOR;
        !          3517:                if (ce->constructor->common.fn_flags & ZEND_ACC_STATIC) {
        !          3518:                        zend_error(E_COMPILE_ERROR, "Constructor %s::%s() cannot be static", ce->name, ce->constructor->common.function_name);
        !          3519:                }
        !          3520:        }
        !          3521:        if (ce->destructor) {
        !          3522:                ce->destructor->common.fn_flags |= ZEND_ACC_DTOR;
        !          3523:                if (ce->destructor->common.fn_flags & ZEND_ACC_STATIC) {
        !          3524:                        zend_error(E_COMPILE_ERROR, "Destructor %s::%s() cannot be static", ce->name, ce->destructor->common.function_name);
        !          3525:                }
        !          3526:        }
        !          3527:        if (ce->clone) {
        !          3528:                ce->clone->common.fn_flags |= ZEND_ACC_CLONE;
        !          3529:                if (ce->clone->common.fn_flags & ZEND_ACC_STATIC) {
        !          3530:                        zend_error(E_COMPILE_ERROR, "Clone method %s::%s() cannot be static", ce->name, ce->clone->common.function_name);
        !          3531:                }
        !          3532:        }
        !          3533: 
        !          3534:        ce->line_end = zend_get_compiled_lineno(TSRMLS_C);
        !          3535: 
        !          3536:        if (!(ce->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS))
        !          3537:                && ((parent_token->op_type != IS_UNUSED) || (ce->num_interfaces > 0))) {
        !          3538:                zend_verify_abstract_class(ce TSRMLS_CC);
        !          3539:                if (ce->num_interfaces) {
        !          3540:                        do_verify_abstract_class(TSRMLS_C);
        !          3541:                }
        !          3542:        }
        !          3543:        /* Inherit interfaces; reset number to zero, we need it for above check and
        !          3544:         * will restore it during actual implementation. 
        !          3545:         * The ZEND_ACC_IMPLEMENT_INTERFACES flag disables double call to
        !          3546:         * zend_verify_abstract_class() */
        !          3547:        if (ce->num_interfaces > 0) {
        !          3548:                ce->interfaces = NULL;
        !          3549:                ce->num_interfaces = 0;
        !          3550:                ce->ce_flags |= ZEND_ACC_IMPLEMENT_INTERFACES;
        !          3551:        }
        !          3552:        CG(active_class_entry) = NULL;
        !          3553: }
        !          3554: /* }}} */
        !          3555: 
        !          3556: void zend_do_implements_interface(znode *interface_name TSRMLS_DC) /* {{{ */
        !          3557: {
        !          3558:        zend_op *opline;
        !          3559: 
        !          3560:        switch (zend_get_class_fetch_type(Z_STRVAL(interface_name->u.constant), Z_STRLEN(interface_name->u.constant))) {
        !          3561:                case ZEND_FETCH_CLASS_SELF:
        !          3562:                case ZEND_FETCH_CLASS_PARENT:
        !          3563:                case ZEND_FETCH_CLASS_STATIC:
        !          3564:                        zend_error(E_COMPILE_ERROR, "Cannot use '%s' as interface name as it is reserved", Z_STRVAL(interface_name->u.constant));
        !          3565:                        break;
        !          3566:                default:
        !          3567:                        break;
        !          3568:        }
        !          3569: 
        !          3570:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3571:        opline->opcode = ZEND_ADD_INTERFACE;
        !          3572:        opline->op1 = CG(implementing_class);
        !          3573:        zend_resolve_class_name(interface_name, &opline->extended_value, 0 TSRMLS_CC);
        !          3574:        opline->extended_value = (opline->extended_value & ~ZEND_FETCH_CLASS_MASK) | ZEND_FETCH_CLASS_INTERFACE;
        !          3575:        opline->op2 = *interface_name;
        !          3576:        CG(active_class_entry)->num_interfaces++;
        !          3577: }
        !          3578: /* }}} */
        !          3579: 
        !          3580: ZEND_API void zend_mangle_property_name(char **dest, int *dest_length, const char *src1, int src1_length, const char *src2, int src2_length, int internal) /* {{{ */
        !          3581: {
        !          3582:        char *prop_name;
        !          3583:        int prop_name_length;
        !          3584: 
        !          3585:        prop_name_length = 1 + src1_length + 1 + src2_length;
        !          3586:        prop_name = pemalloc(prop_name_length + 1, internal);
        !          3587:        prop_name[0] = '\0';
        !          3588:        memcpy(prop_name + 1, src1, src1_length+1);
        !          3589:        memcpy(prop_name + 1 + src1_length + 1, src2, src2_length+1);
        !          3590: 
        !          3591:        *dest = prop_name;
        !          3592:        *dest_length = prop_name_length;
        !          3593: }
        !          3594: /* }}} */
        !          3595: 
        !          3596: static int zend_strnlen(const char* s, int maxlen) /* {{{ */
        !          3597: {
        !          3598:        int len = 0;
        !          3599:        while (*s++ && maxlen--) len++;
        !          3600:        return len;
        !          3601: }
        !          3602: /* }}} */
        !          3603: 
        !          3604: ZEND_API int zend_unmangle_property_name(char *mangled_property, int len, char **class_name, char **prop_name) /* {{{ */
        !          3605: {
        !          3606:        int class_name_len;
        !          3607: 
        !          3608:        *class_name = NULL;
        !          3609: 
        !          3610:        if (mangled_property[0]!=0) {
        !          3611:                *prop_name = mangled_property;
        !          3612:                return SUCCESS;
        !          3613:        }
        !          3614:        if (len < 3 || mangled_property[1]==0) {
        !          3615:                zend_error(E_NOTICE, "Illegal member variable name");
        !          3616:                *prop_name = mangled_property;
        !          3617:                return FAILURE;
        !          3618:        }
        !          3619: 
        !          3620:        class_name_len = zend_strnlen(mangled_property+1, --len - 1) + 1;
        !          3621:        if (class_name_len >= len || mangled_property[class_name_len]!=0) {
        !          3622:                zend_error(E_NOTICE, "Corrupt member variable name");
        !          3623:                *prop_name = mangled_property;
        !          3624:                return FAILURE;
        !          3625:        }
        !          3626:        *class_name = mangled_property+1;
        !          3627:        *prop_name = (*class_name)+class_name_len;
        !          3628:        return SUCCESS;
        !          3629: }
        !          3630: /* }}} */
        !          3631: 
        !          3632: void zend_do_declare_property(const znode *var_name, const znode *value, zend_uint access_type TSRMLS_DC) /* {{{ */
        !          3633: {
        !          3634:        zval *property;
        !          3635:        zend_property_info *existing_property_info;
        !          3636:        char *comment = NULL;
        !          3637:        int comment_len = 0;
        !          3638: 
        !          3639:        if (CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE) {
        !          3640:                zend_error(E_COMPILE_ERROR, "Interfaces may not include member variables");
        !          3641:        }
        !          3642: 
        !          3643:        if (access_type & ZEND_ACC_ABSTRACT) {
        !          3644:                zend_error(E_COMPILE_ERROR, "Properties cannot be declared abstract");
        !          3645:        }
        !          3646: 
        !          3647:        if (access_type & ZEND_ACC_FINAL) {
        !          3648:                zend_error(E_COMPILE_ERROR, "Cannot declare property %s::$%s final, the final modifier is allowed only for methods and classes",
        !          3649:                                        CG(active_class_entry)->name, var_name->u.constant.value.str.val);
        !          3650:        }
        !          3651: 
        !          3652:        if (zend_hash_find(&CG(active_class_entry)->properties_info, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, (void **) &existing_property_info)==SUCCESS) {
        !          3653:                if (!(existing_property_info->flags & ZEND_ACC_IMPLICIT_PUBLIC)) {
        !          3654:                        zend_error(E_COMPILE_ERROR, "Cannot redeclare %s::$%s", CG(active_class_entry)->name, var_name->u.constant.value.str.val);
        !          3655:                }
        !          3656:        }
        !          3657:        ALLOC_ZVAL(property);
        !          3658: 
        !          3659:        if (value) {
        !          3660:                *property = value->u.constant;
        !          3661:        } else {
        !          3662:                INIT_PZVAL(property);
        !          3663:                Z_TYPE_P(property) = IS_NULL;
        !          3664:        }
        !          3665: 
        !          3666:        if (CG(doc_comment)) {
        !          3667:                comment = CG(doc_comment);
        !          3668:                comment_len = CG(doc_comment_len);
        !          3669:                CG(doc_comment) = NULL;
        !          3670:                CG(doc_comment_len) = 0;
        !          3671:        }
        !          3672: 
        !          3673:        zend_declare_property_ex(CG(active_class_entry), var_name->u.constant.value.str.val, var_name->u.constant.value.str.len, property, access_type, comment, comment_len TSRMLS_CC);
        !          3674:        efree(var_name->u.constant.value.str.val);
        !          3675: }
        !          3676: /* }}} */
        !          3677: 
        !          3678: void zend_do_declare_class_constant(znode *var_name, const znode *value TSRMLS_DC) /* {{{ */
        !          3679: {
        !          3680:        zval *property;
        !          3681: 
        !          3682:        if(Z_TYPE(value->u.constant) == IS_CONSTANT_ARRAY) {
        !          3683:                zend_error(E_COMPILE_ERROR, "Arrays are not allowed in class constants");
        !          3684:        }
        !          3685: 
        !          3686:        ALLOC_ZVAL(property);
        !          3687:        *property = value->u.constant;
        !          3688: 
        !          3689:        if (zend_hash_add(&CG(active_class_entry)->constants_table, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL)==FAILURE) {
        !          3690:                FREE_ZVAL(property);
        !          3691:                zend_error(E_COMPILE_ERROR, "Cannot redefine class constant %s::%s", CG(active_class_entry)->name, var_name->u.constant.value.str.val);
        !          3692:        }
        !          3693:        FREE_PNODE(var_name);
        !          3694:        
        !          3695:        if (CG(doc_comment)) {
        !          3696:                efree(CG(doc_comment));
        !          3697:                CG(doc_comment) = NULL;
        !          3698:                CG(doc_comment_len) = 0;
        !          3699:        }
        !          3700: }
        !          3701: /* }}} */
        !          3702: 
        !          3703: void zend_do_fetch_property(znode *result, znode *object, const znode *property TSRMLS_DC) /* {{{ */
        !          3704: {
        !          3705:        zend_op opline;
        !          3706:        zend_llist *fetch_list_ptr;
        !          3707: 
        !          3708:        zend_stack_top(&CG(bp_stack), (void **) &fetch_list_ptr);
        !          3709: 
        !          3710:        if (object->op_type == IS_CV) {
        !          3711:                if (object->u.var == CG(active_op_array)->this_var) {
        !          3712:                        SET_UNUSED(*object); /* this means $this for objects */
        !          3713:                }
        !          3714:        } else if (fetch_list_ptr->count == 1) {
        !          3715:                zend_llist_element *le = fetch_list_ptr->head;
        !          3716:                zend_op *opline_ptr = (zend_op *) le->data;
        !          3717: 
        !          3718:                if (opline_is_fetch_this(opline_ptr TSRMLS_CC)) {
        !          3719:                        efree(Z_STRVAL(opline_ptr->op1.u.constant));
        !          3720:                        SET_UNUSED(opline_ptr->op1); /* this means $this for objects */
        !          3721:                        opline_ptr->op2 = *property;
        !          3722:                        /* if it was usual fetch, we change it to object fetch */
        !          3723:                        switch (opline_ptr->opcode) {
        !          3724:                                case ZEND_FETCH_W:
        !          3725:                                        opline_ptr->opcode = ZEND_FETCH_OBJ_W;
        !          3726:                                        break;
        !          3727:                                case ZEND_FETCH_R:
        !          3728:                                        opline_ptr->opcode = ZEND_FETCH_OBJ_R;
        !          3729:                                        break;
        !          3730:                                case ZEND_FETCH_RW:
        !          3731:                                        opline_ptr->opcode = ZEND_FETCH_OBJ_RW;
        !          3732:                                        break;
        !          3733:                                case ZEND_FETCH_IS:
        !          3734:                                        opline_ptr->opcode = ZEND_FETCH_OBJ_IS;
        !          3735:                                        break;
        !          3736:                                case ZEND_FETCH_UNSET:
        !          3737:                                        opline_ptr->opcode = ZEND_FETCH_OBJ_UNSET;
        !          3738:                                        break;
        !          3739:                                case ZEND_FETCH_FUNC_ARG:
        !          3740:                                        opline_ptr->opcode = ZEND_FETCH_OBJ_FUNC_ARG;
        !          3741:                                        break;
        !          3742:                        }
        !          3743:                        *result = opline_ptr->result;
        !          3744:                        return;
        !          3745:                }
        !          3746:        }
        !          3747: 
        !          3748:        init_op(&opline TSRMLS_CC);
        !          3749:        opline.opcode = ZEND_FETCH_OBJ_W;       /* the backpatching routine assumes W */
        !          3750:        opline.result.op_type = IS_VAR;
        !          3751:        opline.result.u.EA.type = 0;
        !          3752:        opline.result.u.var = get_temporary_variable(CG(active_op_array));
        !          3753:        opline.op1 = *object;
        !          3754:        opline.op2 = *property;
        !          3755:        *result = opline.result;
        !          3756: 
        !          3757:        zend_llist_add_element(fetch_list_ptr, &opline);
        !          3758: }
        !          3759: /* }}} */
        !          3760: 
        !          3761: void zend_do_halt_compiler_register(TSRMLS_D) /* {{{ */
        !          3762: {
        !          3763:        char *name, *cfilename;
        !          3764:        char haltoff[] = "__COMPILER_HALT_OFFSET__";
        !          3765:        int len, clen;
        !          3766:        
        !          3767:        if (CG(has_bracketed_namespaces) && CG(in_namespace)) {
        !          3768:                zend_error(E_COMPILE_ERROR, "__HALT_COMPILER() can only be used from the outermost scope");
        !          3769:        }
        !          3770:        
        !          3771:        cfilename = zend_get_compiled_filename(TSRMLS_C);
        !          3772:        clen = strlen(cfilename);
        !          3773:        zend_mangle_property_name(&name, &len, haltoff, sizeof(haltoff) - 1, cfilename, clen, 0);
        !          3774:        zend_register_long_constant(name, len+1, zend_get_scanned_file_offset(TSRMLS_C), CONST_CS, 0 TSRMLS_CC);
        !          3775:        pefree(name, 0);
        !          3776:        
        !          3777:        if (CG(in_namespace)) {
        !          3778:                zend_do_end_namespace(TSRMLS_C);
        !          3779:        }
        !          3780: }
        !          3781: /* }}} */
        !          3782: 
        !          3783: void zend_do_declare_implicit_property(TSRMLS_D) /* {{{ */
        !          3784: {
        !          3785: /* Fixes bug #26182. Not sure why we needed to do this in the first place.
        !          3786:    Has to be checked with Zeev.
        !          3787: */
        !          3788: #if ANDI_0
        !          3789:        zend_op *opline_ptr;
        !          3790:        zend_llist_element *le;
        !          3791:        zend_llist *fetch_list_ptr;
        !          3792: 
        !          3793: 
        !          3794:        zend_stack_top(&CG(bp_stack), (void **) &fetch_list_ptr);
        !          3795: 
        !          3796:        if (fetch_list_ptr->count != 1) {
        !          3797:                return;
        !          3798:        }
        !          3799: 
        !          3800:        le = fetch_list_ptr->head;
        !          3801:        opline_ptr = (zend_op *) le->data;
        !          3802: 
        !          3803:        if (opline_ptr->op1.op_type == IS_UNUSED
        !          3804:                && CG(active_class_entry)
        !          3805:                && opline_ptr->op2.op_type == IS_CONST
        !          3806:                && !zend_hash_exists(&CG(active_class_entry)->properties_info, opline_ptr->op2.u.constant.value.str.val, opline_ptr->op2.u.constant.value.str.len+1)) {
        !          3807:                znode property;
        !          3808: 
        !          3809:                property = opline_ptr->op2;
        !          3810:                property.u.constant.value.str.val = estrndup(opline_ptr->op2.u.constant.value.str.val, opline_ptr->op2.u.constant.value.str.len);
        !          3811:                zend_do_declare_property(&property, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_IMPLICIT_PUBLIC TSRMLS_CC);
        !          3812:        }
        !          3813: #endif
        !          3814: }
        !          3815: /* }}} */
        !          3816: 
        !          3817: void zend_do_push_object(const znode *object TSRMLS_DC) /* {{{ */
        !          3818: {
        !          3819:        zend_stack_push(&CG(object_stack), object, sizeof(znode));
        !          3820: }
        !          3821: /* }}} */
        !          3822: 
        !          3823: void zend_do_pop_object(znode *object TSRMLS_DC) /* {{{ */
        !          3824: {
        !          3825:        if (object) {
        !          3826:                znode *tmp;
        !          3827: 
        !          3828:                zend_stack_top(&CG(object_stack), (void **) &tmp);
        !          3829:                *object = *tmp;
        !          3830:        }
        !          3831:        zend_stack_del_top(&CG(object_stack));
        !          3832: }
        !          3833: /* }}} */
        !          3834: 
        !          3835: void zend_do_begin_new_object(znode *new_token, znode *class_type TSRMLS_DC) /* {{{ */
        !          3836: {
        !          3837:        zend_op *opline;
        !          3838:        unsigned char *ptr = NULL;
        !          3839: 
        !          3840:        new_token->u.opline_num = get_next_op_number(CG(active_op_array));
        !          3841:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3842:        opline->opcode = ZEND_NEW;
        !          3843:        opline->result.op_type = IS_VAR;
        !          3844:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          3845:        opline->op1 = *class_type;
        !          3846:        SET_UNUSED(opline->op2);
        !          3847: 
        !          3848:        zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(unsigned char *));
        !          3849: }
        !          3850: /* }}} */
        !          3851: 
        !          3852: void zend_do_end_new_object(znode *result, const znode *new_token, const znode *argument_list TSRMLS_DC) /* {{{ */
        !          3853: {
        !          3854:        znode ctor_result;
        !          3855: 
        !          3856:        zend_do_end_function_call(NULL, &ctor_result, argument_list, 1, 0 TSRMLS_CC);
        !          3857:        zend_do_free(&ctor_result TSRMLS_CC);
        !          3858: 
        !          3859:        CG(active_op_array)->opcodes[new_token->u.opline_num].op2.u.opline_num = get_next_op_number(CG(active_op_array));
        !          3860:        *result = CG(active_op_array)->opcodes[new_token->u.opline_num].result;
        !          3861: }
        !          3862: /* }}} */
        !          3863: 
        !          3864: static zend_constant* zend_get_ct_const(const zval *const_name, int all_internal_constants_substitution TSRMLS_DC) /* {{{ */
        !          3865: {
        !          3866:        zend_constant *c = NULL;
        !          3867: 
        !          3868:        if (Z_STRVAL_P(const_name)[0] == '\\') {
        !          3869:                if (zend_hash_find(EG(zend_constants), Z_STRVAL_P(const_name)+1, Z_STRLEN_P(const_name), (void **) &c) == FAILURE) {
        !          3870:                        char *lookup_name = zend_str_tolower_dup(Z_STRVAL_P(const_name)+1, Z_STRLEN_P(const_name)-1);
        !          3871: 
        !          3872:                        if (zend_hash_find(EG(zend_constants), lookup_name, Z_STRLEN_P(const_name), (void **) &c)==SUCCESS) {
        !          3873:                                if ((c->flags & CONST_CT_SUBST) && !(c->flags & CONST_CS)) {
        !          3874:                                        efree(lookup_name);
        !          3875:                                        return c;
        !          3876:                                }
        !          3877:                        }
        !          3878:                        efree(lookup_name);
        !          3879:                        return NULL;
        !          3880:                }
        !          3881:        } else if (zend_hash_find(EG(zend_constants), Z_STRVAL_P(const_name), Z_STRLEN_P(const_name)+1, (void **) &c) == FAILURE) {
        !          3882:                char *lookup_name = zend_str_tolower_dup(Z_STRVAL_P(const_name), Z_STRLEN_P(const_name));
        !          3883:                 
        !          3884:                if (zend_hash_find(EG(zend_constants), lookup_name, Z_STRLEN_P(const_name)+1, (void **) &c)==SUCCESS) {
        !          3885:                        if ((c->flags & CONST_CT_SUBST) && !(c->flags & CONST_CS)) {
        !          3886:                                efree(lookup_name);
        !          3887:                                return c;
        !          3888:                        }
        !          3889:                }
        !          3890:                efree(lookup_name);
        !          3891:                return NULL;
        !          3892:        }
        !          3893:        if (c->flags & CONST_CT_SUBST) {
        !          3894:                return c;
        !          3895:        }
        !          3896:        if (all_internal_constants_substitution &&
        !          3897:                        (c->flags & CONST_PERSISTENT) &&
        !          3898:                        !(CG(compiler_options) & ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION) &&
        !          3899:                        Z_TYPE(c->value) != IS_CONSTANT &&
        !          3900:                        Z_TYPE(c->value) != IS_CONSTANT_ARRAY) {
        !          3901:                return c;
        !          3902:        }
        !          3903:        return NULL;
        !          3904: }
        !          3905: /* }}} */
        !          3906: 
        !          3907: static int zend_constant_ct_subst(znode *result, zval *const_name, int all_internal_constants_substitution TSRMLS_DC) /* {{{ */
        !          3908: {
        !          3909:        zend_constant *c = zend_get_ct_const(const_name, all_internal_constants_substitution TSRMLS_CC);
        !          3910: 
        !          3911:        if (c) {
        !          3912:                zval_dtor(const_name);
        !          3913:                result->op_type = IS_CONST;
        !          3914:                result->u.constant = c->value;
        !          3915:                zval_copy_ctor(&result->u.constant);
        !          3916:                INIT_PZVAL(&result->u.constant);
        !          3917:                return 1;
        !          3918:        }
        !          3919:        return 0;
        !          3920: }
        !          3921: /* }}} */
        !          3922: 
        !          3923: void zend_do_fetch_constant(znode *result, znode *constant_container, znode *constant_name, int mode, zend_bool check_namespace TSRMLS_DC) /* {{{ */
        !          3924: {
        !          3925:        znode tmp;
        !          3926:        zend_op *opline;
        !          3927:        int type;
        !          3928:        char *compound;
        !          3929:        ulong fetch_type = 0;
        !          3930: 
        !          3931:        if (constant_container) {
        !          3932:                switch (mode) {
        !          3933:                        case ZEND_CT:
        !          3934:                                /* this is a class constant */
        !          3935:                                type = zend_get_class_fetch_type(Z_STRVAL(constant_container->u.constant), Z_STRLEN(constant_container->u.constant));
        !          3936:        
        !          3937:                                if (ZEND_FETCH_CLASS_STATIC == type) {
        !          3938:                                        zend_error(E_ERROR, "\"static::\" is not allowed in compile-time constants");
        !          3939:                                } else if (ZEND_FETCH_CLASS_DEFAULT == type) {
        !          3940:                                        zend_resolve_class_name(constant_container, &fetch_type, 1 TSRMLS_CC);
        !          3941:                                }
        !          3942:                                zend_do_build_full_name(NULL, constant_container, constant_name, 1 TSRMLS_CC);
        !          3943:                                *result = *constant_container;
        !          3944:                                result->u.constant.type = IS_CONSTANT | fetch_type;
        !          3945:                                break;
        !          3946:                        case ZEND_RT:
        !          3947:                                if (constant_container->op_type == IS_CONST &&
        !          3948:                                ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_STRVAL(constant_container->u.constant), Z_STRLEN(constant_container->u.constant))) {
        !          3949:                                        zend_resolve_class_name(constant_container, &fetch_type, 1 TSRMLS_CC);
        !          3950:                                } else {
        !          3951:                                        zend_do_fetch_class(&tmp, constant_container TSRMLS_CC);
        !          3952:                                        constant_container = &tmp;
        !          3953:                                }
        !          3954:                                opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3955:                                opline->opcode = ZEND_FETCH_CONSTANT;
        !          3956:                                opline->result.op_type = IS_TMP_VAR;
        !          3957:                                opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          3958:                                opline->op1 = *constant_container;
        !          3959:                                opline->op2 = *constant_name;
        !          3960:                                *result = opline->result;
        !          3961:                                break;
        !          3962:                }
        !          3963:                return;
        !          3964:        }
        !          3965:        /* namespace constant */
        !          3966:        /* only one that did not contain \ from the start can be converted to string if unknown */
        !          3967:        switch (mode) {
        !          3968:                case ZEND_CT:
        !          3969:                        compound = memchr(Z_STRVAL(constant_name->u.constant), '\\', Z_STRLEN(constant_name->u.constant));
        !          3970:                        /* this is a namespace constant, or an unprefixed constant */
        !          3971: 
        !          3972:                        if (zend_constant_ct_subst(result, &constant_name->u.constant, 0 TSRMLS_CC)) {
        !          3973:                                break;
        !          3974:                        }
        !          3975: 
        !          3976:                        zend_resolve_non_class_name(constant_name, check_namespace TSRMLS_CC);
        !          3977: 
        !          3978:                        if(!compound) {
        !          3979:                                fetch_type |= IS_CONSTANT_UNQUALIFIED;
        !          3980:                        }
        !          3981: 
        !          3982:                        *result = *constant_name;
        !          3983:                        result->u.constant.type = IS_CONSTANT | fetch_type;
        !          3984:                        break;
        !          3985:                case ZEND_RT:
        !          3986:                        compound = memchr(Z_STRVAL(constant_name->u.constant), '\\', Z_STRLEN(constant_name->u.constant));
        !          3987: 
        !          3988:                        zend_resolve_non_class_name(constant_name, check_namespace TSRMLS_CC);
        !          3989:                        
        !          3990:                        if(zend_constant_ct_subst(result, &constant_name->u.constant, 1 TSRMLS_CC)) {
        !          3991:                                break;
        !          3992:                        }
        !          3993: 
        !          3994:                        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          3995:                        opline->opcode = ZEND_FETCH_CONSTANT;
        !          3996:                        opline->result.op_type = IS_TMP_VAR;
        !          3997:                        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          3998:                        *result = opline->result;
        !          3999:                        SET_UNUSED(opline->op1);
        !          4000:                        if(compound) {
        !          4001:                                /* the name is unambiguous */
        !          4002:                                opline->extended_value = 0;
        !          4003:                        } else {
        !          4004:                                opline->extended_value = IS_CONSTANT_UNQUALIFIED;
        !          4005:                        }
        !          4006:                        opline->op2 = *constant_name;
        !          4007:                        break;
        !          4008:        }
        !          4009: }
        !          4010: /* }}} */
        !          4011: 
        !          4012: void zend_do_shell_exec(znode *result, const znode *cmd TSRMLS_DC) /* {{{ */
        !          4013: {
        !          4014:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4015: 
        !          4016:        switch (cmd->op_type) {
        !          4017:                case IS_CONST:
        !          4018:                case IS_TMP_VAR:
        !          4019:                        opline->opcode = ZEND_SEND_VAL;
        !          4020:                        break;
        !          4021:                default:
        !          4022:                        opline->opcode = ZEND_SEND_VAR;
        !          4023:                        break;
        !          4024:        }
        !          4025:        opline->op1 = *cmd;
        !          4026:        opline->op2.u.opline_num = 0;
        !          4027:        opline->extended_value = ZEND_DO_FCALL;
        !          4028:        SET_UNUSED(opline->op2);
        !          4029: 
        !          4030:        /* FIXME: exception support not added to this op2 */
        !          4031:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4032:        opline->opcode = ZEND_DO_FCALL;
        !          4033:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          4034:        opline->result.op_type = IS_VAR;
        !          4035:        Z_STRVAL(opline->op1.u.constant) = estrndup("shell_exec", sizeof("shell_exec")-1);
        !          4036:        Z_STRLEN(opline->op1.u.constant) = sizeof("shell_exec")-1;
        !          4037:        INIT_PZVAL(&opline->op1.u.constant);
        !          4038:        Z_TYPE(opline->op1.u.constant) = IS_STRING;
        !          4039:        opline->op1.op_type = IS_CONST;
        !          4040:        opline->extended_value = 1;
        !          4041:        SET_UNUSED(opline->op2);
        !          4042:        ZVAL_LONG(&opline->op2.u.constant, zend_hash_func("shell_exec", sizeof("shell_exec")));
        !          4043:        *result = opline->result;
        !          4044: }
        !          4045: /* }}} */
        !          4046: 
        !          4047: void zend_do_init_array(znode *result, const znode *expr, const znode *offset, zend_bool is_ref TSRMLS_DC) /* {{{ */
        !          4048: {
        !          4049:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4050: 
        !          4051:        opline->opcode = ZEND_INIT_ARRAY;
        !          4052:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          4053:        opline->result.op_type = IS_TMP_VAR;
        !          4054:        *result = opline->result;
        !          4055:        if (expr) {
        !          4056:                opline->op1 = *expr;
        !          4057:                if (offset) {
        !          4058:                        opline->op2 = *offset;
        !          4059:                } else {
        !          4060:                        SET_UNUSED(opline->op2);
        !          4061:                }
        !          4062:        } else {
        !          4063:                SET_UNUSED(opline->op1);
        !          4064:                SET_UNUSED(opline->op2);
        !          4065:        }
        !          4066:        opline->extended_value = is_ref;
        !          4067: }
        !          4068: /* }}} */
        !          4069: 
        !          4070: void zend_do_add_array_element(znode *result, const znode *expr, const znode *offset, zend_bool is_ref TSRMLS_DC) /* {{{ */
        !          4071: {
        !          4072:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4073: 
        !          4074:        opline->opcode = ZEND_ADD_ARRAY_ELEMENT;
        !          4075:        opline->result = *result;
        !          4076:        opline->op1 = *expr;
        !          4077:        if (offset) {
        !          4078:                opline->op2 = *offset;
        !          4079:        } else {
        !          4080:                SET_UNUSED(opline->op2);
        !          4081:        }
        !          4082:        opline->extended_value = is_ref;
        !          4083: }
        !          4084: /* }}} */
        !          4085: 
        !          4086: void zend_do_add_static_array_element(znode *result, znode *offset, const znode *expr) /* {{{ */
        !          4087: {
        !          4088:        zval *element;
        !          4089: 
        !          4090:        ALLOC_ZVAL(element);
        !          4091:        *element = expr->u.constant;
        !          4092:        if (offset) {
        !          4093:                switch (offset->u.constant.type & IS_CONSTANT_TYPE_MASK) {
        !          4094:                        case IS_CONSTANT:
        !          4095:                                /* Ugly hack to denote that this value has a constant index */
        !          4096:                                Z_TYPE_P(element) |= IS_CONSTANT_INDEX;
        !          4097:                                Z_STRVAL(offset->u.constant) = erealloc(Z_STRVAL(offset->u.constant), Z_STRLEN(offset->u.constant)+3);
        !          4098:                                Z_STRVAL(offset->u.constant)[Z_STRLEN(offset->u.constant)+1] = Z_TYPE(offset->u.constant);
        !          4099:                                Z_STRVAL(offset->u.constant)[Z_STRLEN(offset->u.constant)+2] = 0;
        !          4100:                                zend_symtable_update(result->u.constant.value.ht, Z_STRVAL(offset->u.constant), Z_STRLEN(offset->u.constant)+3, &element, sizeof(zval *), NULL);
        !          4101:                                zval_dtor(&offset->u.constant);
        !          4102:                                break;
        !          4103:                        case IS_STRING:
        !          4104:                                zend_symtable_update(result->u.constant.value.ht, offset->u.constant.value.str.val, offset->u.constant.value.str.len+1, &element, sizeof(zval *), NULL);
        !          4105:                                zval_dtor(&offset->u.constant);
        !          4106:                                break;
        !          4107:                        case IS_NULL:
        !          4108:                                zend_symtable_update(Z_ARRVAL(result->u.constant), "", 1, &element, sizeof(zval *), NULL);
        !          4109:                                break;
        !          4110:                        case IS_LONG:
        !          4111:                        case IS_BOOL:
        !          4112:                                zend_hash_index_update(Z_ARRVAL(result->u.constant), Z_LVAL(offset->u.constant), &element, sizeof(zval *), NULL);
        !          4113:                                break;
        !          4114:                        case IS_DOUBLE:
        !          4115:                                zend_hash_index_update(Z_ARRVAL(result->u.constant), zend_dval_to_lval(Z_DVAL(offset->u.constant)), &element, sizeof(zval *), NULL);
        !          4116:                                break;
        !          4117:                        case IS_CONSTANT_ARRAY:
        !          4118:                                zend_error(E_ERROR, "Illegal offset type");
        !          4119:                                break;
        !          4120:                }
        !          4121:        } else {
        !          4122:                zend_hash_next_index_insert(Z_ARRVAL(result->u.constant), &element, sizeof(zval *), NULL);
        !          4123:        }
        !          4124: }
        !          4125: /* }}} */
        !          4126: 
        !          4127: void zend_do_add_list_element(const znode *element TSRMLS_DC) /* {{{ */
        !          4128: {
        !          4129:        list_llist_element lle;
        !          4130: 
        !          4131:        if (element) {
        !          4132:                zend_check_writable_variable(element);
        !          4133: 
        !          4134:                lle.var = *element;
        !          4135:                zend_llist_copy(&lle.dimensions, &CG(dimension_llist));
        !          4136:                zend_llist_prepend_element(&CG(list_llist), &lle);
        !          4137:        }
        !          4138:        (*((int *)CG(dimension_llist).tail->data))++;
        !          4139: }
        !          4140: /* }}} */
        !          4141: 
        !          4142: void zend_do_new_list_begin(TSRMLS_D) /* {{{ */
        !          4143: {
        !          4144:        int current_dimension = 0;
        !          4145:        zend_llist_add_element(&CG(dimension_llist), &current_dimension);
        !          4146: }
        !          4147: /* }}} */
        !          4148: 
        !          4149: void zend_do_new_list_end(TSRMLS_D) /* {{{ */
        !          4150: {
        !          4151:        zend_llist_remove_tail(&CG(dimension_llist));
        !          4152:        (*((int *)CG(dimension_llist).tail->data))++;
        !          4153: }
        !          4154: /* }}} */
        !          4155: 
        !          4156: void zend_do_list_init(TSRMLS_D) /* {{{ */
        !          4157: {
        !          4158:        zend_stack_push(&CG(list_stack), &CG(list_llist), sizeof(zend_llist));
        !          4159:        zend_stack_push(&CG(list_stack), &CG(dimension_llist), sizeof(zend_llist));
        !          4160:        zend_llist_init(&CG(list_llist), sizeof(list_llist_element), NULL, 0);
        !          4161:        zend_llist_init(&CG(dimension_llist), sizeof(int), NULL, 0);
        !          4162:        zend_do_new_list_begin(TSRMLS_C);
        !          4163: }
        !          4164: /* }}} */
        !          4165: 
        !          4166: void zend_do_list_end(znode *result, znode *expr TSRMLS_DC) /* {{{ */
        !          4167: {
        !          4168:        zend_llist_element *le;
        !          4169:        zend_llist_element *dimension;
        !          4170:        zend_op *opline;
        !          4171:        znode last_container;
        !          4172: 
        !          4173:        le = CG(list_llist).head;
        !          4174:        while (le) {
        !          4175:                zend_llist *tmp_dimension_llist = &((list_llist_element *)le->data)->dimensions;
        !          4176:                dimension = tmp_dimension_llist->head;
        !          4177:                while (dimension) {
        !          4178:                        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4179:                        if (dimension == tmp_dimension_llist->head) { /* first */
        !          4180:                                last_container = *expr;
        !          4181:                                switch (expr->op_type) {
        !          4182:                                        case IS_VAR:
        !          4183:                                        case IS_CV:
        !          4184:                                                opline->opcode = ZEND_FETCH_DIM_R;
        !          4185:                                                break;
        !          4186:                                        case IS_TMP_VAR:
        !          4187:                                                opline->opcode = ZEND_FETCH_DIM_TMP_VAR;
        !          4188:                                                break;
        !          4189:                                        case IS_CONST: /* fetch_dim_tmp_var will handle this bogus fetch */
        !          4190:                                                zval_copy_ctor(&expr->u.constant);
        !          4191:                                                opline->opcode = ZEND_FETCH_DIM_TMP_VAR;
        !          4192:                                                break;
        !          4193:                                }
        !          4194:                                opline->extended_value = ZEND_FETCH_ADD_LOCK;
        !          4195:                        } else {
        !          4196:                                opline->opcode = ZEND_FETCH_DIM_R;
        !          4197:                        }
        !          4198:                        opline->result.op_type = IS_VAR;
        !          4199:                        opline->result.u.EA.type = 0;
        !          4200:                        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          4201:                        opline->op1 = last_container;
        !          4202:                        opline->op2.op_type = IS_CONST;
        !          4203:                        Z_TYPE(opline->op2.u.constant) = IS_LONG;
        !          4204:                        Z_LVAL(opline->op2.u.constant) = *((int *) dimension->data);
        !          4205:                        INIT_PZVAL(&opline->op2.u.constant);
        !          4206:                        last_container = opline->result;
        !          4207:                        dimension = dimension->next;
        !          4208:                }
        !          4209:                ((list_llist_element *) le->data)->value = last_container;
        !          4210:                zend_llist_destroy(&((list_llist_element *) le->data)->dimensions);
        !          4211:                zend_do_assign(result, &((list_llist_element *) le->data)->var, &((list_llist_element *) le->data)->value TSRMLS_CC);
        !          4212:                zend_do_free(result TSRMLS_CC);
        !          4213:                le = le->next;
        !          4214:        }
        !          4215:        zend_llist_destroy(&CG(dimension_llist));
        !          4216:        zend_llist_destroy(&CG(list_llist));
        !          4217:        *result = *expr;
        !          4218:        {
        !          4219:                zend_llist *p;
        !          4220: 
        !          4221:                /* restore previous lists */
        !          4222:                zend_stack_top(&CG(list_stack), (void **) &p);
        !          4223:                CG(dimension_llist) = *p;
        !          4224:                zend_stack_del_top(&CG(list_stack));
        !          4225:                zend_stack_top(&CG(list_stack), (void **) &p);
        !          4226:                CG(list_llist) = *p;
        !          4227:                zend_stack_del_top(&CG(list_stack));
        !          4228:        }
        !          4229: }
        !          4230: /* }}} */
        !          4231: 
        !          4232: void zend_do_fetch_static_variable(znode *varname, const znode *static_assignment, int fetch_type TSRMLS_DC) /* {{{ */
        !          4233: {
        !          4234:        zval *tmp;
        !          4235:        zend_op *opline;
        !          4236:        znode lval;
        !          4237:        znode result;
        !          4238: 
        !          4239:        ALLOC_ZVAL(tmp);
        !          4240: 
        !          4241:        if (static_assignment) {
        !          4242:                *tmp = static_assignment->u.constant;
        !          4243:        } else {
        !          4244:                INIT_ZVAL(*tmp);
        !          4245:        }
        !          4246:        if (!CG(active_op_array)->static_variables) {
        !          4247:                ALLOC_HASHTABLE(CG(active_op_array)->static_variables);
        !          4248:                zend_hash_init(CG(active_op_array)->static_variables, 2, NULL, ZVAL_PTR_DTOR, 0);
        !          4249:        }
        !          4250:        zend_hash_update(CG(active_op_array)->static_variables, varname->u.constant.value.str.val, varname->u.constant.value.str.len+1, &tmp, sizeof(zval *), NULL);
        !          4251: 
        !          4252:        if (varname->op_type == IS_CONST) {
        !          4253:                if (Z_TYPE(varname->u.constant) != IS_STRING) {
        !          4254:                        convert_to_string(&varname->u.constant);
        !          4255:                }
        !          4256:        }
        !          4257: 
        !          4258:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4259:        opline->opcode = (fetch_type == ZEND_FETCH_LEXICAL) ? ZEND_FETCH_R : ZEND_FETCH_W;              /* the default mode must be Write, since fetch_simple_variable() is used to define function arguments */
        !          4260:        opline->result.op_type = IS_VAR;
        !          4261:        opline->result.u.EA.type = 0;
        !          4262:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          4263:        opline->op1 = *varname;
        !          4264:        SET_UNUSED(opline->op2);
        !          4265:        opline->op2.u.EA.type = ZEND_FETCH_STATIC;
        !          4266:        result = opline->result;
        !          4267: 
        !          4268:        if (varname->op_type == IS_CONST) {
        !          4269:                zval_copy_ctor(&varname->u.constant);
        !          4270:        }
        !          4271:        fetch_simple_variable(&lval, varname, 0 TSRMLS_CC); /* Relies on the fact that the default fetch is BP_VAR_W */
        !          4272: 
        !          4273:        if (fetch_type == ZEND_FETCH_LEXICAL) {
        !          4274:                znode dummy;
        !          4275: 
        !          4276:                zend_do_begin_variable_parse(TSRMLS_C);
        !          4277:                zend_do_assign(&dummy, &lval, &result TSRMLS_CC);
        !          4278:                zend_do_free(&dummy TSRMLS_CC);
        !          4279:        } else {
        !          4280:                zend_do_assign_ref(NULL, &lval, &result TSRMLS_CC);
        !          4281:        }
        !          4282:        CG(active_op_array)->opcodes[CG(active_op_array)->last-1].result.u.EA.type |= EXT_TYPE_UNUSED;
        !          4283: 
        !          4284: /*     zval_dtor(&varname->u.constant); */
        !          4285: }
        !          4286: /* }}} */
        !          4287: 
        !          4288: void zend_do_fetch_lexical_variable(znode *varname, zend_bool is_ref TSRMLS_DC) /* {{{ */
        !          4289: {
        !          4290:        znode value;
        !          4291: 
        !          4292:        if (Z_STRLEN(varname->u.constant) == sizeof("this") - 1 &&
        !          4293:                        memcmp(Z_STRVAL(varname->u.constant), "this", sizeof("this") - 1) == 0) {
        !          4294:                zend_error(E_COMPILE_ERROR, "Cannot use $this as lexical variable");
        !          4295:                return;
        !          4296:        }
        !          4297: 
        !          4298:        value.op_type = IS_CONST;
        !          4299:        ZVAL_NULL(&value.u.constant);
        !          4300:        Z_TYPE(value.u.constant) |= is_ref ? IS_LEXICAL_REF : IS_LEXICAL_VAR;
        !          4301:        Z_SET_REFCOUNT_P(&value.u.constant, 1);
        !          4302:        Z_UNSET_ISREF_P(&value.u.constant);
        !          4303:        
        !          4304:        zend_do_fetch_static_variable(varname, &value, is_ref ? ZEND_FETCH_STATIC : ZEND_FETCH_LEXICAL TSRMLS_CC);
        !          4305: }
        !          4306: /* }}} */
        !          4307: 
        !          4308: void zend_do_fetch_global_variable(znode *varname, const znode *static_assignment, int fetch_type TSRMLS_DC) /* {{{ */
        !          4309: {
        !          4310:        zend_op *opline;
        !          4311:        znode lval;
        !          4312:        znode result;
        !          4313: 
        !          4314:        if (varname->op_type == IS_CONST) {
        !          4315:                if (Z_TYPE(varname->u.constant) != IS_STRING) {
        !          4316:                        convert_to_string(&varname->u.constant);
        !          4317:                }
        !          4318:        }
        !          4319: 
        !          4320:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4321:        opline->opcode = ZEND_FETCH_W;          /* the default mode must be Write, since fetch_simple_variable() is used to define function arguments */
        !          4322:        opline->result.op_type = IS_VAR;
        !          4323:        opline->result.u.EA.type = 0;
        !          4324:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          4325:        opline->op1 = *varname;
        !          4326:        SET_UNUSED(opline->op2);
        !          4327:        opline->op2.u.EA.type = fetch_type;
        !          4328:        result = opline->result;
        !          4329: 
        !          4330:        if (varname->op_type == IS_CONST) {
        !          4331:                zval_copy_ctor(&varname->u.constant);
        !          4332:        }
        !          4333:        fetch_simple_variable(&lval, varname, 0 TSRMLS_CC); /* Relies on the fact that the default fetch is BP_VAR_W */
        !          4334: 
        !          4335:        zend_do_assign_ref(NULL, &lval, &result TSRMLS_CC);
        !          4336:        CG(active_op_array)->opcodes[CG(active_op_array)->last-1].result.u.EA.type |= EXT_TYPE_UNUSED;
        !          4337: }
        !          4338: /* }}} */
        !          4339: 
        !          4340: void zend_do_cast(znode *result, const znode *expr, int type TSRMLS_DC) /* {{{ */
        !          4341: {
        !          4342:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4343: 
        !          4344:        opline->opcode = ZEND_CAST;
        !          4345:        opline->result.op_type = IS_TMP_VAR;
        !          4346:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          4347:        opline->op1 = *expr;
        !          4348:        SET_UNUSED(opline->op2);
        !          4349:        opline->extended_value = type;
        !          4350:        *result = opline->result;
        !          4351: }
        !          4352: /* }}} */
        !          4353: 
        !          4354: void zend_do_include_or_eval(int type, znode *result, const znode *op1 TSRMLS_DC) /* {{{ */
        !          4355: {
        !          4356:        zend_do_extended_fcall_begin(TSRMLS_C);
        !          4357:        {
        !          4358:                zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4359: 
        !          4360:                opline->opcode = ZEND_INCLUDE_OR_EVAL;
        !          4361:                opline->result.op_type = IS_VAR;
        !          4362:                opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          4363:                opline->op1 = *op1;
        !          4364:                SET_UNUSED(opline->op2);
        !          4365:                Z_LVAL(opline->op2.u.constant) = type;
        !          4366:                *result = opline->result;
        !          4367:        }
        !          4368:        zend_do_extended_fcall_end(TSRMLS_C);
        !          4369: }
        !          4370: /* }}} */
        !          4371: 
        !          4372: void zend_do_indirect_references(znode *result, const znode *num_references, znode *variable TSRMLS_DC) /* {{{ */
        !          4373: {
        !          4374:        int i;
        !          4375: 
        !          4376:        zend_do_end_variable_parse(variable, BP_VAR_R, 0 TSRMLS_CC);
        !          4377:        for (i=1; i<num_references->u.constant.value.lval; i++) {
        !          4378:                fetch_simple_variable_ex(result, variable, 0, ZEND_FETCH_R TSRMLS_CC);
        !          4379:                *variable = *result;
        !          4380:        }
        !          4381:        zend_do_begin_variable_parse(TSRMLS_C);
        !          4382:        fetch_simple_variable(result, variable, 1 TSRMLS_CC);
        !          4383:        /* there is a chance someone is accessing $this */
        !          4384:        if (CG(active_op_array)->scope && CG(active_op_array)->this_var == -1) {
        !          4385:                CG(active_op_array)->this_var = lookup_cv(CG(active_op_array), estrndup("this", sizeof("this")-1), sizeof("this")-1);
        !          4386:        }
        !          4387: }
        !          4388: /* }}} */
        !          4389: 
        !          4390: void zend_do_unset(const znode *variable TSRMLS_DC) /* {{{ */
        !          4391: {
        !          4392:        zend_op *last_op;
        !          4393: 
        !          4394:        zend_check_writable_variable(variable);
        !          4395: 
        !          4396:        if (variable->op_type == IS_CV) {
        !          4397:                zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4398:                opline->opcode = ZEND_UNSET_VAR;
        !          4399:                opline->op1 = *variable;
        !          4400:                SET_UNUSED(opline->op2);
        !          4401:                opline->op2.u.EA.type = ZEND_FETCH_LOCAL;
        !          4402:                SET_UNUSED(opline->result);
        !          4403:                opline->extended_value = ZEND_QUICK_SET;
        !          4404:        } else {
        !          4405:                last_op = &CG(active_op_array)->opcodes[get_next_op_number(CG(active_op_array))-1];
        !          4406: 
        !          4407:                switch (last_op->opcode) {
        !          4408:                        case ZEND_FETCH_UNSET:
        !          4409:                                last_op->opcode = ZEND_UNSET_VAR;
        !          4410:                                break;
        !          4411:                        case ZEND_FETCH_DIM_UNSET:
        !          4412:                                last_op->opcode = ZEND_UNSET_DIM;
        !          4413:                                break;
        !          4414:                        case ZEND_FETCH_OBJ_UNSET:
        !          4415:                                last_op->opcode = ZEND_UNSET_OBJ;
        !          4416:                                break;
        !          4417: 
        !          4418:                }
        !          4419:        }
        !          4420: }
        !          4421: /* }}} */
        !          4422: 
        !          4423: void zend_do_isset_or_isempty(int type, znode *result, znode *variable TSRMLS_DC) /* {{{ */
        !          4424: {
        !          4425:        zend_op *last_op;
        !          4426: 
        !          4427:        zend_do_end_variable_parse(variable, BP_VAR_IS, 0 TSRMLS_CC);
        !          4428: 
        !          4429:        zend_check_writable_variable(variable);
        !          4430: 
        !          4431:        if (variable->op_type == IS_CV) {
        !          4432:                last_op = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4433:                last_op->opcode = ZEND_ISSET_ISEMPTY_VAR;
        !          4434:                last_op->op1 = *variable;
        !          4435:                SET_UNUSED(last_op->op2);
        !          4436:                last_op->op2.u.EA.type = ZEND_FETCH_LOCAL;
        !          4437:                last_op->result.u.var = get_temporary_variable(CG(active_op_array));
        !          4438:                last_op->extended_value = ZEND_QUICK_SET;
        !          4439:        } else {
        !          4440:                last_op = &CG(active_op_array)->opcodes[get_next_op_number(CG(active_op_array))-1];
        !          4441: 
        !          4442:                switch (last_op->opcode) {
        !          4443:                        case ZEND_FETCH_IS:
        !          4444:                                last_op->opcode = ZEND_ISSET_ISEMPTY_VAR;
        !          4445:                                break;
        !          4446:                        case ZEND_FETCH_DIM_IS:
        !          4447:                                last_op->opcode = ZEND_ISSET_ISEMPTY_DIM_OBJ;
        !          4448:                                break;
        !          4449:                        case ZEND_FETCH_OBJ_IS:
        !          4450:                                last_op->opcode = ZEND_ISSET_ISEMPTY_PROP_OBJ;
        !          4451:                                break;
        !          4452:                }
        !          4453:                last_op->extended_value = 0;
        !          4454:        }
        !          4455:        last_op->result.op_type = IS_TMP_VAR;
        !          4456:        last_op->extended_value |= type;
        !          4457: 
        !          4458:        *result = last_op->result;
        !          4459: }
        !          4460: /* }}} */
        !          4461: 
        !          4462: void zend_do_instanceof(znode *result, const znode *expr, const znode *class_znode, int type TSRMLS_DC) /* {{{ */
        !          4463: {
        !          4464:        int last_op_number = get_next_op_number(CG(active_op_array));
        !          4465:        zend_op *opline;
        !          4466: 
        !          4467:        if (last_op_number > 0) {
        !          4468:                opline = &CG(active_op_array)->opcodes[last_op_number-1];
        !          4469:                if (opline->opcode == ZEND_FETCH_CLASS) {
        !          4470:                        opline->extended_value |= ZEND_FETCH_CLASS_NO_AUTOLOAD;
        !          4471:                }
        !          4472:        }
        !          4473: 
        !          4474:        if (expr->op_type == IS_CONST) {
        !          4475:                zend_error(E_COMPILE_ERROR, "instanceof expects an object instance, constant given");
        !          4476:        }
        !          4477: 
        !          4478:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4479:        opline->opcode = ZEND_INSTANCEOF;
        !          4480:        opline->result.op_type = IS_TMP_VAR;
        !          4481:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          4482:        opline->op1 = *expr;
        !          4483: 
        !          4484:        opline->op2 = *class_znode;
        !          4485: 
        !          4486:        *result = opline->result;
        !          4487: }
        !          4488: /* }}} */
        !          4489: 
        !          4490: void zend_do_foreach_begin(znode *foreach_token, znode *open_brackets_token, znode *array, znode *as_token, int variable TSRMLS_DC) /* {{{ */
        !          4491: {
        !          4492:        zend_op *opline;
        !          4493:        zend_bool is_variable;
        !          4494:        zend_bool push_container = 0;
        !          4495:        zend_op dummy_opline;
        !          4496: 
        !          4497:        if (variable) {
        !          4498:                if (zend_is_function_or_method_call(array)) {
        !          4499:                        is_variable = 0;
        !          4500:                } else {
        !          4501:                        is_variable = 1;
        !          4502:                }
        !          4503:                /* save the location of FETCH_W instruction(s) */
        !          4504:                open_brackets_token->u.opline_num = get_next_op_number(CG(active_op_array));
        !          4505:                zend_do_end_variable_parse(array, BP_VAR_W, 0 TSRMLS_CC);
        !          4506:                if (CG(active_op_array)->last > 0 &&
        !          4507:                                CG(active_op_array)->opcodes[CG(active_op_array)->last-1].opcode == ZEND_FETCH_OBJ_W) {
        !          4508:                        /* Only lock the container if we are fetching from a real container and not $this */
        !          4509:                        if (CG(active_op_array)->opcodes[CG(active_op_array)->last-1].op1.op_type == IS_VAR) {
        !          4510:                                CG(active_op_array)->opcodes[CG(active_op_array)->last-1].extended_value |= ZEND_FETCH_ADD_LOCK;
        !          4511:                                push_container = 1;
        !          4512:                        }
        !          4513:                }
        !          4514:        } else {
        !          4515:                is_variable = 0;
        !          4516:                open_brackets_token->u.opline_num = get_next_op_number(CG(active_op_array));
        !          4517:        }
        !          4518: 
        !          4519:        /* save the location of FE_RESET */
        !          4520:        foreach_token->u.opline_num = get_next_op_number(CG(active_op_array));
        !          4521: 
        !          4522:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4523: 
        !          4524:        /* Preform array reset */
        !          4525:        opline->opcode = ZEND_FE_RESET;
        !          4526:        opline->result.op_type = IS_VAR;
        !          4527:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          4528:        opline->op1 = *array;
        !          4529:        SET_UNUSED(opline->op2);
        !          4530:        opline->extended_value = is_variable ? ZEND_FE_RESET_VARIABLE : 0;
        !          4531: 
        !          4532:        dummy_opline.result = opline->result;
        !          4533:        if (push_container) {
        !          4534:                dummy_opline.op1 = CG(active_op_array)->opcodes[CG(active_op_array)->last-2].op1;
        !          4535:        } else {
        !          4536:                znode tmp;
        !          4537: 
        !          4538:                tmp.op_type = IS_UNUSED;
        !          4539:                dummy_opline.op1 = tmp;
        !          4540:        }
        !          4541:        zend_stack_push(&CG(foreach_copy_stack), (void *) &dummy_opline, sizeof(zend_op));
        !          4542: 
        !          4543:        /* save the location of FE_FETCH */
        !          4544:        as_token->u.opline_num = get_next_op_number(CG(active_op_array));
        !          4545: 
        !          4546:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4547:        opline->opcode = ZEND_FE_FETCH;
        !          4548:        opline->result.op_type = IS_VAR;
        !          4549:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          4550:        opline->op1 = dummy_opline.result;
        !          4551:        opline->extended_value = 0;
        !          4552:        SET_UNUSED(opline->op2);
        !          4553: 
        !          4554:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4555:        opline->opcode = ZEND_OP_DATA;
        !          4556:        SET_UNUSED(opline->op1);
        !          4557:        SET_UNUSED(opline->op2);
        !          4558:        SET_UNUSED(opline->result);
        !          4559: }
        !          4560: /* }}} */
        !          4561: 
        !          4562: void zend_do_foreach_cont(znode *foreach_token, const znode *open_brackets_token, const znode *as_token, znode *value, znode *key TSRMLS_DC) /* {{{ */
        !          4563: {
        !          4564:        zend_op *opline;
        !          4565:        znode dummy, value_node;
        !          4566:        zend_bool assign_by_ref=0;
        !          4567: 
        !          4568:        opline = &CG(active_op_array)->opcodes[as_token->u.opline_num];
        !          4569:        if (key->op_type != IS_UNUSED) {
        !          4570:                znode *tmp;
        !          4571: 
        !          4572:                /* switch between the key and value... */
        !          4573:                tmp = key;
        !          4574:                key = value;
        !          4575:                value = tmp;
        !          4576: 
        !          4577:                /* Mark extended_value in case both key and value are being used */
        !          4578:                opline->extended_value |= ZEND_FE_FETCH_WITH_KEY;
        !          4579:        }
        !          4580: 
        !          4581:        if ((key->op_type != IS_UNUSED) && (key->u.EA.type & ZEND_PARSED_REFERENCE_VARIABLE)) {
        !          4582:                zend_error(E_COMPILE_ERROR, "Key element cannot be a reference");
        !          4583:        }
        !          4584: 
        !          4585:        if (value->u.EA.type & ZEND_PARSED_REFERENCE_VARIABLE) {
        !          4586:                assign_by_ref = 1;
        !          4587:                if (!(opline-1)->extended_value) {
        !          4588:                        zend_error(E_COMPILE_ERROR, "Cannot create references to elements of a temporary array expression");
        !          4589:                }
        !          4590:                /* Mark extended_value for assign-by-reference */
        !          4591:                opline->extended_value |= ZEND_FE_FETCH_BYREF;
        !          4592:                CG(active_op_array)->opcodes[foreach_token->u.opline_num].extended_value |= ZEND_FE_RESET_REFERENCE;
        !          4593:        } else {
        !          4594:                zend_op *foreach_copy;
        !          4595:                zend_op *fetch = &CG(active_op_array)->opcodes[foreach_token->u.opline_num];
        !          4596:                zend_op *end = &CG(active_op_array)->opcodes[open_brackets_token->u.opline_num];
        !          4597: 
        !          4598:                /* Change "write context" into "read context" */
        !          4599:                fetch->extended_value = 0;  /* reset ZEND_FE_RESET_VARIABLE */
        !          4600:                while (fetch != end) {
        !          4601:                        --fetch;
        !          4602:                        if (fetch->opcode == ZEND_FETCH_DIM_W && fetch->op2.op_type == IS_UNUSED) {
        !          4603:                                zend_error(E_COMPILE_ERROR, "Cannot use [] for reading");
        !          4604:                        }
        !          4605:                        fetch->opcode -= 3; /* FETCH_W -> FETCH_R */
        !          4606:                }
        !          4607:                /* prevent double SWITCH_FREE */
        !          4608:                zend_stack_top(&CG(foreach_copy_stack), (void **) &foreach_copy);
        !          4609:                foreach_copy->op1.op_type = IS_UNUSED;
        !          4610:        }
        !          4611: 
        !          4612:        value_node = opline->result;
        !          4613: 
        !          4614:        if (assign_by_ref) {
        !          4615:                zend_do_end_variable_parse(value, BP_VAR_W, 0 TSRMLS_CC);
        !          4616:                /* Mark FE_FETCH as IS_VAR as it holds the data directly as a value */
        !          4617:                zend_do_assign_ref(NULL, value, &value_node TSRMLS_CC);
        !          4618:        } else {
        !          4619:                zend_do_assign(&dummy, value, &value_node TSRMLS_CC);
        !          4620:                zend_do_free(&dummy TSRMLS_CC);
        !          4621:        }
        !          4622: 
        !          4623:        if (key->op_type != IS_UNUSED) {
        !          4624:                znode key_node;
        !          4625: 
        !          4626:                opline = &CG(active_op_array)->opcodes[as_token->u.opline_num+1];
        !          4627:                opline->result.op_type = IS_TMP_VAR;
        !          4628:                opline->result.u.EA.type = 0;
        !          4629:                opline->result.u.opline_num = get_temporary_variable(CG(active_op_array));
        !          4630:                key_node = opline->result;
        !          4631: 
        !          4632:                zend_do_assign(&dummy, key, &key_node TSRMLS_CC);
        !          4633:                zend_do_free(&dummy TSRMLS_CC);
        !          4634:        }
        !          4635: 
        !          4636:        do_begin_loop(TSRMLS_C);
        !          4637:        INC_BPC(CG(active_op_array));
        !          4638: }
        !          4639: /* }}} */
        !          4640: 
        !          4641: void zend_do_foreach_end(const znode *foreach_token, const znode *as_token TSRMLS_DC) /* {{{ */
        !          4642: {
        !          4643:        zend_op *container_ptr;
        !          4644:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4645: 
        !          4646:        opline->opcode = ZEND_JMP;
        !          4647:        opline->op1.u.opline_num = as_token->u.opline_num;
        !          4648:        SET_UNUSED(opline->op1);
        !          4649:        SET_UNUSED(opline->op2);
        !          4650: 
        !          4651:        CG(active_op_array)->opcodes[foreach_token->u.opline_num].op2.u.opline_num = get_next_op_number(CG(active_op_array)); /* FE_RESET */
        !          4652:        CG(active_op_array)->opcodes[as_token->u.opline_num].op2.u.opline_num = get_next_op_number(CG(active_op_array)); /* FE_FETCH */
        !          4653: 
        !          4654:        do_end_loop(as_token->u.opline_num, 1 TSRMLS_CC);
        !          4655: 
        !          4656:        zend_stack_top(&CG(foreach_copy_stack), (void **) &container_ptr);
        !          4657:        generate_free_foreach_copy(container_ptr TSRMLS_CC);
        !          4658:        zend_stack_del_top(&CG(foreach_copy_stack));
        !          4659: 
        !          4660:        DEC_BPC(CG(active_op_array));
        !          4661: }
        !          4662: /* }}} */
        !          4663: 
        !          4664: void zend_do_declare_begin(TSRMLS_D) /* {{{ */
        !          4665: {
        !          4666:        zend_stack_push(&CG(declare_stack), &CG(declarables), sizeof(zend_declarables));
        !          4667: }
        !          4668: /* }}} */
        !          4669: 
        !          4670: void zend_do_declare_stmt(znode *var, znode *val TSRMLS_DC) /* {{{ */
        !          4671: {
        !          4672:        if (!zend_binary_strcasecmp(var->u.constant.value.str.val, var->u.constant.value.str.len, "ticks", sizeof("ticks")-1)) {
        !          4673:                convert_to_long(&val->u.constant);
        !          4674:                CG(declarables).ticks = val->u.constant;
        !          4675: #ifdef ZEND_MULTIBYTE
        !          4676:        } else if (!zend_binary_strcasecmp(var->u.constant.value.str.val, var->u.constant.value.str.len, "encoding", sizeof("encoding")-1)) {
        !          4677:                zend_encoding *new_encoding, *old_encoding;
        !          4678:                zend_encoding_filter old_input_filter;
        !          4679: 
        !          4680:                if ((Z_TYPE(val->u.constant) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) {
        !          4681:                        zend_error(E_COMPILE_ERROR, "Cannot use constants as encoding");
        !          4682:                }
        !          4683: 
        !          4684:                /*
        !          4685:                 * Check that the pragma comes before any opcodes. If the compilation
        !          4686:                 * got as far as this, the previous portion of the script must have been
        !          4687:                 * parseable according to the .ini script_encoding setting. We still
        !          4688:                 * want to tell them to put declare() at the top.
        !          4689:                 */
        !          4690:                {
        !          4691:                        int num = CG(active_op_array)->last;
        !          4692:                        /* ignore ZEND_EXT_STMT and ZEND_TICKS */
        !          4693:                        while (num > 0 &&
        !          4694:                                                 (CG(active_op_array)->opcodes[num-1].opcode == ZEND_EXT_STMT ||
        !          4695:                                                        CG(active_op_array)->opcodes[num-1].opcode == ZEND_TICKS)) {
        !          4696:                                --num;
        !          4697:                        }
        !          4698: 
        !          4699:                        if (num > 0) {
        !          4700:                                zend_error(E_COMPILE_ERROR, "Encoding declaration pragma must be the very first statement in the script");
        !          4701:                        }
        !          4702:                }
        !          4703:                CG(encoding_declared) = 1;
        !          4704: 
        !          4705:                convert_to_string(&val->u.constant);
        !          4706:                new_encoding = zend_multibyte_fetch_encoding(val->u.constant.value.str.val);
        !          4707:                if (!new_encoding) {
        !          4708:                        zend_error(E_COMPILE_WARNING, "Unsupported encoding [%s]", val->u.constant.value.str.val);
        !          4709:                } else {
        !          4710:                        old_input_filter = LANG_SCNG(input_filter);
        !          4711:                        old_encoding = LANG_SCNG(script_encoding);
        !          4712:                        zend_multibyte_set_filter(new_encoding TSRMLS_CC);
        !          4713: 
        !          4714:                        /* need to re-scan if input filter changed */
        !          4715:                        if (old_input_filter != LANG_SCNG(input_filter) ||
        !          4716:                                ((old_input_filter == zend_multibyte_script_encoding_filter) &&
        !          4717:                                 (new_encoding != old_encoding))) {
        !          4718:                                zend_multibyte_yyinput_again(old_input_filter, old_encoding TSRMLS_CC);
        !          4719:                        }
        !          4720:                }
        !          4721:                efree(val->u.constant.value.str.val);
        !          4722: #else  /* !ZEND_MULTIBYTE */
        !          4723:        } else if (!zend_binary_strcasecmp(var->u.constant.value.str.val, var->u.constant.value.str.len, "encoding", sizeof("encoding")-1)) {
        !          4724:                /* Do not generate any kind of warning for encoding declares */
        !          4725:                /* zend_error(E_COMPILE_WARNING, "Declare encoding [%s] not supported", val->u.constant.value.str.val); */
        !          4726:                zval_dtor(&val->u.constant);
        !          4727: #endif /* ZEND_MULTIBYTE */
        !          4728:        } else {
        !          4729:                zend_error(E_COMPILE_WARNING, "Unsupported declare '%s'", var->u.constant.value.str.val);
        !          4730:                zval_dtor(&val->u.constant);
        !          4731:        }
        !          4732:        zval_dtor(&var->u.constant);
        !          4733: }
        !          4734: /* }}} */
        !          4735: 
        !          4736: void zend_do_declare_end(const znode *declare_token TSRMLS_DC) /* {{{ */
        !          4737: {
        !          4738:        zend_declarables *declarables;
        !          4739: 
        !          4740:        zend_stack_top(&CG(declare_stack), (void **) &declarables);
        !          4741:        /* We should restore if there was more than (current - start) - (ticks?1:0) opcodes */
        !          4742:        if ((get_next_op_number(CG(active_op_array)) - declare_token->u.opline_num) - ((Z_LVAL(CG(declarables).ticks))?1:0)) {
        !          4743:                CG(declarables) = *declarables;
        !          4744:        }
        !          4745: }
        !          4746: /* }}} */
        !          4747: 
        !          4748: void zend_do_exit(znode *result, const znode *message TSRMLS_DC) /* {{{ */
        !          4749: {
        !          4750:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4751: 
        !          4752:        opline->opcode = ZEND_EXIT;
        !          4753:        opline->op1 = *message;
        !          4754:        SET_UNUSED(opline->op2);
        !          4755: 
        !          4756:        result->op_type = IS_CONST;
        !          4757:        Z_TYPE(result->u.constant) = IS_BOOL;
        !          4758:        Z_LVAL(result->u.constant) = 1;
        !          4759: }
        !          4760: /* }}} */
        !          4761: 
        !          4762: void zend_do_begin_silence(znode *strudel_token TSRMLS_DC) /* {{{ */
        !          4763: {
        !          4764:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4765: 
        !          4766:        opline->opcode = ZEND_BEGIN_SILENCE;
        !          4767:        opline->result.op_type = IS_TMP_VAR;
        !          4768:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          4769:        SET_UNUSED(opline->op1);
        !          4770:        SET_UNUSED(opline->op2);
        !          4771:        *strudel_token = opline->result;
        !          4772: }
        !          4773: /* }}} */
        !          4774: 
        !          4775: void zend_do_end_silence(const znode *strudel_token TSRMLS_DC) /* {{{ */
        !          4776: {
        !          4777:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4778: 
        !          4779:        opline->opcode = ZEND_END_SILENCE;
        !          4780:        opline->op1 = *strudel_token;
        !          4781:        SET_UNUSED(opline->op2);
        !          4782: }
        !          4783: /* }}} */
        !          4784: 
        !          4785: void zend_do_jmp_set(const znode *value, znode *jmp_token, znode *colon_token TSRMLS_DC) /* {{{ */
        !          4786: {
        !          4787:        int op_number = get_next_op_number(CG(active_op_array));
        !          4788:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4789: 
        !          4790:        opline->opcode = ZEND_JMP_SET;
        !          4791:        opline->result.op_type = IS_TMP_VAR;
        !          4792:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          4793:        opline->op1 = *value;
        !          4794:        SET_UNUSED(opline->op2);
        !          4795:        
        !          4796:        *colon_token = opline->result;
        !          4797: 
        !          4798:        jmp_token->u.opline_num = op_number;
        !          4799: 
        !          4800:        INC_BPC(CG(active_op_array));
        !          4801: }
        !          4802: /* }}} */
        !          4803: 
        !          4804: void zend_do_jmp_set_else(znode *result, const znode *false_value, const znode *jmp_token, const znode *colon_token TSRMLS_DC) /* {{{ */
        !          4805: {
        !          4806:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4807: 
        !          4808:        opline->opcode = ZEND_QM_ASSIGN;
        !          4809:        opline->extended_value = 0;
        !          4810:        opline->result = *colon_token;
        !          4811:        opline->op1 = *false_value;
        !          4812:        SET_UNUSED(opline->op2);
        !          4813:        
        !          4814:        *result = opline->result;
        !          4815: 
        !          4816:        CG(active_op_array)->opcodes[jmp_token->u.opline_num].op2.u.opline_num = get_next_op_number(CG(active_op_array));
        !          4817:        
        !          4818:        DEC_BPC(CG(active_op_array));
        !          4819: }
        !          4820: /* }}} */
        !          4821: 
        !          4822: void zend_do_begin_qm_op(const znode *cond, znode *qm_token TSRMLS_DC) /* {{{ */
        !          4823: {
        !          4824:        int jmpz_op_number = get_next_op_number(CG(active_op_array));
        !          4825:        zend_op *opline;
        !          4826: 
        !          4827:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4828: 
        !          4829:        opline->opcode = ZEND_JMPZ;
        !          4830:        opline->op1 = *cond;
        !          4831:        SET_UNUSED(opline->op2);
        !          4832:        opline->op2.u.opline_num = jmpz_op_number;
        !          4833:        *qm_token = opline->op2;
        !          4834: 
        !          4835:        INC_BPC(CG(active_op_array));
        !          4836: }
        !          4837: /* }}} */
        !          4838: 
        !          4839: void zend_do_qm_true(const znode *true_value, znode *qm_token, znode *colon_token TSRMLS_DC) /* {{{ */
        !          4840: {
        !          4841:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4842: 
        !          4843:        CG(active_op_array)->opcodes[qm_token->u.opline_num].op2.u.opline_num = get_next_op_number(CG(active_op_array))+1; /* jmp over the ZEND_JMP */
        !          4844: 
        !          4845:        opline->opcode = ZEND_QM_ASSIGN;
        !          4846:        opline->result.op_type = IS_TMP_VAR;
        !          4847:        opline->result.u.var = get_temporary_variable(CG(active_op_array));
        !          4848:        opline->op1 = *true_value;
        !          4849:        SET_UNUSED(opline->op2);
        !          4850: 
        !          4851:        *qm_token = opline->result;
        !          4852:        colon_token->u.opline_num = get_next_op_number(CG(active_op_array));
        !          4853: 
        !          4854:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4855:        opline->opcode = ZEND_JMP;
        !          4856:        SET_UNUSED(opline->op1);
        !          4857:        SET_UNUSED(opline->op2);
        !          4858: }
        !          4859: /* }}} */
        !          4860: 
        !          4861: void zend_do_qm_false(znode *result, const znode *false_value, const znode *qm_token, const znode *colon_token TSRMLS_DC) /* {{{ */
        !          4862: {
        !          4863:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4864: 
        !          4865:        opline->opcode = ZEND_QM_ASSIGN;
        !          4866:        opline->result = *qm_token;
        !          4867:        opline->op1 = *false_value;
        !          4868:        SET_UNUSED(opline->op2);
        !          4869: 
        !          4870:        CG(active_op_array)->opcodes[colon_token->u.opline_num].op1.u.opline_num = get_next_op_number(CG(active_op_array));
        !          4871: 
        !          4872:        *result = opline->result;
        !          4873: 
        !          4874:        DEC_BPC(CG(active_op_array));
        !          4875: }
        !          4876: /* }}} */
        !          4877: 
        !          4878: void zend_do_extended_info(TSRMLS_D) /* {{{ */
        !          4879: {
        !          4880:        zend_op *opline;
        !          4881: 
        !          4882:        if (!(CG(compiler_options) & ZEND_COMPILE_EXTENDED_INFO)) {
        !          4883:                return;
        !          4884:        }
        !          4885: 
        !          4886:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4887: 
        !          4888:        opline->opcode = ZEND_EXT_STMT;
        !          4889:        SET_UNUSED(opline->op1);
        !          4890:        SET_UNUSED(opline->op2);
        !          4891: }
        !          4892: /* }}} */
        !          4893: 
        !          4894: void zend_do_extended_fcall_begin(TSRMLS_D) /* {{{ */
        !          4895: {
        !          4896:        zend_op *opline;
        !          4897: 
        !          4898:        if (!(CG(compiler_options) & ZEND_COMPILE_EXTENDED_INFO)) {
        !          4899:                return;
        !          4900:        }
        !          4901: 
        !          4902:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4903: 
        !          4904:        opline->opcode = ZEND_EXT_FCALL_BEGIN;
        !          4905:        SET_UNUSED(opline->op1);
        !          4906:        SET_UNUSED(opline->op2);
        !          4907: }
        !          4908: /* }}} */
        !          4909: 
        !          4910: void zend_do_extended_fcall_end(TSRMLS_D) /* {{{ */
        !          4911: {
        !          4912:        zend_op *opline;
        !          4913: 
        !          4914:        if (!(CG(compiler_options) & ZEND_COMPILE_EXTENDED_INFO)) {
        !          4915:                return;
        !          4916:        }
        !          4917: 
        !          4918:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4919: 
        !          4920:        opline->opcode = ZEND_EXT_FCALL_END;
        !          4921:        SET_UNUSED(opline->op1);
        !          4922:        SET_UNUSED(opline->op2);
        !          4923: }
        !          4924: /* }}} */
        !          4925: 
        !          4926: void zend_do_ticks(TSRMLS_D) /* {{{ */
        !          4927: {
        !          4928:        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          4929: 
        !          4930:        opline->opcode = ZEND_TICKS;
        !          4931:        opline->op1.u.constant = CG(declarables).ticks;
        !          4932:        opline->op1.op_type = IS_CONST;
        !          4933:        SET_UNUSED(opline->op2);
        !          4934: }
        !          4935: /* }}} */
        !          4936: 
        !          4937: void zend_auto_global_dtor(zend_auto_global *auto_global) /* {{{ */
        !          4938: {
        !          4939:        free(auto_global->name);
        !          4940: }
        !          4941: /* }}} */
        !          4942: 
        !          4943: zend_bool zend_is_auto_global(const char *name, uint name_len TSRMLS_DC) /* {{{ */
        !          4944: {
        !          4945:        zend_auto_global *auto_global;
        !          4946: 
        !          4947:        if (zend_hash_find(CG(auto_globals), name, name_len+1, (void **) &auto_global)==SUCCESS) {
        !          4948:                if (auto_global->armed) {
        !          4949:                        auto_global->armed = auto_global->auto_global_callback(auto_global->name, auto_global->name_len TSRMLS_CC);
        !          4950:                }
        !          4951:                return 1;
        !          4952:        }
        !          4953:        return 0;
        !          4954: }
        !          4955: /* }}} */
        !          4956: 
        !          4957: int zend_register_auto_global(const char *name, uint name_len, zend_auto_global_callback auto_global_callback TSRMLS_DC) /* {{{ */
        !          4958: {
        !          4959:        zend_auto_global auto_global;
        !          4960: 
        !          4961:        auto_global.name = zend_strndup(name, name_len);
        !          4962:        auto_global.name_len = name_len;
        !          4963:        auto_global.auto_global_callback = auto_global_callback;
        !          4964: 
        !          4965:        return zend_hash_add(CG(auto_globals), name, name_len+1, &auto_global, sizeof(zend_auto_global), NULL);
        !          4966: }
        !          4967: /* }}} */
        !          4968: 
        !          4969: int zendlex(znode *zendlval TSRMLS_DC) /* {{{ */
        !          4970: {
        !          4971:        int retval;
        !          4972: 
        !          4973:        if (CG(increment_lineno)) {
        !          4974:                CG(zend_lineno)++;
        !          4975:                CG(increment_lineno) = 0;
        !          4976:        }
        !          4977: 
        !          4978: again:
        !          4979:        Z_TYPE(zendlval->u.constant) = IS_LONG;
        !          4980:        retval = lex_scan(&zendlval->u.constant TSRMLS_CC);
        !          4981:        switch (retval) {
        !          4982:                case T_COMMENT:
        !          4983:                case T_DOC_COMMENT:
        !          4984:                case T_OPEN_TAG:
        !          4985:                case T_WHITESPACE:
        !          4986:                        goto again;
        !          4987: 
        !          4988:                case T_CLOSE_TAG:
        !          4989:                        if (LANG_SCNG(yy_text)[LANG_SCNG(yy_leng)-1] != '>') {
        !          4990:                                CG(increment_lineno) = 1;
        !          4991:                        }
        !          4992:                        if (CG(has_bracketed_namespaces) && !CG(in_namespace)) {
        !          4993:                                goto again;                             
        !          4994:                        }
        !          4995:                        retval = ';'; /* implicit ; */
        !          4996:                        break;
        !          4997:                case T_OPEN_TAG_WITH_ECHO:
        !          4998:                        retval = T_ECHO;
        !          4999:                        break;
        !          5000:                case T_END_HEREDOC:
        !          5001:                        efree(Z_STRVAL(zendlval->u.constant));
        !          5002:                        break;
        !          5003:        }
        !          5004: 
        !          5005:        INIT_PZVAL(&zendlval->u.constant);
        !          5006:        zendlval->op_type = IS_CONST;
        !          5007:        return retval;
        !          5008: }
        !          5009: /* }}} */
        !          5010: 
        !          5011: ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers TSRMLS_DC) /* {{{ */
        !          5012: {
        !          5013:        zend_bool persistent_hashes = (ce->type == ZEND_INTERNAL_CLASS) ? 1 : 0;
        !          5014:        dtor_func_t zval_ptr_dtor_func = ((persistent_hashes) ? ZVAL_INTERNAL_PTR_DTOR : ZVAL_PTR_DTOR);
        !          5015: 
        !          5016:        ce->refcount = 1;
        !          5017:        ce->constants_updated = 0;
        !          5018:        ce->ce_flags = 0;
        !          5019: 
        !          5020:        ce->doc_comment = NULL;
        !          5021:        ce->doc_comment_len = 0;
        !          5022: 
        !          5023:        zend_hash_init_ex(&ce->default_properties, 0, NULL, zval_ptr_dtor_func, persistent_hashes, 0);
        !          5024:        zend_hash_init_ex(&ce->properties_info, 0, NULL, (dtor_func_t) (persistent_hashes ? zend_destroy_property_info_internal : zend_destroy_property_info), persistent_hashes, 0);
        !          5025:        zend_hash_init_ex(&ce->default_static_members, 0, NULL, zval_ptr_dtor_func, persistent_hashes, 0);
        !          5026:        zend_hash_init_ex(&ce->constants_table, 0, NULL, zval_ptr_dtor_func, persistent_hashes, 0);
        !          5027:        zend_hash_init_ex(&ce->function_table, 0, NULL, ZEND_FUNCTION_DTOR, persistent_hashes, 0);
        !          5028: 
        !          5029:        if (ce->type == ZEND_INTERNAL_CLASS) {
        !          5030: #ifdef ZTS
        !          5031:                int n = zend_hash_num_elements(CG(class_table));
        !          5032: 
        !          5033:                if (CG(static_members) && n >= CG(last_static_member)) {
        !          5034:                        /* Support for run-time declaration: dl() */
        !          5035:                        CG(last_static_member) = n+1;
        !          5036:                        CG(static_members) = realloc(CG(static_members), (n+1)*sizeof(HashTable*));
        !          5037:                        CG(static_members)[n] = NULL;
        !          5038:                }
        !          5039:                ce->static_members = (HashTable*)(zend_intptr_t)n;
        !          5040: #else
        !          5041:                ce->static_members = NULL;
        !          5042: #endif
        !          5043:        } else {
        !          5044:                ce->static_members = &ce->default_static_members;
        !          5045:        }
        !          5046: 
        !          5047:        if (nullify_handlers) {
        !          5048:                ce->constructor = NULL;
        !          5049:                ce->destructor = NULL;
        !          5050:                ce->clone = NULL;
        !          5051:                ce->__get = NULL;
        !          5052:                ce->__set = NULL;
        !          5053:                ce->__unset = NULL;
        !          5054:                ce->__isset = NULL;
        !          5055:                ce->__call = NULL;
        !          5056:                ce->__callstatic = NULL;
        !          5057:                ce->__tostring = NULL;
        !          5058:                ce->create_object = NULL;
        !          5059:                ce->get_iterator = NULL;
        !          5060:                ce->iterator_funcs.funcs = NULL;
        !          5061:                ce->interface_gets_implemented = NULL;
        !          5062:                ce->get_static_method = NULL;
        !          5063:                ce->parent = NULL;
        !          5064:                ce->num_interfaces = 0;
        !          5065:                ce->interfaces = NULL;
        !          5066:                ce->module = NULL;
        !          5067:                ce->serialize = NULL;
        !          5068:                ce->unserialize = NULL;
        !          5069:                ce->serialize_func = NULL;
        !          5070:                ce->unserialize_func = NULL;
        !          5071:                ce->builtin_functions = NULL;
        !          5072:        }
        !          5073: }
        !          5074: /* }}} */
        !          5075: 
        !          5076: int zend_get_class_fetch_type(const char *class_name, uint class_name_len) /* {{{ */
        !          5077: {
        !          5078:        if ((class_name_len == sizeof("self")-1) &&
        !          5079:                !memcmp(class_name, "self", sizeof("self")-1)) {
        !          5080:                return ZEND_FETCH_CLASS_SELF;           
        !          5081:        } else if ((class_name_len == sizeof("parent")-1) &&
        !          5082:                !memcmp(class_name, "parent", sizeof("parent")-1)) {
        !          5083:                return ZEND_FETCH_CLASS_PARENT;
        !          5084:        } else if ((class_name_len == sizeof("static")-1) &&
        !          5085:                !memcmp(class_name, "static", sizeof("static")-1)) {
        !          5086:                return ZEND_FETCH_CLASS_STATIC;
        !          5087:        } else {
        !          5088:                return ZEND_FETCH_CLASS_DEFAULT;
        !          5089:        }
        !          5090: }
        !          5091: /* }}} */
        !          5092: 
        !          5093: ZEND_API char* zend_get_compiled_variable_name(const zend_op_array *op_array, zend_uint var, int* name_len) /* {{{ */
        !          5094: {
        !          5095:        if (name_len) {
        !          5096:                *name_len = op_array->vars[var].name_len;
        !          5097:        }
        !          5098:        return op_array->vars[var].name;
        !          5099: }
        !          5100: /* }}} */
        !          5101: 
        !          5102: void zend_do_build_namespace_name(znode *result, znode *prefix, znode *name TSRMLS_DC) /* {{{ */
        !          5103: {
        !          5104:        if (prefix) {
        !          5105:                *result = *prefix;
        !          5106:                if (Z_TYPE(result->u.constant) == IS_STRING &&
        !          5107:                Z_STRLEN(result->u.constant) == 0) {
        !          5108:                        /* namespace\ */
        !          5109:                        if (CG(current_namespace)) {
        !          5110:                                znode tmp;
        !          5111: 
        !          5112:                                zval_dtor(&result->u.constant);
        !          5113:                                tmp.op_type = IS_CONST;
        !          5114:                                tmp.u.constant = *CG(current_namespace);
        !          5115:                                zval_copy_ctor(&tmp.u.constant);
        !          5116:                                zend_do_build_namespace_name(result, NULL, &tmp TSRMLS_CC);
        !          5117:                        }
        !          5118:                }
        !          5119:        } else {
        !          5120:                result->op_type = IS_CONST;
        !          5121:                Z_TYPE(result->u.constant) = IS_STRING;
        !          5122:                Z_STRVAL(result->u.constant) = NULL;
        !          5123:                Z_STRLEN(result->u.constant) = 0;
        !          5124:        }
        !          5125:        /* prefix = result */
        !          5126:        zend_do_build_full_name(NULL, result, name, 0 TSRMLS_CC);
        !          5127: }
        !          5128: /* }}} */
        !          5129: 
        !          5130: void zend_do_begin_namespace(const znode *name, zend_bool with_bracket TSRMLS_DC) /* {{{ */
        !          5131: {
        !          5132:        char *lcname;
        !          5133: 
        !          5134:        /* handle mixed syntax declaration or nested namespaces */
        !          5135:        if (!CG(has_bracketed_namespaces)) {
        !          5136:                if (CG(current_namespace)) {
        !          5137:                        /* previous namespace declarations were unbracketed */
        !          5138:                        if (with_bracket) {
        !          5139:                                zend_error(E_COMPILE_ERROR, "Cannot mix bracketed namespace declarations with unbracketed namespace declarations");
        !          5140:                        }
        !          5141:                }
        !          5142:        } else {
        !          5143:                /* previous namespace declarations were bracketed */
        !          5144:                if (!with_bracket) {
        !          5145:                        zend_error(E_COMPILE_ERROR, "Cannot mix bracketed namespace declarations with unbracketed namespace declarations");
        !          5146:                } else if (CG(current_namespace) || CG(in_namespace)) {
        !          5147:                        zend_error(E_COMPILE_ERROR, "Namespace declarations cannot be nested");
        !          5148:                }
        !          5149:        }
        !          5150: 
        !          5151:        if (((!with_bracket && !CG(current_namespace)) || (with_bracket && !CG(has_bracketed_namespaces))) && CG(active_op_array)->last > 0) {
        !          5152:                /* ignore ZEND_EXT_STMT and ZEND_TICKS */
        !          5153:                int num = CG(active_op_array)->last;
        !          5154:                while (num > 0 &&
        !          5155:                                         (CG(active_op_array)->opcodes[num-1].opcode == ZEND_EXT_STMT ||
        !          5156:                                                CG(active_op_array)->opcodes[num-1].opcode == ZEND_TICKS)) {
        !          5157:                        --num;
        !          5158:                }
        !          5159:                if (num > 0) {
        !          5160:                        zend_error(E_COMPILE_ERROR, "Namespace declaration statement has to be the very first statement in the script");
        !          5161:                }
        !          5162:        }
        !          5163: 
        !          5164:        CG(in_namespace) = 1;
        !          5165:        if (with_bracket) {
        !          5166:                CG(has_bracketed_namespaces) = 1;
        !          5167:        }
        !          5168: 
        !          5169:        if (name) {
        !          5170:                lcname = zend_str_tolower_dup(Z_STRVAL(name->u.constant), Z_STRLEN(name->u.constant));
        !          5171:                if (((Z_STRLEN(name->u.constant) == sizeof("self")-1) &&
        !          5172:                                        !memcmp(lcname, "self", sizeof("self")-1)) ||
        !          5173:                                ((Z_STRLEN(name->u.constant) == sizeof("parent")-1) &&
        !          5174:                                                !memcmp(lcname, "parent", sizeof("parent")-1))) {
        !          5175:                        zend_error(E_COMPILE_ERROR, "Cannot use '%s' as namespace name", Z_STRVAL(name->u.constant));
        !          5176:                }
        !          5177:                efree(lcname);
        !          5178: 
        !          5179:                if (CG(current_namespace)) {
        !          5180:                        zval_dtor(CG(current_namespace));
        !          5181:                } else {
        !          5182:                        ALLOC_ZVAL(CG(current_namespace));
        !          5183:                }
        !          5184:                *CG(current_namespace) = name->u.constant;
        !          5185:        } else {
        !          5186:                if (CG(current_namespace)) {
        !          5187:                        zval_dtor(CG(current_namespace));
        !          5188:                        FREE_ZVAL(CG(current_namespace));
        !          5189:                        CG(current_namespace) = NULL;
        !          5190:                }
        !          5191:        }
        !          5192: 
        !          5193:        if (CG(current_import)) {
        !          5194:                zend_hash_destroy(CG(current_import));
        !          5195:                efree(CG(current_import));
        !          5196:                CG(current_import) = NULL;
        !          5197:        }
        !          5198: 
        !          5199:        if (CG(doc_comment)) {
        !          5200:                efree(CG(doc_comment));
        !          5201:                CG(doc_comment) = NULL;
        !          5202:                CG(doc_comment_len) = 0;
        !          5203:        }
        !          5204: }
        !          5205: /* }}} */
        !          5206: 
        !          5207: void zend_do_use(znode *ns_name, znode *new_name, int is_global TSRMLS_DC) /* {{{ */
        !          5208: {
        !          5209:        char *lcname;
        !          5210:        zval *name, *ns, tmp;
        !          5211:        zend_bool warn = 0;
        !          5212:        zend_class_entry **pce;
        !          5213: 
        !          5214:        if (!CG(current_import)) {
        !          5215:                CG(current_import) = emalloc(sizeof(HashTable));
        !          5216:                zend_hash_init(CG(current_import), 0, NULL, ZVAL_PTR_DTOR, 0);
        !          5217:        }
        !          5218: 
        !          5219:        ALLOC_ZVAL(ns);
        !          5220:        *ns = ns_name->u.constant;
        !          5221:        if (new_name) {
        !          5222:                name = &new_name->u.constant;
        !          5223:        } else {
        !          5224:                char *p;
        !          5225: 
        !          5226:                /* The form "use A\B" is eqivalent to "use A\B as B".
        !          5227:                   So we extract the last part of compound name to use as a new_name */
        !          5228:                name = &tmp;
        !          5229:                p = zend_memrchr(Z_STRVAL_P(ns), '\\', Z_STRLEN_P(ns));
        !          5230:                if (p) {
        !          5231:                        ZVAL_STRING(name, p+1, 1);
        !          5232:                } else {
        !          5233:                        *name = *ns;
        !          5234:                        zval_copy_ctor(name);
        !          5235:                        warn = !is_global && !CG(current_namespace);
        !          5236:                }
        !          5237:        }
        !          5238: 
        !          5239:        lcname = zend_str_tolower_dup(Z_STRVAL_P(name), Z_STRLEN_P(name));
        !          5240: 
        !          5241:        if (((Z_STRLEN_P(name) == sizeof("self")-1) &&
        !          5242:                                !memcmp(lcname, "self", sizeof("self")-1)) ||
        !          5243:                        ((Z_STRLEN_P(name) == sizeof("parent")-1) &&
        !          5244:                                !memcmp(lcname, "parent", sizeof("parent")-1))) {
        !          5245:                zend_error(E_COMPILE_ERROR, "Cannot use %s as %s because '%s' is a special class name", Z_STRVAL_P(ns), Z_STRVAL_P(name), Z_STRVAL_P(name));
        !          5246:        }
        !          5247: 
        !          5248:        if (CG(current_namespace)) {
        !          5249:                /* Prefix import name with current namespace name to avoid conflicts with classes */
        !          5250:                char *c_ns_name = emalloc(Z_STRLEN_P(CG(current_namespace)) + 1 + Z_STRLEN_P(name) + 1);
        !          5251: 
        !          5252:                zend_str_tolower_copy(c_ns_name, Z_STRVAL_P(CG(current_namespace)), Z_STRLEN_P(CG(current_namespace)));
        !          5253:                c_ns_name[Z_STRLEN_P(CG(current_namespace))] = '\\';
        !          5254:                memcpy(c_ns_name+Z_STRLEN_P(CG(current_namespace))+1, lcname, Z_STRLEN_P(name)+1);
        !          5255:                if (zend_hash_exists(CG(class_table), c_ns_name, Z_STRLEN_P(CG(current_namespace)) + 1 + Z_STRLEN_P(name)+1)) {
        !          5256:                        char *tmp2 = zend_str_tolower_dup(Z_STRVAL_P(ns), Z_STRLEN_P(ns));
        !          5257: 
        !          5258:                        if (Z_STRLEN_P(ns) != Z_STRLEN_P(CG(current_namespace)) + 1 + Z_STRLEN_P(name) ||
        !          5259:                                memcmp(tmp2, c_ns_name, Z_STRLEN_P(ns))) {
        !          5260:                                zend_error(E_COMPILE_ERROR, "Cannot use %s as %s because the name is already in use", Z_STRVAL_P(ns), Z_STRVAL_P(name));
        !          5261:                        }
        !          5262:                        efree(tmp2);
        !          5263:                }
        !          5264:                efree(c_ns_name);
        !          5265:        } else if (zend_hash_find(CG(class_table), lcname, Z_STRLEN_P(name)+1, (void**)&pce) == SUCCESS &&
        !          5266:                   (*pce)->type == ZEND_USER_CLASS &&
        !          5267:                   (*pce)->filename == CG(compiled_filename)) {
        !          5268:                char *c_tmp = zend_str_tolower_dup(Z_STRVAL_P(ns), Z_STRLEN_P(ns));
        !          5269: 
        !          5270:                if (Z_STRLEN_P(ns) != Z_STRLEN_P(name) ||
        !          5271:                        memcmp(c_tmp, lcname, Z_STRLEN_P(ns))) {
        !          5272:                        zend_error(E_COMPILE_ERROR, "Cannot use %s as %s because the name is already in use", Z_STRVAL_P(ns), Z_STRVAL_P(name));
        !          5273:                }
        !          5274:                efree(c_tmp);
        !          5275:        }
        !          5276: 
        !          5277:        if (zend_hash_add(CG(current_import), lcname, Z_STRLEN_P(name)+1, &ns, sizeof(zval*), NULL) != SUCCESS) {
        !          5278:                zend_error(E_COMPILE_ERROR, "Cannot use %s as %s because the name is already in use", Z_STRVAL_P(ns), Z_STRVAL_P(name));
        !          5279:        }
        !          5280:        if (warn) {
        !          5281:                zend_error(E_WARNING, "The use statement with non-compound name '%s' has no effect", Z_STRVAL_P(name));
        !          5282:        }
        !          5283:        efree(lcname);
        !          5284:        zval_dtor(name);
        !          5285: }
        !          5286: /* }}} */
        !          5287: 
        !          5288: void zend_do_declare_constant(znode *name, znode *value TSRMLS_DC) /* {{{ */
        !          5289: {
        !          5290:        zend_op *opline;
        !          5291: 
        !          5292:        if(Z_TYPE(value->u.constant) == IS_CONSTANT_ARRAY) {
        !          5293:                zend_error(E_COMPILE_ERROR, "Arrays are not allowed as constants");
        !          5294:        }
        !          5295: 
        !          5296:        if (zend_get_ct_const(&name->u.constant, 0 TSRMLS_CC)) {
        !          5297:                zend_error(E_COMPILE_ERROR, "Cannot redeclare constant '%s'", Z_STRVAL(name->u.constant));
        !          5298:        }
        !          5299: 
        !          5300:        if (CG(current_namespace)) {
        !          5301:                /* Prefix constant name with name of current namespace, lowercased */
        !          5302:                znode tmp;
        !          5303: 
        !          5304:                tmp.op_type = IS_CONST;
        !          5305:                tmp.u.constant = *CG(current_namespace);
        !          5306:                Z_STRVAL(tmp.u.constant) = zend_str_tolower_dup(Z_STRVAL(tmp.u.constant), Z_STRLEN(tmp.u.constant));
        !          5307:                zend_do_build_namespace_name(&tmp, &tmp, name TSRMLS_CC);
        !          5308:                *name = tmp;
        !          5309:        }
        !          5310: 
        !          5311:        opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        !          5312:        opline->opcode = ZEND_DECLARE_CONST;
        !          5313:        SET_UNUSED(opline->result);
        !          5314:        opline->op1 = *name;
        !          5315:        opline->op2 = *value;
        !          5316: }
        !          5317: /* }}} */
        !          5318: 
        !          5319: void zend_verify_namespace(TSRMLS_D) /* {{{ */
        !          5320: {
        !          5321:        if (CG(has_bracketed_namespaces) && !CG(in_namespace)) {
        !          5322:                zend_error(E_COMPILE_ERROR, "No code may exist outside of namespace {}");
        !          5323:        }
        !          5324: }
        !          5325: /* }}} */
        !          5326: 
        !          5327: void zend_do_end_namespace(TSRMLS_D) /* {{{ */
        !          5328: {
        !          5329:        CG(in_namespace) = 0;
        !          5330:        if (CG(current_namespace)) {
        !          5331:                zval_dtor(CG(current_namespace));
        !          5332:                FREE_ZVAL(CG(current_namespace));
        !          5333:                CG(current_namespace) = NULL;
        !          5334:        }
        !          5335:        if (CG(current_import)) {
        !          5336:                zend_hash_destroy(CG(current_import));
        !          5337:                efree(CG(current_import));
        !          5338:                CG(current_import) = NULL;
        !          5339:        }
        !          5340:        
        !          5341:        if (CG(doc_comment)) {
        !          5342:                efree(CG(doc_comment));
        !          5343:                CG(doc_comment) = NULL;
        !          5344:                CG(doc_comment_len) = 0;
        !          5345:        }
        !          5346: }
        !          5347: /* }}} */
        !          5348: 
        !          5349: void zend_do_end_compilation(TSRMLS_D) /* {{{ */
        !          5350: {
        !          5351:        CG(has_bracketed_namespaces) = 0;
        !          5352:        zend_do_end_namespace(TSRMLS_C);
        !          5353: }
        !          5354: /* }}} */
        !          5355: 
        !          5356: /* {{{ zend_dirname
        !          5357:    Returns directory name component of path */
        !          5358: ZEND_API size_t zend_dirname(char *path, size_t len)
        !          5359: {
        !          5360:        register char *end = path + len - 1;
        !          5361:        unsigned int len_adjust = 0;
        !          5362: 
        !          5363: #ifdef PHP_WIN32
        !          5364:        /* Note that on Win32 CWD is per drive (heritage from CP/M).
        !          5365:         * This means dirname("c:foo") maps to "c:." or "c:" - which means CWD on C: drive.
        !          5366:         */
        !          5367:        if ((2 <= len) && isalpha((int)((unsigned char *)path)[0]) && (':' == path[1])) {
        !          5368:                /* Skip over the drive spec (if any) so as not to change */
        !          5369:                path += 2;
        !          5370:                len_adjust += 2;
        !          5371:                if (2 == len) {
        !          5372:                        /* Return "c:" on Win32 for dirname("c:").
        !          5373:                         * It would be more consistent to return "c:." 
        !          5374:                         * but that would require making the string *longer*.
        !          5375:                         */
        !          5376:                        return len;
        !          5377:                }
        !          5378:        }
        !          5379: #elif defined(NETWARE)
        !          5380:        /*
        !          5381:         * Find the first occurence of : from the left 
        !          5382:         * move the path pointer to the position just after :
        !          5383:         * increment the len_adjust to the length of path till colon character(inclusive)
        !          5384:         * If there is no character beyond : simple return len
        !          5385:         */
        !          5386:        char *colonpos = NULL;
        !          5387:        colonpos = strchr(path, ':');
        !          5388:        if (colonpos != NULL) {
        !          5389:                len_adjust = ((colonpos - path) + 1);
        !          5390:                path += len_adjust;
        !          5391:                if (len_adjust == len) {
        !          5392:                        return len;
        !          5393:                }
        !          5394:        }
        !          5395: #endif
        !          5396: 
        !          5397:        if (len == 0) {
        !          5398:                /* Illegal use of this function */
        !          5399:                return 0;
        !          5400:        }
        !          5401: 
        !          5402:        /* Strip trailing slashes */
        !          5403:        while (end >= path && IS_SLASH_P(end)) {
        !          5404:                end--;
        !          5405:        }
        !          5406:        if (end < path) {
        !          5407:                /* The path only contained slashes */
        !          5408:                path[0] = DEFAULT_SLASH;
        !          5409:                path[1] = '\0';
        !          5410:                return 1 + len_adjust;
        !          5411:        }
        !          5412: 
        !          5413:        /* Strip filename */
        !          5414:        while (end >= path && !IS_SLASH_P(end)) {
        !          5415:                end--;
        !          5416:        }
        !          5417:        if (end < path) {
        !          5418:                /* No slash found, therefore return '.' */
        !          5419: #ifdef NETWARE
        !          5420:                if (len_adjust == 0) {
        !          5421:                        path[0] = '.';
        !          5422:                        path[1] = '\0';
        !          5423:                        return 1; /* only one character */
        !          5424:                } else {
        !          5425:                        path[0] = '\0';
        !          5426:                        return len_adjust;
        !          5427:                }
        !          5428: #else
        !          5429:                path[0] = '.';
        !          5430:                path[1] = '\0';
        !          5431:                return 1 + len_adjust;
        !          5432: #endif
        !          5433:        }
        !          5434: 
        !          5435:        /* Strip slashes which came before the file name */
        !          5436:        while (end >= path && IS_SLASH_P(end)) {
        !          5437:                end--;
        !          5438:        }
        !          5439:        if (end < path) {
        !          5440:                path[0] = DEFAULT_SLASH;
        !          5441:                path[1] = '\0';
        !          5442:                return 1 + len_adjust;
        !          5443:        }
        !          5444:        *(end+1) = '\0';
        !          5445: 
        !          5446:        return (size_t)(end + 1 - path) + len_adjust;
        !          5447: }
        !          5448: /* }}} */
        !          5449: 
        !          5450: /*
        !          5451:  * Local variables:
        !          5452:  * tab-width: 4
        !          5453:  * c-basic-offset: 4
        !          5454:  * indent-tabs-mode: t
        !          5455:  * End:
        !          5456:  */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>