diff --git a/documentation/tutorials/debugging/InteropDebugging/R/main.r b/documentation/tutorials/debugging/InteropDebugging/R/main.r index 383ea6ece226525c9655b32628a0ae1df3e6de50..364d8ae762e9b7a01257f32a7cdd844d914daadb 100644 --- a/documentation/tutorials/debugging/InteropDebugging/R/main.r +++ b/documentation/tutorials/debugging/InteropDebugging/R/main.r @@ -1,5 +1,5 @@ # -# 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") diff --git a/documentation/tutorials/debugging/InteropDebugging/src/com/oracle/truffle/r/Main.java b/documentation/tutorials/debugging/InteropDebugging/src/com/oracle/truffle/r/Main.java index 300a6e6390f598af2856a26f78a8fb2bfab53278..b8d073b0013f2e5c8e4c458f463ebefc1ef78a1f 100644 --- a/documentation/tutorials/debugging/InteropDebugging/src/com/oracle/truffle/r/Main.java +++ b/documentation/tutorials/debugging/InteropDebugging/src/com/oracle/truffle/r/Main.java @@ -1,5 +1,5 @@ /* - * 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(); } } diff --git a/documentation/tutorials/debugging/tutorial.md b/documentation/tutorials/debugging/tutorial.md index 136bc7f1c50e793ffa4d43835429de6ce32b219b..bc6869a13c6083a150bfaef3a3c2735544e16fd3 100644 --- a/documentation/tutorials/debugging/tutorial.md +++ b/documentation/tutorials/debugging/tutorial.md @@ -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*.