diff options
author | Stanislav Malyshev <stas@php.net> | 2003-02-16 11:12:43 +0000 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2003-02-16 11:12:43 +0000 |
commit | a4c3b2ce807dec309812cfe72c91a597c8476113 (patch) | |
tree | df2e8a0aa85b595abf66f0c7b476471c3749fc11 /Zend/zend_execute_API.c | |
parent | 0a18a9d744afb9d97d46bad1f40c11a047bad5df (diff) | |
download | php-git-a4c3b2ce807dec309812cfe72c91a597c8476113.tar.gz |
Namespace patch. Big changes:
1. Nested classes are gone.
2. New syntax for namespaces:
namespace foo {
class X { ... }
function bar { ... }
var x = 1;
const ZZ = 2;
}
3. Namespaced symbol access: $x = new foo::X; - etc.
For now, namespaces are case insensitive, just like classes.
Also, there can be no global class and namespace with the same name
(to avoid ambiguities in :: resolution).
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r-- | Zend/zend_execute_API.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 275278e29d..77d43788e2 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -177,9 +177,10 @@ void init_executor(TSRMLS_D) EG(exception) = NULL; EG(scope) = NULL; + EG(active_namespace) = &CG(global_namespace); - EG(main_class_ptr) = &CG(main_class); - CG(main_class).static_members = &EG(symbol_table); + EG(global_namespace_ptr) = &CG(global_namespace); + CG(global_namespace).static_members = &EG(symbol_table); EG(current_execute_data) = NULL; @@ -191,6 +192,11 @@ void init_executor(TSRMLS_D) void shutdown_executor(TSRMLS_D) { + /* return to global namespace here */ + if(EG(active_namespace) != EG(global_namespace_ptr)) { + zend_switch_namespace(EG(global_namespace_ptr)); + } + zend_try { zend_ptr_stack_destroy(&EG(arg_types_stack)); @@ -531,7 +537,7 @@ int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *fun zend_class_entry *current_scope; zend_class_entry *calling_scope = NULL; zval *current_this; - + zend_namespace *current_namespace = EG(active_namespace); zend_execute_data execute_data; /* Initialize execute_data */ @@ -708,6 +714,7 @@ int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *fun } zend_ptr_stack_clear_multiple(TSRMLS_C); EG(function_state_ptr) = original_function_state_ptr; + EG(active_namespace) = current_namespace; if (EG(This)) { zval_ptr_dtor(&EG(This)); @@ -727,11 +734,6 @@ ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry *** zval *retval_ptr; int retval; - if (EG(scope)) { - if (zend_hash_find(&EG(scope)->class_table, name, name_length+1, (void **) ce) == SUCCESS) { - return SUCCESS; - } - } if (zend_hash_find(EG(class_table), name, name_length+1, (void **) ce) == SUCCESS) { return SUCCESS; } @@ -1037,6 +1039,17 @@ void zend_unset_timeout(TSRMLS_D) #endif } +void zend_switch_namespace(zend_namespace *ns TSRMLS_DC) +{ + if(NULL == ns) { + return; + } + EG(active_namespace) = ns; + EG(function_table) = &ns->function_table; + EG(class_table) = &ns->class_table; +/* EG(zend_constants) = &ns->constants_table; */ +} + /* * Local variables: * tab-width: 4 |