111
111
import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
112
112
import com .oracle .graal .python .nodes .interop .InteropBehavior ;
113
113
import com .oracle .graal .python .nodes .interop .InteropBehaviorMethod ;
114
+ import com .oracle .graal .python .nodes .interop .PForeignToPTypeNode ;
114
115
import com .oracle .graal .python .nodes .truffle .PythonArithmeticTypes ;
115
116
import com .oracle .graal .python .nodes .util .CannotCastException ;
116
117
import com .oracle .graal .python .nodes .util .CastToJavaStringNode ;
@@ -191,7 +192,8 @@ public void initialize(Python3Core core) {
191
192
public abstract static class ImportNode extends PythonBuiltinNode {
192
193
@ Specialization
193
194
@ TruffleBoundary
194
- Object importSymbol (TruffleString name ) {
195
+ Object importSymbol (TruffleString name ,
196
+ @ Cached PForeignToPTypeNode convert ) {
195
197
Env env = getContext ().getEnv ();
196
198
if (!env .isPolyglotBindingsAccessAllowed ()) {
197
199
throw PRaiseNode .raiseUncached (this , PythonErrorType .NotImplementedError , ErrorMessages .POLYGLOT_ACCESS_NOT_ALLOWED );
@@ -200,7 +202,7 @@ Object importSymbol(TruffleString name) {
200
202
if (object == null ) {
201
203
return PNone .NONE ;
202
204
}
203
- return object ;
205
+ return convert . executeConvert ( object ) ;
204
206
}
205
207
}
206
208
@@ -209,7 +211,8 @@ Object importSymbol(TruffleString name) {
209
211
abstract static class EvalInteropNode extends PythonBuiltinNode {
210
212
@ TruffleBoundary
211
213
@ Specialization
212
- Object evalString (@ SuppressWarnings ("unused" ) PNone path , TruffleString tvalue , TruffleString tlangOrMimeType ) {
214
+ Object evalString (@ SuppressWarnings ("unused" ) PNone path , TruffleString tvalue , TruffleString tlangOrMimeType ,
215
+ @ Shared @ Cached PForeignToPTypeNode convert ) {
213
216
Env env = getContext ().getEnv ();
214
217
if (!env .isPolyglotEvalAllowed ()) {
215
218
throw PRaiseNode .raiseUncached (this , PythonErrorType .NotImplementedError , ErrorMessages .POLYGLOT_ACCESS_NOT_ALLOWED );
@@ -224,7 +227,7 @@ Object evalString(@SuppressWarnings("unused") PNone path, TruffleString tvalue,
224
227
if (mimeType ) {
225
228
newBuilder = newBuilder .mimeType (langOrMimeType );
226
229
}
227
- return env .parsePublic (newBuilder .build ()).call ();
230
+ return convert . executeConvert ( env .parsePublic (newBuilder .build ()).call () );
228
231
} catch (RuntimeException e ) {
229
232
throw PRaiseNode .raiseUncached (this , NotImplementedError , e );
230
233
}
@@ -239,7 +242,8 @@ private void raiseIfInternal(Env env, String lang) {
239
242
240
243
@ TruffleBoundary
241
244
@ Specialization
242
- Object evalFile (TruffleString tpath , @ SuppressWarnings ("unused" ) PNone string , TruffleString tlangOrMimeType ) {
245
+ Object evalFile (TruffleString tpath , @ SuppressWarnings ("unused" ) PNone string , TruffleString tlangOrMimeType ,
246
+ @ Shared @ Cached PForeignToPTypeNode convert ) {
243
247
Env env = getContext ().getEnv ();
244
248
if (!env .isPolyglotEvalAllowed ()) {
245
249
throw PRaiseNode .raiseUncached (this , PythonErrorType .NotImplementedError , ErrorMessages .POLYGLOT_ACCESS_NOT_ALLOWED );
@@ -254,7 +258,7 @@ Object evalFile(TruffleString tpath, @SuppressWarnings("unused") PNone string, T
254
258
if (mimeType ) {
255
259
newBuilder = newBuilder .mimeType (langOrMimeType );
256
260
}
257
- return getContext ().getEnv ().parsePublic (newBuilder .name (path ).build ()).call ();
261
+ return convert . executeConvert ( getContext ().getEnv ().parsePublic (newBuilder .name (path ).build ()).call () );
258
262
} catch (IOException e ) {
259
263
throw PRaiseNode .raiseUncached (this , OSError , ErrorMessages .S , e );
260
264
} catch (RuntimeException e ) {
@@ -264,14 +268,15 @@ Object evalFile(TruffleString tpath, @SuppressWarnings("unused") PNone string, T
264
268
265
269
@ TruffleBoundary
266
270
@ Specialization
267
- Object evalFile (TruffleString tpath , @ SuppressWarnings ("unused" ) PNone string , @ SuppressWarnings ("unused" ) PNone lang ) {
271
+ Object evalFile (TruffleString tpath , @ SuppressWarnings ("unused" ) PNone string , @ SuppressWarnings ("unused" ) PNone lang ,
272
+ @ Shared @ Cached PForeignToPTypeNode convert ) {
268
273
Env env = getContext ().getEnv ();
269
274
if (!env .isPolyglotEvalAllowed ()) {
270
275
throw PRaiseNode .raiseUncached (this , PythonErrorType .NotImplementedError , ErrorMessages .POLYGLOT_ACCESS_NOT_ALLOWED );
271
276
}
272
277
try {
273
278
String path = tpath .toJavaStringUncached ();
274
- return getContext ().getEnv ().parsePublic (Source .newBuilder (PythonLanguage .ID , env .getPublicTruffleFile (path )).name (path ).build ()).call ();
279
+ return convert . executeConvert ( getContext ().getEnv ().parsePublic (Source .newBuilder (PythonLanguage .ID , env .getPublicTruffleFile (path )).name (path ).build ()).call () );
275
280
} catch (IOException e ) {
276
281
throw PRaiseNode .raiseUncached (this , OSError , ErrorMessages .S , e );
277
282
} catch (RuntimeException e ) {
0 commit comments