use of com.oracle.truffle.api.vm.PolyglotEngine in project TrufflePascal by Aspect26.
the class CompilerMain method executeSource.
private static void executeSource(Source source, InputStream input, OutputStream output) throws Exception {
PolyglotEngine engine = PolyglotEngine.newBuilder().setIn(input).setOut(output).setErr(System.err).build();
assert engine.getLanguages().containsKey(PascalLanguage.MIME_TYPE);
System.out.println(Truffle.getRuntime().getName());
if (settings.usesTPExtension()) {
UnitEvaluator.evalUnits(engine, settings.getIncludeDirectories());
}
engine.eval(source);
engine.dispose();
}
use of com.oracle.truffle.api.vm.PolyglotEngine 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();
vm.eval(Source.fromText("", "warmup.R").withMimeType("text/x-r"));
URL url = Main.class.getProtectionDomain().getCodeSource().getLocation();
File local = new File(url.toURI());
for (; ; ) {
File sieveInR = new File(local, "sieve.R");
if (sieveInR.exists()) {
break;
}
local = local.getParentFile();
}
System.err.println("engine is ready");
Source r = Source.fromFileName(new File(local, "sieve.R").getPath());
vm.eval(r);
}
use of com.oracle.truffle.api.vm.PolyglotEngine 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);
}
Aggregations