]> granicus.if.org Git - php/commitdiff
- Infrastructure changes for allowing to access the global scope from
authorAndi Gutmans <andi@php.net>
Wed, 12 Dec 2001 20:45:38 +0000 (20:45 +0000)
committerAndi Gutmans <andi@php.net>
Wed, 12 Dec 2001 20:45:38 +0000 (20:45 +0000)
- within a class scope.
- Fix the Zend.dsp project a bit. It seems someone pretty much killed it
- when commiting their own personal configuration. Please be careful in
- future.

Zend/Zend.dsp
Zend/zend.c
Zend/zend_constants.c
Zend/zend_globals.h

index 2a08572e401a1867c4a1c4dd38075f8bc03a5462..03a7bd73e2551c86c65a1e4732fc3a5d8844c3f3 100644 (file)
@@ -183,6 +183,10 @@ SOURCE=.\zend_llist.c
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\zend_objects.c\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\zend_opcode.c\r
 # End Source File\r
 # Begin Source File\r
index 1bd88793954a751b331b37f47b0b97154f46d47a..a6314dfd1bd3626f5c1358c0373e7152556cae20 100644 (file)
@@ -28,9 +28,9 @@
 #include "zend_ini.h"
 
 #ifdef ZTS
-#      define GLOBAL_FUNCTION_TABLE    global_function_table
-#      define GLOBAL_CLASS_TABLE               global_class_table
-#      define GLOBAL_CONSTANTS_TABLE   global_constants_table
+#      define GLOBAL_FUNCTION_TABLE    &global_main_class.function_table
+#      define GLOBAL_CLASS_TABLE               &global_main_class.class_table
+#      define GLOBAL_CONSTANTS_TABLE   &global_main_class.constants_table
 #      define GLOBAL_AUTO_GLOBALS_TABLE        global_auto_globals_table
 #else
 #      define GLOBAL_FUNCTION_TABLE    CG(function_table)
@@ -61,9 +61,7 @@ static int (*zend_get_configuration_directive_p)(char *name, uint name_length, z
 ZEND_API int compiler_globals_id;
 ZEND_API int executor_globals_id;
 ZEND_API int alloc_globals_id;
-HashTable *global_function_table;
-HashTable *global_class_table;
-HashTable *global_constants_table;
+zend_class_entry global_main_class;
 HashTable *global_auto_globals_table;
 #endif
 
@@ -280,13 +278,13 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS
 
        compiler_globals->compiled_filename = NULL;
 
-       compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable));
+       compiler_globals->function_table = &compiler_globals->main_class.function_table;
        zend_hash_init_ex(compiler_globals->function_table, 100, NULL, ZEND_FUNCTION_DTOR, 1, 0);
-       zend_hash_copy(compiler_globals->function_table, global_function_table, NULL, &tmp_func, sizeof(zend_function));
+       zend_hash_copy(compiler_globals->function_table, GLOBAL_FUNCTION_TABLE, NULL, &tmp_func, sizeof(zend_function));
 
-       compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
+       compiler_globals->class_table = &compiler_globals->main_class.class_table;
        zend_hash_init_ex(compiler_globals->class_table, 10, NULL, ZEND_CLASS_DTOR, 1, 0);
-       zend_hash_copy(compiler_globals->class_table, global_class_table, (copy_ctor_func_t) zend_class_add_ref, &tmp_class, sizeof(zend_class_entry));
+       zend_hash_copy(compiler_globals->class_table, GLOBAL_CLASS_TABLE, (copy_ctor_func_t) zend_class_add_ref, &tmp_class, sizeof(zend_class_entry));
 
        zend_set_default_compile_time_values(TSRMLS_C);
 
