use of com.oracle.truffle.api.source.Source in project sieve by jtulach.
the class Main method main.
public static void main(String[] args) throws Exception {
System.err.println("Setting up PolyglotEngine");
PolyglotEngine vm = PolyglotEngine.newBuilder().build();
URL url = Main.class.getProtectionDomain().getCodeSource().getLocation();
File local = new File(url.toURI());
for (; ; ) {
File sieveInRuby = new File(local, "sieve.R");
if (sieveInRuby.exists()) {
break;
}
local = local.getParentFile();
}
Source r = Source.fromFileName(new File(local, "sieve.R").getPath());
Source js = Source.fromFileName(new File(local, "sieve.js").getPath());
vm.eval(r);
vm.eval(js);
}
use of com.oracle.truffle.api.source.Source in project sulong by graalvm.
the class InteropTestBase method loadTestBitcodeInternal.
protected static TruffleObject loadTestBitcodeInternal(String name) {
File dir = new File(testBase, name);
File file = new File(dir, "O0_MEM2REG.bc");
Source source;
try {
source = Source.newBuilder(file).language("llvm").build();
} catch (IOException ex) {
throw new AssertionError(ex);
}
CallTarget target = runWithPolyglot.getTruffleTestEnv().parse(source);
return (TruffleObject) target.call();
}
use of com.oracle.truffle.api.source.Source in project sulong by graalvm.
the class NFIAPITest method loadLibrary.
private static TruffleObject loadLibrary(String lib, String filename, String mimetype) {
File file = new File(TEST_DIR.toFile(), lib + "/" + filename);
String loadLib = "load '" + file.getAbsolutePath() + "'";
Source source = Source.newBuilder(loadLib).name("loadLibrary").mimeType(mimetype).build();
CallTarget target = runWithPolyglot.getTruffleTestEnv().parse(source);
return (TruffleObject) target.call();
}
use of com.oracle.truffle.api.source.Source in project sulong by graalvm.
the class Runner method parse.
private LLVMParserResult[] parse(LLVMLanguage language, LLVMContext context, ExternalLibrary[] libs) {
LLVMParserResult[] parserResults = new LLVMParserResult[libs.length];
for (int i = 0; i < libs.length; i++) {
ExternalLibrary lib = libs[i];
if (!lib.isParsed()) {
try {
Path path = lib.getPath();
byte[] bytes = Files.readAllBytes(path);
// at the moment, we don't need the bitcode as the content of the source
Source source = Source.newBuilder(path.toString()).mimeType(LLVMLanguage.LLVM_BITCODE_MIME_TYPE).name(path.getFileName().toString()).build();
parserResults[i] = parse(language, context, source, lib, ByteBuffer.wrap(bytes));
lib.setParsed();
} catch (Throwable t) {
throw new RuntimeException("Error while trying to parse " + lib.getName(), t);
}
}
}
return parserResults;
}
use of com.oracle.truffle.api.source.Source in project sulong by graalvm.
the class NFIContextExtension method loadDefaultLibrary.
private TruffleObject loadDefaultLibrary() {
CompilerAsserts.neverPartOfCompilation();
final Source source = Source.newBuilder("default").name("default").mimeType("application/x-native").build();
try {
return (TruffleObject) env.parse(source).call();
} catch (Exception ex) {
throw new IllegalArgumentException(ex);
}
}
Aggregations