@@ -20,7 +20,7 @@ fn int_new(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
20
20
required = [ ( cls, None ) ] ,
21
21
optional = [ ( val_option, None ) ]
22
22
) ;
23
- if !objtype:: issubclass ( cls, vm. ctx . int_type ( ) ) {
23
+ if !objtype:: issubclass ( cls, & vm. ctx . int_type ( ) ) {
24
24
return Err ( vm. new_type_error ( format ! ( "{:?} is not a subtype of int" , cls) ) ) ;
25
25
}
26
26
@@ -38,11 +38,11 @@ fn int_new(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
38
38
39
39
// Casting function:
40
40
pub fn to_int ( vm : & mut VirtualMachine , obj : & PyObjectRef , base : u32 ) -> Result < i32 , PyObjectRef > {
41
- let val = if objtype:: isinstance ( obj, vm. ctx . int_type ( ) ) {
41
+ let val = if objtype:: isinstance ( obj, & vm. ctx . int_type ( ) ) {
42
42
get_value ( obj)
43
- } else if objtype:: isinstance ( obj, vm. ctx . float_type ( ) ) {
43
+ } else if objtype:: isinstance ( obj, & vm. ctx . float_type ( ) ) {
44
44
objfloat:: get_value ( obj) as i32
45
- } else if objtype:: isinstance ( obj, vm. ctx . str_type ( ) ) {
45
+ } else if objtype:: isinstance ( obj, & vm. ctx . str_type ( ) ) {
46
46
let s = objstr:: get_value ( obj) ;
47
47
match i32:: from_str_radix ( & s, base) {
48
48
Ok ( v) => v,
@@ -85,11 +85,11 @@ fn int_eq(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
85
85
args,
86
86
required = [ ( zelf, Some ( vm. ctx. int_type( ) ) ) , ( other, None ) ]
87
87
) ;
88
- let result = if objtype:: isinstance ( other, vm. ctx . int_type ( ) ) {
88
+ let result = if objtype:: isinstance ( other, & vm. ctx . int_type ( ) ) {
89
89
let zelf = i32:: from_pyobj ( zelf) ;
90
90
let other = i32:: from_pyobj ( other) ;
91
91
zelf == other
92
- } else if objtype:: isinstance ( other, vm. ctx . float_type ( ) ) {
92
+ } else if objtype:: isinstance ( other, & vm. ctx . float_type ( ) ) {
93
93
let zelf = i32:: from_pyobj ( zelf) as f64 ;
94
94
let other = objfloat:: get_value ( other) ;
95
95
zelf == other
@@ -178,9 +178,9 @@ fn int_add(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
178
178
required = [ ( i, Some ( vm. ctx. int_type( ) ) ) , ( i2, None ) ]
179
179
) ;
180
180
let i = i32:: from_pyobj ( i) ;
181
- if objtype:: isinstance ( i2, vm. ctx . int_type ( ) ) {
181
+ if objtype:: isinstance ( i2, & vm. ctx . int_type ( ) ) {
182
182
Ok ( vm. ctx . new_int ( i + get_value ( i2) ) )
183
- } else if objtype:: isinstance ( i2, vm. ctx . float_type ( ) ) {
183
+ } else if objtype:: isinstance ( i2, & vm. ctx . float_type ( ) ) {
184
184
Ok ( vm. ctx . new_float ( i as f64 + objfloat:: get_value ( i2) ) )
185
185
} else {
186
186
Err ( vm. new_type_error ( format ! ( "Cannot add {:?} and {:?}" , i, i2) ) )
@@ -193,7 +193,7 @@ fn int_floordiv(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
193
193
args,
194
194
required = [ ( i, Some ( vm. ctx. int_type( ) ) ) , ( i2, None ) ]
195
195
) ;
196
- if objtype:: isinstance ( i2, vm. ctx . int_type ( ) ) {
196
+ if objtype:: isinstance ( i2, & vm. ctx . int_type ( ) ) {
197
197
Ok ( vm. ctx . new_int ( get_value ( i) / get_value ( i2) ) )
198
198
} else {
199
199
Err ( vm. new_type_error ( format ! ( "Cannot floordiv {:?} and {:?}" , i, i2) ) )
@@ -207,9 +207,9 @@ fn int_sub(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
207
207
required = [ ( i, Some ( vm. ctx. int_type( ) ) ) , ( i2, None ) ]
208
208
) ;
209
209
let i = i32:: from_pyobj ( i) ;
210
- if objtype:: isinstance ( i2, vm. ctx . int_type ( ) ) {
210
+ if objtype:: isinstance ( i2, & vm. ctx . int_type ( ) ) {
211
211
Ok ( vm. ctx . new_int ( i - get_value ( i2) ) )
212
- } else if objtype:: isinstance ( i2, vm. ctx . float_type ( ) ) {
212
+ } else if objtype:: isinstance ( i2, & vm. ctx . float_type ( ) ) {
213
213
Ok ( vm. ctx . new_float ( i as f64 - objfloat:: get_value ( i2) ) )
214
214
} else {
215
215
Err ( vm. new_type_error ( format ! ( "Cannot substract {:?} and {:?}" , i, i2) ) )
@@ -222,9 +222,9 @@ fn int_mul(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
222
222
args,
223
223
required = [ ( i, Some ( vm. ctx. int_type( ) ) ) , ( i2, None ) ]
224
224
) ;
225
- if objtype:: isinstance ( i2, vm. ctx . int_type ( ) ) {
225
+ if objtype:: isinstance ( i2, & vm. ctx . int_type ( ) ) {
226
226
Ok ( vm. ctx . new_int ( get_value ( i) * get_value ( i2) ) )
227
- } else if objtype:: isinstance ( i2, vm. ctx . float_type ( ) ) {
227
+ } else if objtype:: isinstance ( i2, & vm. ctx . float_type ( ) ) {
228
228
Ok ( vm
229
229
. ctx
230
230
. new_float ( get_value ( i) as f64 * objfloat:: get_value ( i2) ) )
@@ -240,9 +240,9 @@ fn int_truediv(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
240
240
required = [ ( i, Some ( vm. ctx. int_type( ) ) ) , ( i2, None ) ]
241
241
) ;
242
242
let v1 = get_value ( i) ;
243
- if objtype:: isinstance ( i2, vm. ctx . int_type ( ) ) {
243
+ if objtype:: isinstance ( i2, & vm. ctx . int_type ( ) ) {
244
244
Ok ( vm. ctx . new_float ( v1 as f64 / get_value ( i2) as f64 ) )
245
- } else if objtype:: isinstance ( i2, vm. ctx . float_type ( ) ) {
245
+ } else if objtype:: isinstance ( i2, & vm. ctx . float_type ( ) ) {
246
246
Ok ( vm. ctx . new_float ( v1 as f64 / objfloat:: get_value ( i2) ) )
247
247
} else {
248
248
Err ( vm. new_type_error ( format ! ( "Cannot divide {:?} and {:?}" , i, i2) ) )
@@ -256,7 +256,7 @@ fn int_mod(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
256
256
required = [ ( i, Some ( vm. ctx. int_type( ) ) ) , ( i2, None ) ]
257
257
) ;
258
258
let v1 = get_value ( i) ;
259
- if objtype:: isinstance ( i2, vm. ctx . int_type ( ) ) {
259
+ if objtype:: isinstance ( i2, & vm. ctx . int_type ( ) ) {
260
260
Ok ( vm. ctx . new_int ( v1 % get_value ( i2) ) )
261
261
} else {
262
262
Err ( vm. new_type_error ( format ! ( "Cannot modulo {:?} and {:?}" , i, i2) ) )
@@ -270,10 +270,10 @@ fn int_pow(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
270
270
required = [ ( i, Some ( vm. ctx. int_type( ) ) ) , ( i2, None ) ]
271
271
) ;
272
272
let v1 = get_value ( i) ;
273
- if objtype:: isinstance ( i2, vm. ctx . int_type ( ) ) {
273
+ if objtype:: isinstance ( i2, & vm. ctx . int_type ( ) ) {
274
274
let v2 = get_value ( i2) ;
275
275
Ok ( vm. ctx . new_int ( v1. pow ( v2 as u32 ) ) )
276
- } else if objtype:: isinstance ( i2, vm. ctx . float_type ( ) ) {
276
+ } else if objtype:: isinstance ( i2, & vm. ctx . float_type ( ) ) {
277
277
let v2 = objfloat:: get_value ( i2) ;
278
278
Ok ( vm. ctx . new_float ( ( v1 as f64 ) . powf ( v2) ) )
279
279
} else {
@@ -288,7 +288,7 @@ fn int_divmod(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
288
288
required = [ ( i, Some ( vm. ctx. int_type( ) ) ) , ( i2, None ) ]
289
289
) ;
290
290
let args = PyFuncArgs :: new ( vec ! [ i. clone( ) , i2. clone( ) ] , vec ! [ ] ) ;
291
- if objtype:: isinstance ( i2, vm. ctx . int_type ( ) ) {
291
+ if objtype:: isinstance ( i2, & vm. ctx . int_type ( ) ) {
292
292
let r1 = int_floordiv ( vm, args. clone ( ) ) ;
293
293
let r2 = int_mod ( vm, args. clone ( ) ) ;
294
294
Ok ( vm. ctx . new_tuple ( vec ! [ r1. unwrap( ) , r2. unwrap( ) ] ) )
@@ -304,7 +304,7 @@ fn int_xor(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
304
304
required = [ ( i, Some ( vm. ctx. int_type( ) ) ) , ( i2, None ) ]
305
305
) ;
306
306
let v1 = get_value ( i) ;
307
- if objtype:: isinstance ( i2, vm. ctx . int_type ( ) ) {
307
+ if objtype:: isinstance ( i2, & vm. ctx . int_type ( ) ) {
308
308
let v2 = get_value ( i2) ;
309
309
Ok ( vm. ctx . new_int ( v1 ^ v2) )
310
310
} else {
@@ -319,7 +319,7 @@ fn int_or(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
319
319
required = [ ( i, Some ( vm. ctx. int_type( ) ) ) , ( i2, None ) ]
320
320
) ;
321
321
let v1 = get_value ( i) ;
322
- if objtype:: isinstance ( i2, vm. ctx . int_type ( ) ) {
322
+ if objtype:: isinstance ( i2, & vm. ctx . int_type ( ) ) {
323
323
let v2 = get_value ( i2) ;
324
324
Ok ( vm. ctx . new_int ( v1 | v2) )
325
325
} else {
@@ -334,7 +334,7 @@ fn int_and(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
334
334
required = [ ( i, Some ( vm. ctx. int_type( ) ) ) , ( i2, None ) ]
335
335
) ;
336
336
let v1 = get_value ( i) ;
337
- if objtype:: isinstance ( i2, vm. ctx . int_type ( ) ) {
337
+ if objtype:: isinstance ( i2, & vm. ctx . int_type ( ) ) {
338
338
let v2 = get_value ( i2) ;
339
339
Ok ( vm. ctx . new_int ( v1 & v2) )
340
340
} else {
0 commit comments