* Use to_string() instead of __print()

* Support boolean casts ((bool) and (boolean))
This commit is contained in:
Zeev Suraski 1999-06-11 11:17:43 +00:00
parent 99fd17df63
commit 963a004481
3 changed files with 9 additions and 1 deletions

View File

@ -58,7 +58,7 @@
%left T_SL T_SR
%left '+' '-' '.'
%left '*' '/' '%'
%right '!' '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST '@'
%right '!' '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST '@'
%right '['
%nonassoc T_NEW
%token T_EXIT
@ -426,6 +426,7 @@ expr_without_variable:
| T_STRING_CAST expr { do_cast(&$$, &$2, IS_STRING CLS_CC); }
| T_ARRAY_CAST expr { do_cast(&$$, &$2, IS_ARRAY CLS_CC); }
| T_OBJECT_CAST expr { do_cast(&$$, &$2, IS_OBJECT CLS_CC); }
| T_BOOL_CAST expr { do_cast(&$$, &$2, IS_BOOL CLS_CC); }
| T_EXIT exit_expr { do_exit(&$$, &$2 CLS_CC); }
| '@' { do_begin_silence(&$1 CLS_CC); } expr { do_end_silence(&$1 CLS_CC); $$ = $3; }
| scalar { $$ = $1; }

View File

@ -737,6 +737,10 @@ ESCAPED_AND_WHITESPACE [\n\t\r #'.:;,()|^&+-/*=%!~<>?@]+
return T_OBJECT_CAST;
}
<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("bool"|"boolean"){TABS_AND_SPACES}")" {
return T_BOOL_CAST;
}
<ST_IN_SCRIPTING>"eval" {
return T_EVAL;
}

View File

@ -1667,6 +1667,9 @@ send_by_ref:
zendi_zval_copy_ctor(*result);
}
switch (opline->op2.u.constant.type) {
case IS_BOOL:
convert_to_boolean(result);
break;
case IS_LONG:
convert_to_long(result);
break;