]> granicus.if.org Git - php/commitdiff
- Merge new $_GET, $_POST etc. patch from Engine 1 tree
authorAndi Gutmans <andi@php.net>
Wed, 8 Aug 2001 17:18:16 +0000 (17:18 +0000)
committerAndi Gutmans <andi@php.net>
Wed, 8 Aug 2001 17:18:16 +0000 (17:18 +0000)
Zend/zend.c
Zend/zend_compile.c
Zend/zend_compile.h
Zend/zend_globals.h

index c732db54db7f47512e43b735f28c1b645ef5218d..8b59cc0d688cf9e3d87446b84395c6185bd3d143 100644 (file)
 #      define GLOBAL_FUNCTION_TABLE    global_function_table
 #      define GLOBAL_CLASS_TABLE               global_class_table
 #      define GLOBAL_CONSTANTS_TABLE   global_constants_table
+#      define GLOBAL_AUTO_GLOBALS_TABLE        global_auto_globals_table
 #else
 #      define GLOBAL_FUNCTION_TABLE    CG(function_table)
 #      define GLOBAL_CLASS_TABLE               CG(class_table)
 #      define GLOBAL_CONSTANTS_TABLE   CG(zend_constants)
+#      define GLOBAL_AUTO_GLOBALS_TABLE        CG(auto_globals)
 #endif
 
 #if defined(ZEND_WIN32) && ZEND_DEBUG
@@ -62,6 +64,7 @@ ZEND_API int alloc_globals_id;
 HashTable *global_function_table;
 HashTable *global_class_table;
 HashTable *global_constants_table;
+HashTable *global_auto_globals_table;
 #endif
 
 zend_utility_values zend_uv;
@@ -283,6 +286,14 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS
        zend_set_default_compile_time_values(TSRMLS_C);
 
        CG(interactive) = 0;
+
+       compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
+       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));
+
+       compiler_globals->auto_globals = (HashTable *) malloc(sizeof(HashTable));
+       zend_hash_init_ex(compiler_globals->auto_globals, 8, NULL, NULL, 1, 0);
+       zend_hash_copy(compiler_globals->auto_globals, global_auto_globals_table, NULL, NULL, sizeof(void *) /* empty element */);
 }
 
 
@@ -296,6 +307,10 @@ static void compiler_globals_dtor(zend_compiler_globals *compiler_globals TSRMLS
                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);
+               free(compiler_globals->auto_globals);
+       }
 }
 
 
@@ -405,8 +420,10 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
 
        GLOBAL_FUNCTION_TABLE = (HashTable *) malloc(sizeof(HashTable));
        GLOBAL_CLASS_TABLE = (HashTable *) malloc(sizeof(HashTable));
+       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);
+       zend_hash_init_ex(GLOBAL_AUTO_GLOBALS_TABLE, 8, NULL, NULL, 1, 0);
        register_standard_class();
        zend_hash_init_ex(&module_registry, 50, NULL, ZEND_MODULE_DTOR, 1, 0);
        zend_init_rsrc_list_dtors();
@@ -428,9 +445,11 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
        compiler_globals_dtor(compiler_globals, tsrm_ls);
        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);
        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);
        scanner_globals_ctor(&language_scanner_globals TSRMLS_CC);
        zend_startup_constants();
@@ -471,6 +490,8 @@ void zend_shutdown(TSRMLS_D)
        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);
        free(zend_version_info);
 #ifndef ZTS
index c0f068a4099d2a1526691098b3f111d61460c794..1679443b7f46db1e595fcb1015bf50a6982633a7 100644 (file)
@@ -226,7 +226,14 @@ void fetch_simple_variable_ex(znode *result, znode *varname, int bp, int op TSRM
        opline_ptr->op1 = *varname;
        *result = opline_ptr->result;
        SET_UNUSED(opline_ptr->op2);
-       opline_ptr->op2.u.fetch_type = ZEND_FETCH_LOCAL;
+
+       if (varname->op_type == IS_CONST
+               && varname->u.constant.type == IS_STRING
+               && zend_hash_exists(CG(auto_globals), varname->u.constant.value.str.val, varname->u.constant.value.str.len+1)) {
+               opline_ptr->op2.u.fetch_type = ZEND_FETCH_GLOBAL;
+       } else {
+               opline_ptr->op2.u.fetch_type = ZEND_FETCH_LOCAL;
+       }
 
        if (bp) {
                zend_stack_top(&CG(bp_stack), (void **) &fetch_list_ptr);
@@ -2366,6 +2373,7 @@ void zend_do_extended_fcall_end(TSRMLS_D)
        SET_UNUSED(opline->op2);
 }
 
+
 void zend_do_ticks(TSRMLS_D)
 {
        if (CG(declarables).ticks.value.lval) {
@@ -2379,6 +2387,12 @@ void zend_do_ticks(TSRMLS_D)
 }
 
 
+int zend_register_auto_global(char *name, uint name_len TSRMLS_DC)
+{
+       return zend_hash_add_empty_element(CG(auto_globals), name, name_len+1);
+}
+
+
 int zendlex(znode *zendlval TSRMLS_DC)
 {
        int retval;
index 4089309d625ece078fcb7845c26a850b3cd76089..914c7d458dbbff5a8108db2375f99f741e3ee15a 100644 (file)
@@ -391,6 +391,8 @@ zend_brk_cont_element *get_next_brk_cont_element(zend_op_array *op_array);
 ZEND_API zend_bool zend_is_compiling(TSRMLS_D);
 ZEND_API char *zend_make_compiled_string_description(char *name TSRMLS_DC);
 
+int zend_register_auto_global(char *name, uint name_len TSRMLS_DC);
+
 int zendlex(znode *zendlval TSRMLS_DC);
 
 #define ZEND_NOP                                       0
index 2e649d0eca0ae1607be878adb4b14f33f3339f9d..24b1f0442eb87d2ee659e27bfa9ca0feb578dba9 100644 (file)
@@ -94,6 +94,8 @@ struct _zend_compiler_globals {
 
        HashTable filenames_table;
 
+       HashTable *auto_globals;
+
        zend_bool in_compilation;
        zend_bool short_tags;
        zend_bool asp_tags;