- Nuke the namespace work I did. It'll be redone differently.

This commit is contained in:
Andi Gutmans 2001-12-06 17:23:08 +00:00
parent 75b47ad142
commit fe94f59427
6 changed files with 6 additions and 59 deletions

View File

@ -32,13 +32,11 @@
# define GLOBAL_CLASS_TABLE global_class_table
# define GLOBAL_CONSTANTS_TABLE global_constants_table
# define GLOBAL_AUTO_GLOBALS_TABLE global_auto_globals_table
# define GLOBAL_NAMESPACES_TABLE global_namespaces_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)
# define GLOBAL_NAMESPACES_TABLE CG(namespaces)
#endif
#if defined(ZEND_WIN32) && ZEND_DEBUG
@ -67,7 +65,6 @@ HashTable *global_function_table;
HashTable *global_class_table;
HashTable *global_constants_table;
HashTable *global_auto_globals_table;
HashTable *global_namespaces_table;
#endif
zend_utility_values zend_uv;
@ -434,21 +431,9 @@ 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));
GLOBAL_NAMESPACES_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);
zend_hash_init_ex(GLOBAL_NAMESPACES_TABLE, 8, NULL, NULL, 1, 0);
{
zend_namespace main_namespace;
main_namespace.type = INTERNAL_NAMESPACE;
main_namespace.class_table = GLOBAL_CLASS_TABLE;
main_namespace.function_table = GLOBAL_FUNCTION_TABLE;
zend_hash_update(GLOBAL_NAMESPACES_TABLE, "", sizeof(""), &main_namespace, sizeof(zend_namespace), NULL);
}
register_standard_class();
zend_hash_init_ex(&module_registry, 50, NULL, ZEND_MODULE_DTOR, 1, 0);
@ -472,7 +457,6 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
compiler_globals->function_table = GLOBAL_FUNCTION_TABLE;
compiler_globals->class_table = GLOBAL_CLASS_TABLE;
compiler_globals->auto_globals = GLOBAL_AUTO_GLOBALS_TABLE;
compiler_globals->namespaces = GLOBAL_NAMESPACES_TABLE;
zend_startup_constants(tsrm_ls);
GLOBAL_CONSTANTS_TABLE = EG(zend_constants);
#else
@ -519,8 +503,6 @@ void zend_shutdown(TSRMLS_D)
free(GLOBAL_CLASS_TABLE);
zend_hash_destroy(GLOBAL_AUTO_GLOBALS_TABLE);
free(GLOBAL_AUTO_GLOBALS_TABLE);
zend_hash_destroy(GLOBAL_NAMESPACES_TABLE);
free(GLOBAL_NAMESPACES_TABLE);
zend_shutdown_extensions(TSRMLS_C);
free(zend_version_info);
#ifndef ZTS

View File

@ -2445,41 +2445,11 @@ void zend_do_end_heredoc(TSRMLS_D)
void do_namespace(znode *namespace TSRMLS_DC)
{
zend_namespace *namespace_ptr;
zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
if (CG(namespace)) {
efree(CG(namespace));
}
CG(namespace) = namespace->u.constant.value.str.val;
CG(namespace_len) = namespace->u.constant.value.str.len;
opline->opcode = ZEND_NAMESPACE;
zval_copy_ctor(&namespace->u.constant);
opline->op1 = *namespace;
SET_UNUSED(opline->op2);
if (zend_hash_find(CG(namespaces), CG(namespace), CG(namespace_len)+1, (void **) &namespace_ptr) == FAILURE) {
zend_namespace new_namespace;
HashTable *new_function_table;
HashTable *new_class_table;
new_function_table = (HashTable *) malloc(sizeof(HashTable));
new_class_table = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init_ex(new_function_table, 100, NULL, ZEND_FUNCTION_DTOR, 1, 0);
zend_hash_init_ex(new_class_table, 10, NULL, ZEND_CLASS_DTOR, 1, 0);
new_namespace.type = USER_NAMESPACE;
new_namespace.function_table = new_function_table;
new_namespace.class_table = new_class_table;
zend_hash_update(CG(namespaces), CG(namespace), CG(namespace_len)+1, &new_namespace, sizeof(zend_namespace), NULL);
CG(function_table) = new_function_table;
CG(class_table) = new_class_table;
} else {
CG(function_table) = namespace_ptr->function_table;
CG(class_table) = namespace_ptr->class_table;
}
}

View File

@ -1806,13 +1806,6 @@ do_fcall_common:
NEXT_OPCODE();
case ZEND_NAMESPACE:
{
zend_namespace *namespace_ptr;
if (zend_hash_find(EG(namespaces), EX(opline)->op1.u.constant.value.str.val, EX(opline)->op1.u.constant.value.str.len + 1, (void **) &namespace_ptr) == FAILURE) {
zend_error(E_ERROR, "Internal namespaces error. Please report this!");
}
EG(function_table) = namespace_ptr->function_table;
EG(class_table) = namespace_ptr->class_table;
NEXT_OPCODE();
}
case ZEND_SEND_VAL:

View File

@ -129,7 +129,6 @@ void init_executor(TSRMLS_D)
EG(function_table) = CG(function_table);
EG(class_table) = CG(class_table);
EG(namespaces) = CG(namespaces);
EG(in_execution) = 0;

View File

@ -87,7 +87,6 @@ struct _zend_compiler_globals {
HashTable *function_table; /* function symbol table */
HashTable *class_table; /* class table */
HashTable *namespaces;
HashTable filenames_table;
@ -158,7 +157,6 @@ struct _zend_executor_globals {
HashTable *function_table; /* function symbol table */
HashTable *class_table; /* class table */
HashTable *zend_constants; /* constants table */
HashTable *namespaces;
long precision;

View File

@ -209,7 +209,7 @@ unticked_statement:
T_CATCH '(' T_VARIABLE ')' { zend_do_begin_catch(&$1, &$8 TSRMLS_CC); } '{' inner_statement_list '}' { zend_do_end_catch(&$1 TSRMLS_CC); }
| T_THROW expr ';' { zend_do_throw(&$2 TSRMLS_CC); }
| T_DELETE cvar ';' { zend_do_end_variable_parse(BP_VAR_UNSET, 0 TSRMLS_CC); zend_do_unset(&$1, ZEND_UNSET_OBJ TSRMLS_CC); }
| T_NAMESPACE T_STRING { do_namespace(&$2 TSRMLS_CC); }
| T_NAMESPACE namespace_class_entry { do_namespace(&$2 TSRMLS_CC); }
;
unset_variables:
@ -526,6 +526,11 @@ parse_class_name_entry:
| T_STRING T_PAAMAYIM_NEKUDOTAYIM { $$ = $1; }
;
namespace_class_entry:
parse_class_entry T_STRING { do_fetch_class(&$$, &$1, &$2 TSRMLS_CC); }
| T_STRING { do_fetch_class(&$$, NULL, &$1 TSRMLS_CC); }
;
new_class_entry:
parse_class_entry static_or_variable_string { do_fetch_class(&$$, &$1, &$2 TSRMLS_CC); }
| static_or_variable_string { do_fetch_class(&$$, NULL, &$1 TSRMLS_CC); }