Zend !== operator patch submission

From: Date: Wed, 08 Mar 2000 01:01:41 +0000
Subject: Zend !== operator patch submission
Groups: php.dev 
Request: Send a blank email to php-dev+get-16522@lists.php.net to get a copy of this message
I don't know whether patch submissions are accepted for Zend (and I'm positive not for this release :), but anyway... For completeness and ease of coding some expressions, I've hacked my local Zend to include the !== (is not identical to) operator. I've followed Thies's === changes very closely, I think, and the new !== operator works as expected for me. !== simply returns false in any case where === would return true: !(expr1 === expr2) is the same as (expr1 !== expr2). The patch applies and works on the latest Zend cvs. If there are any comments or things I've done really wrong, please let me know what they are. :) Cheers, Torben Index: zend-parser.y =================================================================== RCS file: /repository/Zend/zend-parser.y,v retrieving revision 1.63 diff -u -r1.63 zend-parser.y --- zend-parser.y 2000/02/19 22:46:42 1.63 +++ zend-parser.y 2000/03/05 00:37:29 @@ -62,7 +62,7 @@ %left '|' %left '^' %left '&' -%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL +%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL %nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL %left T_SL T_SR %left '+' '-' '.' @@ -454,6 +454,7 @@ | '!' expr { do_unary_op(ZEND_BOOL_NOT, &$$, &$2 CLS_CC); } | '~' expr { do_unary_op(ZEND_BW_NOT, &$$, &$2 CLS_CC); } | expr T_IS_IDENTICAL expr { do_binary_op(ZEND_IS_IDENTICAL, &$$, &$1, &$3 CLS_CC); } + | expr T_IS_NOT_IDENTICAL expr { do_binary_op(ZEND_IS_NOT_IDENTICAL, &$$, &$1, &$3 CLS_CC); } | expr T_IS_EQUAL expr { do_binary_op(ZEND_IS_EQUAL, &$$, &$1, &$3 CLS_CC); } | expr T_IS_NOT_EQUAL expr { do_binary_op(ZEND_IS_NOT_EQUAL, &$$, &$1, &$3 CLS_CC); } | expr '<' expr { do_binary_op(ZEND_IS_SMALLER, &$$, &$1, &$3 CLS_CC); } Index: zend-scanner.l =================================================================== RCS file: /repository/Zend/zend-scanner.l,v retrieving revision 1.80 diff -u -r1.80 zend-scanner.l --- zend-scanner.l 2000/02/19 22:46:42 1.80 +++ zend-scanner.l 2000/03/05 00:37:30 @@ -967,6 +967,10 @@ return T_IS_IDENTICAL; } +<ST_IN_SCRIPTING>"!==" { + return T_IS_NOT_IDENTICAL; +} + <ST_IN_SCRIPTING>"==" { return T_IS_EQUAL; } Index: zend_compile.h =================================================================== RCS file: /repository/Zend/zend_compile.h,v retrieving revision 1.82 diff -u -r1.82 zend_compile.h --- zend_compile.h 2000/02/19 22:46:42 1.82 +++ zend_compile.h 2000/03/05 00:37:34 @@ -404,120 +404,121 @@ #define ZEND_BOOL_NOT 13 #define ZEND_BOOL_XOR 14 #define ZEND_IS_IDENTICAL 15 -#define ZEND_IS_EQUAL 16 -#define ZEND_IS_NOT_EQUAL 17 -#define ZEND_IS_SMALLER 18 -#define ZEND_IS_SMALLER_OR_EQUAL 19 -#define ZEND_CAST 20 -#define ZEND_QM_ASSIGN 21 - -#define ZEND_ASSIGN_ADD 22 -#define ZEND_ASSIGN_SUB 23 -#define ZEND_ASSIGN_MUL 24 -#define ZEND_ASSIGN_DIV 25 -#define ZEND_ASSIGN_MOD 26 -#define ZEND_ASSIGN_SL 27 -#define ZEND_ASSIGN_SR 28 -#define ZEND_ASSIGN_CONCAT 29 -#define ZEND_ASSIGN_BW_OR 30 -#define ZEND_ASSIGN_BW_AND 31 -#define ZEND_ASSIGN_BW_XOR 32 - -#define ZEND_PRE_INC 33 -#define ZEND_PRE_DEC 34 -#define ZEND_POST_INC 35 -#define ZEND_POST_DEC 36 - -#define ZEND_ASSIGN 37 -#define ZEND_ASSIGN_REF 38 - -#define ZEND_ECHO 39 -#define ZEND_PRINT 40 - -#define ZEND_JMP 41 -#define ZEND_JMPZ 42 -#define ZEND_JMPNZ 43 -#define ZEND_JMPZNZ 44 -#define ZEND_JMPZ_EX 45 -#define ZEND_JMPNZ_EX 46 -#define ZEND_CASE 47 -#define ZEND_SWITCH_FREE 48 -#define ZEND_BRK 49 -#define ZEND_CONT 50 -#define ZEND_BOOL 51 - -#define ZEND_INIT_STRING 52 -#define ZEND_ADD_CHAR 53 -#define ZEND_ADD_STRING 54 -#define ZEND_ADD_VAR 55 - -#define ZEND_BEGIN_SILENCE 56 -#define ZEND_END_SILENCE 57 - -#define ZEND_INIT_FCALL_BY_NAME 58 -#define ZEND_DO_FCALL 59 -#define ZEND_DO_FCALL_BY_NAME 60 -#define ZEND_RETURN 61 - -#define ZEND_RECV 62 -#define ZEND_RECV_INIT 63 - -#define ZEND_SEND_VAL 64 -#define ZEND_SEND_VAR 65 -#define ZEND_SEND_REF 66 - -#define ZEND_NEW 67 -#define ZEND_JMP_NO_CTOR 68 -#define ZEND_FREE 69 - -#define ZEND_INIT_ARRAY 70 -#define ZEND_ADD_ARRAY_ELEMENT 71 - -#define ZEND_INCLUDE_OR_EVAL 72 - -#define ZEND_UNSET_VAR 73 -#define ZEND_UNSET_DIM_OBJ 74 -#define ZEND_ISSET_ISEMPTY 75 +#define ZEND_IS_NOT_IDENTICAL 16 +#define ZEND_IS_EQUAL 17 +#define ZEND_IS_NOT_EQUAL 18 +#define ZEND_IS_SMALLER 19 +#define ZEND_IS_SMALLER_OR_EQUAL 20 +#define ZEND_CAST 21 +#define ZEND_QM_ASSIGN 22 + +#define ZEND_ASSIGN_ADD 23 +#define ZEND_ASSIGN_SUB 24 +#define ZEND_ASSIGN_MUL 25 +#define ZEND_ASSIGN_DIV 26 +#define ZEND_ASSIGN_MOD 27 +#define ZEND_ASSIGN_SL 28 +#define ZEND_ASSIGN_SR 29 +#define ZEND_ASSIGN_CONCAT 30 +#define ZEND_ASSIGN_BW_OR 31 +#define ZEND_ASSIGN_BW_AND 32 +#define ZEND_ASSIGN_BW_XOR 33 + +#define ZEND_PRE_INC 34 +#define ZEND_PRE_DEC 35 +#define ZEND_POST_INC 36 +#define ZEND_POST_DEC 37 + +#define ZEND_ASSIGN 38 +#define ZEND_ASSIGN_REF 39 + +#define ZEND_ECHO 40 +#define ZEND_PRINT 41 + +#define ZEND_JMP 42 +#define ZEND_JMPZ 43 +#define ZEND_JMPNZ 44 +#define ZEND_JMPZNZ 45 +#define ZEND_JMPZ_EX 46 +#define ZEND_JMPNZ_EX 47 +#define ZEND_CASE 48 +#define ZEND_SWITCH_FREE 49 +#define ZEND_BRK 50 +#define ZEND_CONT 51 +#define ZEND_BOOL 52 + +#define ZEND_INIT_STRING 53 +#define ZEND_ADD_CHAR 54 +#define ZEND_ADD_STRING 55 +#define ZEND_ADD_VAR 56 + +#define ZEND_BEGIN_SILENCE 57 +#define ZEND_END_SILENCE 58 + +#define ZEND_INIT_FCALL_BY_NAME 59 +#define ZEND_DO_FCALL 60 +#define ZEND_DO_FCALL_BY_NAME 61 +#define ZEND_RETURN 62 + +#define ZEND_RECV 63 +#define ZEND_RECV_INIT 64 + +#define ZEND_SEND_VAL 65 +#define ZEND_SEND_VAR 66 +#define ZEND_SEND_REF 67 + +#define ZEND_NEW 68 +#define ZEND_JMP_NO_CTOR 69 +#define ZEND_FREE 70 + +#define ZEND_INIT_ARRAY 71 +#define ZEND_ADD_ARRAY_ELEMENT 72 + +#define ZEND_INCLUDE_OR_EVAL 73 + +#define ZEND_UNSET_VAR 74 +#define ZEND_UNSET_DIM_OBJ 75 +#define ZEND_ISSET_ISEMPTY 76 -#define ZEND_FE_RESET 76 -#define ZEND_FE_FETCH 77 +#define ZEND_FE_RESET 77 +#define ZEND_FE_FETCH 78 -#define ZEND_EXIT 78 +#define ZEND_EXIT 79 /* the following 18 opcodes are 6 groups of 3 opcodes each, and must * remain in that order! */ -#define ZEND_FETCH_R 79 -#define ZEND_FETCH_DIM_R 80 -#define ZEND_FETCH_OBJ_R 81 -#define ZEND_FETCH_W 82 -#define ZEND_FETCH_DIM_W 83 -#define ZEND_FETCH_OBJ_W 84 -#define ZEND_FETCH_RW 85 -#define ZEND_FETCH_DIM_RW 86 -#define ZEND_FETCH_OBJ_RW 87 -#define ZEND_FETCH_IS 88 -#define ZEND_FETCH_DIM_IS 89 -#define ZEND_FETCH_OBJ_IS 90 -#define ZEND_FETCH_FUNC_ARG 91 -#define ZEND_FETCH_DIM_FUNC_ARG 92 -#define ZEND_FETCH_OBJ_FUNC_ARG 93 -#define ZEND_FETCH_UNSET 94 -#define ZEND_FETCH_DIM_UNSET 95 -#define ZEND_FETCH_OBJ_UNSET 96 - -#define ZEND_FETCH_DIM_TMP_VAR 97 -#define ZEND_FETCH_CONSTANT 98 - -#define ZEND_DECLARE_FUNCTION_OR_CLASS 99 - -#define ZEND_EXT_STMT 100 -#define ZEND_EXT_FCALL_BEGIN 101 -#define ZEND_EXT_FCALL_END 102 -#define ZEND_EXT_NOP 103 +#define ZEND_FETCH_R 80 +#define ZEND_FETCH_DIM_R 81 +#define ZEND_FETCH_OBJ_R 82 +#define ZEND_FETCH_W 83 +#define ZEND_FETCH_DIM_W 84 +#define ZEND_FETCH_OBJ_W 85 +#define ZEND_FETCH_RW 86 +#define ZEND_FETCH_DIM_RW 87 +#define ZEND_FETCH_OBJ_RW 88 +#define ZEND_FETCH_IS 89 +#define ZEND_FETCH_DIM_IS 90 +#define ZEND_FETCH_OBJ_IS 91 +#define ZEND_FETCH_FUNC_ARG 92 +#define ZEND_FETCH_DIM_FUNC_ARG 93 +#define ZEND_FETCH_OBJ_FUNC_ARG 94 +#define ZEND_FETCH_UNSET 95 +#define ZEND_FETCH_DIM_UNSET 96 +#define ZEND_FETCH_OBJ_UNSET 97 + +#define ZEND_FETCH_DIM_TMP_VAR 98 +#define ZEND_FETCH_CONSTANT 99 + +#define ZEND_DECLARE_FUNCTION_OR_CLASS 100 + +#define ZEND_EXT_STMT 101 +#define ZEND_EXT_FCALL_BEGIN 102 +#define ZEND_EXT_FCALL_END 103 +#define ZEND_EXT_NOP 104 -#define ZEND_TICKS 104 +#define ZEND_TICKS 105 /* end of block */ Index: zend_execute.c =================================================================== RCS file: /repository/Zend/zend_execute.c,v retrieving revision 1.169 diff -u -r1.169 zend_execute.c --- zend_execute.c 2000/02/26 16:21:29 1.169 +++ zend_execute.c 2000/03/05 00:37:34 @@ -1065,6 +1065,9 @@ case ZEND_IS_IDENTICAL: EG(binary_op) = is_identical_function; goto binary_op_addr; + case ZEND_IS_NOT_IDENTICAL: + EG(binary_op) = is_not_identical_function; + goto binary_op_addr; case ZEND_IS_EQUAL: EG(binary_op) = is_equal_function; goto binary_op_addr; Index: zend_opcode.c =================================================================== RCS file: /repository/Zend/zend_opcode.c,v retrieving revision 1.31 diff -u -r1.31 zend_opcode.c --- zend_opcode.c 2000/02/19 22:46:42 1.31 +++ zend_opcode.c 2000/03/05 00:37:34 @@ -386,6 +386,9 @@ case ZEND_IS_IDENTICAL: return (void *) is_identical_function; break; + case ZEND_IS_NOT_IDENTICAL: + return (void *) is_not_identical_function; + break; case ZEND_IS_EQUAL: return (void *) is_equal_function; break; Index: zend_operators.c =================================================================== RCS file: /repository/Zend/zend_operators.c,v retrieving revision 1.52 diff -u -r1.52 zend_operators.c --- zend_operators.c 2000/02/26 04:07:03 1.52 +++ zend_operators.c 2000/03/05 00:37:34 @@ -996,6 +996,17 @@ return FAILURE; } +ZEND_API int is_not_identical_function(zval *result, zval *op1, zval *op2) +{ + result->type = IS_BOOL; + if ( is_identical_function( result, op1, op2 ) == FAILURE ) { + return FAILURE; + } + result->value.lval = !result->value.lval; + return SUCCESS; +} + + ZEND_API int is_equal_function(zval *result, zval *op1, zval *op2) { if (compare_function(result, op1, op2) == FAILURE) { Index: zend_operators.h =================================================================== RCS file: /repository/Zend/zend_operators.h,v retrieving revision 1.16 diff -u -r1.16 zend_operators.h --- zend_operators.h 2000/02/19 22:46:42 1.16 +++ zend_operators.h 2000/03/05 00:37:34 @@ -43,6 +43,7 @@ ZEND_API int is_equal_function(zval *result, zval *op1, zval *op2); ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2); +ZEND_API int is_not_identical_function(zval *result, zval *op1, zval *op2); ZEND_API int is_not_equal_function(zval *result, zval *op1, zval *op2); ZEND_API int is_smaller_function(zval *result, zval *op1, zval *op2); ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2);

« previous php.dev (#16522) next »