|
54 | 54 | import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass; |
55 | 55 | import com.oracle.graal.python.nodes.ErrorMessages; |
56 | 56 | import com.oracle.graal.python.nodes.function.PythonBuiltinNode; |
| 57 | +import com.oracle.graal.python.nodes.util.CannotCastException; |
| 58 | +import com.oracle.graal.python.nodes.util.CastToJavaStringNode; |
57 | 59 | import com.oracle.graal.python.runtime.PythonCore; |
| 60 | +import com.oracle.truffle.api.CompilerDirectives; |
58 | 61 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; |
59 | 62 | import com.oracle.truffle.api.dsl.Cached; |
60 | 63 | import com.oracle.truffle.api.dsl.GenerateNodeFactory; |
@@ -193,8 +196,14 @@ public String normalize(@SuppressWarnings("unused") String form, String unistr, |
193 | 196 | @Specialization(guards = {"form.equals(cachedForm)"}, limit = "4") |
194 | 197 | public String normalize(String form, PString unistr, |
195 | 198 | @Cached("form") String cachedForm, |
| 199 | + @Cached CastToJavaStringNode castToJavaStringNode, |
196 | 200 | @Cached("getForm(cachedForm)") Normalizer.Form cachedNormForm) { |
197 | | - return normalize(form, unistr.getValue(), cachedForm, cachedNormForm); |
| 201 | + try { |
| 202 | + return normalize(form, castToJavaStringNode.execute(unistr), cachedForm, cachedNormForm); |
| 203 | + } catch (CannotCastException e) { |
| 204 | + CompilerDirectives.transferToInterpreterAndInvalidate(); |
| 205 | + throw new IllegalStateException("should not be reached"); |
| 206 | + } |
198 | 207 | } |
199 | 208 |
|
200 | 209 | } |
@@ -226,8 +235,14 @@ public boolean isNormalized(@SuppressWarnings("unused") String form, String unis |
226 | 235 | @Specialization(guards = {"form.equals(cachedForm)"}, limit = "4") |
227 | 236 | public boolean normalize(String form, PString unistr, |
228 | 237 | @Cached("form") String cachedForm, |
| 238 | + @Cached CastToJavaStringNode castToJavaStringNode, |
229 | 239 | @Cached("getForm(cachedForm)") Normalizer.Form cachedNormForm) { |
230 | | - return isNormalized(form, unistr.getValue(), cachedForm, cachedNormForm); |
| 240 | + try { |
| 241 | + return isNormalized(form, castToJavaStringNode.execute(unistr), cachedForm, cachedNormForm); |
| 242 | + } catch (CannotCastException e) { |
| 243 | + CompilerDirectives.transferToInterpreterAndInvalidate(); |
| 244 | + throw new IllegalStateException("should not be reached"); |
| 245 | + } |
231 | 246 | } |
232 | 247 | } |
233 | 248 | } |
0 commit comments