summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-02-22 15:42:37 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-02-22 15:43:08 +0100
commit52605aafc565955436c9f60c33a786302fef7887 (patch)
tree0c827d4da42ee6e604e0b9a90c51dbc2c34ebe0b
parentdda2074bf7bb8a6514b2c29cbf543b8d09ee0603 (diff)
downloadphp-git-52605aafc565955436c9f60c33a786302fef7887.tar.gz
Fix anon class handling in ext mode
Opcode order changes in 7.4 and the EXT_STMT is now declare the DECLARE_ANON. Fix this by returning the opline from compile_class_decl to avoid any fragile opcode searching.
-rw-r--r--Zend/zend_compile.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index eee2347f49..bd7139eb5d 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -3972,7 +3972,7 @@ void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type) /* {{
}
/* }}} */
-void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel);
+zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel);
void zend_compile_new(znode *result, zend_ast *ast) /* {{{ */
{
@@ -3983,13 +3983,8 @@ void zend_compile_new(znode *result, zend_ast *ast) /* {{{ */
zend_op *opline;
if (class_ast->kind == ZEND_AST_CLASS) {
- uint32_t dcl_opnum = get_next_op_number();
- zend_compile_class_decl(class_ast, 0);
/* jump over anon class declaration */
- opline = &CG(active_op_array)->opcodes[dcl_opnum];
- if (opline->opcode == ZEND_FETCH_CLASS) {
- opline++;
- }
+ opline = zend_compile_class_decl(class_ast, 0);
class_node.op_type = opline->result_type;
class_node.u.op.var = opline->result.var;
opline->extended_value = get_next_op_number();
@@ -6181,7 +6176,7 @@ static zend_string *zend_generate_anon_class_name(unsigned char *lex_pos) /* {{{
}
/* }}} */
-void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
+zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
{
zend_ast_decl *decl = (zend_ast_decl *) ast;
zend_ast *extends_ast = decl->child[0];
@@ -6341,7 +6336,7 @@ void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
}
CG(zend_lineno) = ast->lineno;
zend_string_release(lcname);
- return;
+ return NULL;
}
}
} else {
@@ -6349,7 +6344,7 @@ void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
zend_string_release(lcname);
zend_build_properties_info_table(ce);
ce->ce_flags |= ZEND_ACC_LINKED;
- return;
+ return NULL;
}
}
}
@@ -6375,7 +6370,7 @@ void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
zval zv;
ZVAL_PTR(&zv, ce);
destroy_zend_class(&zv);
- return;
+ return opline;
}
} else {
zend_string *key = zend_build_runtime_definition_key(lcname, decl->lex_pos);
@@ -6402,6 +6397,7 @@ void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
opline->opcode = ZEND_DECLARE_CLASS;
}
}
+ return opline;
}
/* }}} */