diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/TruffleRLanguage.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/TruffleRLanguage.java index 81e76870b73734df82dccb61e028f5dbcb541dd3..efa8c2604598ef683d1f30b6464ee83c8798e479 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/TruffleRLanguage.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/TruffleRLanguage.java @@ -107,7 +107,7 @@ public final class TruffleRLanguage extends TruffleLanguage<RContext> { /* * When running under the debugger the loadrun command eventually arrives here with a * FileSource. Since FastR has a custom mechanism for executing a (Root)CallTarget that - * TruffleVM does not know about, we have to use a delegation mechanism via a wrapper + * PolyglotEngine does not know about, we have to use a delegation mechanism via a wrapper * CallTarget class, using a special REngine entry point. */ return RContext.getEngine().parseToCallTarget(source, true); diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/repl/RREPLHandler.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/repl/RREPLHandler.java index 931ddce4ab0291985034159b27ba42cc258d7e9b..51aeeed6d3c1abd0f36073333d353858cf36e1a6 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/repl/RREPLHandler.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/repl/RREPLHandler.java @@ -176,7 +176,7 @@ public abstract class RREPLHandler extends REPLHandler { if (!file.canRead()) { return finishReplyFailed(reply, "can't find file \"" + fileName + "\""); } - final TruffleVM vm = serverContext.vm(); + final PolyglotEngine vm = serverContext.engine(); Source source = Source.fromURL(file.toURI().toURL(), "<REPL_file>").withMimeType(TruffleRLanguage.MIME); vm.eval(source); final String path = file.getCanonicalPath(); diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/repl/RREPLServer.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/repl/RREPLServer.java index f621966fb87f45ebd824db4332bd36ce24a6e33f..51daf4d6d3107d68a9442215065033715a94bc01 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/repl/RREPLServer.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/repl/RREPLServer.java @@ -28,7 +28,7 @@ import com.oracle.truffle.api.debug.*; import com.oracle.truffle.api.instrument.*; import com.oracle.truffle.api.source.*; import com.oracle.truffle.api.vm.*; -import com.oracle.truffle.api.vm.TruffleVM.Language; +import com.oracle.truffle.api.vm.PolyglotEngine.Language; import com.oracle.truffle.r.engine.*; import com.oracle.truffle.r.engine.shell.*; import com.oracle.truffle.r.runtime.*; @@ -58,7 +58,7 @@ public final class RREPLServer extends REPLServer { } private final Language language; - private TruffleVM vm; + private PolyglotEngine vm; private Debugger db; private final String statusPrefix; private final Map<String, REPLHandler> handlerMap = new HashMap<>(); @@ -114,7 +114,7 @@ public final class RREPLServer extends REPLServer { /* * We call a special RCommand entry point that does most of the normal initialization but * returns the initial RContext which has not yet been activated, which means that the - * TruffleVM has not yet been built, but the TruffleVM.Builder has been created. + * PolyglotEngine has not yet been built, but the PolyglotEngine.Builder has been created. */ String[] debugArgs = new String[args.length + 1]; @@ -122,7 +122,7 @@ public final class RREPLServer extends REPLServer { System.arraycopy(args, 0, debugArgs, 1, args.length); RCmdOptions options = RCmdOptions.parseArguments(RCmdOptions.Client.R, args); ContextInfo info = RCommand.createContextInfoFromCommandLine(options); - this.vm = info.apply(TruffleVM.newVM()).onEvent(onHalted).onEvent(onExec).build(); + this.vm = info.apply(PolyglotEngine.buildNew()).onEvent(onHalted).onEvent(onExec).build(); this.language = vm.getLanguages().get(TruffleRLanguage.MIME); assert language != null; @@ -192,7 +192,7 @@ public final class RREPLServer extends REPLServer { } @Override - public TruffleVM vm() { + public PolyglotEngine engine() { return vm; } diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/shell/RCommand.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/shell/RCommand.java index ad2bd0a22d30ccb5ce58e68a0cbf16745132e8cd..b34fe28cf31b6248dcd0e78e8a0aac032fa6db39 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/shell/RCommand.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/shell/RCommand.java @@ -22,25 +22,49 @@ */ package com.oracle.truffle.r.engine.shell; -import static com.oracle.truffle.r.runtime.RCmdOptions.RCmdOption.*; +import static com.oracle.truffle.r.runtime.RCmdOptions.RCmdOption.EXPR; +import static com.oracle.truffle.r.runtime.RCmdOptions.RCmdOption.FILE; +import static com.oracle.truffle.r.runtime.RCmdOptions.RCmdOption.INTERACTIVE; +import static com.oracle.truffle.r.runtime.RCmdOptions.RCmdOption.NO_ENVIRON; +import static com.oracle.truffle.r.runtime.RCmdOptions.RCmdOption.NO_INIT_FILE; +import static com.oracle.truffle.r.runtime.RCmdOptions.RCmdOption.NO_RESTORE; +import static com.oracle.truffle.r.runtime.RCmdOptions.RCmdOption.NO_SAVE; +import static com.oracle.truffle.r.runtime.RCmdOptions.RCmdOption.QUIET; +import static com.oracle.truffle.r.runtime.RCmdOptions.RCmdOption.SAVE; +import static com.oracle.truffle.r.runtime.RCmdOptions.RCmdOption.SILENT; +import static com.oracle.truffle.r.runtime.RCmdOptions.RCmdOption.SLAVE; +import static com.oracle.truffle.r.runtime.RCmdOptions.RCmdOption.VANILLA; -import java.io.*; -import java.nio.file.*; -import java.util.*; +import java.io.Console; +import java.io.EOFException; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.util.List; -import jline.console.*; +import jline.console.ConsoleReader; +import jline.console.UserInterruptException; -import com.oracle.truffle.api.source.*; -import com.oracle.truffle.api.vm.*; -import com.oracle.truffle.r.engine.*; -import com.oracle.truffle.r.nodes.builtin.base.*; -import com.oracle.truffle.r.runtime.*; -import com.oracle.truffle.r.runtime.context.*; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.vm.PolyglotEngine; +import com.oracle.truffle.r.engine.TruffleRLanguage; +import com.oracle.truffle.r.nodes.builtin.base.Quit; +import com.oracle.truffle.r.runtime.BrowserQuitException; +import com.oracle.truffle.r.runtime.RCmdOptions; +import com.oracle.truffle.r.runtime.RError; +import com.oracle.truffle.r.runtime.RInternalError; +import com.oracle.truffle.r.runtime.RRuntime; +import com.oracle.truffle.r.runtime.Utils; +import com.oracle.truffle.r.runtime.context.ConsoleHandler; +import com.oracle.truffle.r.runtime.context.ContextInfo; import com.oracle.truffle.r.runtime.context.Engine.IncompleteSourceException; import com.oracle.truffle.r.runtime.context.Engine.ParseException; +import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.context.RContext.ContextKind; -import com.oracle.truffle.r.runtime.data.*; -import com.oracle.truffle.r.runtime.data.model.*; +import com.oracle.truffle.r.runtime.data.RStringVector; +import com.oracle.truffle.r.runtime.data.model.RAbstractLogicalVector; /** * Emulates the (Gnu)R command as precisely as possible. @@ -153,7 +177,7 @@ public class RCommand { * exiting. So,in either case, we never return. */ public static void readEvalPrint(ContextInfo info) { - TruffleVM vm = info.apply(TruffleVM.newVM()).build(); + PolyglotEngine vm = info.apply(PolyglotEngine.buildNew()).build(); ConsoleHandler consoleHandler = info.getConsoleHandler(); Source source = Source.fromNamedAppendableText(consoleHandler.getInputDescription()); try { @@ -225,7 +249,7 @@ public class RCommand { } } - private static boolean doEcho(TruffleVM vm) { + private static boolean doEcho(PolyglotEngine vm) { Object echo; try { echo = vm.eval(GET_ECHO).get(); diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastr/FastRContext.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastr/FastRContext.java index bbb2641b77aa4019ab33688fe55f0682b174a5d2..3667e76739da5103f419849ac9091fe3bd0626f3 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastr/FastRContext.java +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastr/FastRContext.java @@ -139,7 +139,7 @@ public class FastRContext { } else { for (int i = 0; i < contexts.getLength(); i++) { ContextInfo info = checkContext(contexts.getDataAt(i), this); - TruffleVM vm = info.apply(TruffleVM.newVM()).build(); + PolyglotEngine vm = info.apply(PolyglotEngine.buildNew()).build(); try { Source source = Source.fromText(exprs.getDataAt(i), "<eval>").withMimeType("application/x-r"); vm.eval(source); diff --git a/com.oracle.truffle.r.native/gnur/Makefile.gnur b/com.oracle.truffle.r.native/gnur/Makefile.gnur index 08f3f468a93a770872b35b2b46f8f5d030bd4a9e..bb0f0f2c6ab687444fef33d236507f402c9906c9 100644 --- a/com.oracle.truffle.r.native/gnur/Makefile.gnur +++ b/com.oracle.truffle.r.native/gnur/Makefile.gnur @@ -84,7 +84,7 @@ ifeq ($(OSNAME), SunOS) iconv: $(ICONV) iconv_config iconv_build $(ICONV): - tar xf $(TOPDIR)/../lib/$(ICONV).tar.gz + tar xf $(TOPDIR)/../libdownloads/$(ICONV).tar.gz iconv_config: $(ICONV)/Makefile diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AnyNA.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AnyNA.java index 588b62059700f448f74fa5895cd41fbd96e957ad..f34298e87262cbdbebedb105b912514ccbe1cfbc 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AnyNA.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AnyNA.java @@ -25,6 +25,7 @@ package com.oracle.truffle.r.nodes.builtin.base; import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.builtin.*; +import com.oracle.truffle.r.nodes.control.RLengthNode; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; @@ -138,12 +139,12 @@ public abstract class AnyNA extends RBuiltinNode { @Specialization protected byte isNA(RList list, // @Cached("createRecursive()") AnyNA recursive, // - @Cached("createClassProfile()") ValueProfile elementProfile) { + @Cached("createClassProfile()") ValueProfile elementProfile, // + @Cached("create()") RLengthNode length) { controlVisibility(); for (int i = 0; i < list.getLength(); i++) { Object value = elementProfile.profile(list.getDataAt(i)); - if (value instanceof Byte || value instanceof Integer || value instanceof Double || value instanceof RComplex || value instanceof RScalar || - (value instanceof RAbstractContainer && ((RAbstractContainer) value).getLength() == 1)) { + if (length.executeInteger(value) == 1) { byte result = recursive.execute(value); if (result == RRuntime.LOGICAL_TRUE) { return RRuntime.LOGICAL_TRUE; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java index c41434b4ae6f59f1b88de9460efaa198e1f89654..5b38de2021b573df8efa042169243702740f6cfb 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java @@ -470,6 +470,7 @@ public class BasePackage extends RBuiltinPackage { add(TempFile.class, TempFileNodeGen::create); add(ToLower.class, ToLowerNodeGen::create); add(ToUpper.class, ToUpperNodeGen::create); + add(Traceback.class, TracebackNodeGen::create); add(Transpose.class, TransposeNodeGen::create); add(TrigExpFunctions.Acos.class, TrigExpFunctionsFactory.AcosNodeGen::create); add(TrigExpFunctions.Acosh.class, TrigExpFunctionsFactory.AcoshNodeGen::create); @@ -534,7 +535,5 @@ public class BasePackage extends RBuiltinPackage { addFastPath(baseFrame, "pmin", FastPathFactory.EVALUATE_ARGS); addFastPath(baseFrame, "cbind", FastPathFactory.FORCED_EAGER_ARGS); addFastPath(baseFrame, "rbind", FastPathFactory.FORCED_EAGER_ARGS); -// addFastPath(baseFrame, "cbind.data.frame", FastPathFactory.FORCED_EAGER_ARGS); -// addFastPath(baseFrame, "rbind.data.frame", FastPathFactory.FORCED_EAGER_ARGS); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/InfixEmulationFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/InfixEmulationFunctions.java index b8b8bb22f3fdc733d80bfd37161e92349e45353c..e6c2175704a67dffaa2028632a344a03f20cf090 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/InfixEmulationFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/InfixEmulationFunctions.java @@ -131,50 +131,37 @@ public class InfixEmulationFunctions { @NodeChild(value = "op") protected abstract static class PromiseEvaluator extends RNode { - protected abstract Object execute(VirtualFrame frame, Object op); - - @Child private PromiseHelperNode promiseHelper; - @Child private PromiseEvaluator evalRecursive; - - protected Object evalRecursive(VirtualFrame frame, Object op) { - if (evalRecursive == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - evalRecursive = insert(PromiseEvaluatorNodeGen.create(null)); - } - return evalRecursive.execute(frame, op); + protected PromiseEvaluator create() { + return PromiseEvaluatorNodeGen.create(null); } + protected abstract Object execute(VirtualFrame frame, Object op); + @Specialization(guards = {"!isRPromise(op)", "!isRArgsValuesAndNames(op)"}) protected Object eval(Object op) { return op; } @Specialization - protected Object eval(VirtualFrame frame, RPromise p) { - if (promiseHelper == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - promiseHelper = insert(new PromiseHelperNode()); - } + protected Object eval(VirtualFrame frame, RPromise p, // + @Cached("new()") PromiseHelperNode promiseHelper) { return promiseHelper.evaluate(frame, p); } - @Specialization(guards = "!argsEmpty(args)") - protected RArgsValuesAndNames eval(VirtualFrame frame, RArgsValuesAndNames args) { + @Specialization(guards = "!args.isEmpty()") + protected RArgsValuesAndNames eval(VirtualFrame frame, RArgsValuesAndNames args, // + @Cached("create()") PromiseEvaluator evalRecursive) { Object[] values = args.getArguments(); for (int i = 0; i < values.length; i++) { - values[i] = evalRecursive(frame, values[i]); + values[i] = evalRecursive.execute(frame, values[i]); } return args; } - @Specialization(guards = "argsEmpty(args)") + @Specialization(guards = "args.isEmpty()") protected RArgsValuesAndNames evalEmpty(RArgsValuesAndNames args) { return args; } - - protected boolean argsEmpty(RArgsValuesAndNames args) { - return args.isEmpty(); - } } public abstract static class AccessArrayBuiltin extends RBuiltinNode { @@ -197,7 +184,7 @@ public class InfixEmulationFunctions { if (FastROptions.UseNewVectorNodes) { if (extractNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); - extractNode = insert(ExtractVectorNode.create(isSubset() ? ElementAccessMode.SUBSET : ElementAccessMode.SUBSCRIPT)); + extractNode = insert(ExtractVectorNode.create(isSubset() ? ElementAccessMode.SUBSET : ElementAccessMode.SUBSCRIPT, false)); } result = extractNode.apply(vector, inds.getArguments(), RLogical.valueOf(exact), dropDim); } else { @@ -354,7 +341,7 @@ public class InfixEmulationFunctions { if (FastROptions.UseNewVectorNodes) { if (replaceNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); - replaceNode = insert(ReplaceVectorNode.create(isSubset ? ElementAccessMode.SUBSET : ElementAccessMode.SUBSCRIPT)); + replaceNode = insert(ReplaceVectorNode.create(isSubset ? ElementAccessMode.SUBSET : ElementAccessMode.SUBSCRIPT, false)); } Object[] pos; if (argsLengthLargerThanOneProfile.profile(args.getLength() > 1)) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Match.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Match.java index 33ab0665fcfb19b8623ee899ee6787fc76b9bf24..9f89a8bae7bf4b0dca628e4aa75795693a866c2f 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Match.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Match.java @@ -266,7 +266,7 @@ public abstract class Match extends RBuiltinNode { return RDataFactory.createIntVector(result, setCompleteState(matchAll, nomatch)); } - @Specialization() + @Specialization protected RIntVector match(RAbstractIntVector x, RAbstractLogicalVector table, Object nomatchObj, @SuppressWarnings("unused") Object incomparables) { controlVisibility(); int nomatch = castInt(nomatchObj); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ToLower.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ToLower.java index 33bab9ddb5cdb0dea8473ea91a7ff6a103189358..d10f2a3a99a165b6c9b64a4daea929a992978348 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ToLower.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ToLower.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -29,6 +29,7 @@ import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; +import com.oracle.truffle.r.runtime.data.model.*; @RBuiltin(name = "tolower", kind = INTERNAL, parameterNames = {"x"}) public abstract class ToLower extends RBuiltinNode { @@ -42,7 +43,7 @@ public abstract class ToLower extends RBuiltinNode { @Specialization @TruffleBoundary - protected RStringVector toLower(RStringVector vector) { + protected RStringVector toLower(RAbstractStringVector vector) { controlVisibility(); String[] stringVector = new String[vector.getLength()]; for (int i = 0; i < vector.getLength(); i++) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Traceback.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Traceback.java new file mode 100644 index 0000000000000000000000000000000000000000..dfd0a6549695bdf2362e7c70740a4c3cf7f40a87 --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Traceback.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2013, 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.nodes.builtin.base; + +import static com.oracle.truffle.r.runtime.RBuiltinKind.PRIMITIVE; + +import java.util.Arrays; + +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; +import com.oracle.truffle.r.runtime.RBuiltin; +import com.oracle.truffle.r.runtime.Utils; +import com.oracle.truffle.r.runtime.data.RDataFactory; +import com.oracle.truffle.r.runtime.data.RStringVector; + +@RBuiltin(name = "traceback", kind = PRIMITIVE, parameterNames = {"x"}) +public abstract class Traceback extends RBuiltinNode { + + @Override + protected void createCasts(CastBuilder casts) { + casts.firstIntegerWithWarning(0, 0, "x"); + } + + @Specialization + public RStringVector traceback(int x) { + String[] traceback = Utils.createTraceback(); + for (String s : traceback) { + System.out.println(":: " + s); + } + traceback = Arrays.copyOfRange(traceback, x, traceback.length); + return RDataFactory.createStringVector(traceback, true); + } +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/TrigExpFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/TrigExpFunctions.java index 6998858116e5172880f26fa64eed3d1873e5b60d..d9d8315dc19c347dc4f6129139fed19a536b43dd 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/TrigExpFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/TrigExpFunctions.java @@ -51,6 +51,7 @@ public class TrigExpFunctions { } protected double op(@SuppressWarnings("unused") double x) { + // not abstract because this would confuse the DSL annotation processor throw RInternalError.shouldNotReachHere("this method needs to be implemented in subclasses"); } @@ -356,8 +357,7 @@ public class TrigExpFunctions { double apply(int i); } - protected RDoubleVector doFun(int length, IntDoubleFunction yFun, IntDoubleFunction xFun, // - @Cached("create()") CountedLoopConditionProfile profile) { + protected RDoubleVector doFun(int length, IntDoubleFunction yFun, IntDoubleFunction xFun, CountedLoopConditionProfile profile) { controlVisibility(); double[] resultVector = new double[length]; profile.profileLength(length); diff --git a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNodeTest.java b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNodeTest.java index 8f35da8a79f442cebb840fca4b81a81afd40c092..fe69f606b06acf01a505800280f2d025ac7d5988 100644 --- a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNodeTest.java +++ b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNodeTest.java @@ -283,7 +283,7 @@ public class ExtractVectorNodeTest extends TestBase { } private static NodeHandle<ExtractVectorNode> create(ElementAccessMode mode, boolean exact, boolean dropDimension) { - return createHandle(ExtractVectorNode.create(mode), // + return createHandle(ExtractVectorNode.create(mode, false), // (node, args) -> node.apply(args[0], (Object[]) args[1], RLogical.valueOf(exact), RLogical.valueOf(dropDimension))); } diff --git a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNodeTest.java b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNodeTest.java index 65760088de1454f166846aa78b75c0b94ed65e0b..7130583001cbe18e0ded15a33cd4803e5233cd2b 100644 --- a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNodeTest.java +++ b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNodeTest.java @@ -278,7 +278,7 @@ public class ReplaceVectorNodeTest extends TestBase { } private static NodeHandle<ReplaceVectorNode> create(ElementAccessMode mode) { - return createHandle(ReplaceVectorNode.create(mode), // + return createHandle(ReplaceVectorNode.create(mode, false), // (node, args) -> node.apply(args[0], (Object[]) args[1], args[2])); } diff --git a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/BinaryArithmeticNodeTest.java b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/BinaryArithmeticNodeTest.java index 5ad4926938386366f09e04c009c342fe83d6805b..2dcdaccd724efbb380eccabcfd63e6b004bc0b1a 100644 --- a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/BinaryArithmeticNodeTest.java +++ b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/BinaryArithmeticNodeTest.java @@ -22,27 +22,61 @@ */ package com.oracle.truffle.r.nodes.test; -import static com.oracle.truffle.r.nodes.test.TestUtilities.*; -import static com.oracle.truffle.r.runtime.data.RDataFactory.*; -import static com.oracle.truffle.r.runtime.ops.BinaryArithmetic.*; -import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.*; -import static org.junit.Assume.*; - -import java.util.*; - -import org.junit.*; -import org.junit.experimental.theories.*; -import org.junit.internal.*; -import org.junit.runner.*; - -import com.oracle.truffle.r.nodes.binary.*; +import static com.oracle.truffle.r.nodes.test.TestUtilities.createHandle; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createDoubleSequence; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createDoubleVectorFromScalar; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createEmptyComplexVector; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createEmptyDoubleVector; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createEmptyIntVector; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createEmptyLogicalVector; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createIntSequence; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createIntVectorFromScalar; +import static com.oracle.truffle.r.runtime.ops.BinaryArithmetic.ADD; +import static com.oracle.truffle.r.runtime.ops.BinaryArithmetic.DIV; +import static com.oracle.truffle.r.runtime.ops.BinaryArithmetic.INTEGER_DIV; +import static com.oracle.truffle.r.runtime.ops.BinaryArithmetic.MAX; +import static com.oracle.truffle.r.runtime.ops.BinaryArithmetic.MIN; +import static com.oracle.truffle.r.runtime.ops.BinaryArithmetic.MOD; +import static com.oracle.truffle.r.runtime.ops.BinaryArithmetic.MULTIPLY; +import static com.oracle.truffle.r.runtime.ops.BinaryArithmetic.SUBTRACT; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assume.assumeFalse; +import static org.junit.Assume.assumeThat; +import static org.junit.Assume.assumeTrue; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.theories.DataPoints; +import org.junit.experimental.theories.Theories; +import org.junit.experimental.theories.Theory; +import org.junit.internal.AssumptionViolatedException; +import org.junit.runner.RunWith; + +import com.oracle.truffle.r.nodes.binary.BinaryArithmeticNode; import com.oracle.truffle.r.nodes.test.TestUtilities.NodeHandle; -import com.oracle.truffle.r.runtime.*; -import com.oracle.truffle.r.runtime.data.*; +import com.oracle.truffle.r.runtime.FastROptions; +import com.oracle.truffle.r.runtime.RType; +import com.oracle.truffle.r.runtime.data.RAttributes; import com.oracle.truffle.r.runtime.data.RAttributes.RAttribute; -import com.oracle.truffle.r.runtime.data.model.*; -import com.oracle.truffle.r.runtime.ops.*; +import com.oracle.truffle.r.runtime.data.RComplex; +import com.oracle.truffle.r.runtime.data.RNull; +import com.oracle.truffle.r.runtime.data.RScalarVector; +import com.oracle.truffle.r.runtime.data.RSequence; +import com.oracle.truffle.r.runtime.data.RShareable; +import com.oracle.truffle.r.runtime.data.RVector; +import com.oracle.truffle.r.runtime.data.model.RAbstractVector; +import com.oracle.truffle.r.runtime.ops.BinaryArithmetic; +import com.oracle.truffle.r.runtime.ops.BinaryArithmeticFactory; /** * This test verifies white box assumptions for the arithmetic node. Please note that this node diff --git a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/BinaryBooleanNodeTest.java b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/BinaryBooleanNodeTest.java index 76e7af565de47d54a3271860710d1d08d9b6df9e..620f357b030431983c616668c67367502b3c42d2 100644 --- a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/BinaryBooleanNodeTest.java +++ b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/BinaryBooleanNodeTest.java @@ -22,23 +22,46 @@ */ package com.oracle.truffle.r.nodes.test; -import static com.oracle.truffle.r.nodes.test.TestUtilities.*; -import static com.oracle.truffle.r.runtime.data.RDataFactory.*; -import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.*; -import static org.junit.Assume.*; - -import org.junit.*; -import org.junit.experimental.theories.*; -import org.junit.internal.*; -import org.junit.runner.*; - -import com.oracle.truffle.r.nodes.binary.*; +import static com.oracle.truffle.r.nodes.test.TestUtilities.createHandle; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createEmptyComplexVector; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createEmptyDoubleVector; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createEmptyIntVector; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createEmptyLogicalVector; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createEmptyRawVector; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createEmptyStringVector; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createRaw; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createRawVector; +import static com.oracle.truffle.r.runtime.data.RDataFactory.createStringVector; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assume.assumeFalse; +import static org.junit.Assume.assumeThat; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.experimental.theories.DataPoint; +import org.junit.experimental.theories.DataPoints; +import org.junit.experimental.theories.Theories; +import org.junit.experimental.theories.Theory; +import org.junit.internal.AssumptionViolatedException; +import org.junit.runner.RunWith; + +import com.oracle.truffle.r.nodes.binary.BinaryBooleanNode; import com.oracle.truffle.r.nodes.test.TestUtilities.NodeHandle; -import com.oracle.truffle.r.runtime.*; -import com.oracle.truffle.r.runtime.data.*; -import com.oracle.truffle.r.runtime.data.model.*; -import com.oracle.truffle.r.runtime.ops.*; +import com.oracle.truffle.r.runtime.RRuntime; +import com.oracle.truffle.r.runtime.RType; +import com.oracle.truffle.r.runtime.data.RComplex; +import com.oracle.truffle.r.runtime.data.RNull; +import com.oracle.truffle.r.runtime.data.RScalarVector; +import com.oracle.truffle.r.runtime.data.RShareable; +import com.oracle.truffle.r.runtime.data.model.RAbstractVector; +import com.oracle.truffle.r.runtime.ops.BinaryCompare; +import com.oracle.truffle.r.runtime.ops.BinaryLogic; +import com.oracle.truffle.r.runtime.ops.BooleanOperationFactory; /** * This test verifies white box assumptions for the arithmetic node. Please note that this node diff --git a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/TestBase.java b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/TestBase.java index 4e3c95cb5bb6d2eb6d1aed02621fa347be0c9c5e..165dd4e79c722f1b1c49207542b3d4b8d47a3bc8 100644 --- a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/TestBase.java +++ b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/TestBase.java @@ -34,7 +34,7 @@ import com.oracle.truffle.r.test.generate.*; public class TestBase { - private static TruffleVM testVM; + private static PolyglotEngine testVM; @BeforeClass public static void setupClass() { 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 a65dbc2ae0a26e890167c5e3c7aa75a66b9c4747..b99dd7bb9beac9fa54372016c2d22a66e6e8f1b8 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 @@ -142,15 +142,6 @@ public final class RTruffleVisitor extends BasicVisitor<RSyntaxNode> { @Override public RSyntaxNode visit(Function func) { -// FastPathFactory f = EvaluatedArgumentsVisitor.process(func); -// if (f != null) { -// System.out.println("////////////////////////////////"); -// if (func.getDebugName() != null) { -// System.out.println("// " + func.getDebugName()); -// } -// System.out.println(func.getSource().getCode()); -// System.out.println("names: " + f + "\n"); -// } RootCallTarget callTarget = null; try { callTarget = createFunctionCallTarget(func); @@ -314,13 +305,19 @@ public final class RTruffleVisitor extends BasicVisitor<RSyntaxNode> { return RCallNode.createCallNotSyntax(ReadVariableNode.createForced(null, isSubset ? "[<-" : "[[<-", RType.Function), ArgumentsSignature.get(names), nodes); } - private static String createTempName() { + private int tempNamesCount; + + private void resetTempNames() { + tempNamesCount = 0; + } + + private String createTempName() { //@formatter:off // store a - need to use temporary, otherwise there is a failure in case multiple calls to // the replacement form are chained: // x<-c(1); y<-c(1); dim(x)<-1; dim(y)<-1; attr(x, "dimnames")<-(attr(y, "dimnames")<-list("b")) //@formatter:on - return new Object().toString(); + return "*tmp" + tempNamesCount++ + "*"; } private static ReplacementNode constructReplacementSuffix(RSyntaxNode rhs, RSyntaxNode v, boolean copyRhs, RNode assignFromTemp, String tmpSymbol, String rhsSymbol, SourceSection source) { @@ -329,6 +326,7 @@ public final class RTruffleVisitor extends BasicVisitor<RSyntaxNode> { @Override public RSyntaxNode visit(UpdateVector u) { + resetTempNames(); AccessVector a = u.getVector(); int argLength = a.getIndexes().size() - 1; // If recursive no need to set syntaxAST as already handled at top-level @@ -380,6 +378,7 @@ public final class RTruffleVisitor extends BasicVisitor<RSyntaxNode> { //@formatter:on @Override public RSyntaxNode visit(Replacement replacement) { + resetTempNames(); // preparations ASTNode rhsAst = replacement.getExpr(); RSyntaxNode rhs = rhsAst.accept(this); @@ -591,6 +590,7 @@ public final class RTruffleVisitor extends BasicVisitor<RSyntaxNode> { @Override public RSyntaxNode visit(UpdateField u) { + resetTempNames(); FieldAccess a = u.getVector(); RSyntaxNode rhs = u.getRHS().accept(this); return doReplacementLeftHandSide(a.getLhs(), true, rhs, u.isSuper(), u.getSource(), (receiver, rhsAccess) -> { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedReplaceVectorNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedReplaceVectorNode.java index d910bc22fc342cdf6746a8130e084659661d589a..9239db23e4a08a08e516ccee0c24cd99ac0aa7b3 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedReplaceVectorNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedReplaceVectorNode.java @@ -216,7 +216,7 @@ final class CachedReplaceVectorNode extends CachedVectorNode { * Interestingly we always need to provide not NOT_MULTIPLE_REPLACEMENT error messages * for multi-dimensional deletes. */ - if ((this.numberOfDimensions > 1 && isDeleteElements()) || replacementLength % valueLength != 0) { + if ((this.numberOfDimensions > 1 && isNullValue()) || replacementLength % valueLength != 0) { if (this.numberOfDimensions > 1) { errorBranch.enter(); throw RError.error(this, RError.Message.NOT_MULTIPLE_REPLACEMENT); @@ -249,7 +249,11 @@ final class CachedReplaceVectorNode extends CachedVectorNode { if (mode.isSubset()) { message = RError.Message.SUBASSIGN_TYPE_FIX; } else { - message = RError.Message.SUBSCRIPT_TYPES; + if (vectorType == RType.List) { + message = RError.Message.SUBSCRIPT_TYPES; + } else { + message = RError.Message.SUBASSIGN_TYPE_FIX; + } } throw RError.error(this, message, valueType.getName(), vectorType.getName(), false); } @@ -271,7 +275,7 @@ final class CachedReplaceVectorNode extends CachedVectorNode { } private boolean isDeleteElements() { - return castType == RType.List && valueClass == RNull.class; + return castType == RType.List && isNullValue(); } private boolean isList() { @@ -322,7 +326,9 @@ final class CachedReplaceVectorNode extends CachedVectorNode { if (mode.isSubscript()) { if (!isList()) { errorBranch.enter(); - if (valueLength == 0) { + if (isNullValue()) { + throw RError.error(this, RError.Message.MORE_SUPPLIED_REPLACE); + } else if (valueLength == 0) { throw RError.error(this, RError.Message.REPLACEMENT_0); } else { throw RError.error(this, RError.Message.MORE_SUPPLIED_REPLACE); @@ -330,16 +336,22 @@ final class CachedReplaceVectorNode extends CachedVectorNode { } } else { assert mode.isSubset(); - if (valueLength == 0) { - errorBranch.enter(); - throw RError.error(this, RError.Message.REPLACEMENT_0); - } else if (positionsCheckNode.getContainsNA(positionProfiles)) { - errorBranch.enter(); - throw RError.error(this, RError.Message.NA_SUBSCRIPTED); + if (!isNullValue() || this.numberOfDimensions == 1) { + if (valueLength == 0) { + errorBranch.enter(); + throw RError.error(this, RError.Message.REPLACEMENT_0); + } else if (positionsCheckNode.getContainsNA(positionProfiles)) { + errorBranch.enter(); + throw RError.error(this, RError.Message.NA_SUBSCRIPTED); + } } } } + private boolean isNullValue() { + return valueClass == RNull.class; + } + private void updateVectorWithPositionNames(RAbstractVector vector, Object[] positions) { Object position = positionsCheckNode.getPositionCheckAt(0).profilePosition(positions[0]); RStringVector positionNames; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNode.java index b5f87ba83a17fd6959357cd3c4f139b17690d9e5..4f680e722dfe3bb26bb8b15c6d87258194351544 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNode.java @@ -37,14 +37,16 @@ public abstract class ExtractVectorNode extends Node { protected final ElementAccessMode mode; private final boolean recursive; + private final boolean ignoreRecursive; @Child private BoxPrimitiveNode boxVector = BoxPrimitiveNode.create(); @Child private BoxPrimitiveNode boxExact = BoxPrimitiveNode.create(); @Child private BoxPrimitiveNode boxDropdimensions = BoxPrimitiveNode.create(); - ExtractVectorNode(ElementAccessMode mode, boolean recursive) { + ExtractVectorNode(ElementAccessMode mode, boolean recursive, boolean ignoreRecursive) { this.mode = mode; this.recursive = recursive; + this.ignoreRecursive = ignoreRecursive; } public ElementAccessMode getMode() { @@ -55,12 +57,12 @@ public abstract class ExtractVectorNode extends Node { return execute(boxVector.execute(vector), positions, boxExact.execute(exact), boxDropdimensions.execute(dropDimensions)); } - public static ExtractVectorNode create(ElementAccessMode accessMode) { - return ExtractVectorNodeGen.create(accessMode, false); + public static ExtractVectorNode create(ElementAccessMode accessMode, boolean ignoreRecursive) { + return ExtractVectorNodeGen.create(accessMode, false, ignoreRecursive); } static ExtractVectorNode createRecursive(ElementAccessMode accessMode) { - return ExtractVectorNodeGen.create(accessMode, true); + return ExtractVectorNodeGen.create(accessMode, true, false); } protected abstract Object execute(Object vector, Object[] positions, Object exact, Object dropDimensions); @@ -79,7 +81,7 @@ public abstract class ExtractVectorNode extends Node { } protected boolean isRecursiveSubscript(Object vector, Object[] positions) { - return !recursive && mode.isSubscript() && vector instanceof RAbstractListVector && positions.length == 1; + return !recursive && !ignoreRecursive && mode.isSubscript() && vector instanceof RAbstractListVector && positions.length == 1; } @Specialization(limit = "CACHE_LIMIT", guards = {"cached != null", "cached.isSupported(vector, positions, exact, dropDimensions)"}) diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCharacterLookupNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCharacterLookupNode.java index b16a4a29802ffce824d89451e62aa914a982ce97..572fb97006a28d196ca8d2e37ceb6184491cb131 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCharacterLookupNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCharacterLookupNode.java @@ -66,7 +66,7 @@ final class PositionCharacterLookupNode extends Node { result = searchNode.apply(dimName, position, notFoundStartIndex); } else { emptyProfile.enter(); - throw noDimNames(); + throw RError.error(this, Message.SUBSCRIPT_BOUNDS); } } else { emptyProfile.enter(); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckSubscriptNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckSubscriptNode.java index 43643d26027d9205dd0b55bb235d82aab26ce710..b62d065d580864420043aa193c90a1c56bd096d1 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckSubscriptNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckSubscriptNode.java @@ -76,15 +76,24 @@ abstract class PositionCheckSubscriptNode extends PositionCheckNode { protected RAbstractVector doInteger(PositionProfile profile, int dimSize, RAbstractIntVector position, int positionLength) { if (positionLength != 1) { error.enter(); + Message message; if (positionLength > 1) { - throw RError.error(this, RError.Message.SELECT_MORE_1); + /* This is a very specific check. But it just did not fit into other checks. */ + if (positionLength == 2 && position.getDataAt(0) == 0) { + message = RError.Message.SELECT_LESS_1; + } else { + message = RError.Message.SELECT_MORE_1; + } } else { - throw RError.error(this, RError.Message.SELECT_LESS_1); + message = RError.Message.SELECT_LESS_1; } + throw RError.error(this, message); } assert positionLength == 1; positionNACheck.enable(position); - return doIntegerImpl(profile, dimSize, position.getDataAt(0), position); + RAbstractVector result = doIntegerImpl(profile, dimSize, position.getDataAt(0), position); + return result; + } private RAbstractVector doIntegerImpl(PositionProfile profile, int dimSize, int value, RAbstractVector originalVector) { @@ -127,11 +136,22 @@ abstract class PositionCheckSubscriptNode extends PositionCheckNode { } } error.enter(); - if (value == 0 || dimSize <= 2) { + int selected = 0; + if (value > 0) { + selected = 1; + } else if (value < 0) { + if (-value <= dimSize) { + selected = dimSize - 1; + } else { + selected = dimSize; + } + } + if (selected <= 1) { throw RError.error(this, RError.Message.SELECT_LESS_1); } else { throw RError.error(this, RError.Message.SELECT_MORE_1); } + } } @@ -151,6 +171,9 @@ abstract class PositionCheckSubscriptNode extends PositionCheckNode { throw RError.error(this, message); } else { if (containerType == RType.List && numDimensions == 1) { + if (recursive) { + throwBoundsError(); + } // lists pass on the NA value } else { error.enter(); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveExtractSubscriptNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveExtractSubscriptNode.java index 1300b80b543be6d8156d3abca1c8ae52c47dca07..396c8b8602b30eae7f03e920ab30fd60eda7a6bc 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveExtractSubscriptNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveExtractSubscriptNode.java @@ -29,8 +29,9 @@ import com.oracle.truffle.r.runtime.data.model.*; abstract class RecursiveExtractSubscriptNode extends RecursiveSubscriptNode { + @Child private ExtractVectorNode getPositionExtract = ExtractVectorNode.create(ElementAccessMode.SUBSCRIPT, true); @Child private ExtractVectorNode recursiveSubscriptExtract = ExtractVectorNode.createRecursive(ElementAccessMode.SUBSCRIPT); - @Child private ExtractVectorNode getPositionExtract = ExtractVectorNode.create(ElementAccessMode.SUBSCRIPT); + @Child private ExtractVectorNode subscriptExtract = ExtractVectorNode.create(ElementAccessMode.SUBSCRIPT, true); public RecursiveExtractSubscriptNode(RAbstractListVector vector, Object position) { super(vector, position); @@ -52,7 +53,7 @@ abstract class RecursiveExtractSubscriptNode extends RecursiveSubscriptNode { @SuppressWarnings("unused") protected Object doDefault(Object vector, Object[] positions, Object firstPosition, int positionLength, Object exact, Object dropDimensions) { try { - return recursiveSubscriptExtract.apply(vector, positions, exact, dropDimensions); + return subscriptExtract.apply(vector, positions, exact, dropDimensions); } catch (RecursiveIndexNotFoundError e) { errorBranch.enter(); throw RError.error(this, RError.Message.SUBSCRIPT_BOUNDS); @@ -65,30 +66,31 @@ abstract class RecursiveExtractSubscriptNode extends RecursiveSubscriptNode { @Cached("createPositionCast()") PositionCastNode positionCast) { Object firstPosition = positionCast.execute(originalFirstPosition); Object currentVector = vector; - for (int i = 1; i <= positionLength; i++) { + for (int i = 1; i < positionLength; i++) { Object selection = getPositionExtract.apply(firstPosition, new Object[]{RInteger.valueOf(i)}, RLogical.TRUE, RLogical.TRUE); try { - if (i < positionLength && !(currentVector instanceof RAbstractListVector)) { - if (currentVector == RNull.instance) { - throw noSuchIndex(i - 1); - } else { - throw indexingFailed(i - 1); - } - } else if (i <= positionLength && currentVector == RNull.instance) { - throw noSuchIndex(i - 1); + if (!(currentVector instanceof RAbstractListVector)) { + errorBranch.enter(); + throw indexingFailed(i); } currentVector = recursiveSubscriptExtract.apply(currentVector, new Object[]{selection}, exact, dropDimensions); - } catch (RecursiveIndexNotFoundError e) { - errorBranch.enter(); - if (i > 1) { - throw noSuchIndex(i - 1); - } else { + if (currentVector == RNull.instance) { + errorBranch.enter(); throw RError.error(this, RError.Message.SUBSCRIPT_BOUNDS); } + } catch (RecursiveIndexNotFoundError e) { + errorBranch.enter(); + throw noSuchIndex(i); } } - return currentVector; + Object selection = getPositionExtract.apply(firstPosition, new Object[]{RInteger.valueOf(positionLength)}, RLogical.TRUE, RLogical.TRUE); + try { + return subscriptExtract.apply(currentVector, new Object[]{selection}, exact, dropDimensions); + } catch (RecursiveIndexNotFoundError e) { + errorBranch.enter(); + throw RError.error(this, RError.Message.SUBSCRIPT_BOUNDS); + } } protected PositionCastNode createPositionCast() { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveIndexNotFoundError.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveIndexNotFoundError.java index 6cf1a25c4e42106aaed77cafcef9fab656557139..7f8db1365c5d35ae4d3e28927fbe79b89dde3008 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveIndexNotFoundError.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveIndexNotFoundError.java @@ -24,8 +24,7 @@ package com.oracle.truffle.r.nodes.access.vector; import com.oracle.truffle.api.nodes.*; +@SuppressWarnings("serial") final class RecursiveIndexNotFoundError extends ControlFlowException { - private static final long serialVersionUID = 1L; - } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveReplaceSubscriptNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveReplaceSubscriptNode.java index 7a48b04431d51579d0ac896db77da6e59a4e14ee..8c8254538eb1090e322f87e4bb8be7bbc127b119 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveReplaceSubscriptNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveReplaceSubscriptNode.java @@ -29,6 +29,7 @@ import com.oracle.truffle.r.runtime.data.model.*; abstract class RecursiveReplaceSubscriptNode extends RecursiveSubscriptNode { @Child private ReplaceVectorNode recursiveSubscriptReplace = ReplaceVectorNode.createRecursive(ElementAccessMode.SUBSCRIPT); + @Child private ReplaceVectorNode subscriptReplace = ReplaceVectorNode.create(ElementAccessMode.SUBSCRIPT, true); @Child private ExtractVectorNode getPositionExtract = ExtractVectorNode.createRecursive(ElementAccessMode.SUBSCRIPT); @Child private ExtractVectorNode recursiveSubscriptExtract = ExtractVectorNode.createRecursive(ElementAccessMode.SUBSCRIPT); @@ -52,7 +53,7 @@ abstract class RecursiveReplaceSubscriptNode extends RecursiveSubscriptNode { @Specialization(guards = "positionLength <= 1") @SuppressWarnings("unused") protected Object doDefault(Object vector, Object[] positions, Object firstPosition, int positionLength, Object value) { - return recursiveSubscriptReplace.apply(vector, positions, value); + return subscriptReplace.apply(vector, positions, value); } /** @@ -83,7 +84,6 @@ abstract class RecursiveReplaceSubscriptNode extends RecursiveSubscriptNode { throw indexingFailed(i); } currentVector = recursiveSubscriptExtract.apply(currentVector, new Object[]{parentPosition}, RLogical.TRUE, RLogical.TRUE); - if (currentVector == RNull.instance) { throw noSuchIndex(i); } @@ -94,9 +94,12 @@ abstract class RecursiveReplaceSubscriptNode extends RecursiveSubscriptNode { } Object recursiveValue = value; positionStack[positionLength - 1] = getPositionValue(firstPosition, positionLength - 1); - for (int i = positionLength - 1; i >= 0; i--) { + for (int i = positionLength - 1; i >= 1; i--) { recursiveValue = recursiveSubscriptReplace.apply(valueStack[i], new Object[]{positionStack[i]}, recursiveValue); } + // the last recursive replace need to have recursive set to false + recursiveValue = subscriptReplace.apply(valueStack[0], new Object[]{positionStack[0]}, recursiveValue); + return recursiveValue; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNode.java index 78cc3a7291a5a4d6320e35e0a58ae5540fcfb0a0..5818862e29748f45740e8558d438844c1178680b 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNode.java @@ -41,13 +41,15 @@ public abstract class ReplaceVectorNode extends Node { private final ElementAccessMode mode; private final boolean recursive; + private final boolean ignoreRecursive; @Child private BoxPrimitiveNode boxVector = BoxPrimitiveNode.create(); @Child private BoxPrimitiveNode boxValue = BoxPrimitiveNode.create(); - public ReplaceVectorNode(ElementAccessMode mode, boolean recursive) { + public ReplaceVectorNode(ElementAccessMode mode, boolean recursive, boolean ignoreRecursive) { this.mode = mode; this.recursive = recursive; + this.ignoreRecursive = ignoreRecursive; } public final Object apply(Object vector, Object[] positions, Object value) { @@ -56,12 +58,12 @@ public abstract class ReplaceVectorNode extends Node { protected abstract Object execute(Object vector, Object[] positions, Object value); - public static ReplaceVectorNode create(ElementAccessMode mode) { - return ReplaceVectorNodeGen.create(mode, false); + public static ReplaceVectorNode create(ElementAccessMode mode, boolean ignoreRecursive) { + return ReplaceVectorNodeGen.create(mode, false, ignoreRecursive); } static ReplaceVectorNode createRecursive(ElementAccessMode mode) { - return ReplaceVectorNodeGen.create(mode, true); + return ReplaceVectorNodeGen.create(mode, true, false); } @SuppressWarnings("unchecked") @@ -86,7 +88,7 @@ public abstract class ReplaceVectorNode extends Node { } private boolean isRecursiveSubscript(Object vector, Object[] positions) { - return !recursive && mode.isSubscript() && vector instanceof RAbstractListVector && positions.length == 1; + return !recursive && !ignoreRecursive && mode.isSubscript() && vector instanceof RAbstractListVector && positions.length == 1; } @Specialization(limit = "CACHE_LIMIT", guards = {"cached != null", "cached.isSupported(vector, positions, value)"}) diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/SearchFirstStringNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/SearchFirstStringNode.java index fb3c0f3138e6f823edaee2cb74f540184eae0590..51a3b0caab2ff24ae962253b347181fdcb500317 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/SearchFirstStringNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/SearchFirstStringNode.java @@ -86,9 +86,11 @@ final class SearchFirstStringNode extends Node { if (!isCacheValid(targetProfiled, targetLength, elementsProfiled, elementsLength, cachedIndices)) { CompilerDirectives.transferToInterpreterAndInvalidate(); cachedIndices = null; // set to generic + // fallthrough to generic + } else { + assert sameVector(searchCached(target, targetLength, elements, elementsLength), cachedIndices); + return RDataFactory.createIntVector(cachedIndices, true); } - assert sameVector(searchCached(target, targetLength, elements, elementsLength), cachedIndices); - return RDataFactory.createIntVector(cachedIndices, true); } return searchGeneric(targetProfiled, targetLength, elementsProfiled, elementsLength, notFoundStartIndex, false); @@ -100,7 +102,10 @@ final class SearchFirstStringNode extends Node { protected int[] searchCached(RAbstractStringVector target, int targetLength, RAbstractStringVector elements, int elementsLength) { if (exactMatch) { - return (int[]) searchGeneric(target, targetLength, elements, elementsLength, -1, true).getInternalStore(); + RAbstractIntVector genericResult = searchGeneric(target, targetLength, elements, elementsLength, -1, true); + if (genericResult != null) { + return (int[]) genericResult.getInternalStore(); + } } return null; } @@ -117,10 +122,7 @@ final class SearchFirstStringNode extends Node { int cachedIndex = cached[i]; String cachedElement = elements.getDataAt(i); - if (elementsNACheck.check(cachedElement) || cachedElement.length() == 0) { - seenInvalid.enter(); - return false; - } + assert !elementsNACheck.check(cachedElement) && cachedElement.length() > 0; int cachedTranslatedIndex = cachedIndex - 1; for (int j = 0; j < cachedTranslatedIndex; j++) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallNode.java index 5a54b08ad797cf5268242394a573dedd98d565c5..65ffe8de46ee7b9c3fc4055dad9cd39d37b1d048 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallNode.java @@ -86,12 +86,12 @@ import com.oracle.truffle.r.runtime.nodes.*; * U = {@link UninitializedCallNode}: Forms the uninitialized end of the function PIC * D = {@link DispatchedCallNode}: Function fixed, no varargs * G = {@link GenericCallNode}: Function arbitrary - * + * * UV = {@link UninitializedCallNode} with varargs, * UVC = {@link UninitializedVarArgsCacheCallNode} with varargs, for varargs cache * DV = {@link DispatchedVarArgsCallNode}: Function fixed, with cached varargs * DGV = {@link DispatchedGenericVarArgsCallNode}: Function fixed, with arbitrary varargs (generic case) - * + * * (RB = {@link RBuiltinNode}: individual functions that are builtins are represented by this node * which is not aware of caching). Due to {@link CachedCallNode} (see below) this is transparent to * the cache and just behaves like a D/DGV) @@ -104,11 +104,11 @@ import com.oracle.truffle.r.runtime.nodes.*; * non varargs, max depth: * | * D-D-D-U - * + * * no varargs, generic (if max depth is exceeded): * | * D-D-D-D-G - * + * * varargs: * | * DV-DV-UV <- function call target identity level cache @@ -116,7 +116,7 @@ import com.oracle.truffle.r.runtime.nodes.*; * DV * | * UVC <- varargs signature level cache - * + * * varargs, max varargs depth exceeded: * | * DV-DV-UV @@ -128,7 +128,7 @@ import com.oracle.truffle.r.runtime.nodes.*; * DV * | * DGV - * + * * varargs, max function depth exceeded: * | * DV-DV-DV-DV-GV @@ -166,6 +166,8 @@ public final class RCallNode extends RNode implements RSyntaxNode { private static final int FUNCTION_INLINE_CACHE_SIZE = 4; private static final int VARARGS_INLINE_CACHE_SIZE = 4; + private static final Object[] defaultTempIdentifiers = new Object[]{new Object(), new Object(), new Object(), new Object()}; + @Child private RNode functionNode; @Child private PromiseHelperNode promiseHelper; @Child private RootCallNode call; @@ -203,8 +205,6 @@ public final class RCallNode extends RNode implements RSyntaxNode { private final SyntaxArguments arguments; private final ArgumentsSignature signature; - private final Object tempIdentifier = new Object(); - private final ValueProfile builtinProfile = ValueProfile.createIdentityProfile(); private final ConditionProfile implicitTypeProfile = ConditionProfile.createBinaryProfile(); private final ConditionProfile resultIsBuiltinProfile = ConditionProfile.createBinaryProfile(); @@ -213,6 +213,8 @@ public final class RCallNode extends RNode implements RSyntaxNode { private final BranchProfile errorProfile = BranchProfile.create(); private final ConditionProfile isRFunctionProfile = ConditionProfile.createBinaryProfile(); + private int tempIdentifier; + @Child private Node foreignCall; @CompilationFinal private int foreignCallArgCount; @Child private CallArgumentsNode foreignCallArguments; @@ -267,13 +269,28 @@ public final class RCallNode extends RNode implements RSyntaxNode { if (builtin.getDispatch() == RDispatch.INTERNAL_GENERIC) { if (internalDispatchCall == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); - dispatchTempSlot = insert(FrameSlotNode.createInitialized(frame.getFrameDescriptor(), tempIdentifier, true)); - internalDispatchCall = insert(new UninitializedCallNode(this, tempIdentifier)); + dispatchTempSlot = insert(FrameSlotNode.createInitialized(frame.getFrameDescriptor(), defaultTempIdentifiers[0], true)); + internalDispatchCall = insert(new UninitializedCallNode(this, defaultTempIdentifiers[0])); dispatchArgument = insert(NodeUtil.cloneNode(arguments.v[0].asRNode())); dispatchLookup = insert(S3FunctionLookupNode.create(true, false)); classHierarchyNode = insert(ClassHierarchyNodeGen.create(false)); } FrameSlot slot = dispatchTempSlot.executeFrameSlot(frame); + try { + if (frame.isObject(slot) && frame.getObject(slot) != null) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + // keep the complete loop in the slow path + do { + tempIdentifier++; + Object identifier = tempIdentifier < defaultTempIdentifiers.length ? defaultTempIdentifiers[tempIdentifier] : new Object(); + dispatchTempSlot.replace(FrameSlotNode.createInitialized(frame.getFrameDescriptor(), identifier, true)); + internalDispatchCall.replace(new UninitializedCallNode(this, identifier)); + slot = dispatchTempSlot.executeFrameSlot(frame); + } while (frame.isObject(slot) && frame.getObject(slot) != null); + } + } catch (FrameSlotTypeException e) { + throw RInternalError.shouldNotReachHere(); + } try { Object dispatch = dispatchArgument.execute(frame); frame.setObject(slot, dispatch); @@ -816,8 +833,6 @@ public final class RCallNode extends RNode implements RSyntaxNode { this.fastPath = function.getFastPath() == null ? null : function.getFastPath().create(); if (fastPath == null) { this.call = Truffle.getRuntime().createDirectCallNode(function.getTarget()); - } else { -// System.out.println("created fast path " + fastPath); } } @@ -830,7 +845,6 @@ public final class RCallNode extends RNode implements RSyntaxNode { } CompilerDirectives.transferToInterpreterAndInvalidate(); fastPath = null; -// System.out.println("falling back to method execution"); call = insert(Truffle.getRuntime().createDirectCallNode(callTarget)); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/primitive/BinaryMapNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/primitive/BinaryMapNode.java index 509fdaf3ecde3458552ff8e8d43c37aaa95ae8b9..fb258a3dd7f7ee6c17c2106873339e6dc165e28c 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/primitive/BinaryMapNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/primitive/BinaryMapNode.java @@ -125,7 +125,7 @@ public final class BinaryMapNode extends RBaseNode { int[] leftDimensions = left.getDimensions(); int[] rightDimensions = right.getDimensions(); int leftLength = leftDimensions.length; - int rightLength = leftDimensions.length; + int rightLength = rightDimensions.length; if (leftLength != rightLength) { return true; } diff --git a/com.oracle.truffle.r.runtime/.checkstyle_checks.xml b/com.oracle.truffle.r.runtime/.checkstyle_checks.xml index a5bee0389855b1c8f00545a423aa633339dd0493..495343675dd749682689f55ae0ff1459f2e38efb 100644 --- a/com.oracle.truffle.r.runtime/.checkstyle_checks.xml +++ b/com.oracle.truffle.r.runtime/.checkstyle_checks.xml @@ -101,7 +101,6 @@ <property name="severity" value="ignore"/> <metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/> </module> - <module name="JUnitTestCase"/> <module name="ModifiedControlVariable"/> <module name="MutableException"> <property name="severity" value="ignore"/> diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/FastROptions.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/FastROptions.java index 1f2c0ea67a8ef6ccb38b56d1dc6d486000287e34..4713bd247899cc2ac42b3c83f981a86da84fcfe7 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/FastROptions.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/FastROptions.java @@ -77,7 +77,7 @@ public class FastROptions { public static final boolean InvisibleArgs = parseBooleanOption("InvisibleArgs", true, "Argument writes do not trigger state transitions"); public static final boolean NewStateTransition = parseBooleanOption("NewStateTransition", false, "Experimental state transition implementation"); public static final boolean RefCountIncrementOnly = parseBooleanOption("RefCountIncrementOnly", false, "Disable reference count decrements for eperimental state transition implementation"); - public static final boolean UseNewVectorNodes = parseBooleanOption("UseNewVectorNodes", false, "temporary option"); + public static final boolean UseNewVectorNodes = parseBooleanOption("UseNewVectorNodes", true, "temporary option"); // Promises optimizations public static final boolean EagerEval = parseBooleanOption("EagerEval", false, "If enabled, overrides all other EagerEval switches (see EagerEvalHelper)"); diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Utils.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Utils.java index 7b181fb60473c40c21c08061f100b7beca09b8ff..30a48a80f2562c939f5f96d2a249324cdfeb7526 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Utils.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Utils.java @@ -40,6 +40,7 @@ import com.oracle.truffle.r.runtime.conn.*; import com.oracle.truffle.r.runtime.context.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; +import com.oracle.truffle.r.runtime.nodes.RSyntaxNode; public final class Utils { @@ -315,6 +316,37 @@ public final class Utils { return createStackTrace(true); } + /** + * Generate a stack trace as a string. + */ + @TruffleBoundary + public static String[] createTraceback() { + ArrayList<String> strings = new ArrayList<>(); + FrameInstance current = Truffle.getRuntime().getCurrentFrame(); + if (current != null) { + strings.add(traceback(current.getFrame(FrameAccess.READ_ONLY, true))); + Truffle.getRuntime().iterateFrames(frameInstance -> { + strings.add(traceback(frameInstance.getFrame(FrameAccess.READ_ONLY, true))); + return null; + }); + } + return strings.toArray(new String[strings.size()]); + } + + private static String traceback(Frame frame) { + Frame unwrapped = RArguments.unwrap(frame); + if (RArguments.isRFrame(frame)) { + RCaller call = RArguments.getCall(unwrapped); + if (call != null) { + RRuntimeASTAccess rASTAccess = RContext.getRRuntimeASTAccess(); + RLanguage caller = rASTAccess.getSyntaxCaller(call); + RSyntaxNode sn = (RSyntaxNode) caller.getRep(); + return sn.getSourceSection().getCode() + " (" + sn.getSourceSection().getShortDescription() + ")"; + } + } + return "<unknown>"; + } + /** * Generate a stack trace as a string. */ diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/ContextInfo.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/ContextInfo.java index 401e6588b60534cd381c33551e3fbade601eda35..5f3656f66b40d4a07ec98713bfdbae09c80adc43 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/ContextInfo.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/ContextInfo.java @@ -35,8 +35,8 @@ import com.oracle.truffle.r.runtime.context.RContext.ContextKind; /** * Represents custom initialization state for an R instance. * - * Use {@link #apply(com.oracle.truffle.api.vm.TruffleVM.Builder)} to apply this information to a - * newly-built {@link TruffleVM} instance (it will be stored in the "fastrContextInfo" global + * Use {@link #apply(com.oracle.truffle.api.vm.PolyglotEngine.Builder)} to apply this information to + * a newly-built {@link PolyglotEngine} instance (it will be stored in the "fastrContextInfo" global * symbol). */ public final class ContextInfo implements TruffleObject { @@ -66,7 +66,7 @@ public final class ContextInfo implements TruffleObject { this.id = id; } - public TruffleVM.Builder apply(TruffleVM.Builder builder) { + public PolyglotEngine.Builder apply(PolyglotEngine.Builder builder) { return builder.globalSymbol(GLOBAL_SYMBOL, this); } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/DefaultConsoleHandler.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/DefaultConsoleHandler.java index 9a3bcad867752a987576e42934921ba5a26dcc54..1d7b4025020332cb229e3dca0130a23f0bad24cf 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/DefaultConsoleHandler.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/DefaultConsoleHandler.java @@ -98,6 +98,6 @@ public class DefaultConsoleHandler implements ConsoleHandler { } public String getInputDescription() { - return "<TruffleVM env input>"; + return "<PolyglotEngine env input>"; } } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/RContext.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/RContext.java index b8a040178db97f7a9ba6368bec2fa921e822b030..2fe1ba8c8d2ee513dfa116c1c82a58598255ed7c 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/RContext.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/RContext.java @@ -23,34 +23,52 @@ package com.oracle.truffle.r.runtime.context; import java.io.IOException; -import java.util.*; -import java.util.concurrent.*; +import java.util.HashMap; +import java.util.Map; +import java.util.TimeZone; +import java.util.concurrent.ConcurrentHashMap; -import com.oracle.truffle.api.*; +import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.ExecutionContext; +import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.TruffleLanguage.Env; -import com.oracle.truffle.api.interop.*; -import com.oracle.truffle.api.nodes.*; -import com.oracle.truffle.api.source.*; -import com.oracle.truffle.api.vm.*; -import com.oracle.truffle.r.runtime.*; +import com.oracle.truffle.api.interop.ForeignAccess; +import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.api.nodes.InvalidAssumptionException; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.vm.PolyglotEngine; +import com.oracle.truffle.r.runtime.RBuiltinKind; +import com.oracle.truffle.r.runtime.RBuiltinLookup; +import com.oracle.truffle.r.runtime.RCmdOptions; import com.oracle.truffle.r.runtime.RCmdOptions.Client; -import com.oracle.truffle.r.runtime.conn.*; +import com.oracle.truffle.r.runtime.REnvVars; +import com.oracle.truffle.r.runtime.RError; +import com.oracle.truffle.r.runtime.RErrorHandling; +import com.oracle.truffle.r.runtime.RInternalError; +import com.oracle.truffle.r.runtime.ROptions; +import com.oracle.truffle.r.runtime.RProfile; +import com.oracle.truffle.r.runtime.RRuntimeASTAccess; +import com.oracle.truffle.r.runtime.RSerialize; +import com.oracle.truffle.r.runtime.Utils; +import com.oracle.truffle.r.runtime.conn.ConnectionSupport; +import com.oracle.truffle.r.runtime.conn.StdConnections; import com.oracle.truffle.r.runtime.context.Engine.ParseException; -import com.oracle.truffle.r.runtime.data.*; -import com.oracle.truffle.r.runtime.env.*; -import com.oracle.truffle.r.runtime.ffi.*; -import com.oracle.truffle.r.runtime.rng.*; +import com.oracle.truffle.r.runtime.data.RBuiltinDescriptor; +import com.oracle.truffle.r.runtime.data.RFunction; +import com.oracle.truffle.r.runtime.env.REnvironment; +import com.oracle.truffle.r.runtime.ffi.RFFIContextStateFactory; +import com.oracle.truffle.r.runtime.rng.RRNG; /** * Encapsulates the runtime state ("context") of an R session. All access to that state from the * implementation <b>must</b> go through this class. There can be multiple instances * (multiple-tenancy) active within a single process/Java-VM. * - * Contexts are created during construction of the {@link TruffleVM} instance. In case a context - * needs to be configured, the TruffleVM needs to be created via the {@code RContextFactory} class, - * which takes a {@link ContextInfo} object for configuration. + * Contexts are created during construction of the {@link PolyglotEngine} instance. In case a + * context needs to be configured, the PolyglotEngine needs to be created via the + * {@code RContextFactory} class, which takes a {@link ContextInfo} object for configuration. * * The context provides a so-called {@link Engine} (accessed via {@link #getEngine()}), which * provides basic parsing and execution functionality . @@ -156,7 +174,7 @@ public final class RContext extends ExecutionContext implements TruffleObject { @Override public void run() { - TruffleVM vm = info.apply(TruffleVM.newVM()).build(); + PolyglotEngine vm = info.apply(PolyglotEngine.buildNew()).build(); try { setContext((RContext) vm.eval(GET_CONTEXT).get()); } catch (IOException e1) { @@ -515,7 +533,7 @@ public final class RContext extends ExecutionContext implements TruffleObject { private static final Source GET_CONTEXT = Source.fromText("invisible(fastr.context.get())", "<get_context>").withMimeType("application/x-r"); - public static void destroyContext(TruffleVM vm) { + public static void destroyContext(PolyglotEngine vm) { try { RContext context = (RContext) vm.eval(GET_CONTEXT).get(); context.destroy(); diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/FastPathFactory.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/FastPathFactory.java index e5b4d03fb40500fd8ef2935e306eaca5bff869f0..ae926e03902f4783eead60a70b156a00161d36ff 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/FastPathFactory.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/FastPathFactory.java @@ -25,7 +25,10 @@ package com.oracle.truffle.r.runtime.data; import com.oracle.truffle.r.runtime.nodes.*; /** - * This implies that all arguments can be evaluated eagerly. + * This interface can be used to provide a fast path, implemented in Java, for an R function. This + * may be useful for cases in which there is a significantly simpler implementation for a known + * configuration of arguments. Returning {@code null} from the fast path node will revert the call + * site so that it calls the normal R code again. */ @FunctionalInterface public interface FastPathFactory { diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ops/BinaryArithmetic.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ops/BinaryArithmetic.java index 201d764c35a9741970e67ded5bed49ef28c217e8..0acbdafe954d70ef93bd6d71248274c59cef9ba0 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ops/BinaryArithmetic.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ops/BinaryArithmetic.java @@ -906,6 +906,10 @@ public abstract class BinaryArithmetic extends Operation { private static class Max extends BinaryArithmetic { + private final BranchProfile incomparableProfile = BranchProfile.create(); + private final BranchProfile zeroProfile = BranchProfile.create(); + private final ConditionProfile compareProfile = ConditionProfile.createBinaryProfile(); + public Max() { super(true, true, true); } @@ -924,11 +928,13 @@ public abstract class BinaryArithmetic extends Operation { public double op(double left, double right) { // explicit checks, since Math.max uses a non-final static field if (left != left) { + incomparableProfile.enter(); return left; } else if (left == 0.0d && right == 0.0d && Double.doubleToRawLongBits(left) == Double.doubleToRawLongBits(-0.0d)) { + zeroProfile.enter(); return right; } else { - return left >= right ? left : right; + return compareProfile.profile(left >= right) ? left : right; } } @@ -947,6 +953,10 @@ public abstract class BinaryArithmetic extends Operation { private static class Min extends BinaryArithmetic { + private final BranchProfile incomparableProfile = BranchProfile.create(); + private final BranchProfile zeroProfile = BranchProfile.create(); + private final ConditionProfile compareProfile = ConditionProfile.createBinaryProfile(); + public Min() { super(true, true, true); } @@ -963,13 +973,15 @@ public abstract class BinaryArithmetic extends Operation { @Override public double op(double left, double right) { - // explicit checks, since Math.max uses a non-final static field + // explicit checks, since Math.min uses a non-final static field if (left != left) { + incomparableProfile.enter(); return left; } else if (left == 0.0d && right == 0.0d && Double.doubleToRawLongBits(right) == Double.doubleToRawLongBits(-0.0d)) { + zeroProfile.enter(); return right; } else { - return left <= right ? left : right; + return compareProfile.profile(left <= right) ? left : right; } } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestBase.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestBase.java index b0760d0eaa4f5d9e3131e6e87b2d5aac939d1e34..464d54d9bf0d038c9b7ba47e453dbb5b6a135e2d 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestBase.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestBase.java @@ -43,6 +43,7 @@ public class TestBase { public static enum Output implements TestTrait { ContainsError, + ContainsAmbiguousError, ContainsWarning, MayContainError, MayContainWarning; @@ -419,9 +420,10 @@ public class TestBase { boolean ignored = TestTrait.contains(traits, Ignored.class) ^ (ProcessFailedTests && !(TestTrait.contains(traits, Ignored.Unstable) || TestTrait.contains(traits, Ignored.SideEffects))); boolean containsWarning = TestTrait.contains(traits, Output.ContainsWarning); - boolean containsError = (!FULL_COMPARE_ERRORS && TestTrait.contains(traits, Output.ContainsError)); + boolean containsError = (!FULL_COMPARE_ERRORS && (TestTrait.contains(traits, Output.ContainsError) || TestTrait.contains(traits, Output.ContainsAmbiguousError))); boolean mayContainWarning = TestTrait.contains(traits, Output.MayContainWarning); boolean mayContainError = TestTrait.contains(traits, Output.MayContainError); + boolean ambiguousError = TestTrait.contains(traits, Output.ContainsAmbiguousError); int index = 1; boolean allOk = true; @@ -432,7 +434,7 @@ public class TestBase { } else { String result = fastREval(input); - CheckResult checkResult = checkResult(whiteLists, input, expected, result, containsWarning, mayContainWarning, containsError, mayContainError); + CheckResult checkResult = checkResult(whiteLists, input, expected, result, containsWarning, mayContainWarning, containsError, mayContainError, ambiguousError); result = checkResult.result; expected = checkResult.expected; @@ -495,11 +497,11 @@ public class TestBase { } private CheckResult checkResult(WhiteList[] whiteLists, String input, String originalExpected, String originalResult, boolean containsWarning, boolean mayContainWarning, boolean containsError, - boolean mayContainError) { + boolean mayContainError, boolean ambiguousError) { boolean ok; String result = originalResult; String expected = originalExpected; - if (expected.equals(result) || searchWhiteLists(whiteLists, input, expected, result, containsWarning, mayContainWarning, containsError, mayContainError)) { + if (expected.equals(result) || searchWhiteLists(whiteLists, input, expected, result, containsWarning, mayContainWarning, containsError, mayContainError, ambiguousError)) { ok = true; } else { if (containsWarning || (mayContainWarning && expected.contains(WARNING))) { @@ -513,7 +515,7 @@ public class TestBase { } if (ok) { if (containsError || (mayContainError && expected.startsWith(ERROR))) { - ok = result.startsWith(ERROR) && (IGNORE_ERROR_COMPARISON || checkMessageStripped(expected, result)); + ok = result.startsWith(ERROR) && (ambiguousError || checkMessageStripped(expected, result)); } else { ok = expected.equals(result); } @@ -523,19 +525,19 @@ public class TestBase { } private boolean searchWhiteLists(WhiteList[] whiteLists, String input, String expected, String result, boolean containsWarning, boolean mayContainWarning, boolean containsError, - boolean mayContainError) { + boolean mayContainError, boolean ambiguousError) { if (whiteLists == null) { return false; } for (WhiteList list : whiteLists) { WhiteList.Results wlr = list.get(input); if (wlr != null) { - CheckResult checkedResult = checkResult(null, input, wlr.expected, expected, containsWarning, mayContainWarning, containsError, mayContainError); + CheckResult checkedResult = checkResult(null, input, wlr.expected, expected, containsWarning, mayContainWarning, containsError, mayContainError, ambiguousError); if (!checkedResult.ok) { System.out.println("expected output does not match: " + wlr.expected + " vs. " + expected); return false; } - CheckResult fastRResult = checkResult(null, input, wlr.fastR, result, containsWarning, mayContainWarning, containsError, mayContainError); + CheckResult fastRResult = checkResult(null, input, wlr.fastR, result, containsWarning, mayContainWarning, containsError, mayContainError, ambiguousError); if (fastRResult.ok) { list.markUsed(input); return true; diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/generate/FastRSession.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/generate/FastRSession.java index 40a512bf4890f4205bae613d2a3c15e77ff5f125..2c093bc09a5cd82730d4435bca98b34b384b0c4b 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/generate/FastRSession.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/generate/FastRSession.java @@ -105,7 +105,7 @@ public final class FastRSession implements RSession { private static FastRSession singleton; private final TestConsoleHandler consoleHandler; - private final TruffleVM main; + private final PolyglotEngine main; private final RContext mainContext; private EvalThread evalThread; @@ -119,11 +119,11 @@ public final class FastRSession implements RSession { private static final Source GET_CONTEXT = Source.fromText("invisible(fastr.context.get())", "<get_context>").withMimeType(TruffleRLanguage.MIME); - public TruffleVM createTestContext() { + public PolyglotEngine createTestContext() { create(); RCmdOptions options = RCmdOptions.parseArguments(Client.RSCRIPT, new String[0]); ContextInfo info = ContextInfo.create(options, ContextKind.SHARE_PARENT_RW, mainContext, consoleHandler, TimeZone.getTimeZone("CET")); - return info.apply(TruffleVM.newVM()).build(); + return info.apply(PolyglotEngine.buildNew()).build(); } private FastRSession() { @@ -131,7 +131,7 @@ public final class FastRSession implements RSession { try { RCmdOptions options = RCmdOptions.parseArguments(Client.RSCRIPT, new String[0]); ContextInfo info = ContextInfo.create(options, ContextKind.SHARE_NOTHING, null, consoleHandler); - main = info.apply(TruffleVM.newVM()).build(); + main = info.apply(PolyglotEngine.buildNew()).build(); try { mainContext = (RContext) main.eval(GET_CONTEXT).get(); } catch (IOException e) { @@ -198,7 +198,7 @@ public final class FastRSession implements RSession { break; } try { - TruffleVM vm = createTestContext(); + PolyglotEngine vm = createTestContext(); try { Source source = Source.fromText(expression, "<eval>").withMimeType(TruffleRLanguage.MIME); vm.eval(source); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleArrays.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleArrays.java index 3e81bf0186e3dc7e3bf5b2b59e4748bc383c4da7..a7e97f72c9320c13527669b47df0fea725a677e6 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleArrays.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleArrays.java @@ -387,7 +387,7 @@ public class TestSimpleArrays extends TestBase { assertEval(Output.ContainsError, "{ a <- 1:9 ; a[1, 1, 1] <- 10L }"); assertEval(Output.ContainsError, "{ m <- matrix(1:6, nrow=2) ; m[[1, 1]] <- integer() }"); - assertEval(Output.ContainsError, "{ m <- matrix(1:6, nrow=2) ; m[[1:2, 1]] <- integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ m <- matrix(1:6, nrow=2) ; m[[1:2, 1]] <- integer() }"); assertEval(Output.ContainsError, "{ m <- matrix(1:6, nrow=2) ; m[1, 2] <- integer() }"); assertEval(Output.ContainsError, "{ m <- matrix(1:6, nrow=2) ; m[1, 2] <- 1:3 }"); @@ -400,7 +400,7 @@ public class TestSimpleArrays extends TestBase { assertEval("{ m <- matrix(1:6, nrow=2) ; f <- function(i,j) { m[i,j] <- 10 ; m } ; m <- f(1,c(-1,-10)) ; m <- f(-1,2) ; m }"); assertEval("{ m <- matrix(1:6, nrow=2) ; f <- function(i,j) { m[i,j] <- 10 ; m } ; m <- f(2,1:3) ; m <- f(1,-2) ; m }"); - assertEval(Output.ContainsError, "{ x<-1:8; dim(x)<-c(2,2,2); y<-c(101:104); dim(y)<-c(2,2); z<-(x[1:2,c(1,2,NA),1]<-y); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:8; dim(x)<-c(2,2,2); y<-c(101:104); dim(y)<-c(2,2); z<-(x[1:2,c(1,2,NA),1]<-y); x }"); assertEval("{ m <- matrix(1:6, nrow=3) ; m[2] <- list(100) ; m }"); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleVectors.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleVectors.java index 2ade5df4c8128d724cb9cd796984b175c5e0393f..bcbfa20fcaeb7d8562b0125fc110e9b5b88fe257 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleVectors.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleVectors.java @@ -265,6 +265,9 @@ public class TestSimpleVectors extends TestBase { @Test public void testMoreVectorsOther() { + + assertEval("{ x<-matrix(1:4, ncol=2, dimnames=list(c(\"a\", \"b\"), c(\"c\", \"d\"))); dimnames(x)[[1]][1]<-\"z\"; x }"); + assertEval("{ x<-c(TRUE,TRUE,FALSE); x[1L] }"); assertEval("{ x<-c(TRUE,TRUE,FALSE); x[2L] }"); assertEval("{ x<-c(TRUE,TRUE,FALSE); x[3L] }"); @@ -307,11 +310,12 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsError, "{ x<-as.integer(1:4); x[[as.integer(NA)]] }"); assertEval(Output.ContainsError, "{ x<-as.integer(1:4); dim(x)<-c(2,2); x[[as.integer(NA)]] }"); assertEval("{ x<-1:4; dim(x)<-c(2,2); x[0,0]<-integer(); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[0, 0]] <- integer(); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[-1, 0]] <- integer(); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[0, -1]] <- integer(); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[-5, 0]] <- integer(); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[0, -5]] <- integer(); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[0, 0]] <- integer(); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[-1, 0]] <- integer(); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[0, -1]] <- integer(); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[-5, 0]] <- integer(); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[0, -5]] <- integer(); x }"); + assertEval("{ x<-1:4; dim(x)<-c(2,2); x[-1,0]<-integer(); x }"); assertEval("{ x<-1:4; dim(x)<-c(2,2); x[0,-1]<-integer(); x }"); assertEval("{ x<-1:4; dim(x)<-c(2,2); x[-5,0]<-integer(); x }"); @@ -366,11 +370,11 @@ public class TestSimpleVectors extends TestBase { assertEval("{ x<-list(a=list(42)); x[[c(\"a\", \"y\")]] }"); assertEval("{ x<-list(a=list(b=42)); x[[c(\"a\", \"b\")]] }"); - assertEval(Output.ContainsError, "{ l<-list(1,2,3,4); l[[c(NA,1)]]<-c(1); l }"); + assertEval(Output.ContainsAmbiguousError, "{ l<-list(1,2,3,4); l[[c(NA,1)]]<-c(1); l }"); assertEval(Output.ContainsError, "{ l<-list(1,2,3,4); l[[c(1,NA)]]<-c(1); l }"); assertEval(Output.ContainsError, "{ l<-list(1,2,3,4); l[[c(7,1)]]<-c(1); l }"); assertEval(Output.ContainsError, "{ l<-list(1,2,3,4); l[[c(NA)]]<-c(1); l }"); - assertEval(Output.ContainsError, "{ l<-list(1,2,3,4); l[[c(NA,1)]]<-c(-1); l }"); + assertEval(Output.ContainsAmbiguousError, "{ l<-list(1,2,3,4); l[[c(NA,1)]]<-c(-1); l }"); assertEval(Output.ContainsError, "{ l<-list(1,2,3,4); l[[c(-1)]]<-c(1); l }"); assertEval(Output.ContainsError, "{ l<-list(1,2,3,4); l[[c(-1,1)]]<-c(1); l }"); assertEval(Output.ContainsError, "{ l<-list(1,2,3,4); l[[c(0)]]<-c(1); l }"); @@ -383,7 +387,7 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsWarning, "{ x<-1:4; x[1]<-c(1,1); x }"); assertEval(Output.ContainsError, "{ x<-1:4; x[[1]]<-c(1,1); x }"); assertEval("{ x<-1; x[0]<-integer(); x }"); - assertEval(Output.ContainsError, "{ x<-1; x[[0]]<-integer(); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1; x[[0]]<-integer(); x }"); assertEval(Output.ContainsError, "{ x<-1; x[1]<-integer(); x }"); assertEval("{ x<-1; x[]<-42; x }"); assertEval(Output.ContainsError, "{ x<-1; x[[]]<-42; x }"); @@ -392,7 +396,7 @@ public class TestSimpleVectors extends TestBase { assertEval("{ x<-7; x[NULL]<-42; x }"); assertEval("{ x<-7; x[0]<-42; x }"); assertEval(Output.ContainsError, "{ x<-7; x[[NA]]<-42; x }"); - assertEval(Output.ContainsError, "{ x<-7; x[[NA]]<-c(42, 7); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-7; x[[NA]]<-c(42, 7); x }"); assertEval(Output.ContainsError, "{ x<-7; x[[NULL]]<-42; x }"); assertEval(Output.ContainsError, "{ x<-7; x[[0]]<-42; x }"); assertEval("{ x<-1:4; x[c(1, 0)]<-42; x }"); @@ -412,52 +416,52 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsWarning, "{ x<-1:4; dim(x)<-c(2,2); x[c(1,0,0)]<-c(42, 43); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(1,1,0)]]<-c(42, 43); x }"); assertEval("{ x<-1:4; dim(x)<-c(2,2); x[c(1,1,0)]<-c(42, 43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(0,1)]]<-c(42, 43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(0,1)]]<-c(42, 43); x }"); assertEval(Output.ContainsWarning, "{ x<-1:4; dim(x)<-c(2,2); x[c(0,1)]<-c(42, 43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(0,0,1)]]<-c(42, 43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(0,0,1)]]<-c(42, 43); x }"); assertEval(Output.ContainsWarning, "{ x<-1:4; dim(x)<-c(2,2); x[c(0,0,1)]<-c(42, 43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(0,1,1)]]<-c(42, 43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(0,1,1)]]<-c(42, 43); x }"); assertEval("{ x<-1:4; dim(x)<-c(2,2); x[c(0,1,1)]<-c(42, 43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(0,0)]]<-c(42, 43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(0,0)]]<-c(42, 43); x }"); assertEval("{ x<-1:4; dim(x)<-c(2,2); x[c(0,0)]<-c(42, 43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(0,0,0)]]<-c(42, 43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(0,0,0)]]<-c(42, 43); x }"); assertEval("{ x<-1:4; dim(x)<-c(2,2); x[c(0,0,0)]<-c(42, 43); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(FALSE,TRUE)]]<-c(42,43); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(FALSE,TRUE,TRUE)]]<-c(42,43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[complex()]]<-c(42,43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(1+1i)]]<-integer(); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[complex()]]<-c(42,43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(1+1i)]]<-integer(); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(1+1i)]]<-c(42); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(1+1i)]]<-c(42,43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(1+1i,42+7i,3+3i)]]<-c(42,43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(0,42+7i)]]<-c(42,43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[c(1+1i)]<-integer(); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(1+1i)]]<-c(42,43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(1+1i,42+7i,3+3i)]]<-c(42,43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(0,42+7i)]]<-c(42,43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[c(1+1i)]<-integer(); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[c(1+1i)]<-c(42); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[complex()]<-c(42,43); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[c(1+1i)]<-c(42,43); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[c(1+1i,42+7i,3+3i)]<-c(42,43); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[c(0,42+7i)]<-c(42,43); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(0,0,42+71)]]<-c(42,43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(as.raw(integer()))]]<-c(42,43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(as.raw(42))]]<-integer(); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(as.raw(integer()))]]<-c(42,43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(as.raw(42))]]<-integer(); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(as.raw(42))]]<-c(43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(as.raw(42))]]<-c(42,43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(as.raw(42), as.raw(7))]]<-c(42,43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(as.raw(42), as.raw(7), as.raw(1))]]<-c(42,43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(as.raw(42))]]<-c(42,43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(as.raw(42), as.raw(7))]]<-c(42,43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[c(as.raw(42), as.raw(7), as.raw(1))]]<-c(42,43); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[c(as.raw(integer()))]<-c(42,43); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[c(as.raw(42))]<-integer(); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[c(as.raw(42))]<-c(43); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[c(as.raw(42))]<-c(42,43); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[c(as.raw(42), as.raw(7))]<-c(42,43); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[c(as.raw(42), as.raw(7), as.raw(1))]<-c(42,43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list()]]<-integer(); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list()]]<-c(42); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list()]]<-c(42,43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1)]]<-integer(); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list()]]<-integer(); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list()]]<-c(42); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list()]]<-c(42,43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1)]]<-integer(); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1)]]<-c(42); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1)]]<-c(42,43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2)]]<-c(42,43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2,3)]]<-c(42,43); x }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[list()]<-integer(); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1)]]<-c(42,43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2)]]<-c(42,43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2,3)]]<-c(42,43); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[list()]<-integer(); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[list()]<-c(42); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[list()]<-c(42,43); x }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[list(1)]<-integer(); x }"); @@ -611,7 +615,6 @@ public class TestSimpleVectors extends TestBase { assertEval("{ x<-list(aa=1, ba=2); x[[exact=TRUE], \"a\"] }"); assertEval("{ x<-list(ab=1, ac=2); x[[\"a\", exact=FALSE]] }"); - assertEval("{ x<-matrix(1:4, ncol=2, dimnames=list(c(\"a\", \"b\"), c(\"c\", \"d\"))); dimnames(x)[[1]][1]<-\"z\"; x }"); // this works but should generate a "coerce to list warning" assertEval(Ignored.MissingWarning, "{ x<-matrix(1:4, ncol=2, dimnames=list(c(m=\"a\", \"b\"), c(\"c\", \"d\"))); dimnames(x)[[1]]$m<-\"z\"; x }"); // this works but matrix printing is off @@ -632,7 +635,7 @@ public class TestSimpleVectors extends TestBase { assertEval("{ x<-list(data=list(matrix(1:4, ncol=2))); x$data[[1]][2,2]<-42; x }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[as.raw(1), 1]]<-NULL }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[as.raw(1), 1]]<-NULL }"); assertEval(Output.ContainsError, "{ x<-1:4; x[[1]]<-NULL; x }"); assertEval("{ f<-function(x,y) sys.call(); x<-f(7, 42); x[c(1,2)] }"); @@ -654,18 +657,18 @@ public class TestSimpleVectors extends TestBase { // this came from testRawIndex // weird problems with fluctuating error messages in GNU R - assertEval(Ignored.Unknown, Output.ContainsError, "{ x<-1:4; x[[0]]<-NULL; x }"); + assertEval(Output.ContainsError, "{ x<-1:4; x[[0]]<-NULL; x }"); assertEval(Ignored.Unknown, Output.ContainsError, "{ b<-3:5; dim(b) <- c(1,3) ; b[[c(1)]] <- NULL ; b }"); assertEval(Ignored.Unknown, Output.ContainsError, "{ b<-3:5; dim(b) <- c(1,3) ; b[[0]] <- NULL ; b }"); - assertEval(Ignored.Unknown, Output.ContainsError, "{ x <- integer() ; x[[NA]] <- NULL ; x }"); + assertEval(Output.ContainsError, "{ x <- integer() ; x[[NA]] <- NULL ; x }"); assertEval(Ignored.Unknown, Output.ContainsError, "{ x <- c(1) ; x[[NA]] <- NULL ; x }"); - assertEval(Ignored.Unknown, Output.ContainsError, "{ x <- c(1,2) ; x[[NA]] <- NULL ; x }"); - assertEval(Ignored.Unknown, Output.ContainsError, "{ x <- c(1,2,3) ; x[[NA]] <- NULL ; x }"); + assertEval(Output.ContainsError, "{ x <- c(1,2) ; x[[NA]] <- NULL ; x }"); + assertEval(Output.ContainsError, "{ x <- c(1,2,3) ; x[[NA]] <- NULL ; x }"); assertEval(Ignored.Unknown, Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[1]]<-NULL; x }"); // inconsistent error messages in expected output and shell - assertEval(Ignored.Unknown, "{ x <- c(1); x[[-4]] <- NULL }"); - assertEval(Ignored.Unknown, "{ x <- c(1,2,3); x[[-1]] <- NULL }"); + assertEval(Output.ContainsAmbiguousError, "{ x <- c(1); x[[-4]] <- NULL }"); + assertEval(Output.ContainsAmbiguousError, "{ x <- c(1,2,3); x[[-1]] <- NULL }"); } @Test @@ -693,9 +696,9 @@ public class TestSimpleVectors extends TestBase { assertEval("{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[NA]<-7; x }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[NA]]<-7; x }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[NA]<-c(7,42); x }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[NA]]<-c(7, 42); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[NA]]<-c(7, 42); x }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[NA]<-c(7, 42, 1); x }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[NA]]<-c(7, 42, 1); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[NA]]<-c(7, 42, 1); x }"); assertEval("{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[NA]<-7; x }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[NA]]<-7; x }"); @@ -713,12 +716,12 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[NA, NA]]<-7; x }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[1, NA]]<-7; x }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[NA, 1]]<-7; x }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[NA, NA]]<-c(7, 42); x }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[1, NA]]<-c(7, 42); x }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[NA, 1]]<-c(7, 42); x }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[NA, NA]]<-c(7, 42, 1); x }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[1, NA]]<-c(7, 42, 1); x }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[NA, 1]]<-c(7, 42, 1); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[NA, NA]]<-c(7, 42); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[1, NA]]<-c(7, 42); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[NA, 1]]<-c(7, 42); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[NA, NA]]<-c(7, 42, 1); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[1, NA]]<-c(7, 42, 1); x }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[NA, 1]]<-c(7, 42, 1); x }"); assertEval("{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[NA, NA]<-7; x }"); assertEval("{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[1, NA]<-7; x }"); @@ -742,19 +745,19 @@ public class TestSimpleVectors extends TestBase { @Test public void testComplexIndex() { - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[[1+1i]]<-integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); x[[1+1i]]<-integer() }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[[1+1i]]<-c(1) }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[[1+1i]]<-c(1,2) }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[[1+1i]]<-c(1,2,3) }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); x[[1+1i]]<-c(1,2) }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); x[[1+1i]]<-c(1,2,3) }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[1+1i]<-NULL }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[1+1i]<-integer() }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[1+1i]<-c(1) }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[1+1i]<-c(1,2) }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[1+1i]<-c(1,2,3) }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[1+1i, 1]]<-integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[1+1i, 1]]<-integer() }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[1+1i, 1]]<-7 }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[1+1i, 1]]<-c(7,42) }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[1+1i, 1]]<-c(7,42) }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[1+1i, 1]<-integer() }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[1+1i, 1]<-7 }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[1+1i, 1]<-c(7,42) }"); @@ -770,7 +773,7 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); x[1+1i]<-c(1,2) }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); x[1+1i]<-c(1,2,3) }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[1+1i, 1]]<-NULL }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[1+1i, 1]]<-NULL }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[1+1i, 1]]<-integer() }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[1+1i, 1]]<-7 }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[1+1i, 1]]<-c(7,42) }"); @@ -787,20 +790,20 @@ public class TestSimpleVectors extends TestBase { @Test public void testRawIndex() { - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[[as.raw(1)]]<-NULL }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[[as.raw(1)]]<-integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); x[[as.raw(1)]]<-NULL }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); x[[as.raw(1)]]<-integer() }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[[as.raw(1)]]<-c(1) }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[[as.raw(1)]]<-c(1,2) }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[[as.raw(1)]]<-c(1,2,3) }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); x[[as.raw(1)]]<-c(1,2) }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); x[[as.raw(1)]]<-c(1,2,3) }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[as.raw(1)]<-NULL }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[as.raw(1)]<-integer() }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[as.raw(1)]<-c(1) }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[as.raw(1)]<-c(1,2) }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); x[as.raw(1)]<-c(1,2,3) }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[as.raw(1), 1]]<-integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[as.raw(1), 1]]<-integer() }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[as.raw(1), 1]]<-7 }"); - assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[as.raw(1), 1]]<-c(7,42) }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[[as.raw(1), 1]]<-c(7,42) }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[as.raw(1), 1]<-NULL }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[as.raw(1), 1]<-integer() }"); assertEval(Output.ContainsError, "{ x<-c(1,2,3,4); dim(x)<-c(2,2); x[as.raw(1), 1]<-7 }"); @@ -817,7 +820,7 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); x[as.raw(1)]<-c(1,2) }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); x[as.raw(1)]<-c(1,2,3) }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[as.raw(1), 1]]<-NULL }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[as.raw(1), 1]]<-NULL }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[as.raw(1), 1]]<-integer() }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[as.raw(1), 1]]<-7 }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[as.raw(1), 1]]<-c(7,42) }"); @@ -842,17 +845,17 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsError, "{ z<-1:4; z[list(1)]<-NULL }"); assertEval(Output.ContainsError, "{ z<-1:4; z[list(1,2)]<-NULL }"); assertEval(Output.ContainsError, "{ z<-1:4; z[list(1,2,3)]<-NULL }"); - assertEval(Output.ContainsError, "{ z<-1:4; z[[list()]]<-42 }"); + assertEval(Output.ContainsAmbiguousError, "{ z<-1:4; z[[list()]]<-42 }"); assertEval(Output.ContainsError, "{ z<-1:4; z[[list(1)]]<-42 }"); - assertEval(Output.ContainsError, "{ z<-1:4; z[[list(1,2)]]<-42 }"); - assertEval(Output.ContainsError, "{ z<-1:4; z[[list(1,2,3)]]<-42 }"); - assertEval(Output.ContainsError, "{ z<-1:4; z[[list()]]<-integer() }"); - assertEval(Output.ContainsError, "{ z<-1:4; z[[list(1)]]<-integer() }"); - assertEval(Output.ContainsError, "{ z<-1:4; z[[list(1,2)]]<-integer() }"); - assertEval(Output.ContainsError, "{ z<-1:4; z[[list(1,2,3)]]<-integer() }"); - assertEval(Output.ContainsError, "{ z<-1:4; z[[list(1)]]<-NULL }"); - assertEval(Output.ContainsError, "{ z<-1:4; z[[list(1,2)]]<-NULL }"); - assertEval(Output.ContainsError, "{ z<-1:4; z[[list(1,2,3)]]<-NULL }"); + assertEval(Output.ContainsAmbiguousError, "{ z<-1:4; z[[list(1,2)]]<-42 }"); + assertEval(Output.ContainsAmbiguousError, "{ z<-1:4; z[[list(1,2,3)]]<-42 }"); + assertEval(Output.ContainsAmbiguousError, "{ z<-1:4; z[[list()]]<-integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ z<-1:4; z[[list(1)]]<-integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ z<-1:4; z[[list(1,2)]]<-integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ z<-1:4; z[[list(1,2,3)]]<-integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ z<-1:4; z[[list(1)]]<-NULL }"); + assertEval(Output.ContainsAmbiguousError, "{ z<-1:4; z[[list(1,2)]]<-NULL }"); + assertEval(Output.ContainsAmbiguousError, "{ z<-1:4; z[[list(1,2,3)]]<-NULL }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[list()]<-42 }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[list(1)]<-42 }"); @@ -866,15 +869,15 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[list(1)]<-NULL }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[list(1,2)]<-NULL }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[list(1,2,3)]<-NULL }"); - assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[[list()]]<-42 }"); + assertEval(Output.ContainsAmbiguousError, "{ z<-list(1,2,3,4); z[[list()]]<-42 }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[[list(1)]]<-42 }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[[list(1,2)]]<-42 }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[[list(1,2,3)]]<-42 }"); - assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[[list()]]<-integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ z<-list(1,2,3,4); z[[list()]]<-integer() }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[[list(1)]]<-integer() }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[[list(1,2)]]<-integer() }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[[list(1,2,3)]]<-integer() }"); - assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[[list()]]<-NULL }"); + assertEval(Output.ContainsAmbiguousError, "{ z<-list(1,2,3,4); z[[list()]]<-NULL }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[[list(1)]]<-NULL }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[[list(1,2)]]<-NULL }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[[list(1,2,3)]]<-NULL }"); @@ -891,18 +894,18 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[list(1,2,3), 1]<-integer() }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[list(1,2,3), 1]<-7 }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[list(1,2,3), 1]<-c(7,42) }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(), 1]]<-integer() }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(), 1]]<-7 }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(), 1]]<-c(7,42) }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1), 1]]<-integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(), 1]]<-integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(), 1]]<-7 }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(), 1]]<-c(7,42) }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1), 1]]<-integer() }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1), 1]]<-7 }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1), 1]]<-c(7,42) }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2), 1]]<-integer() }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2), 1]]<-7 }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2), 1]]<-c(7,42) }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2,3), 1]]<-integer() }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2,3), 1]]<-7 }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2,3), 1]]<-c(7,42) }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1), 1]]<-c(7,42) }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2), 1]]<-integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2), 1]]<-7 }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2), 1]]<-c(7,42) }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2,3), 1]]<-integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2,3), 1]]<-7 }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2,3), 1]]<-c(7,42) }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[list(), 1]<-NULL }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[list(), 1]<-integer() }"); @@ -920,22 +923,22 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[list(1,2,3), 1]<-integer() }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[list(1,2,3), 1]<-7 }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[list(1,2,3), 1]<-c(7,42) }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(), 1]]<-NULL }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(), 1]]<-integer() }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(), 1]]<-7 }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(), 1]]<-c(7,42) }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1), 1]]<-NULL }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(), 1]]<-NULL }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(), 1]]<-integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(), 1]]<-7 }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(), 1]]<-c(7,42) }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1), 1]]<-NULL }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1), 1]]<-integer() }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1), 1]]<-7 }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1), 1]]<-c(7,42) }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2), 1]]<-NULL }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2), 1]]<-integer() }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2), 1]]<-7 }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2), 1]]<-c(7,42) }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2,3), 1]]<-NULL }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2,3), 1]]<-integer() }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2,3), 1]]<-7 }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2,3), 1]]<-c(7,42) }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2), 1]]<-NULL }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2), 1]]<-integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2), 1]]<-7 }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2), 1]]<-c(7,42) }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2,3), 1]]<-NULL }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2,3), 1]]<-integer() }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2,3), 1]]<-7 }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2,3), 1]]<-c(7,42) }"); assertEval(Output.ContainsError, "{ z<-1:4; z[list()] }"); assertEval(Output.ContainsError, "{ z<-1:4; z[list(1)] }"); @@ -943,12 +946,12 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[list(), 1] }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[list(1), 1] }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[list(1,2), 1] }"); - assertEval(Output.ContainsError, "{ z<-1:4; z[[list()]] }"); + assertEval(Output.ContainsAmbiguousError, "{ z<-1:4; z[[list()]] }"); assertEval(Output.ContainsError, "{ z<-1:4; z[[list(1)]] }"); - assertEval(Output.ContainsError, "{ z<-1:4; z[[list(1,2)]] }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(), 1]] }"); + assertEval(Output.ContainsAmbiguousError, "{ z<-1:4; z[[list(1,2)]] }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(), 1]] }"); assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1), 1]] }"); - assertEval(Output.ContainsError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2), 1]] }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-1:4; dim(x)<-c(2,2); x[[list(1,2), 1]] }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[list()] }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[list(1)] }"); @@ -956,12 +959,12 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[list(), 1] }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[list(1), 1] }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[list(1,2), 1] }"); - assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[[list()]] }"); + assertEval(Output.ContainsAmbiguousError, "{ z<-list(1,2,3,4); z[[list()]] }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[[list(1)]] }"); assertEval(Output.ContainsError, "{ z<-list(1,2,3,4); z[[list(1,2)]] }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(), 1]] }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(), 1]] }"); assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1), 1]] }"); - assertEval(Output.ContainsError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2), 1]] }"); + assertEval(Output.ContainsAmbiguousError, "{ x<-list(1,2,3,4); dim(x)<-c(2,2); x[[list(1,2), 1]] }"); assertEval(Ignored.Unknown, Output.ContainsError, "{ z<-1:4; z[[list()]]<-NULL }"); } @@ -1004,9 +1007,9 @@ public class TestSimpleVectors extends TestBase { assertEval("{ x<-c(1L,2L,3L); typeof(x[NA]) }"); assertEval("{ x<-1:3; typeof(x[NA]) }"); - assertEval(Ignored.Unknown, "{ x<-c(1,2,3); x[-0.1] }"); - assertEval(Ignored.Unknown, "{ x<-c(1L,2L,3L); x[-0.1] }"); - assertEval(Ignored.Unknown, "{ x<-1:3; x[-0.1] }"); + assertEval("{ x<-c(1,2,3); x[-0.1] }"); + assertEval("{ x<-c(1L,2L,3L); x[-0.1] }"); + assertEval("{ x<-1:3; x[-0.1] }"); } @Test @@ -1146,10 +1149,10 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsError, "{ x <- 1:3 ; x[[FALSE]] <- 10 ; x }"); assertEval(Output.ContainsError, "{ x <- 1:3 ; x[[NA]] <- 10 ; x }"); assertEval(Output.ContainsError, "{ f <- function(b,i,v) { b[[i]] <- v ; b } ; f(1:3, 1L, 10) ; f(c(1,2), \"hello\", TRUE) ; f(1:2, list(1), 3) }"); - assertEval(Output.ContainsError, "{ f <- function(b,i,v) { b[[i]] <- v ; b } ; f(1:3, 1L, 10) ; f(c(1,2), \"hello\", TRUE) ; f(1:2, list(), 3) }"); + assertEval(Output.ContainsAmbiguousError, "{ f <- function(b,i,v) { b[[i]] <- v ; b } ; f(1:3, 1L, 10) ; f(c(1,2), \"hello\", TRUE) ; f(1:2, list(), 3) }"); assertEval(Output.ContainsError, "{ f <- function(b,i,v) { b[i] <- v ; b } ; f(1:3, 1L, 10) ; f(c(1,2), \"hello\", TRUE) ; f(1:2, 1+2i, 3) }"); assertEval(Output.ContainsError, "{ f <- function(b,i,v) { b[[i]] <- v ; b } ; f(1:3, 1L, 10) ; f(c(1,2), \"hello\", TRUE) ; f(1:2, 1, 3:4) }"); - assertEval(Output.ContainsError, "{ f <- function(b,i,v) { b[[i]] <- v ; b } ; f(1:3, 1L, 10) ; f(c(1,2), \"hello\", TRUE) ; f(1:2, as.integer(NA), 3:4) }"); + assertEval(Output.ContainsAmbiguousError, "{ f <- function(b,i,v) { b[[i]] <- v ; b } ; f(1:3, 1L, 10) ; f(c(1,2), \"hello\", TRUE) ; f(1:2, as.integer(NA), 3:4) }"); assertEval(Output.ContainsError, "{ x <- 1:2 ; x[as.integer(NA)] <- 3:4 }"); assertEval("{ b <- c(1+2i,3+4i) ; dim(b) <- c(2,1) ; b[1] <- 3+1i ; b }"); @@ -1161,7 +1164,7 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsError, "{ f <- function(x,i) { x[[i]]} ; f(list(1,2,3,4), 3); f(f,2) }"); assertEval(Output.ContainsError, "{ f <- function(x,i) { x[i] } ; x <- c(a=1,b=2) ; f(x,\"a\") ; f(function(){3},\"b\") }"); - assertEval(Ignored.Unknown, "{ x<-1:4; x[c(-0.5)] }"); + assertEval("{ x<-1:4; x[c(-0.5)] }"); } @Test @@ -1303,8 +1306,8 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsError, "{ x <- list(a=1,b=1:3) ; f <- function(i) { x[[i]] } ; f(c(2,2)) ; f(2+3i) }"); assertEval(Output.ContainsError, "{ x <- 1:3; x[list(2,3)] }"); assertEval(Output.ContainsError, "{ x <- 1:3; x[function(){3}] }"); - assertEval(Output.ContainsError, "{ x <- 1:2; x[[list()]] }"); - assertEval(Output.ContainsError, "{ x <- 1:2; x[[list(-0,-1)]] }"); + assertEval(Output.ContainsAmbiguousError, "{ x <- 1:2; x[[list()]] }"); + assertEval(Output.ContainsAmbiguousError, "{ x <- 1:2; x[[list(-0,-1)]] }"); assertEval(Output.ContainsError, "{ x <- 1:2; x[[list(0)]] }"); assertEval(Output.ContainsError, "{ f <- function(b,i) { b[[i]] } ; f(list(1,list(2)),c(2,1)) ; f(1:3,list(1)) }"); @@ -1317,10 +1320,10 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsError, "{ f <- function(b,i) { b[i] } ; f(1:3, c(TRUE,FALSE,TRUE)) ; f(function(){2},3:1) }"); assertEval(Output.ContainsError, "{ f <- function(b,i) { b[i] } ; f(1:3, c(TRUE,FALSE)) ; f(f, c(TRUE,NA)) }"); assertEval(Output.ContainsError, "{ f <- function(b,i) { b[i] } ; f(1:3, c(\"h\",\"hi\")) ; f(function(){3},\"hi\") }"); - assertEval(Output.ContainsError, "{ f <- function(i) { l[[i]] } ; l <- list(1, f) ; f(c(2,1)) }"); - assertEval(Output.ContainsError, "{ x <- list(a=1,b=function(){3},d=list(x=3)) ; x[[c(2,10)]] }"); - assertEval(Output.ContainsError, "{ x <- list(a=1,b=function(){3},d=list(x=3)) ; x[[c(2,-3)]] }"); - assertEval(Output.ContainsError, "{ x <- list(a=1,b=function(){3},d=list(x=3)) ; f <- function(i) { x[[i]] } ; f(c(\"d\",\"x\")) ; f(c(\"b\",\"z\")) }"); + assertEval(Output.ContainsAmbiguousError, "{ f <- function(i) { l[[i]] } ; l <- list(1, f) ; f(c(2,1)) }"); + assertEval(Output.ContainsAmbiguousError, "{ x <- list(a=1,b=function(){3},d=list(x=3)) ; x[[c(2,10)]] }"); + assertEval(Output.ContainsAmbiguousError, "{ x <- list(a=1,b=function(){3},d=list(x=3)) ; x[[c(2,-3)]] }"); + assertEval(Output.ContainsAmbiguousError, "{ x <- list(a=1,b=function(){3},d=list(x=3)) ; f <- function(i) { x[[i]] } ; f(c(\"d\",\"x\")) ; f(c(\"b\",\"z\")) }"); assertEval(Output.ContainsError, "{ x <- list(a=1,b=1:3) ; f <- function(i) { x[[i]] } ; f(c(2,2)) ; x <- f ; f(2+3i) }"); } @@ -1812,7 +1815,7 @@ public class TestSimpleVectors extends TestBase { assertEval("{ x<-1:5 ; x[x[4]<-2] <- (x[4]<-100) ; x }"); assertEval("{ x<-5:1 ; x[x[2]<-2] }"); - assertEval(Ignored.Unknown, "{ f <- function(a) { a }; x<-1:5 ; x[x[4]<-2] <- ({x[4]<-100; f(x)[4]}) ; x }"); + assertEval("{ f <- function(a) { a }; x<-1:5 ; x[x[4]<-2] <- ({x[4]<-100; f(x)[4]}) ; x }"); } @Test @@ -2008,7 +2011,7 @@ public class TestSimpleVectors extends TestBase { assertEval(Output.ContainsError, "{ f <- function(b,i,v) { b[[i]] <- v ; b } ; f(list(1,2,b=list(a=1)),c(\"b\",\"a\"),10) ; f(f,TRUE,3) }"); assertEval(Output.ContainsError, "{ f <- function(b,i,v) { b[[i]] <- v ; b } ; f(list(1,2,b=list(a=1)),c(\"b\",\"a\"),10) ; f(c(a=1,b=2),\"b\",NULL) }"); assertEval(Output.ContainsError, "{ f <- function(b,i,v) { b[[i]] <- v ; b } ; f(list(1,2,b=list(a=1)),c(\"b\",\"a\"),10) ; f(c(a=1,b=2),\"b\",as.raw(12)) }"); - assertEval(Output.ContainsError, "{ f <- function(b,i,v) { b[[i]] <- v ; b } ; f(list(1,2,b=list(a=1)),c(\"b\",\"a\"),10) ; f(c(a=1,b=2),c(1+2i,3+4i),as.raw(12)) }"); + assertEval(Output.ContainsAmbiguousError, "{ f <- function(b,i,v) { b[[i]] <- v ; b } ; f(list(1,2,b=list(a=1)),c(\"b\",\"a\"),10) ; f(c(a=1,b=2),c(1+2i,3+4i),as.raw(12)) }"); assertEval("{ l <- list(a=1,b=2,cd=list(c=3,d=4)) ; x <- list(l,xy=list(x=l,y=l)) ; x[[c(2,2,3,2)]] <- 10 ; l }"); assertEval("{ l <- list(a=1,b=2,cd=list(c=3,d=4)) ; x <- list(l,xy=list(x=l,y=l)) ; x[[c(\"xy\",\"y\",\"cd\",\"d\")]] <- 10 ; l }"); @@ -2071,38 +2074,39 @@ public class TestSimpleVectors extends TestBase { assertEval("{ x <- NULL; x[c(1,2)] <- c(5); x; }"); assertEval("{ x <- NULL; x[c(1,2)] <- c(1,5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[[0]] <- c(); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[[1]] <- c(); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[[c(1,0)]] <- c(); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[[c(1,2)]] <- c(); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[[c(0,1)]] <- c(); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[[c(0,2)]] <- c(); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[[0]] <- c(5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[[c(1,0)]] <- c(5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[[c(1,2)]] <- c(5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[[c(0,1)]] <- c(5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[[c(0,2)]] <- c(5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[[0]] <- c(1,5); x; }"); + assertEval("{ x <- NULL; x[[0]] <- c(); x; }"); + assertEval("{ x <- NULL; x[[1]] <- c(); x; }"); + assertEval("{ x <- NULL; x[[c(1,0)]] <- c(); x; }"); + assertEval("{ x <- NULL; x[[c(1,2)]] <- c(); x; }"); + assertEval("{ x <- NULL; x[[c(0,1)]] <- c(); x; }"); + assertEval("{ x <- NULL; x[[c(0,2)]] <- c(); x; }"); + assertEval("{ x <- NULL; x[[0]] <- c(5); x; }"); + assertEval(Output.ContainsError, "{ x <- NULL; x[[c(1,0)]] <- c(5); x; }"); + assertEval(Output.ContainsError, "{ x <- NULL; x[[c(1,2)]] <- c(5); x; }"); + assertEval(Output.ContainsError, "{ x <- NULL; x[[c(0,1)]] <- c(5); x; }"); + assertEval(Output.ContainsError, "{ x <- NULL; x[[c(0,2)]] <- c(5); x; }"); + assertEval(Output.ContainsError, "{ x <- NULL; x[[0]] <- c(1,5); x; }"); + assertEval(Output.ContainsError, "{ x <- NULL; x[[c(0,1)]] <- c(1,5); x; }"); + assertEval(Output.ContainsError, "{ x <- NULL; x[[c(0,2)]] <- c(1,5); x; }"); + assertEval("{ x <- NULL; x[0] <- c(); x; }"); + assertEval("{ x <- NULL; x[1] <- c(); x; }"); + assertEval("{ x <- NULL; x[c(1,0)] <- c(); x; }"); + assertEval("{ x <- NULL; x[c(1,2)] <- c(); x; }"); + assertEval("{ x <- NULL; x[c(0,1)] <- c(); x; }"); + assertEval("{ x <- NULL; x[c(0,2)] <- c(); x; }"); + assertEval("{ x <- NULL; x[0] <- c(5); x; }"); + assertEval("{ x <- NULL; x[c(1,0)] <- c(5); x; }"); + assertEval("{ x <- NULL; x[c(0,1)] <- c(5); x; }"); + assertEval("{ x <- NULL; x[c(0,2)] <- c(5); x; }"); + assertEval("{ x <- NULL; x[0] <- c(1,5); x; }"); + assertEval(Output.ContainsWarning, "{ x <- NULL; x[1] <- c(1,5); x; }"); + assertEval(Output.ContainsWarning, "{ x <- NULL; x[c(1,0)] <- c(1,5); x; }"); + assertEval(Output.ContainsWarning, "{ x <- NULL; x[c(0,1)] <- c(1,5); x; }"); + assertEval(Output.ContainsWarning, "{ x <- NULL; x[c(0,2)] <- c(1,5); x; }"); + assertEval(Output.ContainsAmbiguousError, "{ x <- NULL; x[[c(1,0)]] <- c(1,5); x; }"); + assertEval(Output.ContainsAmbiguousError, "{ x <- NULL; x[[c(1,2)]] <- c(1,5); x; }"); + assertEval(Ignored.Unknown, "{ x <- NULL; x[[1]] <- c(1,5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[[c(1,0)]] <- c(1,5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[[c(1,2)]] <- c(1,5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[[c(0,1)]] <- c(1,5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[[c(0,2)]] <- c(1,5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[0] <- c(); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[1] <- c(); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[c(1,0)] <- c(); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[c(1,2)] <- c(); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[c(0,1)] <- c(); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[c(0,2)] <- c(); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[0] <- c(5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[c(1,0)] <- c(5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[c(0,1)] <- c(5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[c(0,2)] <- c(5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[0] <- c(1,5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[1] <- c(1,5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[c(1,0)] <- c(1,5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[c(0,1)] <- c(1,5); x; }"); - assertEval(Ignored.Unknown, "{ x <- NULL; x[c(0,2)] <- c(1,5); x; }"); } @Test diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tck/FastRTckTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tck/FastRTckTest.java index 7fc9ff1e0a40c946b4be9cf9d692c73e18cb6c6c..f7ded046762ad88d96026a64edfe34947f99e50b 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tck/FastRTckTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tck/FastRTckTest.java @@ -22,19 +22,19 @@ */ package com.oracle.truffle.r.test.tck; -import com.oracle.truffle.r.engine.TruffleRLanguage; -import com.oracle.truffle.tck.TruffleTCK; -import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.vm.TruffleVM; - -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; import org.junit.Test; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.vm.PolyglotEngine; +import com.oracle.truffle.r.engine.TruffleRLanguage; +import com.oracle.truffle.tck.TruffleTCK; + public class FastRTckTest extends TruffleTCK { @Test public void testVerifyPresence() { - TruffleVM vm = TruffleVM.newVM().build(); + PolyglotEngine vm = PolyglotEngine.buildNew().build(); assertTrue("Our language is present", vm.getLanguages().containsKey("text/x-r")); } @@ -70,8 +70,8 @@ public class FastRTckTest extends TruffleTCK { // @formatter:on @Override - protected TruffleVM prepareVM() throws Exception { - TruffleVM vm = TruffleVM.newVM().build(); + protected PolyglotEngine prepareVM() throws Exception { + PolyglotEngine vm = PolyglotEngine.buildNew().build(); vm.eval(INITIALIZATION); return vm; } diff --git a/mx.fastr/suite.py b/mx.fastr/suite.py index ba25f1346cf4ee5bfaddf87222f50328aa06a571..4b450530e9d77fe44b53f6e95f760c047fd04cf4 100644 --- a/mx.fastr/suite.py +++ b/mx.fastr/suite.py @@ -28,7 +28,7 @@ suite = { "suites" : [ { "name" : "graal", - "version" : "350e41999d304cbae6b37455f6dc27424c0f6ec8", + "version" : "98e7ddb9fe6355618b3acf59ee824771333b1bcf", "urls" : [{"url" : "http://lafo.ssw.uni-linz.ac.at/hg/graal-compiler", "kind" : "hg"}] }, ],