114
114
import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
115
115
import com .oracle .graal .python .nodes .interop .InteropBehavior ;
116
116
import com .oracle .graal .python .nodes .interop .InteropBehaviorMethod ;
117
+ import com .oracle .graal .python .nodes .interop .PForeignToPTypeNode ;
117
118
import com .oracle .graal .python .nodes .truffle .PythonArithmeticTypes ;
118
119
import com .oracle .graal .python .nodes .util .CannotCastException ;
119
120
import com .oracle .graal .python .nodes .util .CastToJavaStringNode ;
@@ -196,7 +197,8 @@ public void initialize(Python3Core core) {
196
197
public abstract static class ImportNode extends PythonBuiltinNode {
197
198
@ Specialization
198
199
@ TruffleBoundary
199
- Object importSymbol (TruffleString name ) {
200
+ Object importSymbol (TruffleString name ,
201
+ @ Cached PForeignToPTypeNode convert ) {
200
202
Env env = getContext ().getEnv ();
201
203
if (!env .isPolyglotBindingsAccessAllowed ()) {
202
204
throw PRaiseNode .raiseUncached (this , PythonErrorType .NotImplementedError , ErrorMessages .POLYGLOT_ACCESS_NOT_ALLOWED );
@@ -205,7 +207,7 @@ Object importSymbol(TruffleString name) {
205
207
if (object == null ) {
206
208
return PNone .NONE ;
207
209
}
208
- return object ;
210
+ return convert . executeConvert ( object ) ;
209
211
}
210
212
}
211
213
@@ -214,7 +216,8 @@ Object importSymbol(TruffleString name) {
214
216
abstract static class EvalInteropNode extends PythonBuiltinNode {
215
217
@ TruffleBoundary
216
218
@ Specialization
217
- Object evalString (@ SuppressWarnings ("unused" ) PNone path , TruffleString tvalue , TruffleString tlangOrMimeType ) {
219
+ Object evalString (@ SuppressWarnings ("unused" ) PNone path , TruffleString tvalue , TruffleString tlangOrMimeType ,
220
+ @ Shared @ Cached PForeignToPTypeNode convert ) {
218
221
Env env = getContext ().getEnv ();
219
222
if (!env .isPolyglotEvalAllowed ()) {
220
223
throw PRaiseNode .raiseUncached (this , PythonErrorType .NotImplementedError , ErrorMessages .POLYGLOT_ACCESS_NOT_ALLOWED );
@@ -229,7 +232,7 @@ Object evalString(@SuppressWarnings("unused") PNone path, TruffleString tvalue,
229
232
if (mimeType ) {
230
233
newBuilder = newBuilder .mimeType (langOrMimeType );
231
234
}
232
- return env .parsePublic (newBuilder .build ()).call ();
235
+ return convert . executeConvert ( env .parsePublic (newBuilder .build ()).call () );
233
236
} catch (RuntimeException e ) {
234
237
throw PRaiseNode .raiseUncached (this , NotImplementedError , e );
235
238
}
@@ -244,7 +247,8 @@ private void raiseIfInternal(Env env, String lang) {
244
247
245
248
@ TruffleBoundary
246
249
@ Specialization
247
- Object evalFile (TruffleString tpath , @ SuppressWarnings ("unused" ) PNone string , TruffleString tlangOrMimeType ) {
250
+ Object evalFile (TruffleString tpath , @ SuppressWarnings ("unused" ) PNone string , TruffleString tlangOrMimeType ,
251
+ @ Shared @ Cached PForeignToPTypeNode convert ) {
248
252
Env env = getContext ().getEnv ();
249
253
if (!env .isPolyglotEvalAllowed ()) {
250
254
throw PRaiseNode .raiseUncached (this , PythonErrorType .NotImplementedError , ErrorMessages .POLYGLOT_ACCESS_NOT_ALLOWED );
@@ -259,7 +263,7 @@ Object evalFile(TruffleString tpath, @SuppressWarnings("unused") PNone string, T
259
263
if (mimeType ) {
260
264
newBuilder = newBuilder .mimeType (langOrMimeType );
261
265
}
262
- return getContext ().getEnv ().parsePublic (newBuilder .name (path ).build ()).call ();
266
+ return convert . executeConvert ( getContext ().getEnv ().parsePublic (newBuilder .name (path ).build ()).call () );
263
267
} catch (IOException e ) {
264
268
throw PRaiseNode .raiseUncached (this , OSError , ErrorMessages .S , e );
265
269
} catch (RuntimeException e ) {
@@ -269,14 +273,15 @@ Object evalFile(TruffleString tpath, @SuppressWarnings("unused") PNone string, T
269
273
270
274
@ TruffleBoundary
271
275
@ Specialization
272
- Object evalFile (TruffleString tpath , @ SuppressWarnings ("unused" ) PNone string , @ SuppressWarnings ("unused" ) PNone lang ) {
276
+ Object evalFile (TruffleString tpath , @ SuppressWarnings ("unused" ) PNone string , @ SuppressWarnings ("unused" ) PNone lang ,
277
+ @ Shared @ Cached PForeignToPTypeNode convert ) {
273
278
Env env = getContext ().getEnv ();
274
279
if (!env .isPolyglotEvalAllowed ()) {
275
280
throw PRaiseNode .raiseUncached (this , PythonErrorType .NotImplementedError , ErrorMessages .POLYGLOT_ACCESS_NOT_ALLOWED );
276
281
}
277
282
try {
278
283
String path = tpath .toJavaStringUncached ();
279
- return getContext ().getEnv ().parsePublic (Source .newBuilder (PythonLanguage .ID , env .getPublicTruffleFile (path )).name (path ).build ()).call ();
284
+ return convert . executeConvert ( getContext ().getEnv ().parsePublic (Source .newBuilder (PythonLanguage .ID , env .getPublicTruffleFile (path )).name (path ).build ()).call () );
280
285
} catch (IOException e ) {
281
286
throw PRaiseNode .raiseUncached (this , OSError , ErrorMessages .S , e );
282
287
} catch (RuntimeException e ) {
0 commit comments