|
28 | 28 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__AND__;
|
29 | 29 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__CONTAINS__;
|
30 | 30 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__EQ__;
|
| 31 | +import static com.oracle.graal.python.nodes.SpecialMethodNames.__GE__; |
| 32 | +import static com.oracle.graal.python.nodes.SpecialMethodNames.__GT__; |
31 | 33 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__ITER__;
|
32 | 34 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__LEN__;
|
33 | 35 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__LE__;
|
| 36 | +import static com.oracle.graal.python.nodes.SpecialMethodNames.__LT__; |
34 | 37 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__SUB__;
|
35 | 38 |
|
36 | 39 | import java.util.List;
|
@@ -324,4 +327,78 @@ boolean isSuperSet(PBaseSet self, String other,
|
324 | 327 | return isSupersetNode.execute(self.getDictStorage(), otherSet.getDictStorage());
|
325 | 328 | }
|
326 | 329 | }
|
| 330 | + |
| 331 | + @Builtin(name = __LE__, fixedNumOfArguments = 2) |
| 332 | + @GenerateNodeFactory |
| 333 | + abstract static class LessEqualNode extends IsSubsetNode { |
| 334 | + } |
| 335 | + |
| 336 | + @Builtin(name = __GE__, fixedNumOfArguments = 2) |
| 337 | + @GenerateNodeFactory |
| 338 | + abstract static class GreaterEqualNode extends IsSupersetNode { |
| 339 | + } |
| 340 | + |
| 341 | + @Builtin(name = __LT__, fixedNumOfArguments = 2) |
| 342 | + @GenerateNodeFactory |
| 343 | + abstract static class LessThanNode extends PythonBinaryBuiltinNode { |
| 344 | + @Child LessEqualNode lessEqualNode; |
| 345 | + |
| 346 | + private LessEqualNode getLessEqualNode() { |
| 347 | + if (lessEqualNode == null) { |
| 348 | + CompilerDirectives.transferToInterpreterAndInvalidate(); |
| 349 | + lessEqualNode = insert(FrozenSetBuiltinsFactory.LessEqualNodeFactory.create()); |
| 350 | + } |
| 351 | + return lessEqualNode; |
| 352 | + } |
| 353 | + |
| 354 | + @Specialization |
| 355 | + boolean isLessThan(PBaseSet self, PBaseSet other, |
| 356 | + @Cached("createBinaryProfile()") ConditionProfile sizeProfile) { |
| 357 | + if (sizeProfile.profile(self.size() >= other.size())) { |
| 358 | + return false; |
| 359 | + } |
| 360 | + return (Boolean) getLessEqualNode().execute(self, other); |
| 361 | + } |
| 362 | + |
| 363 | + @Specialization |
| 364 | + boolean isLessThan(PBaseSet self, String other, |
| 365 | + @Cached("createBinaryProfile()") ConditionProfile sizeProfile) { |
| 366 | + if (sizeProfile.profile(self.size() >= other.length())) { |
| 367 | + return false; |
| 368 | + } |
| 369 | + return (Boolean) getLessEqualNode().execute(self, other); |
| 370 | + } |
| 371 | + } |
| 372 | + |
| 373 | + @Builtin(name = __GT__, fixedNumOfArguments = 2) |
| 374 | + @GenerateNodeFactory |
| 375 | + abstract static class GreaterThanNode extends PythonBinaryBuiltinNode { |
| 376 | + @Child GreaterEqualNode greaterEqualNode; |
| 377 | + |
| 378 | + private GreaterEqualNode getGreaterEqualNode() { |
| 379 | + if (greaterEqualNode == null) { |
| 380 | + CompilerDirectives.transferToInterpreterAndInvalidate(); |
| 381 | + greaterEqualNode = insert(FrozenSetBuiltinsFactory.GreaterEqualNodeFactory.create()); |
| 382 | + } |
| 383 | + return greaterEqualNode; |
| 384 | + } |
| 385 | + |
| 386 | + @Specialization |
| 387 | + boolean isGreaterThan(PBaseSet self, PBaseSet other, |
| 388 | + @Cached("createBinaryProfile()") ConditionProfile sizeProfile) { |
| 389 | + if (sizeProfile.profile(self.size() <= other.size())) { |
| 390 | + return false; |
| 391 | + } |
| 392 | + return (Boolean) getGreaterEqualNode().execute(self, other); |
| 393 | + } |
| 394 | + |
| 395 | + @Specialization |
| 396 | + boolean isGreaterThan(PBaseSet self, String other, |
| 397 | + @Cached("createBinaryProfile()") ConditionProfile sizeProfile) { |
| 398 | + if (sizeProfile.profile(self.size() <= other.length())) { |
| 399 | + return false; |
| 400 | + } |
| 401 | + return (Boolean) getGreaterEqualNode().execute(self, other); |
| 402 | + } |
| 403 | + } |
327 | 404 | }
|
0 commit comments