# 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
HashTable *global_function_table;
HashTable *global_class_table;
HashTable *global_constants_table;
+HashTable *global_auto_globals_table;
#endif
zend_utility_values zend_uv;
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 */);
}
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);
+ }
}
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();
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();
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
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);
SET_UNUSED(opline->op2);
}
+
void zend_do_ticks(TSRMLS_D)
{
if (CG(declarables).ticks.value.lval) {
}
+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;