@@ -608,6 +608,18 @@ fn int_conjugate(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
608608 Ok ( vm. ctx . new_int ( v) )
609609}
610610
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+
611623pub fn init ( context : & PyContext ) {
612624 let int_doc = "int(x=0) -> integer
613625int(x, base=10) -> integer
@@ -680,4 +692,6 @@ Base 0 means to interpret the base from the string as an integer literal.
680692 ) ;
681693 context. set_attr ( & int_type, "__doc__" , context. new_str ( int_doc. to_string ( ) ) ) ;
682694 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) ) ;
683697}
0 commit comments