From: Andi Gutmans Date: Tue, 14 Jan 2003 21:29:23 +0000 (+0000) Subject: - Change "is" to "instanceof" as it explains better what the operator means. X-Git-Tag: PHP_5_0_dev_before_13561_fix~229 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c073b76aac82e3c00ad56119bd8e509f9f2a4670;p=php - Change "is" to "instanceof" as it explains better what the operator means. - "is_a" was also appropriate but ugly. --- diff --git a/Zend/ZEND_CHANGES b/Zend/ZEND_CHANGES index 265be180a1..50737429ba 100644 --- a/Zend/ZEND_CHANGES +++ b/Zend/ZEND_CHANGES @@ -496,6 +496,8 @@ Changes in the Zend Engine 2.0 * Abstract methods. (TBD) + * instanceof (TBD) + * Static function variables. Statics are now treated at compile-time which allows developers diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 509aaff2a1..cd6c48317e 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2820,11 +2820,11 @@ void zend_do_isset_or_isempty(int type, znode *result, znode *variable TSRMLS_DC } -void zend_do_is_class(znode *result, znode *expr, znode *class_znode, int type TSRMLS_DC) +void zend_do_instanceof(znode *result, znode *expr, znode *class_znode, int type TSRMLS_DC) { zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); - opline->opcode = ZEND_IS_CLASS; + opline->opcode = ZEND_INSTANCEOF; opline->result.op_type = IS_TMP_VAR; opline->result.u.var = get_temporary_variable(CG(active_op_array)); opline->op1 = *expr; diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 5a2bb4962e..1b965cef76 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -379,7 +379,7 @@ void zend_do_include_or_eval(int type, znode *result, znode *op1 TSRMLS_DC); void zend_do_unset(znode *variable TSRMLS_DC); void zend_do_isset_or_isempty(int type, znode *result, znode *variable TSRMLS_DC); -void zend_do_is_class(znode *result, znode *expr, znode *class_znode, int type TSRMLS_DC); +void zend_do_instanceof(znode *result, znode *expr, znode *class_znode, int type TSRMLS_DC); void zend_do_foreach_begin(znode *foreach_token, znode *array, znode *open_brackets_token, znode *as_token, int variable TSRMLS_DC); void zend_do_foreach_cont(znode *value, znode *key, znode *as_token TSRMLS_DC); @@ -621,7 +621,7 @@ int zendlex(znode *zendlval TSRMLS_DC); #define ZEND_ASSIGN_OBJ 136 #define ZEND_MAKE_VAR 137 -#define ZEND_IS_CLASS 138 +#define ZEND_INSTANCEOF 138 #define ZEND_DECLARE_CLASS 139 #define ZEND_DECLARE_INHERITED_CLASS 140 diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 18e048ad90..ea4e9114fc 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -3792,10 +3792,10 @@ int zend_ticks_handler(ZEND_OPCODE_HANDLER_ARGS) NEXT_OPCODE(); } -int zend_is_class_handler(ZEND_OPCODE_HANDLER_ARGS) +int zend_instanceof_handler(ZEND_OPCODE_HANDLER_ARGS) { zval *expr = get_zval_ptr(&EX(opline)->op1, EX(Ts), &EG(free_op1), BP_VAR_R); - is_class_function(&EX_T(EX(opline)->result.u.var).tmp_var, expr, + instanceof_function(&EX_T(EX(opline)->result.u.var).tmp_var, expr, EX_T(EX(opline)->op2.u.var).EA.class_entry TSRMLS_CC); FREE_OP(EX(Ts), &EX(opline)->op1, EG(free_op1)); NEXT_OPCODE(); @@ -3978,7 +3978,7 @@ void zend_init_opcodes_handlers() zend_opcode_handlers[ZEND_ASSIGN_OBJ] = zend_assign_obj_handler; zend_opcode_handlers[ZEND_MAKE_VAR] = zend_make_var_handler; - zend_opcode_handlers[ZEND_IS_CLASS] = zend_is_class_handler; + zend_opcode_handlers[ZEND_INSTANCEOF] = zend_instanceof_handler; zend_opcode_handlers[ZEND_DECLARE_CLASS] = zend_declare_class_handler; zend_opcode_handlers[ZEND_DECLARE_INHERITED_CLASS] = zend_declare_inherited_class_handler; diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 0b1e0fa1e0..bc2db46fdb 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -67,7 +67,7 @@ %left '*' '/' '%' %right '!' '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@' %right '[' -%nonassoc T_NEW T_IS_CLASS +%nonassoc T_NEW T_INSTANCEOF %token T_EXIT %token T_IF %left T_ELSEIF @@ -94,7 +94,7 @@ %token T_ENDFOREACH %token T_DECLARE %token T_ENDDECLARE -%token T_IS_CLASS +%token T_INSTANCEOF %token T_AS %token T_SWITCH %token T_ENDSWITCH @@ -548,7 +548,7 @@ expr_without_variable: | expr T_IS_SMALLER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$1, &$3 TSRMLS_CC); } | expr '>' expr { zend_do_binary_op(ZEND_IS_SMALLER, &$$, &$3, &$1 TSRMLS_CC); } | expr T_IS_GREATER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$3, &$1 TSRMLS_CC); } - | expr T_IS_CLASS is_class_expr { zend_do_is_class(&$$, &$1, &$3, 0 TSRMLS_CC); } + | expr T_INSTANCEOF instanceof_expr { zend_do_instanceof(&$$, &$1, &$3, 0 TSRMLS_CC); } | '(' expr ')' { $$ = $2; } | expr '?' { zend_do_begin_qm_op(&$1, &$2 TSRMLS_CC); } expr ':' { zend_do_qm_true(&$4, &$2, &$5 TSRMLS_CC); } @@ -606,7 +606,7 @@ static_or_variable_string: | r_variable_without_static_member { $$ = $1; } ; -is_class_expr: +instanceof_expr: parse_class_entry T_STRING { do_fetch_class(&$$, &$1, &$2 TSRMLS_CC); } | T_STRING { do_fetch_class(&$$, NULL, &$1 TSRMLS_CC); } ; diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index aabe7b00a2..30a76a5ba4 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -572,8 +572,8 @@ NEWLINE ("\r"|"\n"|"\r\n") return T_ENDDECLARE; } -"is" { - return T_IS_CLASS; +"instanceof" { + return T_INSTANCEOF; } "as" { diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index fd7142a8e9..e497947389 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1360,7 +1360,7 @@ ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSR } -ZEND_API int is_class_function(zval *result, zval *op1, zend_class_entry *class TSRMLS_DC) +ZEND_API int instanceof_function(zval *result, zval *op1, zend_class_entry *class TSRMLS_DC) { if (Z_TYPE_P(op1) == IS_OBJECT) { zend_class_entry *ce; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 8df40baf80..de7ed9da00 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -58,7 +58,7 @@ ZEND_API int is_not_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) ZEND_API int is_smaller_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); -ZEND_API int is_class_function(zval *result, zval *op1, zend_class_entry *ce TSRMLS_DC); +ZEND_API int instanceof_function(zval *result, zval *op1, zend_class_entry *ce TSRMLS_DC); static inline zend_bool is_numeric_string(char *str, int length, long *lval, double *dval, zend_bool allow_errors) {