]> granicus.if.org Git - php/commitdiff
Added !== (is not identical) operator.
authorTorben Wilson <torben@php.net>
Wed, 29 Mar 2000 22:05:19 +0000 (22:05 +0000)
committerTorben Wilson <torben@php.net>
Wed, 29 Mar 2000 22:05:19 +0000 (22:05 +0000)
Zend/zend-parser.y
Zend/zend-scanner.l
Zend/zend_compile.h
Zend/zend_execute.c
Zend/zend_opcode.c
Zend/zend_operators.c
Zend/zend_operators.h

index c6e7fc3c2327007e4560ef5b871a4c6b0a843230..6c1a4095cec75bb3596cbec500654c9adb68483f 100644 (file)
@@ -60,7 +60,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_without_variable:
        |       '!' 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 5e214e13e6c2ffce282402216a64f30401a21bf7..86566de35bc5a11bc2b47dd2cfc5a5e9c694051a 100644 (file)
@@ -989,6 +989,10 @@ ESCAPED_AND_WHITESPACE [\n\t\r #'.:;,()|^&+-/*=%!~<>?@]+
        return T_IS_IDENTICAL;
 }
 
+<ST_IN_SCRIPTING>"!==" {
+       return T_IS_NOT_IDENTICAL;
+}
+
 <ST_IN_SCRIPTING>"==" {
        return T_IS_EQUAL;
 }
index 5bcd93c7230940b6aae4dc05fee999d41484789f..0bc4199526f73a254d279869b0c959a201d3a0b3 100644 (file)
@@ -403,120 +403,121 @@ int zendlex(znode *zendlval CLS_DC);
 #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_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                           33
-#define ZEND_PRE_DEC                           34
-#define ZEND_POST_INC                          35
-#define ZEND_POST_DEC                          36
+#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_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_SEND_VAL                          65
+#define ZEND_SEND_VAR                          66
+#define ZEND_SEND_REF                          67
 
-#define ZEND_NEW                                       67
-#define ZEND_JMP_NO_CTOR                       68
-#define ZEND_FREE                                      69
+#define ZEND_NEW                                       68
+#define ZEND_JMP_NO_CTOR                       69
+#define ZEND_FREE                                      70
                                                                        
-#define ZEND_INIT_ARRAY                                70
-#define ZEND_ADD_ARRAY_ELEMENT         71
+#define ZEND_INIT_ARRAY                                71
+#define ZEND_ADD_ARRAY_ELEMENT         72
                                                                        
-#define ZEND_INCLUDE_OR_EVAL           72
+#define ZEND_INCLUDE_OR_EVAL           73
                                                                        
-#define ZEND_UNSET_VAR                         73
-#define ZEND_UNSET_DIM_OBJ                     74
-#define ZEND_ISSET_ISEMPTY                     75
+#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_TICKS                                     104
+#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                                     105
 
 /* end of block */
 
index d8c44c0f1fb0d79d464a94658b9aefa91168e743..54a97671ade48af041750277253a07d9da11216f 100644 (file)
@@ -1051,6 +1051,9 @@ void execute(zend_op_array *op_array ELS_DC)
                        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 96ac7952ecb4b13fa1104d8288c1148b0685564e..9d05b2cbc58d52f92299e787eb6fd26b5461b422 100644 (file)
@@ -384,6 +384,9 @@ ZEND_API void *get_binary_op(int opcode)
                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 ece7d04dcdc9f863e1e2fcc1d0a98c7a7cfb7898..0a2cc35148abc2c3dfedbbd75dce5a1e5ce13421 100644 (file)
@@ -999,6 +999,18 @@ ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2)
        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 ad3cab6ef11c7c79a22cdf22b60a64d65bd103bf..ace040cb9af56aec956d6025d70191a84a305606 100644 (file)
@@ -43,6 +43,7 @@ ZEND_API int concat_function(zval *result, zval *op1, zval *op2);
 
 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);