zend_standard_class_def.name = zend_strndup("stdClass", zend_standard_class_def.name_length);
zend_standard_class_def.parent = NULL;
zend_hash_init_ex(&zend_standard_class_def.default_properties, 0, NULL, ZVAL_PTR_DTOR, 1, 0);
- zend_hash_init_ex(&zend_standard_class_def.static_members, 0, NULL, ZVAL_PTR_DTOR, 1, 0);
+ zend_standard_class_def.static_members = (HashTable *) malloc(sizeof(HashTable));
+ zend_hash_init_ex(zend_standard_class_def.static_members, 0, NULL, ZVAL_PTR_DTOR, 1, 0);
zend_hash_init_ex(&zend_standard_class_def.constants_table, 0, NULL, ZVAL_PTR_DTOR, 1, 0);
zend_hash_init_ex(&zend_standard_class_def.class_table, 10, NULL, ZEND_CLASS_DTOR, 1, 0);
zend_hash_init_ex(&zend_standard_class_def.function_table, 0, NULL, ZEND_FUNCTION_DTOR, 1, 0);
executor_globals = ts_resource(executor_globals_id);
tsrm_ls = ts_resource_ex(0, NULL);
compiler_globals_dtor(compiler_globals, tsrm_ls);
- compiler_globals->function_table = GLOBAL_FUNCTION_TABLE;
- compiler_globals->class_table = GLOBAL_CLASS_TABLE;
+ *compiler_globals->function_table = *GLOBAL_FUNCTION_TABLE;
+ *compiler_globals->class_table = *GLOBAL_CLASS_TABLE;
compiler_globals->auto_globals = GLOBAL_AUTO_GLOBALS_TABLE;
zend_startup_constants(tsrm_ls);
#else
#endif
zend_destroy_rsrc_list_dtors();
zend_hash_destroy(&module_registry);
+#ifndef ZTS
zend_hash_destroy(GLOBAL_FUNCTION_TABLE);
zend_hash_destroy(GLOBAL_CLASS_TABLE);
+#endif
zend_hash_destroy(GLOBAL_AUTO_GLOBALS_TABLE);
free(GLOBAL_AUTO_GLOBALS_TABLE);
zend_shutdown_extensions(TSRMLS_C);
HashTable function_table;
HashTable default_properties;
HashTable class_table;
- HashTable static_members;
+ HashTable *static_members;
HashTable constants_table;
zend_function_entry *builtin_functions;
if (!class_type->constants_updated) {
zend_hash_apply_with_argument(&class_type->default_properties, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
- zend_hash_apply_with_argument(&class_type->static_members, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
+ zend_hash_apply_with_argument(class_type->static_members, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
class_type->constants_updated = 1;
}
*class_entry->refcount = 1;
class_entry->constants_updated = 0;
zend_hash_init(&class_entry->default_properties, 0, NULL, ZVAL_PTR_DTOR, 1);
- zend_hash_init(&class_entry->static_members, 0, NULL, ZVAL_PTR_DTOR, 1);
+ class_entry->static_members = (HashTable *) malloc(sizeof(HashTable));
+ zend_hash_init(class_entry->static_members, 0, NULL, ZVAL_PTR_DTOR, 1);
zend_hash_init(&class_entry->constants_table, 0, NULL, ZVAL_PTR_DTOR, 1);
zend_hash_init(&class_entry->function_table, 0, NULL, ZEND_FUNCTION_DTOR, 1);
zend_hash_init(&class_entry->class_table, 10, NULL, ZEND_CLASS_DTOR, 1);
SET_UNUSED(opline->op2);
opline->extended_value = ZEND_FETCH_CLASS_SELF;
zval_dtor(&class_name->u.constant);
+ } else if ((class_name->u.constant.value.str.len == (sizeof("main") - 1)) &&
+ !memcmp(class_name->u.constant.value.str.val, "main", sizeof("main"))) {
+ SET_UNUSED(opline->op2);
+ opline->extended_value = ZEND_FETCH_CLASS_MAIN;
+ zval_dtor(&class_name->u.constant);
} else {
opline->op2 = *class_name;
}
/* Perform inheritance */
zend_hash_merge(&ce->default_properties, &parent_ce->default_properties, (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0);
/* STATIC_MEMBERS_FIXME */
- zend_hash_merge(&ce->static_members, &parent_ce->static_members, (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0);
+ zend_hash_merge(ce->static_members, parent_ce->static_members, (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0);
zend_hash_merge(&ce->constants_table, &parent_ce->constants_table, (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0);
zend_hash_merge(&ce->function_table, &parent_ce->function_table, (void (*)(void *)) function_add_ref, &tmp_zend_function, sizeof(zend_function), 0);
ce->parent = parent_ce;
(*ce->refcount)--;
zend_hash_destroy(&ce->function_table);
zend_hash_destroy(&ce->default_properties);
- zend_hash_destroy(&ce->static_members);
+ zend_hash_destroy(ce->static_members);
zend_hash_destroy(&ce->constants_table);
return FAILURE;
}
zend_hash_init(&new_class_entry.function_table, 10, NULL, ZEND_FUNCTION_DTOR, 0);
zend_hash_init(&new_class_entry.class_table, 10, NULL, ZEND_CLASS_DTOR, 0);
zend_hash_init(&new_class_entry.default_properties, 10, NULL, ZVAL_PTR_DTOR, 0);
- zend_hash_init(&new_class_entry.static_members, 10, NULL, ZVAL_PTR_DTOR, 0);
+ new_class_entry.static_members = (HashTable *) emalloc(sizeof(HashTable));
+ zend_hash_init(new_class_entry.static_members, 10, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_init(&new_class_entry.constants_table, 10, NULL, ZVAL_PTR_DTOR, 0);
new_class_entry.constructor = NULL;
zend_hash_copy(&new_class_entry.default_properties, &parent_class->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
/* copy static members */
- zend_hash_copy(&new_class_entry.static_members, &parent_class->static_members, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
+ zend_hash_copy(new_class_entry.static_members, parent_class->static_members, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
/* copy constants */
zend_hash_copy(&new_class_entry.constants_table, &parent_class->constants_table, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
zend_hash_update(&CG(active_class_entry)->default_properties, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL);
break;
case T_STATIC:
- zend_hash_update(&CG(active_class_entry)->static_members, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL);
+ zend_hash_update(CG(active_class_entry)->static_members, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL);
break;
case T_CONST:
zend_hash_update(&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);
/* class fetches */
#define ZEND_FETCH_CLASS_DEFAULT 0
#define ZEND_FETCH_CLASS_SELF 1
+#define ZEND_FETCH_CLASS_MAIN 2
/* unset types */
#define ZEND_UNSET_REG 0
target_symbol_table = EG(active_op_array)->static_variables;
break;
case ZEND_FETCH_STATIC_MEMBER:
- target_symbol_table = &Ts[opline->op2.u.var].EA.class_entry->static_members;
+ target_symbol_table = Ts[opline->op2.u.var].EA.class_entry->static_members;
break;
EMPTY_SWITCH_DEFAULT_CASE()
}
}
EX(Ts)[EX(opline)->result.u.var].EA.class_entry = EG(namespace);
NEXT_OPCODE();
+ } else if (EX(opline)->extended_value == ZEND_FETCH_CLASS_MAIN) {
+ EX(Ts)[EX(opline)->result.u.var].EA.class_entry = EG(main_class_ptr);
+ NEXT_OPCODE();
}
class_name = get_zval_ptr(&EX(opline)->op2, EX(Ts), &EG(free_op2), BP_VAR_R);
zval_copy_ctor(this_ptr);
EX(object).ptr = this_ptr;
}
- active_function_table = &Z_OBJCE_P(EX(object).ptr)->function_table;
+ //active_function_table = &Z_OBJCE_P(EX(object).ptr)->function_table;
EX(calling_namespace) = Z_OBJCE_P(EX(object).ptr);
}
if (zend_hash_find(active_function_table, function_name->value.str.val, function_name->value.str.len+1, (void **) &function)==FAILURE) {
if (zend_hash_find(EG(namespace)?&EG(namespace)->function_table:EG(function_table), fname->value.str.val, fname->value.str.len+1, (void **) &EX(function_state).function)==FAILURE) {
zend_error(E_ERROR, "Unknown function: %s()\n", fname->value.str.val);
}
+ EX(calling_namespace) = EG(namespace);
FREE_OP(EX(Ts), &EX(opline)->op1, EG(free_op1));
zend_ptr_stack_push(&EG(arg_types_stack), EX(object).ptr);
EX(object).ptr = NULL;
ce = EX(Ts)[EX(opline)->op1.u.var].EA.class_entry;
+ if (&ce->constants_table == &EG(main_class_ptr)->constants_table) {
+ if (!zend_get_constant(EX(opline)->op2.u.constant.value.str.val, EX(opline)->op2.u.constant.value.str.len, &EX(Ts)[EX(opline)->result.u.var].tmp_var TSRMLS_CC)) {
+ zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
+ EX(opline)->op2.u.constant.value.str.val,
+ EX(opline)->op2.u.constant.value.str.val);
+ EX(Ts)[EX(opline)->result.u.var].tmp_var = EX(opline)->op2.u.constant;
+ zval_copy_ctor(&EX(Ts)[EX(opline)->result.u.var].tmp_var);
+ }
+ NEXT_OPCODE();
+ }
if (zend_hash_find(&ce->constants_table, EX(opline)->op2.u.constant.value.str.val, EX(opline)->op2.u.constant.value.str.len+1, (void **) &value) == SUCCESS) {
zval_update_constant(value, (void *) 1 TSRMLS_CC);
EX(Ts)[EX(opline)->result.u.var].tmp_var = **value;
zend_hash_init(&EG(symbol_table), 50, NULL, ZVAL_PTR_DTOR, 0);
EG(active_symbol_table) = &EG(symbol_table);
-
+
zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_activator TSRMLS_CC);
EG(opline_ptr) = NULL;
EG(garbage_ptr) = 0;
EG(exception) = NULL;
EG(namespace) = NULL;
+
+ EG(main_class_ptr) = &CG(main_class);
+ CG(main_class).static_members = &EG(symbol_table);
+
}
HashTable *zend_constants; /* constants table */
zend_class_entry *namespace;
+ zend_class_entry *main_class_ptr;
long precision;
efree(ce->refcount);
zend_hash_destroy(&ce->function_table);
zend_hash_destroy(&ce->default_properties);
- zend_hash_destroy(&ce->static_members);
+ zend_hash_destroy(ce->static_members);
+ efree(ce->static_members);
zend_hash_destroy(&ce->constants_table);
zend_hash_destroy(&ce->class_table);
break;
free(ce->refcount);
zend_hash_destroy(&ce->function_table);
zend_hash_destroy(&ce->default_properties);
- zend_hash_destroy(&ce->static_members);
+ zend_hash_destroy(ce->static_members);
+ free(ce->static_members);
zend_hash_destroy(&ce->constants_table);
zend_hash_destroy(&ce->class_table);
break;