@@ -242,10 +242,11 @@ public static AbsNode create() {
242
242
243
243
}
244
244
245
+ @ Builtin (name = __RADD__ , minNumOfPositionalArgs = 2 )
245
246
@ Builtin (name = __ADD__ , minNumOfPositionalArgs = 2 )
246
247
@ TypeSystemReference (PythonArithmeticTypes .class )
247
248
@ GenerateNodeFactory
248
- abstract static class AddNode extends PythonBuiltinNode {
249
+ abstract static class AddNode extends PythonBinaryBuiltinNode {
249
250
@ Specialization
250
251
PComplex doComplexLong (PComplex left , long right ) {
251
252
return factory ().createComplex (left .getReal () + right , left .getImag ());
@@ -274,14 +275,10 @@ PNotImplemented doComplex(Object left, Object right) {
274
275
}
275
276
}
276
277
277
- @ GenerateNodeFactory
278
- @ Builtin (name = __RADD__ , minNumOfPositionalArgs = 2 )
279
- abstract static class RAddNode extends AddNode {
280
- }
281
-
282
- @ GenerateNodeFactory
278
+ @ Builtin (name = __RTRUEDIV__ , minNumOfPositionalArgs = 2 , reverseOperation = true )
283
279
@ Builtin (name = __TRUEDIV__ , minNumOfPositionalArgs = 2 )
284
280
@ TypeSystemReference (PythonArithmeticTypes .class )
281
+ @ GenerateNodeFactory
285
282
public abstract static class DivNode extends PythonBinaryBuiltinNode {
286
283
287
284
public abstract PComplex executeComplex (VirtualFrame frame , Object left , Object right );
@@ -339,19 +336,8 @@ PComplex doComplex(PComplex left, PComplex right,
339
336
return factory ().createComplex (real , imag );
340
337
}
341
338
342
- @ SuppressWarnings ("unused" )
343
- @ Fallback
344
- PNotImplemented doComplex (Object left , Object right ) {
345
- return PNotImplemented .NOT_IMPLEMENTED ;
346
- }
347
- }
348
-
349
- @ GenerateNodeFactory
350
- @ Builtin (name = __RTRUEDIV__ , minNumOfPositionalArgs = 2 )
351
- @ TypeSystemReference (PythonArithmeticTypes .class )
352
- abstract static class RDivNode extends PythonBinaryBuiltinNode {
353
339
@ Specialization
354
- PComplex doComplexDouble (PComplex right , double left ) {
340
+ PComplex doComplexDouble (double left , PComplex right ) {
355
341
double oprealSq = right .getReal () * right .getReal ();
356
342
double opimagSq = right .getImag () * right .getImag ();
357
343
double twice = 2 * right .getImag () * right .getReal ();
@@ -361,7 +347,7 @@ PComplex doComplexDouble(PComplex right, double left) {
361
347
}
362
348
363
349
@ Specialization
364
- PComplex doComplexInt (PComplex right , long left ) {
350
+ PComplex doComplexInt (long left , PComplex right ) {
365
351
double oprealSq = right .getReal () * right .getReal ();
366
352
double opimagSq = right .getImag () * right .getImag ();
367
353
double twice = 2 * right .getImag () * right .getReal ();
@@ -371,7 +357,7 @@ PComplex doComplexInt(PComplex right, long left) {
371
357
}
372
358
373
359
@ Specialization
374
- PComplex doComplexPInt (PComplex right , PInt left ) {
360
+ PComplex doComplexPInt (PInt left , PComplex right ) {
375
361
return doComplexDouble (right , left .doubleValue ());
376
362
}
377
363
@@ -382,6 +368,16 @@ PNotImplemented doComplex(Object left, Object right) {
382
368
}
383
369
}
384
370
371
+ @ GenerateNodeFactory
372
+ @ TypeSystemReference (PythonArithmeticTypes .class )
373
+ abstract static class RDivNode extends PythonBinaryBuiltinNode {
374
+ @ SuppressWarnings ("unused" )
375
+ @ Fallback
376
+ PNotImplemented doComplex (Object left , Object right ) {
377
+ return PNotImplemented .NOT_IMPLEMENTED ;
378
+ }
379
+ }
380
+
385
381
@ GenerateNodeFactory
386
382
@ Builtin (name = __DIVMOD__ , minNumOfPositionalArgs = 2 )
387
383
abstract static class DivModNode extends PythonBinaryBuiltinNode {
@@ -394,6 +390,7 @@ PComplex doComplexDouble(Object right, Object left) {
394
390
}
395
391
396
392
@ GenerateNodeFactory
393
+ @ Builtin (name = __RMUL__ , minNumOfPositionalArgs = 2 )
397
394
@ Builtin (name = __MUL__ , minNumOfPositionalArgs = 2 )
398
395
@ TypeSystemReference (PythonArithmeticTypes .class )
399
396
abstract static class MulNode extends PythonBinaryBuiltinNode {
@@ -427,11 +424,7 @@ PNotImplemented doGeneric(Object left, Object right) {
427
424
}
428
425
429
426
@ GenerateNodeFactory
430
- @ Builtin (name = __RMUL__ , minNumOfPositionalArgs = 2 )
431
- abstract static class RMulNode extends MulNode {
432
- }
433
-
434
- @ GenerateNodeFactory
427
+ @ Builtin (name = __RSUB__ , minNumOfPositionalArgs = 2 , reverseOperation = true )
435
428
@ Builtin (name = __SUB__ , minNumOfPositionalArgs = 2 )
436
429
@ TypeSystemReference (PythonArithmeticTypes .class )
437
430
abstract static class SubNode extends PythonBinaryBuiltinNode {
@@ -450,26 +443,20 @@ PComplex doComplex(PComplex left, long right) {
450
443
return factory ().createComplex (left .getReal () - right , left .getImag ());
451
444
}
452
445
453
- @ SuppressWarnings ("unused" )
454
- @ Fallback
455
- PNotImplemented doComplex (Object left , Object right ) {
456
- return PNotImplemented .NOT_IMPLEMENTED ;
446
+ @ Specialization
447
+ PComplex doComplexDouble (double left , PComplex right ) {
448
+ return factory ().createComplex (left - right .getReal (), -right .getImag ());
457
449
}
458
- }
459
450
460
- @ GenerateNodeFactory
461
- @ Builtin (name = __RSUB__ , minNumOfPositionalArgs = 2 )
462
- abstract static class RSubNode extends SubNode {
463
- @ Override
464
451
@ Specialization
465
- PComplex doComplexDouble ( PComplex left , double right ) {
466
- return factory ().createComplex (right - left .getReal (), -left .getImag ());
452
+ PComplex doComplex ( long left , PComplex right ) {
453
+ return factory ().createComplex (left - right .getReal (), -right .getImag ());
467
454
}
468
455
469
- @ Override
470
- @ Specialization
471
- PComplex doComplex (PComplex left , long right ) {
472
- return factory (). createComplex ( right - left . getReal (), - left . getImag ()) ;
456
+ @ SuppressWarnings ( "unused" )
457
+ @ Fallback
458
+ PNotImplemented doComplex (Object left , Object right ) {
459
+ return PNotImplemented . NOT_IMPLEMENTED ;
473
460
}
474
461
}
475
462
0 commit comments