diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java index 86a08332003f12f1cfdd3aebc4f9ca78e44050b8..6dd582b8741acf34d388e9cbaa54ff9674cf232e 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java @@ -390,7 +390,7 @@ final class REngine implements Engine, Engine.Timings { break; } sb.append(input); - Source src = Source.newBuilder(sb.toString()).mimeType(RRuntime.R_APP_MIME).name(file + "#" + startLine + "-" + lineIndex).uri(uri).build(); + Source src = Source.newBuilder(sb.toString()).language(RRuntime.R_LANGUAGE_ID).name(file + "#" + startLine + "-" + lineIndex).uri(uri).build(); lineIndex++; List<RSyntaxNode> currentStmts = null; try { diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/TruffleRLanguageImpl.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/TruffleRLanguageImpl.java index 50633e95daf86e2f7f48ce313b85859912660432..17940abb3e8e8b3c06301b58525ef24f2a241eee 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/TruffleRLanguageImpl.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/TruffleRLanguageImpl.java @@ -94,8 +94,6 @@ public final class TruffleRLanguageImpl extends TruffleRLanguage { private static boolean systemInitialized; - public static final String MIME = RRuntime.R_APP_MIME; - @Override protected boolean isObjectOfLanguage(Object object) { return object instanceof RTypedValue; diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nfi/TruffleNFI_Context.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nfi/TruffleNFI_Context.java index d1e3aba0258a5e33e5114be04706cb544ae85252..1f1a0ddfc0e9c8aab6fa11e7c1bd2d560a2b31a8 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nfi/TruffleNFI_Context.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nfi/TruffleNFI_Context.java @@ -308,7 +308,7 @@ final class TruffleNFI_Context extends RFFIContext { // new thread, initialize properly assert defaultLibrary == null && rlibDLLInfo == null; rlibDLLInfo = DLL.findLibraryContainingSymbol(context, "dot_call0"); - defaultLibrary = (TruffleObject) RContext.getInstance().getEnv().parse(Source.newBuilder("default").name("(load default)").mimeType("application/x-native").build()).call(); + defaultLibrary = (TruffleObject) RContext.getInstance().getEnv().parse(Source.newBuilder("default").name("(load default)").language("native").build()).call(); initCallbacks(context); break; case SHARE_PARENT_RO: diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nfi/TruffleNFI_DLL.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nfi/TruffleNFI_DLL.java index b55ff1ec00e3cc798165519cef1e6ae58b0e5c41..c9922c8ffaec3e72d14ea313a7138bf6c8187e7a 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nfi/TruffleNFI_DLL.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nfi/TruffleNFI_DLL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,7 +57,7 @@ public class TruffleNFI_DLL implements DLLRFFI { public Object execute(String path, boolean local, boolean now) { String libName = DLL.libName(path); Env env = RContext.getInstance().getEnv(); - TruffleObject libHandle = (TruffleObject) env.parse(Source.newBuilder(prepareLibraryOpen(path, local, now)).name(path).mimeType("application/x-native").build()).call(); + TruffleObject libHandle = (TruffleObject) env.parse(Source.newBuilder(prepareLibraryOpen(path, local, now)).name(path).language("native").build()).call(); return new NFIHandle(libName, libHandle); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Parse.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Parse.java index b35736e7e3754999eb003298b92533a89245a6ae..0fb4a4a351ae3e20d2ef3dd7a3301bea8e1f9513 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Parse.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Parse.java @@ -223,12 +223,12 @@ public abstract class Parse extends RBuiltinNode.Arg6 { assert result != null : "Source created from environment should not be null"; return result; } else { - return Source.newBuilder(coalescedLines).name("<parse>").mimeType(RRuntime.R_APP_MIME).build(); + return Source.newBuilder(coalescedLines).name("<parse>").language(RRuntime.R_LANGUAGE_ID).build(); } } else { String srcFileText = RRuntime.asString(srcFile); if (srcFileText.equals("<text>")) { - return Source.newBuilder(coalescedLines).name("<parse>").mimeType(RRuntime.R_APP_MIME).build(); + return Source.newBuilder(coalescedLines).name("<parse>").language(RRuntime.R_LANGUAGE_ID).build(); } else { return createFileSource(ConnectionSupport.removeFileURLPrefix(srcFileText), coalescedLines, false); } @@ -247,7 +247,7 @@ public abstract class Parse extends RBuiltinNode.Arg6 { return RSource.fromFileName(chars, path, internal); } catch (URISyntaxException e) { // Note: to be compatible with GnuR we construct Source even with a malformed path - Source.Builder<RuntimeException, RuntimeException, RuntimeException> builder = Source.newBuilder(chars).name(path).mimeType(RRuntime.R_APP_MIME); + Source.Builder<RuntimeException, RuntimeException, RuntimeException> builder = Source.newBuilder(chars).name(path).language(RRuntime.R_LANGUAGE_ID); if (internal) { builder.internal(); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRInterop.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRInterop.java index 554c855c75a5eaeaf519142a70dd953cf1658819..9d1335b53a9b2ff0232780f5ddb35de43b2ad7c6 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRInterop.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRInterop.java @@ -169,7 +169,7 @@ public class FastRInterop { protected CallTarget parse(String languageId, String source) { CompilerAsserts.neverPartOfCompilation(); - Source sourceObject = Source.newBuilder(source).name(RSource.Internal.EVAL_WRAPPER.string).language(languageId).internal().build(); + Source sourceObject = RSource.fromTextInternalInvisible(source, RSource.Internal.EVAL_WRAPPER, languageId); try { return RContext.getInstance().getEnv().parse(sourceObject); } catch (Throwable t) { diff --git a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/SpecialCallTest.java b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/SpecialCallTest.java index 89a959f4b3d4ee8c19bc2edf8dbb05a55b26ba89..cef464a9b4b267b333049bd20800fda1f83b95f0 100644 --- a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/SpecialCallTest.java +++ b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/SpecialCallTest.java @@ -32,6 +32,7 @@ import com.oracle.truffle.r.engine.TruffleRLanguageImpl; import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.FastROptions; import com.oracle.truffle.r.runtime.RError; +import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.RootWithBody; import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.data.RExpression; @@ -287,8 +288,8 @@ public class SpecialCallTest extends TestBase { if (!FastROptions.UseSpecials.getBooleanValue()) { return; } - Source setupSource = Source.newBuilder("{" + setup + "}").mimeType(TruffleRLanguageImpl.MIME).name("test").build(); - Source testSource = Source.newBuilder(test).mimeType(TruffleRLanguageImpl.MIME).name("test").build(); + Source setupSource = Source.newBuilder("{" + setup + "}").language(RRuntime.R_LANGUAGE_ID).name("test").build(); + Source testSource = Source.newBuilder(test).language(RRuntime.R_LANGUAGE_ID).name("test").build(); RExpression setupExpression = testVMContext.getThisEngine().parse(setupSource); RExpression testExpression = testVMContext.getThisEngine().parse(testSource); diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RRuntime.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RRuntime.java index 9ce0b2aea175901d30b86102d4c45c01f3295c37..43a08e94cc1b48514865dc9c3224bcfab57e92ad 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RRuntime.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RRuntime.java @@ -72,6 +72,7 @@ public class RRuntime { public static final boolean True = true; public static final boolean False = false; + public static final String R_LANGUAGE_ID = "R"; public static final String R_APP_MIME = "application/x-r"; public static final String R_TEXT_MIME = "text/x-r"; diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSource.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSource.java index 4e66f50794be836f27a49ed83cc90c5b7d6a3e14..d1429ce1dee20143b7f056db5aa17d60d62831dc 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSource.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -110,7 +110,7 @@ public class RSource { public static Source fromFileName(String text, String path, boolean internal) throws URISyntaxException { File file = new File(path).getAbsoluteFile(); URI uri = new URI("file://" + file.getAbsolutePath()); - Source.Builder<RuntimeException, RuntimeException, RuntimeException> builder = Source.newBuilder(file).content(text).uri(uri).mimeType(RRuntime.R_APP_MIME); + Source.Builder<RuntimeException, RuntimeException, RuntimeException> builder = Source.newBuilder(file).content(text).uri(uri).language(RRuntime.R_LANGUAGE_ID); if (internal) { builder.internal(); } @@ -121,32 +121,32 @@ public class RSource { * Create an {@code internal} source from {@code text} and {@code description}. */ public static Source fromTextInternal(String text, Internal description) { - return fromTextInternal(text, description, RRuntime.R_APP_MIME); + return fromTextInternal(text, description, RRuntime.R_LANGUAGE_ID); } /** * Create an {@code internal} source from {@code text} and {@code description}. */ public static Source fromTextInternalInvisible(String text, Internal description) { - return fromTextInternalInvisible(text, description, RRuntime.R_APP_MIME); + return fromTextInternalInvisible(text, description, RRuntime.R_LANGUAGE_ID); } /** * Create an {@code internal} source from {@code text} and {@code description} of given - * {@code mimeType}. + * {@code languageId}. */ - public static Source fromTextInternal(String text, Internal description, String mimeType) { - return Source.newBuilder(text).name(description.string).mimeType(mimeType).internal().interactive().build(); + public static Source fromTextInternal(String text, Internal description, String languageId) { + return Source.newBuilder(text).name(description.string).language(languageId).internal().interactive().build(); } /** * Create an {@code internal} source from {@code text} and {@code description} of given - * {@code mimeType}. + * {@code languageId}. */ - public static Source fromTextInternalInvisible(String text, Internal description, String mimeType) { - return Source.newBuilder(text).name(description.string).mimeType(mimeType).internal().build(); + public static Source fromTextInternalInvisible(String text, Internal description, String languageId) { + return Source.newBuilder(text).name(description.string).language(languageId).internal().build(); } /** @@ -155,7 +155,7 @@ public class RSource { */ public static Source fromPackageTextInternal(String text, String packageName) { String name = String.format(Internal.PACKAGE.string, packageName); - return Source.newBuilder(text).name(name).mimeType(RRuntime.R_APP_MIME).build(); + return Source.newBuilder(text).name(name).language(RRuntime.R_LANGUAGE_ID).build(); } /** @@ -167,7 +167,7 @@ public class RSource { if (functionName == null) { return fromPackageTextInternal(text, packageName); } else { - return Source.newBuilder(text).name(packageName + "::" + functionName).mimeType(RRuntime.R_APP_MIME).build(); + return Source.newBuilder(text).name(packageName + "::" + functionName).language(RRuntime.R_LANGUAGE_ID).build(); } } @@ -177,7 +177,7 @@ public class RSource { public static Source fromFileName(String path, boolean internal) throws IOException { File file = new File(path); return getCachedByOrigin(file, origin -> { - Source.Builder<IOException, RuntimeException, RuntimeException> builder = Source.newBuilder(file).mimeType(RRuntime.R_APP_MIME); + Source.Builder<IOException, RuntimeException, RuntimeException> builder = Source.newBuilder(file).language(RRuntime.R_LANGUAGE_ID); if (internal) { builder.internal(); } @@ -189,21 +189,21 @@ public class RSource { * Create an (external) source from the file system path denoted by {@code file}. */ public static Source fromFile(File file) throws IOException { - return getCachedByOrigin(file, origin -> Source.newBuilder(file).name(file.getName()).mimeType(RRuntime.R_APP_MIME).build()); + return getCachedByOrigin(file, origin -> Source.newBuilder(file).name(file.getName()).language(RRuntime.R_LANGUAGE_ID).build()); } /** * Create a source from the file system path denoted by {@code file}. */ public static Source fromTempFile(File file) throws IOException { - return getCachedByOrigin(file, origin -> Source.newBuilder(file).name(file.getName()).mimeType(RRuntime.R_APP_MIME).internal().build()); + return getCachedByOrigin(file, origin -> Source.newBuilder(file).name(file.getName()).language(RRuntime.R_LANGUAGE_ID).internal().build()); } /** * Create an (external) source from {@code url}. */ public static Source fromURL(URL url, String name) throws IOException { - return getCachedByOrigin(url, origin -> Source.newBuilder(url).name(name).mimeType(RRuntime.R_APP_MIME).build()); + return getCachedByOrigin(url, origin -> Source.newBuilder(url).name(name).language(RRuntime.R_LANGUAGE_ID).build()); } /** @@ -240,7 +240,7 @@ public class RSource { * Create an unknown source with the given name. */ public static SourceSection createUnknown(String name) { - return Source.newBuilder("").name(name).mimeType(RRuntime.R_APP_MIME).build().createSection(0, 0); + return Source.newBuilder("").name(name).language(RRuntime.R_LANGUAGE_ID).build().createSection(0, 0); } /**