@@ -3412,6 +3412,22 @@ int zend_compile_func_typecheck(znode *result, zend_ast_list *args, uint32_t typ
3412
3412
}
3413
3413
/* }}} */
3414
3414
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
+
3415
3431
int zend_compile_func_defined (znode * result , zend_ast_list * args ) /* {{{ */
3416
3432
{
3417
3433
zend_string * name ;
@@ -3677,6 +3693,16 @@ int zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_l
3677
3693
return zend_compile_func_typecheck (result , args , IS_OBJECT );
3678
3694
} else if (zend_string_equals_literal (lcname , "is_resource" )) {
3679
3695
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 );
3680
3706
} else if (zend_string_equals_literal (lcname , "defined" )) {
3681
3707
return zend_compile_func_defined (result , args );
3682
3708
} else if (zend_string_equals_literal (lcname , "chr" ) && type == BP_VAR_R ) {
0 commit comments