Skip to content
Snippets Groups Projects
Commit 85ae61db authored by stepan's avatar stepan
Browse files

Remove references to deprecated PolyglotEngine from examples

parent 9730f8d1
No related branches found
No related tags found
No related merge requests found
#
# Copyright (c) 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
......@@ -34,7 +34,6 @@ clazz <- new.java.class("com.oracle.truffle.r.JavaMessage")
obj <- new.external(clazz, "Hi there")
print(obj$getMessage())
JS_MIME_TYPE <- "application/javascript"
eval.external(JS_MIME_TYPE, source='var s = "Hello from Javascript"; print(s)')
eval.external(JS_MIME_TYPE, path="JS/main.js")
eval.external('js', source='var s = "Hello from Javascript"; print(s)')
eval.external('js', path="JS/main.js")
/*
* Copyright (c) 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
......@@ -27,8 +27,8 @@
*/
package com.oracle.truffle.r;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.vm.PolyglotEngine;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Source;
import java.io.File;
import java.io.IOException;
......@@ -41,17 +41,14 @@ public class Main {
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException {
PolyglotEngine newVM = PolyglotEngine.newBuilder().config(R_MIME_TYPE, "debugContext", null).build();
newVM.eval(fromString("print('Hello, World! (from string)')"));
newVM.eval(fromFile("R/main.r"));
}
private static Source fromString(String code) {
return Source.newBuilder(code).name("<shell_input>").mimeType(R_MIME_TYPE).interactive().build();
Context context = Context.create();
context.eval("R", "print('Hello, World! (from string)')");
context.eval(fromFile("R/main.r"));
}
private static Source fromFile(String path) throws IOException {
return Source.newBuilder(new File(path)).mimeType(R_MIME_TYPE).build();
return Source.newBuilder("R", new File(path)).build();
}
}
......@@ -150,8 +150,8 @@ It is also possible to cross language boundaries during stepping when using the
### Inter-language Debugging
File `Main.java` creates a `PolyglotEngine` object that can execute R code. This is basically the FastR engine.
The engine object can now run R code by creating a source object (representing R code) and submitting the source to the engine.
File `Main.java` creates a `Context` object that can execute R code. This is basically the FastR engine.
The engine object can now run R code by creating a source object (representing R code) and submitting the source to the context object.
The expression `fromString("print('Hello, World! (from string)')")` creates a source code from a string.
Expression `fromFile("R/main.r")` creates source code from file *R/main.r*.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment