Add int.__rlshift__, int.__rrshift__ methods.
@@ -345,6 +345,16 @@ impl PyInt {
inner_lshift(self, other, vm)
}
+ #[pymethod(name = "__rlshift__")]
+ fn rlshift(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult {
+ if !objtype::isinstance(&other, &vm.ctx.int_type()) {
+ return Ok(vm.ctx.not_implemented());
+ }
+
+ let other = other.payload::<PyInt>().unwrap();
+ inner_lshift(other, self, vm)
+ }
+
#[pymethod(name = "__rshift__")]
fn rshift(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult {
if !objtype::isinstance(&other, &vm.ctx.int_type()) {
@@ -355,6 +365,16 @@ impl PyInt {
inner_rshift(self, other, vm)
}
+ #[pymethod(name = "__rrshift__")]
+ fn rrshift(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult {
+ if !objtype::isinstance(&other, &vm.ctx.int_type()) {
+ return Ok(vm.ctx.not_implemented());
+ }
+
+ let other = other.payload::<PyInt>().unwrap();
+ inner_rshift(other, self, vm)
+ }
+
#[pymethod(name = "__xor__")]
pub fn xor(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyObjectRef {
if objtype::isinstance(&other, &vm.ctx.int_type()) {
