Add int.__rlshift__, int.__rrshift__ methods.

This commit is contained in:
ChJR
2019-08-15 18:51:09 +09:00
parent 95b5508f52
commit f4b0195643

View File

@@ -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()) {