@@ -107,6 +107,36 @@ def __pow__(self, other: AstConvertible) -> OQPyBinaryExpression:
107
107
def __rpow__ (self , other : AstConvertible ) -> OQPyBinaryExpression :
108
108
return self ._to_binary ("**" , other , self )
109
109
110
+ def __lshift__ (self , other : AstConvertible ) -> OQPyBinaryExpression :
111
+ return self ._to_binary ("<<" , self , other )
112
+
113
+ def __rlshift__ (self , other : AstConvertible ) -> OQPyBinaryExpression :
114
+ return self ._to_binary ("<<" , other , self )
115
+
116
+ def __rshift__ (self , other : AstConvertible ) -> OQPyBinaryExpression :
117
+ return self ._to_binary (">>" , self , other )
118
+
119
+ def __rrshift__ (self , other : AstConvertible ) -> OQPyBinaryExpression :
120
+ return self ._to_binary (">>" , other , self )
121
+
122
+ def __and__ (self , other : AstConvertible ) -> OQPyBinaryExpression :
123
+ return self ._to_binary ("&" , self , other )
124
+
125
+ def __rand__ (self , other : AstConvertible ) -> OQPyBinaryExpression :
126
+ return self ._to_binary ("&" , other , self )
127
+
128
+ def __or__ (self , other : AstConvertible ) -> OQPyBinaryExpression :
129
+ return self ._to_binary ("|" , self , other )
130
+
131
+ def __ror__ (self , other : AstConvertible ) -> OQPyBinaryExpression :
132
+ return self ._to_binary ("|" , other , self )
133
+
134
+ def __xor__ (self , other : AstConvertible ) -> OQPyBinaryExpression :
135
+ return self ._to_binary ("^" , self , other )
136
+
137
+ def __rxor__ (self , other : AstConvertible ) -> OQPyBinaryExpression :
138
+ return self ._to_binary ("^" , other , self )
139
+
110
140
def __eq__ (self , other : AstConvertible ) -> OQPyBinaryExpression : # type: ignore[override]
111
141
return self ._to_binary ("==" , self , other )
112
142
@@ -125,13 +155,26 @@ def __ge__(self, other: AstConvertible) -> OQPyBinaryExpression:
125
155
def __le__ (self , other : AstConvertible ) -> OQPyBinaryExpression :
126
156
return self ._to_binary ("<=" , self , other )
127
157
158
+ def __invert__ (self ) -> OQPyUnaryExpression :
159
+ return self ._to_unary ("~" , self )
160
+
128
161
def __bool__ (self ) -> bool :
129
162
raise RuntimeError (
130
163
"OQPy expressions cannot be converted to bool. This can occur if you try to check "
131
164
"the equality of expressions using == instead of expr_matches."
132
165
)
133
166
134
167
168
+ def logical_and (first : AstConvertible , second : AstConvertible ) -> OQPyBinaryExpression :
169
+ """Logical AND."""
170
+ return OQPyBinaryExpression (ast .BinaryOperator ["&&" ], first , second )
171
+
172
+
173
+ def logical_or (first : AstConvertible , second : AstConvertible ) -> OQPyBinaryExpression :
174
+ """Logical OR."""
175
+ return OQPyBinaryExpression (ast .BinaryOperator ["||" ], first , second )
176
+
177
+
135
178
def expr_matches (a : Any , b : Any ) -> bool :
136
179
"""Check equality of the given objects.
137
180
0 commit comments