diff options
author | Andi Gutmans <andi@php.net> | 1999-07-25 20:14:36 +0000 |
---|---|---|
committer | Andi Gutmans <andi@php.net> | 1999-07-25 20:14:36 +0000 |
commit | 79b3d341d3b55ecbed3120436abdbe3cb552c0b3 (patch) | |
tree | 057ce4275e8cb5219f2cff9fbd0f20d289f1f33f | |
parent | b1617d8ac3bad1ace92085194e24cff8cbdbaf31 (diff) | |
download | php-git-79b3d341d3b55ecbed3120436abdbe3cb552c0b3.tar.gz |
- Commiting to branch newoperator.
- To check it out do cvs checkout -rnewoperator libzend
-rw-r--r-- | Zend/zend-parser.y | 2 | ||||
-rw-r--r-- | Zend/zend_compile.c | 13 | ||||
-rw-r--r-- | Zend/zend_compile.h | 4 | ||||
-rw-r--r-- | Zend/zend_execute.c | 27 |
4 files changed, 27 insertions, 19 deletions
diff --git a/Zend/zend-parser.y b/Zend/zend-parser.y index f0c853d2af..0a9cbd03f0 100644 --- a/Zend/zend-parser.y +++ b/Zend/zend-parser.y @@ -367,7 +367,7 @@ expr_without_variable: T_LIST '(' { do_list_init(CLS_C); } assignment_list ')' '=' expr { do_list_end(&$$, &$7 CLS_CC); } | w_cvar '=' expr { do_assign(&$$, &$1, &$3 CLS_CC); } | w_cvar '=' '&' w_cvar { do_assign_ref(&$$, &$1, &$4 CLS_CC); } - | w_cvar '=' T_NEW class_name { do_extended_fcall_begin(CLS_C); do_begin_new_object(&$2, &$1, &$3, &$4 CLS_CC); } ctor_arguments { do_end_new_object(&$4, &$3, &$6 CLS_CC); do_extended_fcall_end(CLS_C); $$ = $2;} + | T_NEW class_name { do_extended_fcall_begin(CLS_C); do_begin_new_object(&$1, &$2 CLS_CC); } ctor_arguments { do_end_new_object(&$$, &$2, &$1, &$4 CLS_CC); do_extended_fcall_end(CLS_C);} | rw_cvar T_PLUS_EQUAL expr { do_binary_assign_op(ZEND_ASSIGN_ADD, &$$, &$1, &$3 CLS_CC); } | rw_cvar T_MINUS_EQUAL expr { do_binary_assign_op(ZEND_ASSIGN_SUB, &$$, &$1, &$3 CLS_CC); } | rw_cvar T_MUL_EQUAL expr { do_binary_assign_op(ZEND_ASSIGN_MUL, &$$, &$1, &$3 CLS_CC); } diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 5a224a8b7e..8f949208f1 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1332,7 +1332,7 @@ void do_pop_object(znode *object CLS_DC) } -void do_begin_new_object(znode *result, znode *variable, znode *new_token, znode *class_name CLS_DC) +void do_begin_new_object(znode *new_token, znode *class_name CLS_DC) { zend_op *opline = get_next_op(CG(active_op_array) CLS_CC); unsigned char *ptr = NULL; @@ -1343,12 +1343,14 @@ void do_begin_new_object(znode *result, znode *variable, znode *new_token, znode opline->op1 = *class_name; SET_UNUSED(opline->op2); - do_assign(result, variable, &opline->result CLS_CC); + //*result = opline->result; + //do_assign(result, variable, &opline->result CLS_CC); + new_token->u.opline_num = get_next_op_number(CG(active_op_array)); opline = get_next_op(CG(active_op_array) CLS_CC); opline->opcode = ZEND_JMP_NO_CTOR; - opline->op1 = *result; + opline->op1 = (opline-1)->result; SET_UNUSED(opline->op2); if (class_name->op_type == IS_CONST) { @@ -1356,14 +1358,14 @@ void do_begin_new_object(znode *result, znode *variable, znode *new_token, znode } opline = get_next_op(CG(active_op_array) CLS_CC); opline->opcode = ZEND_INIT_FCALL_BY_NAME; - opline->op1 = *result; + opline->op1 = (opline-2)->result; opline->op2 = *class_name; opline->extended_value = ZEND_MEMBER_FUNC_CALL | ZEND_CTOR_CALL; zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(unsigned char *)); } -void do_end_new_object(znode *class_name, znode *new_token, znode *argument_list CLS_DC) +void do_end_new_object(znode *result, znode *class_name, znode *new_token, znode *argument_list CLS_DC) { znode ctor_result; @@ -1374,6 +1376,7 @@ void do_end_new_object(znode *class_name, znode *new_token, znode *argument_list do_free(&ctor_result CLS_CC); CG(active_op_array)->opcodes[new_token->u.opline_num].op2.u.opline_num = get_next_op_number(CG(active_op_array)); + *result = CG(active_op_array)->opcodes[new_token->u.opline_num].op1; } diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index b1ad05ca1b..6fe52704b1 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -295,8 +295,8 @@ void do_push_object(znode *object CLS_DC); void do_pop_object(znode *object CLS_DC); -void do_begin_new_object(znode *result, znode *variable, znode *new_token, znode *class_name CLS_DC); -void do_end_new_object(znode *class_name, znode *new_token, znode *argument_list CLS_DC); +void do_begin_new_object(znode *new_token, znode *class_name CLS_DC); +void do_end_new_object(znode *result, znode *class_name, znode *new_token, znode *argument_list CLS_DC); void do_fetch_constant(znode *result, znode *constant_name, int mode CLS_DC); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index ca8a7303bc..78d1ac0737 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -844,7 +844,7 @@ void execute(zend_op_array *op_array ELS_DC) zend_function_state function_state; HashTable *calling_symbol_table; zend_function *function_being_called=NULL; - zval **object_ptr=NULL; + zval *object_ptr=NULL; #if !defined (__GNUC__) || __GNUC__ < 2 temp_variable *Ts = (temp_variable *) do_alloca(sizeof(temp_variable)*op_array->T); #else @@ -1270,7 +1270,9 @@ binary_assign_op_addr: { if (opline->extended_value & ZEND_CTOR_CALL) { /* constructor call */ - PZVAL_LOCK(*Ts[opline->op1.u.var].var); + if (opline->op1.op_type == IS_VAR) { + PZVAL_LOCK(*Ts[opline->op1.u.var].var); + } if (opline->op2.op_type==IS_VAR) { PZVAL_LOCK(*Ts[opline->op2.u.var].var); } @@ -1295,11 +1297,11 @@ binary_assign_op_addr: { object_ptr=NULL; } } else { /* used for member function calls */ - object_ptr = get_zval_ptr_ptr(&opline->op1, Ts, BP_VAR_R); - + object_ptr = get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R); + if (!object_ptr - || ((*object_ptr)->type==IS_OBJECT && (*object_ptr)->value.obj.ce->handle_function_call)) { /* overloaded function call */ + || (object_ptr->type==IS_OBJECT && object_ptr->value.obj.ce->handle_function_call)) { /* overloaded function call */ zend_overloaded_element overloaded_element; zend_property_reference *property_reference; @@ -1322,10 +1324,10 @@ binary_assign_op_addr: { goto overloaded_function_call_cont; } - if ((*object_ptr)->type != IS_OBJECT) { + if (object_ptr->type != IS_OBJECT) { zend_error(E_ERROR, "Call to a member function on a non-object"); } - active_function_table = &(*object_ptr)->value.obj.ce->function_table; + active_function_table = &object_ptr->value.obj.ce->function_table; } } else { /* function pointer */ object_ptr = NULL; @@ -1359,7 +1361,7 @@ do_fcall_common: zend_ptr_stack_push(&EG(argument_stack), (void *) opline->extended_value); if (function_state.function->type==ZEND_INTERNAL_FUNCTION) { var_uninit(&Ts[opline->result.u.var].tmp_var); - ((zend_internal_function *) function_state.function)->handler(opline->extended_value, &Ts[opline->result.u.var].tmp_var, &EG(regular_list), &EG(persistent_list), (object_ptr?*object_ptr:NULL)); + ((zend_internal_function *) function_state.function)->handler(opline->extended_value, &Ts[opline->result.u.var].tmp_var, &EG(regular_list), &EG(persistent_list), (object_ptr?object_ptr:NULL)); } else if (function_state.function->type==ZEND_USER_FUNCTION) { if (EG(symtable_cache_ptr)>=EG(symtable_cache)) { /*printf("Cache hit! Reusing %x\n", symtable_cache[symtable_cache_ptr]);*/ @@ -1374,12 +1376,13 @@ do_fcall_common: if (opline->opcode==ZEND_DO_FCALL_BY_NAME && object_ptr && function_being_called->type!=ZEND_OVERLOADED_FUNCTION) { - zval *dummy = (zval *) emalloc(sizeof(zval)), **this_ptr; + /*zval *dummy = (zval *) emalloc(sizeof(zval)), **this_ptr; var_uninit(dummy); INIT_PZVAL(dummy); 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); @@ -1850,8 +1853,10 @@ send_by_ref: break; case ZEND_JMP_NO_CTOR: { zval *object; - - PZVAL_LOCK(*Ts[opline->op1.u.var].var); + + if (opline->op1.op_type == IS_VAR) { + PZVAL_LOCK(*Ts[opline->op1.u.var].var); + } object = get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R); if (!object->value.obj.ce->handle_function_call && !zend_hash_exists(&object->value.obj.ce->function_table, object->value.obj.ce->name, object->value.obj.ce->name_length+1)) { |