Skip to content

Commit 9c25d6d

Browse files
committed
Migrate to Env API changes.
1 parent cf3ba6a commit 9c25d6d

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ImpModuleBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ private Object loadDynamicModuleWithSpec(String name, String path, InteropLibrar
200200
String basename = name.substring(name.lastIndexOf('.') + 1);
201201
TruffleObject sulongLibrary;
202202
try {
203-
CallTarget callTarget = env.parse(Source.newBuilder(LLVM_LANGUAGE, env.getTruffleFile(path)).build());
203+
CallTarget callTarget = env.parseInternal(Source.newBuilder(LLVM_LANGUAGE, env.getTruffleFile(path)).build());
204204
sulongLibrary = (TruffleObject) callTarget.call();
205205
} catch (SecurityException | IOException e) {
206206
throw raise(ImportError, "cannot load %s: %m", path, e);
@@ -250,7 +250,7 @@ private void ensureCapiWasLoaded() {
250250
if (!PythonOptions.getOption(ctxt, PythonOptions.ExposeInternalSources)) {
251251
capiSrcBuilder.internal(true);
252252
}
253-
capi = ctxt.getEnv().parse(capiSrcBuilder.build()).call();
253+
capi = ctxt.getEnv().parseInternal(capiSrcBuilder.build()).call();
254254
} catch (SecurityException | IOException e) {
255255
throw raise(PythonErrorType.ImportError, "cannot load capi from " + capiFile.getAbsoluteFile().getPath());
256256
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public abstract static class ImportNode extends PythonBuiltinNode {
119119
@TruffleBoundary
120120
public Object importSymbol(String name) {
121121
Env env = getContext().getEnv();
122-
if (!env.isPolyglotAccessAllowed()) {
122+
if (!env.isPolyglotBindingsAccessAllowed()) {
123123
throw raise(PythonErrorType.NotImplementedError, "polyglot access is not allowed");
124124
}
125125
Object object = env.importSymbol(name);
@@ -137,7 +137,7 @@ abstract static class EvalInteropNode extends PythonBuiltinNode {
137137
@Specialization
138138
Object evalString(@SuppressWarnings("unused") PNone path, String value, String langOrMimeType) {
139139
Env env = getContext().getEnv();
140-
if (!env.isPolyglotAccessAllowed()) {
140+
if (!env.isPolyglotEvalAllowed()) {
141141
throw raise(PythonErrorType.NotImplementedError, "polyglot access is not allowed");
142142
}
143143
try {
@@ -148,14 +148,14 @@ Object evalString(@SuppressWarnings("unused") PNone path, String value, String l
148148
if (mimeType) {
149149
newBuilder = newBuilder.mimeType(langOrMimeType);
150150
}
151-
return env.parse(newBuilder.build()).call();
151+
return env.parsePublic(newBuilder.build()).call();
152152
} catch (RuntimeException e) {
153153
throw raise(NotImplementedError, e);
154154
}
155155
}
156156

157157
private void raiseIfInternal(Env env, String lang) {
158-
LanguageInfo languageInfo = env.getLanguages().get(lang);
158+
LanguageInfo languageInfo = env.getPublicLanguages().get(lang);
159159
if (languageInfo != null && languageInfo.isInternal()) {
160160
throw raise(NotImplementedError, "access to internal language %s is not permitted", lang);
161161
}
@@ -165,7 +165,7 @@ private void raiseIfInternal(Env env, String lang) {
165165
@Specialization
166166
Object evalFile(String path, @SuppressWarnings("unused") PNone string, String langOrMimeType) {
167167
Env env = getContext().getEnv();
168-
if (!env.isPolyglotAccessAllowed()) {
168+
if (!env.isPolyglotEvalAllowed()) {
169169
throw raise(PythonErrorType.NotImplementedError, "polyglot access is not allowed");
170170
}
171171
try {
@@ -176,7 +176,7 @@ Object evalFile(String path, @SuppressWarnings("unused") PNone string, String la
176176
if (mimeType) {
177177
newBuilder = newBuilder.mimeType(langOrMimeType);
178178
}
179-
return getContext().getEnv().parse(newBuilder.name(path).build()).call();
179+
return getContext().getEnv().parsePublic(newBuilder.name(path).build()).call();
180180
} catch (IOException e) {
181181
throw raise(OSError, "%s", e);
182182
} catch (RuntimeException e) {
@@ -188,11 +188,11 @@ Object evalFile(String path, @SuppressWarnings("unused") PNone string, String la
188188
@Specialization
189189
Object evalFile(String path, @SuppressWarnings("unused") PNone string, @SuppressWarnings("unused") PNone lang) {
190190
Env env = getContext().getEnv();
191-
if (!env.isPolyglotAccessAllowed()) {
191+
if (!env.isPolyglotEvalAllowed()) {
192192
throw raise(PythonErrorType.NotImplementedError, "polyglot access is not allowed");
193193
}
194194
try {
195-
return getContext().getEnv().parse(Source.newBuilder(PythonLanguage.ID, env.getTruffleFile(path)).name(path).build()).call();
195+
return getContext().getEnv().parsePublic(Source.newBuilder(PythonLanguage.ID, env.getTruffleFile(path)).name(path).build()).call();
196196
} catch (IOException e) {
197197
throw raise(OSError, "%s", e);
198198
} catch (RuntimeException e) {
@@ -214,7 +214,7 @@ Object evalWithoutContent(Object path, Object string, Object lang) {
214214

215215
@TruffleBoundary(transferToInterpreterOnException = false)
216216
private static String findLanguageByMimeType(Env env, String mimeType) {
217-
Map<String, LanguageInfo> languages = env.getLanguages();
217+
Map<String, LanguageInfo> languages = env.getPublicLanguages();
218218
for (String language : languages.keySet()) {
219219
for (String registeredMimeType : languages.get(language).getMimeTypes()) {
220220
if (mimeType.equals(registeredMimeType)) {
@@ -240,7 +240,7 @@ public abstract static class ExportSymbolNode extends PythonBuiltinNode {
240240
@TruffleBoundary
241241
public Object exportSymbolKeyValue(String name, Object value) {
242242
Env env = getContext().getEnv();
243-
if (!env.isPolyglotAccessAllowed()) {
243+
if (!env.isPolyglotBindingsAccessAllowed()) {
244244
throw raise(PythonErrorType.NotImplementedError, "polyglot access is not allowed");
245245
}
246246
env.exportSymbol(name, value);
@@ -268,7 +268,7 @@ public Object exportSymbolAmbiguous(Object arg1, String arg2) {
268268
@TruffleBoundary
269269
public Object exportSymbol(PFunction fun, @SuppressWarnings("unused") PNone name) {
270270
Env env = getContext().getEnv();
271-
if (!env.isPolyglotAccessAllowed()) {
271+
if (!env.isPolyglotBindingsAccessAllowed()) {
272272
throw raise(PythonErrorType.NotImplementedError, "polyglot access is not allowed");
273273
}
274274
env.exportSymbol(fun.getName(), fun);
@@ -279,7 +279,7 @@ public Object exportSymbol(PFunction fun, @SuppressWarnings("unused") PNone name
279279
@TruffleBoundary
280280
public Object exportSymbol(PBuiltinFunction fun, @SuppressWarnings("unused") PNone name) {
281281
Env env = getContext().getEnv();
282-
if (!env.isPolyglotAccessAllowed()) {
282+
if (!env.isPolyglotBindingsAccessAllowed()) {
283283
throw raise(PythonErrorType.NotImplementedError, "polyglot access is not allowed");
284284
}
285285
env.exportSymbol(fun.getName(), fun);
@@ -322,7 +322,7 @@ protected static boolean isModule(Object o) {
322322
@TruffleBoundary
323323
private void export(String name, Object obj) {
324324
Env env = getContext().getEnv();
325-
if (!env.isPolyglotAccessAllowed()) {
325+
if (!env.isPolyglotBindingsAccessAllowed()) {
326326
throw raise(PythonErrorType.NotImplementedError, "polyglot access is not allowed");
327327
}
328328
env.exportSymbol(name, obj);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SREModuleBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Object useSRE(@SuppressWarnings("unused") String code,
105105
@TruffleBoundary
106106
Object run(String code,
107107
@SuppressWarnings("unused") @CachedContext(PythonLanguage.class) PythonContext context) {
108-
return getContext().getEnv().parse(Source.newBuilder("regex", code, "build-regex-engine").build()).call();
108+
return getContext().getEnv().parseInternal(Source.newBuilder("regex", code, "build-regex-engine").build()).call();
109109
}
110110
}
111111

0 commit comments

Comments
 (0)