@@ -608,6 +608,18 @@ fn int_conjugate(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
608
608
Ok ( vm. ctx . new_int ( v) )
609
609
}
610
610
611
+ fn int_real ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
612
+ arg_check ! ( vm, args, required = [ ( zelf, Some ( vm. ctx. int_type( ) ) ) ] ) ;
613
+ let value = BigInt :: from_pyobj ( zelf) ;
614
+ Ok ( vm. ctx . new_int ( value) )
615
+ }
616
+
617
+ fn int_imag ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
618
+ arg_check ! ( vm, args, required = [ ( zelf, Some ( vm. ctx. int_type( ) ) ) ] ) ;
619
+ let value = BigInt :: from ( 0 ) ;
620
+ Ok ( vm. ctx . new_int ( value) )
621
+ }
622
+
611
623
pub fn init ( context : & PyContext ) {
612
624
let int_doc = "int(x=0) -> integer
613
625
int(x, base=10) -> integer
@@ -680,4 +692,6 @@ Base 0 means to interpret the base from the string as an integer literal.
680
692
) ;
681
693
context. set_attr ( & int_type, "__doc__" , context. new_str ( int_doc. to_string ( ) ) ) ;
682
694
context. set_attr ( & int_type, "conjugate" , context. new_rustfunc ( int_conjugate) ) ;
695
+ context. set_attr ( & int_type, "real" , context. new_property ( int_real) ) ;
696
+ context. set_attr ( & int_type, "imag" , context. new_property ( int_imag) ) ;
683
697
}
0 commit comments