diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java index b0f63c19d036f82ceb00ec723ae1f243cb415fda..a7647aab86bb3cc131a119143e7eb581461f974c 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java @@ -390,8 +390,6 @@ final class REngine implements Engine, Engine.Timings { return result; } - private static final String EVAL_FUNCTION_NAME = "<eval wrapper>"; - public Object eval(RLanguage expr, MaterializedFrame frame) { RNode n = (RNode) expr.getRep(); // TODO perhaps this ought to be being checked earlier @@ -466,8 +464,8 @@ final class REngine implements Engine, Engine.Timings { } /** - * Creates an anonymous function, with no arguments to evaluate {@code body}. If {@body} - * is a not a syntax node, uses a simple {@link BodyNode} with no source information. Otherwise + * Creates an anonymous function, with no arguments to evaluate {@code body}. If {@body} is a + * not a syntax node, uses a simple {@link BodyNode} with no source information. Otherwise * creates a {@link FunctionStatementsNode} using {@code body}. and ensures that the * {@link FunctionBodyNode} has a {@link SourceSection}, for instrumentation, although the * anonymous {@link FunctionDefinitionNode} itself does not need one. diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastr/InteropEval.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastr/InteropEval.java new file mode 100644 index 0000000000000000000000000000000000000000..9ec0a8eef13c1aee2f22367f7f7134f164c8b654 --- /dev/null +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastr/InteropEval.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2015, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.truffle.r.library.fastr; + +import java.io.IOException; + +import com.oracle.truffle.api.CallTarget; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.*; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.r.nodes.builtin.*; +import com.oracle.truffle.r.runtime.*; +import com.oracle.truffle.r.runtime.context.*; + +public abstract class InteropEval extends RExternalBuiltinNode.Arg2 { + + @Specialization + @TruffleBoundary + protected Object interopEval(Object mimeType, Object source) { + Source sourceObject = Source.fromText(RRuntime.asString(source), Engine.EVAL_FUNCTION_NAME).withMimeType(RRuntime.asString(mimeType)); + + CallTarget callTarget; + + try { + callTarget = RContext.getInstance().getEnv().parse(sourceObject); + } catch (IOException e) { + throw new RuntimeException(e); + } + + return callTarget.call(); + } +} diff --git a/com.oracle.truffle.r.native/fficall/src/common/arithmetic.c b/com.oracle.truffle.r.native/fficall/src/common/arithmetic.c index 0b226545638067b8af612baf466f39bcab820616..fb36b55c42e9022e34adabbce2b922b03b16ce82 100644 --- a/com.oracle.truffle.r.native/fficall/src/common/arithmetic.c +++ b/com.oracle.truffle.r.native/fficall/src/common/arithmetic.c @@ -170,9 +170,57 @@ double R_pow_di(double x, int n) return xn; } -double R_pow(double x, double y) { - unimplemented("R_pow"); - return 0; +/* Keep these two in step */ +/* FIXME: consider using + tmp = (LDOUBLE)x1 - floor(q) * (LDOUBLE)x2; + */ +static double myfmod(double x1, double x2) +{ + if (x2 == 0.0) return R_NaN; + double q = x1 / x2, tmp = x1 - floor(q) * x2; + if(R_FINITE(q) && (fabs(q) > 1/ /*R_AccuracyInfo.eps*/2.220446e-16)) // FastR: removed reference to R_AccuracyInfo.eps + warning(_("probable complete loss of accuracy in modulus")); + q = floor(tmp/x2); + return tmp - q * x2; } +double R_pow(double x, double y) /* = x ^ y */ +{ + /* squaring is the most common of the specially handled cases so + check for it first. */ + if(y == 2.0) + return x * x; + if(x == 1. || y == 0.) + return(1.); + if(x == 0.) { + if(y > 0.) return(0.); + else if(y < 0) return(R_PosInf); + else return(y); /* NA or NaN, we assert */ + } + if (R_FINITE(x) && R_FINITE(y)) { + /* There was a special case for y == 0.5 here, but + gcc 4.3.0 -g -O2 mis-compiled it. Showed up with + 100^0.5 as 3.162278, example(pbirthday) failed. */ + return pow(x, y); + } + if (ISNAN(x) || ISNAN(y)) + return(x + y); + if(!R_FINITE(x)) { + if(x > 0) /* Inf ^ y */ + return (y < 0.)? 0. : R_PosInf; + else { /* (-Inf) ^ y */ + if(R_FINITE(y) && y == floor(y)) /* (-Inf) ^ n */ + return (y < 0.) ? 0. : (myfmod(y, 2.) ? x : -x); + } + } + if(!R_FINITE(y)) { + if(x >= 0) { + if(y > 0) /* y == +Inf */ + return (x >= 1) ? R_PosInf : 0.; + else /* y == -Inf */ + return (x < 1) ? R_PosInf : 0.; + } + } + return R_NaN; // all other cases: (-Inf)^{+-Inf, non-int}; (neg)^{+-Inf} +} diff --git a/com.oracle.truffle.r.native/library/fastr/src/NAMESPACE b/com.oracle.truffle.r.native/library/fastr/src/NAMESPACE index 574088856d14193f7e39812e876458ec830c4e83..ce552b66e4763b61804870ebd9a6d2c24873f833 100644 --- a/com.oracle.truffle.r.native/library/fastr/src/NAMESPACE +++ b/com.oracle.truffle.r.native/library/fastr/src/NAMESPACE @@ -1,6 +1,7 @@ ## exported functions export(Interop.import) export(Interop.export) +export(Interop.eval) export(fastr.createcc) export(fastr.getcc) export(fastr.compile) diff --git a/com.oracle.truffle.r.native/library/fastr/src/R/fastr.R b/com.oracle.truffle.r.native/library/fastr/src/R/fastr.R index 85a5922773024059af0f89d8bfd1c78d2841ff0e..af74cd4ec1d3397b14bdef51ec973f4dacc7e454 100644 --- a/com.oracle.truffle.r.native/library/fastr/src/R/fastr.R +++ b/com.oracle.truffle.r.native/library/fastr/src/R/fastr.R @@ -25,6 +25,8 @@ Interop.import <- function(name) invisible(.FastR(.NAME="Interop.import", name)) Interop.export <- function(name, value) invisible(.FastR(.NAME="Interop.export", name, value)) +Interop.eval <- function(mimeType, source) invisible(.FastR(.NAME="Interop.eval", mimeType, source)) + fastr.createcc <- function(func) invisible(.FastR(.NAME="createcc", func)) fastr.getcc <- function(func) .FastR(.NAME="getcc", func) diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LaFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LaFunctions.java index cfd71fb5db2ddba93919185203b53068773dae0c..9820a2cada5a35d3b0c37343e158059cd4ddf634 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LaFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LaFunctions.java @@ -452,7 +452,7 @@ public class LaFunctions { System.arraycopy(bin.getInternalStore(), 0, bData, 0, n * p); - int[] ipiv = new int[1]; + int[] ipiv = new int[n]; // work on a copy of A double[] avals = new double[n * n]; if (a instanceof RAbstractDoubleVector) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/foreign/FastR.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/foreign/FastR.java index be6095b3c57b8ac8d1da70d008a73c6b5fc85dac..4b1a08a4967d2c159486479c257e36d0fe792cc9 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/foreign/FastR.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/foreign/FastR.java @@ -60,6 +60,8 @@ public abstract class FastR extends RBuiltinNode { return InteropImportNodeGen.create(); case "Interop.export": return InteropExportNodeGen.create(); + case "Interop.eval": + return InteropEvalNodeGen.create(); case "createcc": return FastRCallCountingFactory.CreateCallCounterNodeGen.create(); case "getcc": diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RTruffleVisitor.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RTruffleVisitor.java index 64541106145dfabe334d6e23c28892c1e6c119cb..23b8ef26b78225307cc187d2d2cac36fba313196 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RTruffleVisitor.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RTruffleVisitor.java @@ -22,27 +22,84 @@ */ package com.oracle.truffle.r.nodes; -import java.util.*; -import java.util.function.*; - -import com.oracle.truffle.api.*; -import com.oracle.truffle.api.frame.*; -import com.oracle.truffle.api.source.*; -import com.oracle.truffle.r.nodes.access.*; -import com.oracle.truffle.r.nodes.access.variables.*; -import com.oracle.truffle.r.nodes.binary.*; -import com.oracle.truffle.r.nodes.control.*; -import com.oracle.truffle.r.nodes.function.*; -import com.oracle.truffle.r.parser.ast.*; +import java.util.ArrayList; +import java.util.List; +import java.util.function.BiFunction; + +import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.Truffle; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.MaterializedFrame; +import com.oracle.truffle.api.source.SourceSection; +import com.oracle.truffle.r.nodes.access.AccessArgumentNode; +import com.oracle.truffle.r.nodes.access.ConstantNode; +import com.oracle.truffle.r.nodes.access.ReadVariadicComponentNode; +import com.oracle.truffle.r.nodes.access.WriteLocalFrameVariableNode; +import com.oracle.truffle.r.nodes.access.WriteReplacementNode; +import com.oracle.truffle.r.nodes.access.WriteVariableNode; +import com.oracle.truffle.r.nodes.access.variables.ReadVariableNode; +import com.oracle.truffle.r.nodes.binary.ColonNode; +import com.oracle.truffle.r.nodes.control.BlockNode; +import com.oracle.truffle.r.nodes.control.BreakNode; +import com.oracle.truffle.r.nodes.control.ForNode; +import com.oracle.truffle.r.nodes.control.IfNode; +import com.oracle.truffle.r.nodes.control.NextNode; +import com.oracle.truffle.r.nodes.control.ReplacementNode; +import com.oracle.truffle.r.nodes.control.WhileNode; +import com.oracle.truffle.r.nodes.function.FormalArguments; +import com.oracle.truffle.r.nodes.function.FunctionBodyNode; +import com.oracle.truffle.r.nodes.function.FunctionDefinitionNode; +import com.oracle.truffle.r.nodes.function.FunctionExpressionNode; +import com.oracle.truffle.r.nodes.function.FunctionStatementsNode; +import com.oracle.truffle.r.nodes.function.GroupDispatchNode; +import com.oracle.truffle.r.nodes.function.PostProcessArgumentsNode; +import com.oracle.truffle.r.nodes.function.RCallNode; +import com.oracle.truffle.r.nodes.function.SaveArgumentsNode; +import com.oracle.truffle.r.nodes.function.WrapDefaultArgumentNode; +import com.oracle.truffle.r.parser.ast.ASTNode; +import com.oracle.truffle.r.parser.ast.AccessVariable; +import com.oracle.truffle.r.parser.ast.AccessVector; +import com.oracle.truffle.r.parser.ast.ArgNode; +import com.oracle.truffle.r.parser.ast.BinaryOperation; +import com.oracle.truffle.r.parser.ast.Break; +import com.oracle.truffle.r.parser.ast.Constant; import com.oracle.truffle.r.parser.ast.Constant.ConstantType; -import com.oracle.truffle.r.parser.ast.Operation.ArithmeticOperator; -import com.oracle.truffle.r.parser.ast.Operation.Operator; +import com.oracle.truffle.r.parser.ast.FieldAccess; +import com.oracle.truffle.r.parser.ast.For; +import com.oracle.truffle.r.parser.ast.Formula; import com.oracle.truffle.r.parser.ast.Function; -import com.oracle.truffle.r.parser.tools.*; -import com.oracle.truffle.r.runtime.*; -import com.oracle.truffle.r.runtime.data.*; -import com.oracle.truffle.r.runtime.env.frame.*; -import com.oracle.truffle.r.runtime.nodes.*; +import com.oracle.truffle.r.parser.ast.FunctionCall; +import com.oracle.truffle.r.parser.ast.If; +import com.oracle.truffle.r.parser.ast.Missing; +import com.oracle.truffle.r.parser.ast.Next; +import com.oracle.truffle.r.parser.ast.Operation.ArithmeticOperator; +import com.oracle.truffle.r.parser.ast.Repeat; +import com.oracle.truffle.r.parser.ast.Replacement; +import com.oracle.truffle.r.parser.ast.Sequence; +import com.oracle.truffle.r.parser.ast.SimpleAccessTempVariable; +import com.oracle.truffle.r.parser.ast.SimpleAccessVariable; +import com.oracle.truffle.r.parser.ast.SimpleAccessVariadicComponent; +import com.oracle.truffle.r.parser.ast.SimpleAssignVariable; +import com.oracle.truffle.r.parser.ast.UnaryOperation; +import com.oracle.truffle.r.parser.ast.UpdateField; +import com.oracle.truffle.r.parser.ast.UpdateVector; +import com.oracle.truffle.r.parser.ast.While; +import com.oracle.truffle.r.parser.tools.BasicVisitor; +import com.oracle.truffle.r.parser.tools.EvaluatedArgumentsVisitor; +import com.oracle.truffle.r.runtime.ArgumentsSignature; +import com.oracle.truffle.r.runtime.FastROptions; +import com.oracle.truffle.r.runtime.RGroupGenerics; +import com.oracle.truffle.r.runtime.RInternalError; +import com.oracle.truffle.r.runtime.RRuntime; +import com.oracle.truffle.r.runtime.RType; +import com.oracle.truffle.r.runtime.data.FastPathFactory; +import com.oracle.truffle.r.runtime.data.RDataFactory; +import com.oracle.truffle.r.runtime.data.REmpty; +import com.oracle.truffle.r.runtime.data.RFunction; +import com.oracle.truffle.r.runtime.data.RNull; +import com.oracle.truffle.r.runtime.env.frame.FrameSlotChangeMonitor; +import com.oracle.truffle.r.runtime.nodes.RNode; +import com.oracle.truffle.r.runtime.nodes.RSyntaxNode; public final class RTruffleVisitor extends BasicVisitor<RSyntaxNode> { diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java index 6a0941c5b4b62223e30e301112dc05457e28298a..425e5d847c6458a5f5243c83532305286a9bd866 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java @@ -190,9 +190,7 @@ public class RSerialize { protected Object addReadRef(Object item) { assert item != null; if (refTableIndex >= refTable.length) { - Object[] newRefTable = new Object[2 * refTable.length]; - System.arraycopy(refTable, 0, newRefTable, 0, refTable.length); - refTable = newRefTable; + refTable = Arrays.copyOf(refTable, refTable.length * 2); } refTable[refTableIndex++] = item; return item; @@ -416,15 +414,19 @@ public class RSerialize { Object enclos = readItem(); REnvironment enclosing = enclos == RNull.instance ? REnvironment.baseEnv() : (REnvironment) enclos; + final REnvironment.NewEnv env = RDataFactory.createNewEnv(enclosing, null); + /* + * We update the env reference as soon as possible, in case the contents of an + * environment contain a reference to the env itself. + */ + updateEnvReadRef(envRefTableIndex, env); Object frame = readItem(); boolean hashed = frame == RNull.instance; - REnvironment env; Object hashtab = readItem(); if (hashed) { - if (hashtab == RNull.instance) { - env = RDataFactory.createNewEnv(enclosing, null); - } else { - env = RDataFactory.createNewEnv(enclosing, null, true, ((RList) hashtab).getLength()); + if (hashtab != RNull.instance) { + env.setHashed(true); + env.setInitialSize(((RList) hashtab).getLength()); RList hashList = (RList) hashtab; // GnuR sizes its hash tables, empty slots indicated by RNull for (int i = 0; i < hashList.getLength(); i++) { @@ -437,14 +439,12 @@ public class RSerialize { } } } else { - env = RDataFactory.createNewEnv(enclosing, null); while (frame != RNull.instance) { RPairList pl = (RPairList) frame; env.safePut(((RSymbol) pl.getTag()).getName(), pl.car()); frame = pl.cdr(); } } - updateEnvReadRef(envRefTableIndex, env); if (locked != 0) { env.lock(false); } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/Engine.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/Engine.java index ea59ceb931907d683287c40363003018531d6ef6..dbf53a8960b748e89b0ebda8dd43085da911ce94 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/Engine.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/Engine.java @@ -36,6 +36,8 @@ import com.oracle.truffle.r.runtime.env.*; public interface Engine { + public static final String EVAL_FUNCTION_NAME = "<eval wrapper>"; + public static class ParseException extends IOException { private static final long serialVersionUID = 1L; diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RDataFactory.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RDataFactory.java index 1014afa96b595033e3003ec30c2a079be6034e21..1c26f186889cae2f77521f15702933e5badeb83c 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RDataFactory.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RDataFactory.java @@ -437,15 +437,18 @@ public final class RDataFactory { } public static REnvironment createInternalEnv() { - return traceDataCreated(new REnvironment.NewEnv(null, RRuntime.createNonFunctionFrame().materialize(), REnvironment.UNNAMED, false, 0)); + return traceDataCreated(new REnvironment.NewEnv(null, RRuntime.createNonFunctionFrame().materialize(), REnvironment.UNNAMED)); } - public static REnvironment createNewEnv(REnvironment parent, String name) { - return traceDataCreated(new REnvironment.NewEnv(parent, RRuntime.createNonFunctionFrame().materialize(), name, false, 0)); + public static REnvironment.NewEnv createNewEnv(REnvironment parent, String name) { + return traceDataCreated(new REnvironment.NewEnv(parent, RRuntime.createNonFunctionFrame().materialize(), name)); } - public static REnvironment createNewEnv(REnvironment parent, String name, boolean hash, int size) { - return traceDataCreated(new REnvironment.NewEnv(parent, RRuntime.createNonFunctionFrame().materialize(), name, hash, size)); + public static REnvironment createNewEnv(REnvironment parent, String name, boolean hashed, int initialSize) { + REnvironment.NewEnv env = new REnvironment.NewEnv(parent, RRuntime.createNonFunctionFrame().materialize(), name); + env.setHashed(hashed); + env.setInitialSize(initialSize); + return traceDataCreated(env); } public static RS4Object createS4Object() { diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/REnvironment.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/REnvironment.java index db9575fff28277529841188da2761790dda20ef7..f6b6f3d4b914614496f5aefeea89a9dd86bf6354 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/REnvironment.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/REnvironment.java @@ -487,7 +487,7 @@ public abstract class REnvironment extends RAttributeStorage implements RTypedVa /** * Add name to namespace registry. - * + * * @param name namespace name * @param env namespace value * @return {@code null} if name is already registered else {@code env} @@ -504,7 +504,7 @@ public abstract class REnvironment extends RAttributeStorage implements RTypedVa /** * Remove name from namespace registry. - * + * * @param name namespace name * @return {@code null} if name is not registered else namespace value */ @@ -641,7 +641,7 @@ public abstract class REnvironment extends RAttributeStorage implements RTypedVa */ @TruffleBoundary public static REnvironment createFromList(RAttributeProfiles attrProfiles, RList list, REnvironment parent) { - REnvironment result = RDataFactory.createNewEnv(parent, null, false, 0); + REnvironment result = RDataFactory.createNewEnv(parent, null); RStringVector names = list.getNames(attrProfiles); for (int i = 0; i < list.getLength(); i++) { try { @@ -980,13 +980,11 @@ public abstract class REnvironment extends RAttributeStorage implements RTypedVa * */ public static final class NewEnv extends REnvironment { - private final boolean hash; - private final int size; + private boolean hashed; + private int initialSize; - public NewEnv(REnvironment parent, MaterializedFrame frame, String name, boolean hash, int size) { + public NewEnv(REnvironment parent, MaterializedFrame frame, String name) { super(parent, UNNAMED, frame); - this.hash = hash; - this.size = size; if (parent != null) { RArguments.setEnclosingFrame(frame, parent.getFrame()); } @@ -995,14 +993,21 @@ public abstract class REnvironment extends RAttributeStorage implements RTypedVa } } - public boolean hashed() { - return hash; + public boolean isHashed() { + return hashed; } - public int createdSize() { - return size; + public void setHashed(boolean hashed) { + this.hashed = hashed; } + public int getInitialSize() { + return initialSize; + } + + public void setInitialSize(int initialSize) { + this.initialSize = initialSize; + } } /** diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test index d40360b003007b924b5028a38b99f251d2e85914..7d9fa7f80c3becfa9c006dfe57995ed7014af2dd 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test @@ -102596,6 +102596,10 @@ a b c d e [1] 42 +##com.oracle.truffle.r.test.library.fastr.TestInteropEval.testInteropEval +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 16 } else { Interop.eval('application/x-r', '14 + 2') } +[1] 16 + ##com.oracle.truffle.r.test.library.fastr.TestStateTrans.testTransitions #if (length(grep("FastR", R.Version()$version.string)) != 1) { 1 } else { f<-function(x) fastr.refcountinfo(x); f(c(1,2)) } [1] 1 diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestInteropEval.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestInteropEval.java new file mode 100644 index 0000000000000000000000000000000000000000..2efa100de1a1344bae1a3eb5ad828d116778c9ba --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestInteropEval.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.truffle.r.test.library.fastr; + +import org.junit.*; + +import com.oracle.truffle.r.test.*; + +public class TestInteropEval extends TestBase { + + @Test + public void testInteropEval() { + assertEvalFastR("{ Interop.eval('application/x-r', '14 + 2') }", "16"); + } +}