Browse files

- Put in the infrastructure for the unset() fix. Right now it has the…

… old

  behavior but I just need time tomorrow to add the correct behavior.
  • Loading branch information...
1 parent 95c7788 commit 7fa17e8e08ca4543a88e9b2467e56eb34c30341c @andigutmans andigutmans committed Feb 14, 2000
Showing with 35 additions and 13 deletions.
  1. +1 −1 Zend/zend-parser.y
  2. +6 −3 Zend/zend_compile.c
  3. +13 −9 Zend/zend_compile.h
  4. +15 −0 Zend/zend_execute.c
View
2 Zend/zend-parser.y
@@ -201,7 +201,7 @@ unticked_statement:
| expr ';' { do_free(&$1 CLS_CC); }
| T_REQUIRE expr ';' { do_require(&$2 CLS_CC); }
| T_USE use_filename ';' { use_filename($2.u.constant.value.str.val, $2.u.constant.value.str.len CLS_CC); zval_dtor(&$2.u.constant); }
- | T_UNSET '(' r_cvar ')' ';' { do_unset(&$3 CLS_CC); }
+ | T_UNSET '(' cvar ')' ';' { do_end_variable_parse(BP_VAR_UNSET, 0 CLS_CC); do_unset(&$3 CLS_CC); }
| T_FOREACH '(' expr T_AS { do_foreach_begin(&$1, &$3, &$2, &$4 CLS_CC); } w_cvar foreach_optional_arg ')' { do_foreach_cont(&$6, &$7, &$4 CLS_CC); } foreach_statement { do_foreach_end(&$1, &$2 CLS_CC); }
| T_DECLARE { do_declare_begin(CLS_C); } '(' declare_list ')' declare_statement { do_declare_end(CLS_C); }
| ';' /* empty statement */
View
9 Zend/zend_compile.c
@@ -576,6 +576,9 @@ void do_end_variable_parse(int type, int arg_offset CLS_DC)
opline->opcode += 9; /* 3+3+3 */
opline->extended_value = arg_offset;
break;
+ case BP_VAR_UNSET:
+ opline->opcode += 12; /* 3+3+3+3 */
+ break;
}
le = le->next;
}
@@ -1943,11 +1946,11 @@ void do_unset(znode *variable CLS_DC)
last_op = &CG(active_op_array)->opcodes[get_next_op_number(CG(active_op_array))-1];
switch (last_op->opcode) {
- case ZEND_FETCH_R:
+ case ZEND_FETCH_UNSET:
last_op->opcode = ZEND_UNSET_VAR;
break;
- case ZEND_FETCH_DIM_R:
- case ZEND_FETCH_OBJ_R:
+ case ZEND_FETCH_DIM_UNSET:
+ case ZEND_FETCH_OBJ_UNSET:
last_op->opcode = ZEND_UNSET_DIM_OBJ;
break;
View
22 Zend/zend_compile.h
@@ -485,7 +485,7 @@ int zendlex(znode *zendlval CLS_DC);
#define ZEND_EXIT 78
-/* the following 15 opcodes are 5 groups of 3 opcodes each, and must
+/* the following 18 opcodes are 6 groups of 3 opcodes each, and must
* remain in that order!
*/
#define ZEND_FETCH_R 79
@@ -503,18 +503,21 @@ int zendlex(znode *zendlval CLS_DC);
#define ZEND_FETCH_FUNC_ARG 91
#define ZEND_FETCH_DIM_FUNC_ARG 92
#define ZEND_FETCH_OBJ_FUNC_ARG 93
+#define ZEND_FETCH_UNSET 94
+#define ZEND_FETCH_DIM_UNSET 95
+#define ZEND_FETCH_OBJ_UNSET 96
-#define ZEND_FETCH_DIM_TMP_VAR 94
-#define ZEND_FETCH_CONSTANT 95
+#define ZEND_FETCH_DIM_TMP_VAR 97
+#define ZEND_FETCH_CONSTANT 98
-#define ZEND_DECLARE_FUNCTION_OR_CLASS 96
+#define ZEND_DECLARE_FUNCTION_OR_CLASS 99
-#define ZEND_EXT_STMT 97
-#define ZEND_EXT_FCALL_BEGIN 98
-#define ZEND_EXT_FCALL_END 99
-#define ZEND_EXT_NOP 100
+#define ZEND_EXT_STMT 100
+#define ZEND_EXT_FCALL_BEGIN 101
+#define ZEND_EXT_FCALL_END 102
+#define ZEND_EXT_NOP 103
-#define ZEND_TICKS 101
+#define ZEND_TICKS 104
/* end of block */
@@ -533,6 +536,7 @@ int zendlex(znode *zendlval CLS_DC);
#define BP_VAR_IS 3
#define BP_VAR_NA 4 /* if not applicable */
#define BP_VAR_FUNC_ARG 5
+#define BP_VAR_UNSET 6
#define ZEND_INTERNAL_FUNCTION 1
View
15 Zend/zend_execute.c
@@ -1246,6 +1246,10 @@ binary_assign_op_addr: {
AI_USE_PTR(Ts[opline->result.u.var].var);
}
NEXT_OPCODE();
+ case ZEND_FETCH_UNSET:
+ zend_fetch_var_address(&opline->result, &opline->op1, &opline->op2, Ts, BP_VAR_R ELS_CC);
+ AI_USE_PTR(Ts[opline->result.u.var].var);
+ NEXT_OPCODE();
case ZEND_FETCH_IS:
zend_fetch_var_address(&opline->result, &opline->op1, &opline->op2, Ts, BP_VAR_IS ELS_CC);
AI_USE_PTR(Ts[opline->result.u.var].var);
@@ -1277,6 +1281,13 @@ binary_assign_op_addr: {
AI_USE_PTR(Ts[opline->result.u.var].var);
}
NEXT_OPCODE();
+ case ZEND_FETCH_DIM_UNSET:
+ if (opline->extended_value == ZEND_FETCH_ADD_LOCK) {
+ PZVAL_LOCK(*Ts[opline->op1.u.var].var.ptr_ptr);
+ }
+ zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, Ts, BP_VAR_R ELS_CC);
+ AI_USE_PTR(Ts[opline->result.u.var].var);
+ NEXT_OPCODE();
case ZEND_FETCH_OBJ_R:
zend_fetch_property_address(&opline->result, &opline->op1, &opline->op2, Ts, BP_VAR_R ELS_CC);
AI_USE_PTR(Ts[opline->result.u.var].var);
@@ -1300,6 +1311,10 @@ binary_assign_op_addr: {
AI_USE_PTR(Ts[opline->result.u.var].var);
}
NEXT_OPCODE();
+ case ZEND_FETCH_OBJ_UNSET:
+ zend_fetch_property_address(&opline->result, &opline->op1, &opline->op2, Ts, BP_VAR_R ELS_CC);
+ AI_USE_PTR(Ts[opline->result.u.var].var);
+ NEXT_OPCODE();
case ZEND_FETCH_DIM_TMP_VAR:
zend_fetch_dimension_address_from_tmp_var(&opline->result, &opline->op1, &opline->op2, Ts ELS_CC);
AI_USE_PTR(Ts[opline->result.u.var].var);

0 comments on commit 7fa17e8

Please sign in to comment.