Skip to content

Commit a499cfc

Browse files
committed
Merge branch 'PHP-7.1'
2 parents 53b3ef5 + 30af806 commit a499cfc

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Zend/zend_compile.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3412,6 +3412,22 @@ int zend_compile_func_typecheck(znode *result, zend_ast_list *args, uint32_t typ
34123412
}
34133413
/* }}} */
34143414

3415+
int zend_compile_func_cast(znode *result, zend_ast_list *args, uint32_t type) /* {{{ */
3416+
{
3417+
znode arg_node;
3418+
zend_op *opline;
3419+
3420+
if (args->children != 1 || args->child[0]->kind == ZEND_AST_UNPACK) {
3421+
return FAILURE;
3422+
}
3423+
3424+
zend_compile_expr(&arg_node, args->child[0]);
3425+
opline = zend_emit_op_tmp(result, ZEND_CAST, &arg_node, NULL);
3426+
opline->extended_value = type;
3427+
return SUCCESS;
3428+
}
3429+
/* }}} */
3430+
34153431
int zend_compile_func_defined(znode *result, zend_ast_list *args) /* {{{ */
34163432
{
34173433
zend_string *name;
@@ -3677,6 +3693,16 @@ int zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_l
36773693
return zend_compile_func_typecheck(result, args, IS_OBJECT);
36783694
} else if (zend_string_equals_literal(lcname, "is_resource")) {
36793695
return zend_compile_func_typecheck(result, args, IS_RESOURCE);
3696+
} else if (zend_string_equals_literal(lcname, "boolval")) {
3697+
return zend_compile_func_cast(result, args, _IS_BOOL);
3698+
} else if (zend_string_equals_literal(lcname, "intval")) {
3699+
return zend_compile_func_cast(result, args, IS_LONG);
3700+
} else if (zend_string_equals_literal(lcname, "floatval")
3701+
|| zend_string_equals_literal(lcname, "doubleval")
3702+
) {
3703+
return zend_compile_func_cast(result, args, IS_DOUBLE);
3704+
} else if (zend_string_equals_literal(lcname, "strval")) {
3705+
return zend_compile_func_cast(result, args, IS_STRING);
36803706
} else if (zend_string_equals_literal(lcname, "defined")) {
36813707
return zend_compile_func_defined(result, args);
36823708
} else if (zend_string_equals_literal(lcname, "chr") && type == BP_VAR_R) {

0 commit comments

Comments
 (0)