@@ -300,13 +298,11 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS
 
 static void compiler_globals_dtor(zend_compiler_globals *compiler_globals TSRMLS_DC)
 {
-       if (compiler_globals->function_table != global_function_table) {
+       if (compiler_globals->function_table != GLOBAL_FUNCTION_TABLE) {
                zend_hash_destroy(compiler_globals->function_table);
-               free(compiler_globals->function_table);
        }
-       if (compiler_globals->class_table != global_class_table) {
+       if (compiler_globals->class_table != GLOBAL_CLASS_TABLE) {
                zend_hash_destroy(compiler_globals->class_table);
-               free(compiler_globals->class_table);
        }
        if (compiler_globals->auto_globals != global_auto_globals_table) {
                zend_hash_destroy(compiler_globals->auto_globals);
@@ -317,9 +313,9 @@ static void compiler_globals_dtor(zend_compiler_globals *compiler_globals TSRMLS
 
 static void executor_globals_ctor(zend_executor_globals *executor_globals TSRMLS_DC)
 {
-       if (global_constants_table) {
+       if (GLOBAL_CONSTANTS_TABLE) {
                zend_startup_constants(TSRMLS_C);
-               zend_copy_constants(EG(zend_constants), global_constants_table);
+               zend_copy_constants(EG(zend_constants), GLOBAL_CONSTANTS_TABLE);
        }
        zend_init_rsrc_plist(TSRMLS_C);
        EG(lambda_count)=0;
@@ -424,8 +420,10 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
        zend_version_info = strdup(ZEND_CORE_VERSION_INFO);
        zend_version_info_length = sizeof(ZEND_CORE_VERSION_INFO)-1;
 
-       GLOBAL_FUNCTION_TABLE = (HashTable *) malloc(sizeof(HashTable));
-       GLOBAL_CLASS_TABLE = (HashTable *) malloc(sizeof(HashTable));
+#ifndef ZTS
+       GLOBAL_FUNCTION_TABLE = &compiler_globals.main_class.function_table;
+       GLOBAL_CLASS_TABLE = &compiler_globals.main_class.class_table;
+#endif
        GLOBAL_AUTO_GLOBALS_TABLE = (HashTable *) malloc(sizeof(HashTable));
        zend_hash_init_ex(GLOBAL_FUNCTION_TABLE, 100, NULL, ZEND_FUNCTION_DTOR, 1, 0);
        zend_hash_init_ex(GLOBAL_CLASS_TABLE, 10, NULL, ZEND_CLASS_DTOR, 1, 0);
@@ -441,7 +439,6 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
        zval_used_for_init.type = IS_NULL;
 
 #ifdef ZTS
-       global_constants_table = NULL;
        ts_allocate_id(&compiler_globals_id, sizeof(zend_compiler_globals), (ts_allocate_ctor) compiler_globals_ctor, (ts_allocate_dtor) compiler_globals_dtor);
        ts_allocate_id(&executor_globals_id, sizeof(zend_executor_globals), (ts_allocate_ctor) executor_globals_ctor, (ts_allocate_dtor) executor_globals_dtor);
        ts_allocate_id(&language_scanner_globals_id, sizeof(zend_scanner_globals), (ts_allocate_ctor) scanner_globals_ctor, NULL);
@@ -454,7 +451,6 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
        compiler_globals->class_table = GLOBAL_CLASS_TABLE;
        compiler_globals->auto_globals = GLOBAL_AUTO_GLOBALS_TABLE;
        zend_startup_constants(tsrm_ls);
-       GLOBAL_CONSTANTS_TABLE = EG(zend_constants);
 #else
        zend_hash_init_ex(CG(auto_globals), 8, NULL, NULL, 1, 0);
        scanner_globals_ctor(&ini_scanner_globals TSRMLS_CC);
@@ -494,9 +490,7 @@ void zend_shutdown(TSRMLS_D)
        zend_destroy_rsrc_list_dtors();
        zend_hash_destroy(&module_registry);
        zend_hash_destroy(GLOBAL_FUNCTION_TABLE);
-       free(GLOBAL_FUNCTION_TABLE);
        zend_hash_destroy(GLOBAL_CLASS_TABLE);
-       free(GLOBAL_CLASS_TABLE);
        zend_hash_destroy(GLOBAL_AUTO_GLOBALS_TABLE);
        free(GLOBAL_AUTO_GLOBALS_TABLE);
        zend_shutdown_extensions(TSRMLS_C);
index b0169d72e1ae88c83dfda5d0488528e053917c39..8976543d52f9267d05e8ef4320f92aecffc9b168 100644 (file)
@@ -90,7 +90,7 @@ int zend_startup_constants(TSRMLS_D)
        DWORD dwWindowsMinorVersion =  (DWORD)(HIBYTE(LOWORD(dwVersion)));
 #endif
 
-       EG(zend_constants) = (HashTable *) malloc(sizeof(HashTable));
+       EG(zend_constants) = &CG(main_class).constants_table;
 
        if (zend_hash_init(EG(zend_constants), 20, NULL, ZEND_CONSTANT_DTOR, 1)==FAILURE) {
                return FAILURE;
@@ -153,7 +153,6 @@ void zend_register_standard_constants(TSRMLS_D)
 int zend_shutdown_constants(TSRMLS_D)
 {
        zend_hash_destroy(EG(zend_constants));
-       free(EG(zend_constants));
        return SUCCESS;
 }
 
index a360d5043676e1a5482b3035a9d1701c6088cdf3..d6001aac43c6714116e5918a97157ead433b0c8b 100644 (file)
@@ -85,6 +85,7 @@ struct _zend_compiler_globals {
 
        zend_op_array *active_op_array;
 
+       zend_class_entry main_class;
        HashTable *function_table;      /* function symbol table */
        HashTable *class_table;         /* class table */