|
263 | 263 | import com.oracle.graal.python.builtins.objects.set.PBaseSet;
|
264 | 264 | import com.oracle.graal.python.builtins.objects.set.PFrozenSet;
|
265 | 265 | import com.oracle.graal.python.builtins.objects.set.PSet;
|
| 266 | +import com.oracle.graal.python.builtins.objects.set.SetBuiltins.ClearNode; |
266 | 267 | import com.oracle.graal.python.builtins.objects.set.SetNodes.ConstructSetNode;
|
267 | 268 | import com.oracle.graal.python.builtins.objects.set.SetNodes.DiscardNode;
|
268 | 269 | import com.oracle.graal.python.builtins.objects.str.NativeCharSequence;
|
@@ -2962,6 +2963,45 @@ protected com.oracle.graal.python.nodes.expression.BinaryArithmetic.AddNode crea
|
2962 | 2963 | }
|
2963 | 2964 | }
|
2964 | 2965 |
|
| 2966 | + @Builtin(name = "PySet_Clear", minNumOfPositionalArgs = 1) |
| 2967 | + @GenerateNodeFactory |
| 2968 | + public abstract static class PySetClearNode extends PythonUnaryBuiltinNode { |
| 2969 | + |
| 2970 | + @Specialization(guards = {"!isNone(s)", "!isNoValue(s)"}) |
| 2971 | + public Object clear(VirtualFrame frame, PSet s, |
| 2972 | + @Cached ClearNode clearNode, |
| 2973 | + @Cached TransformExceptionToNativeNode transformExceptionToNativeNode) { |
| 2974 | + try { |
| 2975 | + clearNode.execute(frame, s); |
| 2976 | + return 0; |
| 2977 | + } catch (PException e) { |
| 2978 | + transformExceptionToNativeNode.execute(e); |
| 2979 | + return -1; |
| 2980 | + } |
| 2981 | + } |
| 2982 | + |
| 2983 | + @Specialization(guards = {"!isPSet(set)", "isSetSubtype(frame, set, getClassNode, isSubtypeNode)"}) |
| 2984 | + public Object clearNative(VirtualFrame frame, @SuppressWarnings("unused") Object set, |
| 2985 | + @SuppressWarnings("unused") @Cached GetClassNode getClassNode, |
| 2986 | + @SuppressWarnings("unused") @Cached IsSubtypeNode isSubtypeNode, |
| 2987 | + @Cached PRaiseNativeNode raiseNativeNode) { |
| 2988 | + return raiseNativeNode.raiseInt(frame, -1, PythonBuiltinClassType.NotImplementedError, NATIVE_S_SUBTYPES_NOT_IMPLEMENTED, "set"); |
| 2989 | + } |
| 2990 | + |
| 2991 | + @Specialization(guards = {"!isPSet(set)", "!isSetSubtype(frame, set, getClassNode, isSubtypeNode)"}) |
| 2992 | + public Object clear(VirtualFrame frame, Object set, |
| 2993 | + @SuppressWarnings("unused") @Cached GetClassNode getClassNode, |
| 2994 | + @SuppressWarnings("unused") @Cached IsSubtypeNode isSubtypeNode, |
| 2995 | + @Cached StrNode strNode, |
| 2996 | + @Cached PRaiseNativeNode raiseNativeNode) { |
| 2997 | + return raiseNativeNode.raiseInt(frame, -1, SystemError, BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P, strNode.executeWith(frame, set), set); |
| 2998 | + } |
| 2999 | + |
| 3000 | + protected boolean isSetSubtype(VirtualFrame frame, Object obj, GetClassNode getClassNode, IsSubtypeNode isSubtypeNode) { |
| 3001 | + return isSubtypeNode.execute(frame, getClassNode.execute(obj), PythonBuiltinClassType.PSet); |
| 3002 | + } |
| 3003 | + } |
| 3004 | + |
2965 | 3005 | ///////////// unicode /////////////
|
2966 | 3006 |
|
2967 | 3007 | @Builtin(name = "PyUnicode_FromObject", minNumOfPositionalArgs = 1)
|
|
0 commit comments