summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>1999-04-12 19:40:48 +0000
committerZeev Suraski <zeev@php.net>1999-04-12 19:40:48 +0000
commit714f450a0047fe66024c2fc46fd084eadc063c0e (patch)
treee2eb0fdfda916ea8b55d5f08fd6e8b12bb993e7f
parent0666083907bc8e7070b34d339bfe12c69e0cd9fe (diff)
downloadphp-git-714f450a0047fe66024c2fc46fd084eadc063c0e.tar.gz
This should take care of "this" for user-defined functions. It wasn't yet working
for built-in functions anyway, this one is coming soon.
-rw-r--r--Zend/zend_execute.c48
1 files changed, 21 insertions, 27 deletions
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index bf868a04ae..ee07642c2d 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -1307,42 +1307,26 @@ overloaded_function_call_cont:
zend_ptr_stack_push(&EG(arg_types_stack), function_being_called);
FREE_OP(&opline->op2, free_op2);
}
- goto init_by_name_cont;
break;
case ZEND_INIT_FCALL:
object_ptr=NULL;
function_being_called=NULL;
-init_by_name_cont:
-#if 0
- if (object_ptr && function_being_called && function_being_called->type!=ZEND_OVERLOADED_FUNCTION) {
- zval *dummy = (zval *) emalloc(sizeof(zval)), **this_ptr;
-
- var_uninit(dummy);
- dummy->refcount=1;
- dummy->is_ref=0;
- zend_hash_update_ptr(function_state.function_symbol_table, "this", sizeof("this"), dummy, sizeof(zval *), (void **) &this_ptr);
- zend_assign_to_variable_reference(NULL, this_ptr, object_ptr, NULL ELS_CC);
- object_ptr = NULL;
- }
-#endif
break;
- case ZEND_DO_FCALL:
- if (function_being_called) {
- function_state.function = function_being_called;
- } else {
- zval *fname = get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R);
-
- if (zend_hash_find(EG(function_table), fname->value.str.val, fname->value.str.len+1, (void **) &function_state.function)==FAILURE) {
- zend_error(E_ERROR, "Unknown function: %s()\n", fname->value.str.val);
- }
- FREE_OP(&opline->op1, free_op1);
- }
- {
+ case ZEND_DO_FCALL: {
zval *original_return_value;
-
+
if (function_being_called) {
function_being_called = zend_ptr_stack_pop(&EG(arg_types_stack));
+ function_state.function = function_being_called;
+ } else {
+ zval *fname = get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R);
+
+ if (zend_hash_find(EG(function_table), fname->value.str.val, fname->value.str.len+1, (void **) &function_state.function)==FAILURE) {
+ zend_error(E_ERROR, "Unknown function: %s()\n", fname->value.str.val);
+ }
+ FREE_OP(&opline->op1, free_op1);
}
+
calling_symbol_table = EG(active_symbol_table);
zend_ptr_stack_push(&EG(argument_stack), (void *) opline->extended_value);
if (function_state.function->type==ZEND_INTERNAL_FUNCTION) {
@@ -1358,6 +1342,16 @@ init_by_name_cont:
//printf("Cache miss! Initialized %x\n", function_state.function_symbol_table);
}
EG(active_symbol_table) = function_state.function_symbol_table;
+ if (object_ptr && function_being_called && function_being_called->type!=ZEND_OVERLOADED_FUNCTION) {
+ zval *dummy = (zval *) emalloc(sizeof(zval)), **this_ptr;
+
+ var_uninit(dummy);
+ dummy->refcount=1;
+ dummy->is_ref=0;
+ zend_hash_update_ptr(function_state.function_symbol_table, "this", sizeof("this"), dummy, sizeof(zval *), (void **) &this_ptr);
+ zend_assign_to_variable_reference(NULL, this_ptr, object_ptr, NULL ELS_CC);
+ object_ptr = NULL;
+ }
original_return_value = EG(return_value);
EG(return_value) = &Ts[opline->result.u.var].tmp_var;
var_uninit(EG(return_value));