|
53 | 53 | import com.oracle.graal.python.builtins.objects.common.PHashingCollection;
|
54 | 54 | import com.oracle.graal.python.builtins.objects.set.FrozenSetBuiltinsFactory.BinaryUnionNodeGen;
|
55 | 55 | import com.oracle.graal.python.nodes.PBaseNode;
|
| 56 | +import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode; |
56 | 57 | import com.oracle.graal.python.nodes.control.GetIteratorNode;
|
57 | 58 | import com.oracle.graal.python.nodes.control.GetNextNode;
|
58 | 59 | import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
|
59 | 60 | import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
|
60 | 61 | import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
|
61 | 62 | import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
|
62 | 63 | import com.oracle.graal.python.runtime.exception.PException;
|
| 64 | +import com.oracle.graal.python.runtime.exception.PythonErrorType; |
63 | 65 | import com.oracle.truffle.api.CompilerDirectives;
|
64 | 66 | import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
|
65 | 67 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
|
@@ -366,11 +368,29 @@ boolean isSuperSet(PBaseSet self, String other,
|
366 | 368 | @Builtin(name = __LE__, fixedNumOfArguments = 2)
|
367 | 369 | @GenerateNodeFactory
|
368 | 370 | abstract static class LessEqualNode extends IsSubsetNode {
|
| 371 | + @Specialization |
| 372 | + Object isLessEqual(PBaseSet self, Object other, |
| 373 | + @Cached("create(__GE__)") LookupAndCallBinaryNode lookupAndCallBinaryNode) { |
| 374 | + Object result = lookupAndCallBinaryNode.executeObject(other, self); |
| 375 | + if (result != PNone.NO_VALUE) { |
| 376 | + return result; |
| 377 | + } |
| 378 | + throw raise(PythonErrorType.TypeError, "unorderable types: %p <= %p", self, other); |
| 379 | + } |
369 | 380 | }
|
370 | 381 |
|
371 | 382 | @Builtin(name = __GE__, fixedNumOfArguments = 2)
|
372 | 383 | @GenerateNodeFactory
|
373 | 384 | abstract static class GreaterEqualNode extends IsSupersetNode {
|
| 385 | + @Specialization |
| 386 | + Object isGreaterEqual(PBaseSet self, Object other, |
| 387 | + @Cached("create(__LE__)") LookupAndCallBinaryNode lookupAndCallBinaryNode) { |
| 388 | + Object result = lookupAndCallBinaryNode.executeObject(other, self); |
| 389 | + if (result != PNone.NO_VALUE) { |
| 390 | + return result; |
| 391 | + } |
| 392 | + throw raise(PythonErrorType.TypeError, "unorderable types: %p >= %p", self, other); |
| 393 | + } |
374 | 394 | }
|
375 | 395 |
|
376 | 396 | @Builtin(name = __LT__, fixedNumOfArguments = 2)
|
@@ -403,6 +423,16 @@ boolean isLessThan(PBaseSet self, String other,
|
403 | 423 | }
|
404 | 424 | return (Boolean) getLessEqualNode().execute(self, other);
|
405 | 425 | }
|
| 426 | + |
| 427 | + @Specialization |
| 428 | + Object isLessThan(PBaseSet self, Object other, |
| 429 | + @Cached("create(__GT__)") LookupAndCallBinaryNode lookupAndCallBinaryNode) { |
| 430 | + Object result = lookupAndCallBinaryNode.executeObject(other, self); |
| 431 | + if (result != PNone.NO_VALUE) { |
| 432 | + return result; |
| 433 | + } |
| 434 | + throw raise(PythonErrorType.TypeError, "unorderable types: %p < %p", self, other); |
| 435 | + } |
406 | 436 | }
|
407 | 437 |
|
408 | 438 | @Builtin(name = __GT__, fixedNumOfArguments = 2)
|
@@ -435,5 +465,15 @@ boolean isGreaterThan(PBaseSet self, String other,
|
435 | 465 | }
|
436 | 466 | return (Boolean) getGreaterEqualNode().execute(self, other);
|
437 | 467 | }
|
| 468 | + |
| 469 | + @Specialization |
| 470 | + Object isLessThan(PBaseSet self, Object other, |
| 471 | + @Cached("create(__LT__)") LookupAndCallBinaryNode lookupAndCallBinaryNode) { |
| 472 | + Object result = lookupAndCallBinaryNode.executeObject(other, self); |
| 473 | + if (result != PNone.NO_VALUE) { |
| 474 | + return result; |
| 475 | + } |
| 476 | + throw raise(PythonErrorType.TypeError, "unorderable types: %p > %p", self, other); |
| 477 | + } |
438 | 478 | }
|
439 | 479 | }
|
0 commit comments