From 85ae61dbb25d7ec5ed96b0a7e5053dc46bca9684 Mon Sep 17 00:00:00 2001 From: stepan <stepan.sindelar@oracle.com> Date: Wed, 14 Feb 2018 17:05:17 +0100 Subject: [PATCH] Remove references to deprecated PolyglotEngine from examples --- .../debugging/InteropDebugging/R/main.r | 7 +++---- .../src/com/oracle/truffle/r/Main.java | 19 ++++++++----------- documentation/tutorials/debugging/tutorial.md | 4 ++-- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/documentation/tutorials/debugging/InteropDebugging/R/main.r b/documentation/tutorials/debugging/InteropDebugging/R/main.r index 383ea6ece2..364d8ae762 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 300a6e6390..b8d073b001 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 136bc7f1c5..bc6869a13c 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*. -- GitLab