@@ -153,6 +153,50 @@ class NotEqualOp {
153153 }
154154};
155155
156+ /* *
157+ * @brief Identity comparison operator
158+ *
159+ * Checks if two operands refer to the same object.
160+ * If both operands are None, returns true.
161+ */
162+ class IsOp {
163+ public:
164+ /* *
165+ * @brief Performs identity comparison between two operands
166+ *
167+ * @param v1 First operand
168+ * @param v2 Second operand
169+ * @return Boolean result of v1 is v2
170+ */
171+ static OpReturnType operate (OpReturnType v1, OpReturnType v2) {
172+ bool isIdentical = (v1 == v2);
173+ bool bothNone = (v1->is_none () && v2->is_none ());
174+ return OpReturnType (new SingleVariable<bool >(isIdentical || bothNone));
175+ }
176+ };
177+
178+ /* *
179+ * @brief Identity negation comparison operator
180+ *
181+ * Checks if two operands do not refer to the same object.
182+ * If both operands are None, returns false.
183+ */
184+ class IsNotOp {
185+ public:
186+ /* *
187+ * @brief Performs negated identity comparison between two operands
188+ *
189+ * @param v1 First operand
190+ * @param v2 Second operand
191+ * @return Boolean result of v1 is not v2
192+ */
193+ static OpReturnType operate (OpReturnType v1, OpReturnType v2) {
194+ bool isDifferent = (v1 != v2);
195+ bool bothNone = (v1->is_none () && v2->is_none ());
196+ return OpReturnType (new SingleVariable<bool >(isDifferent && !bothNone));
197+ }
198+ };
199+
156200/* *
157201 * @brief Main class for comparison operations
158202 *
@@ -225,6 +269,28 @@ class CompareOperators {
225269 static OpReturnType notIn (OpReturnType v1, OpReturnType v2) {
226270 return OpReturnType (new SingleVariable<bool >(v2->notIn (v1)));
227271 }
272+
273+ /* *
274+ * @brief Tests if the two operands refer to the same object.
275+ *
276+ * @param v1 First operand
277+ * @param v2 Second operand
278+ * @return Boolean result of v1 is v2
279+ */
280+ static OpReturnType is (OpReturnType v1, OpReturnType v2) {
281+ return IsOp::operate (v1, v2);
282+ }
283+
284+ /* *
285+ * @brief Tests if the two operands do not refer to the same object.
286+ *
287+ * @param v1 First operand
288+ * @param v2 Second operand
289+ * @return Boolean result of v1 is not v2
290+ */
291+ static OpReturnType isNot (OpReturnType v1, OpReturnType v2) {
292+ return IsNotOp::operate (v1, v2);
293+ }
228294};
229295
230296/* *
0 commit comments