@@ -262,15 +262,15 @@ fn builtin_locals(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
262
262
263
263
fn builtin_pow ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
264
264
arg_check ! (
265
- vm,
266
- args,
267
- required = [ ( x, None ) , ( y, None ) ] ,
268
- optional= [ ( mod_value, Some ( vm. ctx. int_type( ) ) ) ]
265
+ vm,
266
+ args,
267
+ required = [ ( x, None ) , ( y, None ) ] ,
268
+ optional = [ ( mod_value, Some ( vm. ctx. int_type( ) ) ) ]
269
269
) ;
270
270
let pow_method_name = "__pow__" . to_string ( ) ;
271
271
let result = match vm. get_attribute ( x. clone ( ) , & pow_method_name) {
272
272
Ok ( attrib) => vm. invoke ( attrib, PyFuncArgs :: new ( vec ! [ y. clone( ) ] , vec ! [ ] ) ) ,
273
- Err ( ..) => Err ( vm. new_type_error ( "unsupported operand type(s) for pow" . to_string ( ) ) )
273
+ Err ( ..) => Err ( vm. new_type_error ( "unsupported operand type(s) for pow" . to_string ( ) ) ) ,
274
274
} ;
275
275
//Check if the 3rd argument is defined and perform modulus on the result
276
276
//this should be optimized in the future to perform a "power-mod" algorithm in
@@ -279,23 +279,19 @@ fn builtin_pow(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
279
279
Some ( mod_value) => {
280
280
let mod_method_name = "__mod__" . to_string ( ) ;
281
281
match vm. get_attribute (
282
- result. expect ( "result not defined" ) . clone ( ) ,
283
- & mod_method_name
284
- ) {
285
- Ok ( value) => vm. invoke (
286
- value,
287
- PyFuncArgs :: new ( vec ! [ mod_value. clone( ) ] , vec ! [ ] )
288
- ) ,
289
- Err ( ..) => Err (
290
- vm. new_type_error ( "unsupported operand type(s) for mod" . to_string ( ) )
291
- )
282
+ result. expect ( "result not defined" ) . clone ( ) ,
283
+ & mod_method_name,
284
+ ) {
285
+ Ok ( value) => vm. invoke ( value, PyFuncArgs :: new ( vec ! [ mod_value. clone( ) ] , vec ! [ ] ) ) ,
286
+ Err ( ..) => {
287
+ Err ( vm. new_type_error ( "unsupported operand type(s) for mod" . to_string ( ) ) )
288
+ }
292
289
}
293
290
}
294
- None => result
291
+ None => result,
295
292
}
296
293
}
297
294
298
-
299
295
pub fn builtin_print ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
300
296
trace ! ( "print called with {:?}" , args) ;
301
297
for a in args. args {
0 commit comments