Permalink
Browse files

- Merge new $_GET, $_POST etc. patch from Engine 1 tree

  • Loading branch information...
andigutmans committed Aug 8, 2001
1 parent 5eb9495 commit 9d11db12002cc4e41efce0f3e9aec3d35b35a6f8
Showing with 40 additions and 1 deletion.
  1. +21 −0 Zend/zend.c
  2. +15 −1 Zend/zend_compile.c
  3. +2 −0 Zend/zend_compile.h
  4. +2 −0 Zend/zend_globals.h
View
@@ -31,10 +31,12 @@
# 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
View
@@ -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;
View
@@ -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
View
@@ -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;

0 comments on commit 9d11db1

Please sign in to comment.