Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
[GR-40012] Source#path is not transferred to the Truffle isolate.
Browse files Browse the repository at this point in the history
PullRequest: graal/12316
  • Loading branch information
tzezula committed Jul 25, 2022
2 parents 72883c7 + a7234c6 commit dde1006
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ public <S, T> Object newTargetTypeMapping(Class<S> sourceType, Class<T> targetTy
}

@Override
public Source build(String language, Object origin, URI uri, String name, String mimeType, Object content, boolean interactive, boolean internal, boolean cached, Charset encoding)
public Source build(String language, Object origin, URI uri, String name, String mimeType, Object content, boolean interactive, boolean internal, boolean cached, Charset encoding, String path)
throws IOException {
throw noPolyglotImplementationFound();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ public Builder encoding(Charset encoding) {
* @since 19.0
*/
public Source build() throws IOException {
Source source = getImpl().build(language, origin, uri, name, mimeType, content, interactive, internal, cached, fileEncoding);
Source source = getImpl().build(language, origin, uri, name, mimeType, content, interactive, internal, cached, fileEncoding, null);

// make sure origin is not consumed again if builder is used twice
if (source.hasBytes()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ public void resetPreInitializedEngine() {
getNext().resetPreInitializedEngine();
}

public Source build(String language, Object origin, URI uri, String name, String mimeType, Object content, boolean interactive, boolean internal, boolean cached, Charset encoding)
public Source build(String language, Object origin, URI uri, String name, String mimeType, Object content, boolean interactive, boolean internal, boolean cached, Charset encoding, String path)
throws IOException {
return getNext().build(language, origin, uri, name, mimeType, content, interactive, internal, cached, encoding);
return getNext().build(language, origin, uri, name, mimeType, content, interactive, internal, cached, encoding, path);
}

public String findLanguage(File file) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ public abstract org.graalvm.polyglot.Source getOrCreatePolyglotSource(Source sou
public abstract void mergeLoadedSources(Source[] sources);

public abstract void setEmbedderSource(SourceBuilder builder, boolean b);

public abstract void setPath(SourceBuilder builder, String path);
}

public abstract static class InteropSupport extends Support {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,10 @@ void embedderSource(boolean b) {
this.embedderSource = b;
}

void path(String path) {
this.path = path;
}

/**
* Uses configuration of this builder to create new {@link Source} object. The method throws
* an {@link IOException} if an error loading the source occurred.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ public void setEmbedderSource(SourceBuilder builder, boolean enabled) {
builder.embedderSource(enabled);
}

@Override
public void setPath(SourceBuilder builder, String path) {
builder.path(path);
}

@Override
public void invalidateAfterPreinitialiation(Source source) {
((SourceImpl) source).key.invalidateAfterPreinitialiation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ public String findLanguage(String mimeType) {

@Override
public org.graalvm.polyglot.Source build(String language, Object origin, URI uri, String name, String mimeType, Object content, boolean interactive, boolean internal, boolean cached,
Charset encoding)
Charset encoding, String path)
throws IOException {
assert language != null;
com.oracle.truffle.api.source.Source.SourceBuilder builder;
Expand All @@ -567,6 +567,9 @@ public org.graalvm.polyglot.Source build(String language, Object origin, URI uri
}

EngineAccessor.SOURCE.setEmbedderSource(builder, true);
if (path != null) {
EngineAccessor.SOURCE.setPath(builder, path);
}

if (content instanceof CharSequence) {
builder.content((CharSequence) content);
Expand Down

0 comments on commit dde1006

Please sign in to comment.