|
71 | 71 | import com.oracle.graal.python.nodes.function.builtins.PythonClinicBuiltinNode; |
72 | 72 | import com.oracle.graal.python.nodes.function.builtins.PythonTernaryClinicBuiltinNode; |
73 | 73 | import com.oracle.graal.python.nodes.function.builtins.PythonUnaryClinicBuiltinNode; |
74 | | -import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentCastNode.ArgumentCastNodeWithRaise; |
| 74 | +import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentCastNode; |
75 | 75 | import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; |
76 | 76 | import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; |
77 | 77 | import com.oracle.graal.python.runtime.IndirectCallData; |
@@ -104,7 +104,7 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa |
104 | 104 | return BinasciiModuleBuiltinsFactory.getFactories(); |
105 | 105 | } |
106 | 106 |
|
107 | | - abstract static class AsciiBufferConverter extends ArgumentCastNodeWithRaise { |
| 107 | + abstract static class AsciiBufferConverter extends ArgumentCastNode { |
108 | 108 | @Specialization(guards = "acquireLib.hasBuffer(value)", limit = "getCallSiteInlineCacheMaxDepth()") |
109 | 109 | Object doObject(VirtualFrame frame, Object value, |
110 | 110 | @Cached("createFor(this)") IndirectCallData indirectCallData, |
@@ -143,35 +143,37 @@ byte readByte(int byteOffset, |
143 | 143 | } |
144 | 144 |
|
145 | 145 | @Specialization(guards = "isAscii(value, getCodeRangeNode)") |
146 | | - Object asciiString(TruffleString value, |
| 146 | + static Object asciiString(TruffleString value, |
147 | 147 | @Shared("getCodeRange") @Cached @SuppressWarnings("unused") TruffleString.GetCodeRangeNode getCodeRangeNode) { |
148 | 148 | return new AsciiStringBuffer(value); |
149 | 149 | } |
150 | 150 |
|
151 | 151 | @Specialization(guards = "!isAscii(value, getCodeRangeNode)") |
152 | | - Object nonAsciiString(@SuppressWarnings("unused") TruffleString value, |
153 | | - @Shared("getCodeRange") @Cached @SuppressWarnings("unused") TruffleString.GetCodeRangeNode getCodeRangeNode) { |
154 | | - throw raise(ValueError, ErrorMessages.STRING_ARG_SHOULD_CONTAIN_ONLY_ASCII); |
| 152 | + static Object nonAsciiString(@SuppressWarnings("unused") TruffleString value, |
| 153 | + @Shared("getCodeRange") @Cached @SuppressWarnings("unused") TruffleString.GetCodeRangeNode getCodeRangeNode, |
| 154 | + @Shared @Cached PRaiseNode raiseNode) { |
| 155 | + throw raiseNode.raise(ValueError, ErrorMessages.STRING_ARG_SHOULD_CONTAIN_ONLY_ASCII); |
155 | 156 | } |
156 | 157 |
|
157 | 158 | @Specialization |
158 | | - @SuppressWarnings("truffle-static-method") |
159 | | - Object string(PString value, |
| 159 | + static Object string(PString value, |
160 | 160 | @Bind("this") Node inliningTarget, |
161 | 161 | @Cached CastToTruffleStringNode cast, |
162 | 162 | @Shared("getCodeRange") @Cached @SuppressWarnings("unused") TruffleString.GetCodeRangeNode getCodeRangeNode, |
163 | | - @Cached InlinedConditionProfile asciiProfile) { |
| 163 | + @Cached InlinedConditionProfile asciiProfile, |
| 164 | + @Cached PRaiseNode.Lazy raiseNode) { |
164 | 165 | TruffleString ts = cast.execute(inliningTarget, value); |
165 | 166 | if (asciiProfile.profile(inliningTarget, isAscii(ts, getCodeRangeNode))) { |
166 | 167 | return asciiString(ts, getCodeRangeNode); |
167 | 168 | } else { |
168 | | - return nonAsciiString(ts, getCodeRangeNode); |
| 169 | + return nonAsciiString(ts, getCodeRangeNode, raiseNode.get(inliningTarget)); |
169 | 170 | } |
170 | 171 | } |
171 | 172 |
|
172 | 173 | @Fallback |
173 | | - Object error(@SuppressWarnings("unused") Object value) { |
174 | | - throw raise(TypeError, ErrorMessages.ARG_SHOULD_BE_BYTES_BUFFER_OR_ASCII_NOT_P, value); |
| 174 | + static Object error(@SuppressWarnings("unused") Object value, |
| 175 | + @Shared @Cached PRaiseNode raiseNode) { |
| 176 | + throw raiseNode.raise(TypeError, ErrorMessages.ARG_SHOULD_BE_BYTES_BUFFER_OR_ASCII_NOT_P, value); |
175 | 177 | } |
176 | 178 |
|
177 | 179 | @ClinicConverterFactory |
|
0 commit comments