Permalink
Browse files

- make class tables contain class_entry *, not class_entry

- fix isset($this)
  • Loading branch information...
1 parent bcdf9b3 commit 92dd5e611b897bdca8ba27cbfcdc0fc3d7416c85 @smalyshev smalyshev committed Mar 12, 2002
Showing with 196 additions and 148 deletions.
  1. +24 −22 Zend/zend.c
  2. +1 −1 Zend/zend.h
  3. +17 −10 Zend/zend_API.c
  4. +14 −6 Zend/zend_builtin_functions.c
  5. +98 −86 Zend/zend_compile.c
  6. +1 −1 Zend/zend_compile.h
  7. +34 −19 Zend/zend_execute.c
  8. +2 −2 Zend/zend_execute_API.c
  9. +5 −1 Zend/zend_opcode.c
View
@@ -44,7 +44,7 @@ BOOL WINAPI IsDebuggerPresent(VOID);
#endif
/* true multithread-shared globals */
-ZEND_API zend_class_entry zend_standard_class_def;
+ZEND_API zend_class_entry *zend_standard_class_def = NULL;
ZEND_API int (*zend_printf)(const char *format, ...);
ZEND_API zend_write_func_t zend_write;
ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path);
@@ -148,7 +148,7 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
break;
case IS_OBJECT:
expr_copy->value.str.val = (char *) emalloc(sizeof("Object id #")-1 + MAX_LENGTH_OF_LONG);
- expr_copy->value.str.len = sprintf(expr_copy->value.str.val, "Object id #%ld", expr->value.obj.handle);
+ expr_copy->value.str.len = sprintf(expr_copy->value.str.val, "Object id #%ld", (long)expr->value.obj.handle);
#if 0
/* FIXME: This might break BC for some people */
expr_copy->value.str.len = sizeof("Object")-1;
@@ -246,26 +246,28 @@ static FILE *zend_fopen_wrapper(const char *filename, char **opened_path)
static void register_standard_class(void)
{
- zend_standard_class_def.type = ZEND_INTERNAL_CLASS;
- zend_standard_class_def.name_length = sizeof("stdClass") - 1;
- 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.private_properties, 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);
- zend_standard_class_def.constructor = NULL;
- zend_standard_class_def.destructor = NULL;
- zend_standard_class_def.clone = NULL;
- zend_standard_class_def.handle_function_call = NULL;
- zend_standard_class_def.handle_property_get = NULL;
- zend_standard_class_def.handle_property_set = NULL;
- zend_standard_class_def.refcount = (int *) malloc(sizeof(int));
- *zend_standard_class_def.refcount = 1;
- zend_hash_add(GLOBAL_CLASS_TABLE, "stdclass", sizeof("stdclass"), &zend_standard_class_def, sizeof(zend_class_entry), NULL);
+ zend_standard_class_def = malloc(sizeof(zend_class_entry));
+
+ zend_standard_class_def->type = ZEND_INTERNAL_CLASS;
+ zend_standard_class_def->name_length = sizeof("stdClass") - 1;
+ 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->private_properties, 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);
+ zend_standard_class_def->constructor = NULL;
+ zend_standard_class_def->destructor = NULL;
+ zend_standard_class_def->clone = NULL;
+ zend_standard_class_def->handle_function_call = NULL;
+ zend_standard_class_def->handle_property_get = NULL;
+ zend_standard_class_def->handle_property_set = NULL;
+ zend_standard_class_def->refcount = (int *) malloc(sizeof(int));
+ *zend_standard_class_def->refcount = 1;
+ zend_hash_add(GLOBAL_CLASS_TABLE, "stdclass", sizeof("stdclass"), &zend_standard_class_def, sizeof(zend_class_entry *), NULL);
}
View
@@ -428,7 +428,7 @@ ZEND_API void zend_error(int type, const char *format, ...);
void zenderror(char *error);
-extern ZEND_API zend_class_entry zend_standard_class_def;
+extern ZEND_API zend_class_entry *zend_standard_class_def;
extern zend_utility_values zend_uv;
extern ZEND_API zval zval_used_for_init;
View
@@ -1202,9 +1202,12 @@ ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *cla
zend_class_entry *register_class;
if (!parent_ce && parent_name) {
- if (zend_hash_find(CG(class_table), parent_name, strlen(parent_name)+1, (void **) &parent_ce)==FAILURE) {
- return NULL;
- }
+ zend_class_entry **pce;
+ if (zend_hash_find(CG(class_table), parent_name, strlen(parent_name)+1, (void **) &pce)==FAILURE) {
+ return NULL;
+ } else {
+ parent_ce = *pce;
+ }
}
register_class = zend_register_internal_class(class_entry TSRMLS_CC);
@@ -1215,10 +1218,11 @@ ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *cla
return register_class;
}
-ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry TSRMLS_DC)
+ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *orig_class_entry TSRMLS_DC)
{
- zend_class_entry *register_class;
- char *lowercase_name = zend_strndup(class_entry->name, class_entry->name_length);
+ zend_class_entry *class_entry = malloc(sizeof(zend_class_entry));
+ char *lowercase_name = zend_strndup(orig_class_entry->name, orig_class_entry->name_length);
+ *class_entry = *orig_class_entry;
zend_str_tolower(lowercase_name, class_entry->name_length);
@@ -1239,9 +1243,9 @@ ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_
zend_register_functions(class_entry->builtin_functions, &class_entry->function_table, MODULE_PERSISTENT TSRMLS_CC);
}
- zend_hash_update(CG(class_table), lowercase_name, class_entry->name_length+1, class_entry, sizeof(zend_class_entry), (void **) &register_class);
+ zend_hash_update(CG(class_table), lowercase_name, class_entry->name_length+1, &class_entry, sizeof(zend_class_entry *), NULL);
free(lowercase_name);
- return register_class;
+ return class_entry;
}
@@ -1327,7 +1331,7 @@ zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char **callabl
{
zval **method;
zval **obj;
- zend_class_entry *ce = NULL;
+ zend_class_entry *ce = NULL, **pce;
char callable_name_len;
if (zend_hash_num_elements(Z_ARRVAL_P(callable)) == 2 &&
@@ -1354,7 +1358,10 @@ zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char **callabl
lcname = estrndup(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj));
zend_str_tolower(lcname, Z_STRLEN_PP(obj));
- zend_hash_find(EG(class_table), lcname, Z_STRLEN_PP(obj) + 1, (void**)&ce);
+ if(zend_hash_find(EG(class_table), lcname, Z_STRLEN_PP(obj) + 1, (void**)&pce) == SUCCESS) {
+ ce = *pce;
+ }
+
efree(lcname);
} else {
ce = Z_OBJCE_PP(obj); /* ??? */
@@ -532,9 +532,13 @@ ZEND_FUNCTION(get_parent_class)
}
RETURN_STRINGL(name, name_length, 1);
} else if (Z_TYPE_PP(arg) == IS_STRING) {
+ zend_class_entry **pce;
+
SEPARATE_ZVAL(arg);
zend_str_tolower(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg));
- zend_hash_find(EG(class_table), Z_STRVAL_PP(arg), Z_STRLEN_PP(arg)+1, (void **)&ce);
+ if(zend_hash_find(EG(class_table), Z_STRVAL_PP(arg), Z_STRLEN_PP(arg)+1, (void **)&pce) == SUCCESS) {
+ ce = *pce;
+ }
}
if (ce && ce->parent) {
@@ -609,7 +613,7 @@ ZEND_FUNCTION(get_class_vars)
{
zval **class_name;
char *lcname;
- zend_class_entry *ce;
+ zend_class_entry *ce, **pce;
zval *tmp;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &class_name)==FAILURE) {
@@ -620,10 +624,11 @@ ZEND_FUNCTION(get_class_vars)
lcname = estrndup((*class_name)->value.str.val, (*class_name)->value.str.len);
zend_str_tolower(lcname, (*class_name)->value.str.len);
- if (zend_hash_find(EG(class_table), lcname, (*class_name)->value.str.len+1, (void **)&ce)==FAILURE) {
+ if (zend_hash_find(EG(class_table), lcname, (*class_name)->value.str.len+1, (void **)&pce) == FAILURE) {
efree(lcname);
RETURN_FALSE;
} else {
+ ce = *pce;
efree(lcname);
array_init(return_value);
if (!ce->constants_updated) {
@@ -667,7 +672,7 @@ ZEND_FUNCTION(get_class_methods)
{
zval **class;
zval *method_name;
- zend_class_entry *ce = NULL;
+ zend_class_entry *ce = NULL, **pce;
char *string_key;
ulong num_key;
int key_type;
@@ -685,7 +690,9 @@ ZEND_FUNCTION(get_class_methods)
} else if (Z_TYPE_PP(class) == IS_STRING) {
SEPARATE_ZVAL(class);
zend_str_tolower(Z_STRVAL_PP(class), Z_STRLEN_PP(class));
- zend_hash_find(EG(class_table), Z_STRVAL_PP(class), Z_STRLEN_PP(class)+1, (void **)&ce);
+ if(zend_hash_find(EG(class_table), Z_STRVAL_PP(class), Z_STRLEN_PP(class)+1, (void **)&pce) == SUCCESS) {
+ ce = *pce;
+ }
}
if (!ce) {
@@ -926,9 +933,10 @@ ZEND_FUNCTION(restore_error_handler)
}
-static int copy_class_name(zend_class_entry *ce, int num_args, va_list args, zend_hash_key *hash_key)
+static int copy_class_name(zend_class_entry **pce, int num_args, va_list args, zend_hash_key *hash_key)
{
zval *array = va_arg(args, zval *);
+ zend_class_entry *ce = *pce;
if (hash_key->nKeyLength==0 || hash_key->arKey[0]!=0) {
add_next_index_stringl(array, ce->name, ce->name_length, 1);
Oops, something went wrong.

0 comments on commit 92dd5e6

Please sign in to comment.