diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsCharacter.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsCharacter.java index 6b199dcff3410039dc25bbfb09979c06da250b03..9f81e651faa3866aef9d85504708e8687cfb62be 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsCharacter.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsCharacter.java @@ -120,25 +120,26 @@ public abstract class AsCharacter extends RBuiltinNode { return RDataFactory.createStringVector(0); } - @Specialization(guards = "!isObject") - protected RStringVector doStringVector(RStringVector vector) { + @Specialization(guards = "!isObject(frame, vector)") + protected RStringVector doStringVector(@SuppressWarnings("unused") VirtualFrame frame, RStringVector vector) { controlVisibility(); return RDataFactory.createStringVector(vector.getDataCopy(), vector.isComplete()); } - @Specialization(guards = "!isObject") - protected RStringVector doList(@SuppressWarnings("unused") RList list) { + @Specialization(guards = "!isObject(frame, list)") + @SuppressWarnings("unused") + protected RStringVector doList(VirtualFrame frame, RList list) { controlVisibility(); throw new UnsupportedOperationException("list type not supported for as.character - requires deparsing"); } - @Specialization(guards = "!isObject") + @Specialization(guards = "!isObject(frame, container)") protected RStringVector doVector(VirtualFrame frame, RAbstractContainer container) { controlVisibility(); return castStringVector(frame, container); } - @Specialization(guards = "isObject") + @Specialization(guards = "isObject(frame, container)") protected Object doObject(VirtualFrame frame, RAbstractContainer container) { controlVisibility(); if (dcn == null) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsRaw.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsRaw.java index ab4f5f2969d7492ca5aa4f9bee486d936aaea1a4..76b23aa5554398995d4dc999a1e76c90a51cd4fe 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsRaw.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsRaw.java @@ -117,7 +117,7 @@ public abstract class AsRaw extends RBuiltinNode { return value; } - @Specialization(guards = {"!isListVector", "!isRawVector"}) + @Specialization(guards = {"!isListVector(vector)", "!isRawVector(vector)"}) protected RRawVector asRaw(VirtualFrame frame, RAbstractVector vector) { controlVisibility(); return castRawVector(frame, vector); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsVector.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsVector.java index 1345bc20ad9781a8ca7d28ddfda5d015db8e1813..4f495dc9f16e2436798ef63c240f72f84575de98 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsVector.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsVector.java @@ -126,61 +126,61 @@ public abstract class AsVector extends RBuiltinNode { return x; } - @Specialization(guards = "castToInt") + @Specialization(guards = "castToInt(x, mode)") protected RAbstractVector asVectorInt(VirtualFrame frame, RAbstractContainer x, @SuppressWarnings("unused") String mode) { controlVisibility(); return castInteger(frame, x); } - @Specialization(guards = "castToDouble") + @Specialization(guards = "castToDouble(x, mode)") protected RAbstractVector asVectorDouble(VirtualFrame frame, RAbstractContainer x, @SuppressWarnings("unused") String mode) { controlVisibility(); return castDouble(frame, x); } - @Specialization(guards = "castToComplex") + @Specialization(guards = "castToComplex(x, mode)") protected RAbstractVector asVectorComplex(VirtualFrame frame, RAbstractContainer x, @SuppressWarnings("unused") String mode) { controlVisibility(); return castComplex(frame, x); } - @Specialization(guards = "castToLogical") + @Specialization(guards = "castToLogical(x, mode)") protected RAbstractVector asVectorLogical(VirtualFrame frame, RAbstractContainer x, @SuppressWarnings("unused") String mode) { controlVisibility(); return castLogical(frame, x); } - @Specialization(guards = "castToString") + @Specialization(guards = "castToString(x, mode)") protected RAbstractVector asVectorString(VirtualFrame frame, RAbstractContainer x, @SuppressWarnings("unused") String mode) { controlVisibility(); return castString(frame, x); } - @Specialization(guards = "castToRaw") + @Specialization(guards = "castToRaw(x, mode)") protected RAbstractVector asVectorRaw(VirtualFrame frame, RAbstractContainer x, @SuppressWarnings("unused") String mode) { controlVisibility(); return castRaw(frame, x); } - @Specialization(guards = "castToList") + @Specialization(guards = "castToList(x, mode)") protected RAbstractVector asVectorList(VirtualFrame frame, RAbstractContainer x, @SuppressWarnings("unused") String mode) { controlVisibility(); return castList(frame, x); } - @Specialization(guards = "castToList") + @Specialization(guards = "castToList(x, mode)") protected RAbstractVector asVectorList(@SuppressWarnings("unused") RNull x, @SuppressWarnings("unused") String mode) { controlVisibility(); return RDataFactory.createList(); } - @Specialization(guards = "castToSymbol") + @Specialization(guards = "castToSymbol(x, mode)") protected RSymbol asVectorSymbol(VirtualFrame frame, RAbstractContainer x, @SuppressWarnings("unused") String mode) { controlVisibility(); return castSymbol(frame, x); } - @Specialization(guards = "isSymbol") + @Specialization(guards = "isSymbol(x, mode)") protected RSymbol asVectorSymbol(RSymbol x, @SuppressWarnings("unused") String mode) { controlVisibility(); return RDataFactory.createSymbol(x.getName()); @@ -190,7 +190,7 @@ public abstract class AsVector extends RBuiltinNode { return RType.Symbol.getName().equals(mode); } - @Specialization(guards = "modeIsAny") + @Specialization(guards = "modeIsAny(mode)") protected RAbstractVector asVector(RList x, @SuppressWarnings("unused") String mode) { controlVisibility(); RList result = x.copyWithNewDimensions(null); @@ -198,7 +198,7 @@ public abstract class AsVector extends RBuiltinNode { return result; } - @Specialization(guards = "modeIsAny") + @Specialization(guards = "modeIsAny(mode)") protected RAbstractVector asVector(RFactor x, @SuppressWarnings("unused") String mode) { RVector levels = x.getLevels(); RVector result = levels.createEmptySameType(x.getLength(), RDataFactory.COMPLETE_VECTOR); @@ -209,13 +209,13 @@ public abstract class AsVector extends RBuiltinNode { return result; } - @Specialization(guards = "modeIsAny") + @Specialization(guards = "modeIsAny(mode)") protected RNull asVector(RNull x, @SuppressWarnings("unused") String mode) { controlVisibility(); return x; } - @Specialization(guards = "modeIsPairList") + @Specialization(guards = "modeIsPairList(mode)") protected Object asVectorPairList(RList x, @SuppressWarnings("unused") String mode) { controlVisibility(); // TODO implement non-empty element list conversion; this is a placeholder for type test @@ -226,13 +226,13 @@ public abstract class AsVector extends RBuiltinNode { } } - @Specialization(guards = "castToExpression") + @Specialization(guards = "castToExpression(x, mode)") protected RExpression asVectorExpression(VirtualFrame frame, Object x, @SuppressWarnings("unused") String mode) { controlVisibility(); return castExpression(frame, x); } - @Specialization(guards = "modeIsAnyOrMatches") + @Specialization(guards = "modeIsAnyOrMatches(x, mode)") protected RAbstractVector asVector(RAbstractVector x, @SuppressWarnings("unused") String mode) { controlVisibility(); return x.copyWithNewDimensions(null); @@ -282,15 +282,11 @@ public abstract class AsVector extends RBuiltinNode { return RType.Any.getName().equals(mode) || RRuntime.classToString(x.getElementClass()).equals(mode) || x.getElementClass() == RDouble.class && RType.Double.getName().equals(mode); } - protected boolean modeIsAny(@SuppressWarnings("unused") RAbstractContainer x, String mode) { + protected boolean modeIsAny(String mode) { return RType.Any.getName().equals(mode); } - protected boolean modeIsAny(@SuppressWarnings("unused") RNull x, String mode) { - return RType.Any.getName().equals(mode); - } - - protected boolean modeIsPairList(@SuppressWarnings("unused") RAbstractVector x, String mode) { + protected boolean modeIsPairList(String mode) { return RType.PairList.getName().equals(mode); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Assign.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Assign.java index 911736647d1a90772a696895d36a867203cad379..576c1babe7bde3e0e6c71482e42a16cf8facd4fe 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Assign.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Assign.java @@ -26,15 +26,14 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; -import com.oracle.truffle.api.utilities.BranchProfile; +import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.model.*; import com.oracle.truffle.r.runtime.env.*; -import com.oracle.truffle.r.runtime.env.REnvironment.*; +import com.oracle.truffle.r.runtime.env.REnvironment.PutException; /** * The {@code assign} builtin. There are two special cases worth optimizing: @@ -76,7 +75,7 @@ public abstract class Assign extends RInvisibleBuiltinNode { /** * The general case that requires searching the environment hierarchy. */ - @Specialization(guards = {"inheritsIsTrue"}) + @Specialization(guards = {"inheritsIsTrue(inherits)"}) protected Object assignInherit(RAbstractStringVector xVec, Object value, REnvironment envir, @SuppressWarnings("unused") byte inherits) { controlVisibility(); String x = checkVariable(xVec); @@ -100,7 +99,7 @@ public abstract class Assign extends RInvisibleBuiltinNode { return value; } - @Specialization(guards = {"!inheritsIsTrue"}) + @Specialization(guards = {"!inheritsIsTrue(inherits)"}) @SuppressWarnings("unused") protected Object assignNoInherit(RAbstractStringVector xVec, Object value, REnvironment envir, byte inherits) { String x = checkVariable(xVec); @@ -131,8 +130,7 @@ public abstract class Assign extends RInvisibleBuiltinNode { } } - @SuppressWarnings("unused") - protected static boolean inheritsIsTrue(VirtualFrame frame, RAbstractStringVector x, Object value, REnvironment envir, byte inherits) { + protected static boolean inheritsIsTrue(byte inherits) { return inherits == RRuntime.LOGICAL_TRUE; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Attr.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Attr.java index 682b980ecab6c8c4c37d9473efed481fd67a9639..d84b820128848033820a6b6b36697b3b7ce5a961 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Attr.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Attr.java @@ -94,7 +94,7 @@ public abstract class Attr extends RBuiltinNode { } } - @Specialization(guards = "!isRowNamesAttr") + @Specialization(guards = "!isRowNamesAttr(container, name)") protected Object attr(RAbstractContainer container, String name) { controlVisibility(); return attrRA(container, intern(name)); @@ -110,7 +110,7 @@ public abstract class Attr extends RBuiltinNode { } } - @Specialization(guards = "isRowNamesAttr") + @Specialization(guards = "isRowNamesAttr(container, name)") protected Object attrRowNames(RAbstractContainer container, @SuppressWarnings("unused") String name) { controlVisibility(); RAttributes attributes = container.getAttributes(); @@ -121,18 +121,18 @@ public abstract class Attr extends RBuiltinNode { } } - @Specialization(guards = {"!emptyName", "isRowNamesAttr"}) + @Specialization(guards = {"!emptyName(name)", "isRowNamesAttr(container, name)"}) protected Object attrRowNames(RAbstractContainer container, RStringVector name) { return attrRowNames(container, name.getDataAt(0)); } - @Specialization(guards = {"!emptyName", "!isRowNamesAttr"}) + @Specialization(guards = {"!emptyName(name)", "!isRowNamesAttr(container, name)"}) protected Object attr(RAbstractContainer container, RStringVector name) { return attr(container, name.getDataAt(0)); } @SuppressWarnings("unused") - @Specialization(guards = "emptyName") + @Specialization(guards = "emptyName(name)") protected Object attrEmtpyName(RAbstractContainer container, RStringVector name) { controlVisibility(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.EXACTLY_ONE_WHICH); @@ -164,7 +164,7 @@ public abstract class Attr extends RBuiltinNode { return isRowNamesAttr(container, name.getDataAt(0)); } - protected boolean emptyName(@SuppressWarnings("unused") RAbstractContainer container, RStringVector name) { + protected boolean emptyName(RStringVector name) { return name.getLength() == 0; } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Attributes.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Attributes.java index 755e63e024128a4c1098bfd866733217a93fd6a7..17fb582c283264f3e5c69cdddbba61425b411d49 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Attributes.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Attributes.java @@ -40,13 +40,13 @@ public abstract class Attributes extends RBuiltinNode { private final BranchProfile rownamesBranch = BranchProfile.create(); - @Specialization(guards = "!hasAttributes") + @Specialization(guards = "!hasAttributes(vector)") protected RNull attributesNull(@SuppressWarnings("unused") RAbstractVector vector) { controlVisibility(); return RNull.instance; } - @Specialization(guards = "hasAttributes") + @Specialization(guards = "hasAttributes(container)") protected Object attributes(RAbstractContainer container) { controlVisibility(); return createResult(container, container instanceof RLanguage); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Bind.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Bind.java index 25db106a39c129652f576658155f9c6ed04f8c39..ab13da101dff27f6708ea811c0f1e74dff088fc2 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Bind.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Bind.java @@ -70,7 +70,7 @@ public abstract class Bind extends RPrecedenceBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "isNullPrecedence") + @Specialization(guards = "isNullPrecedence(frame, args)") protected RNull allNull(VirtualFrame frame, Object deparseLevelObj, RArgsValuesAndNames args) { controlVisibility(); return RNull.instance; @@ -78,7 +78,7 @@ public abstract class Bind extends RPrecedenceBuiltinNode { private static final ArgumentsSignature SIGNATURE = ArgumentsSignature.get(new String[]{"deparse.level", "..."}); - @Specialization(guards = {"!oneElement", "isDataFrame"}) + @Specialization(guards = {"!oneElement(args)", "isDataFrame(args)"}) protected Object allDataFrame(VirtualFrame frame, Object deparseLevel, RArgsValuesAndNames args) { if (dcn == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -125,31 +125,31 @@ public abstract class Bind extends RPrecedenceBuiltinNode { return genericBind(frame, vectors, complete, vecNames, naCheck.neverSeenNA(), deparseLevel); } - @Specialization(guards = {"isIntegerPrecedence", "!oneElement", "!isDataFrame"}) + @Specialization(guards = {"isIntegerPrecedence(frame, args)", "!oneElement(args)", "!isDataFrame(args)"}) @ExplodeLoop protected Object allInt(VirtualFrame frame, Object deparseLevel, RArgsValuesAndNames args) { return bindInternal(frame, deparseLevel, args, (f, e) -> castVector(f, castInteger(f, e, true))); } - @Specialization(guards = {"isDoublePrecedence", "!oneElement", "!isDataFrame"}) + @Specialization(guards = {"isDoublePrecedence(frame, args)", "!oneElement(args)", "!isDataFrame(args)"}) @ExplodeLoop protected Object allDouble(VirtualFrame frame, Object deparseLevel, RArgsValuesAndNames args) { return bindInternal(frame, deparseLevel, args, (f, e) -> castVector(f, castDouble(f, e, true))); } - @Specialization(guards = {"isStringPrecedence", "!oneElement", "!isDataFrame"}) + @Specialization(guards = {"isStringPrecedence(frame, args)", "!oneElement(args)", "!isDataFrame(args)"}) @ExplodeLoop protected Object allString(VirtualFrame frame, Object deparseLevel, RArgsValuesAndNames args) { return bindInternal(frame, deparseLevel, args, (f, e) -> castVector(f, castString(f, e, true))); } - @Specialization(guards = {"isComplexPrecedence", "!oneElement", "!isDataFrame"}) + @Specialization(guards = {"isComplexPrecedence(frame, args)", "!oneElement(args)", "!isDataFrame(args)"}) @ExplodeLoop protected Object allComplex(VirtualFrame frame, Object deparseLevel, RArgsValuesAndNames args) { return bindInternal(frame, deparseLevel, args, (f, e) -> castVector(f, castComplex(f, e, true))); } - @Specialization(guards = {"isListPrecedence", "!oneElement", "!isDataFrame"}) + @Specialization(guards = {"isListPrecedence(frame, args)", "!oneElement(args)", "!isDataFrame(args)"}) @ExplodeLoop protected Object allList(VirtualFrame frame, Object deparseLevel, RArgsValuesAndNames args) { return bindInternal(frame, deparseLevel, args, (f, e) -> castList(f, e, true)); @@ -360,35 +360,11 @@ public abstract class Bind extends RPrecedenceBuiltinNode { } - protected boolean oneElement(@SuppressWarnings("unused") Object deparseLevelObj, RArgsValuesAndNames args) { + protected boolean oneElement(RArgsValuesAndNames args) { return args.length() == 1; } - protected boolean isNullPrecedence(VirtualFrame frame, @SuppressWarnings("unused") Object deparseLevelObj, RArgsValuesAndNames args) { - return isNullPrecedence(frame, args); - } - - protected boolean isIntegerPrecedence(VirtualFrame frame, @SuppressWarnings("unused") Object deparseLevelObj, RArgsValuesAndNames args) { - return isIntegerPrecedence(frame, args); - } - - protected boolean isDoublePrecedence(VirtualFrame frame, @SuppressWarnings("unused") Object deparseLevelObj, RArgsValuesAndNames args) { - return isDoublePrecedence(frame, args); - } - - protected boolean isStringPrecedence(VirtualFrame frame, @SuppressWarnings("unused") Object deparseLevelObj, RArgsValuesAndNames args) { - return isStringPrecedence(frame, args); - } - - protected boolean isComplexPrecedence(VirtualFrame frame, @SuppressWarnings("unused") Object deparseLevelObj, RArgsValuesAndNames args) { - return isComplexPrecedence(frame, args); - } - - protected boolean isListPrecedence(VirtualFrame frame, @SuppressWarnings("unused") Object deparseLevelObj, RArgsValuesAndNames args) { - return isListPrecedence(frame, args); - } - - protected boolean isDataFrame(@SuppressWarnings("unused") Object deparseLevelObj, RArgsValuesAndNames args) { + protected boolean isDataFrame(RArgsValuesAndNames args) { return args.getValues()[0] instanceof RDataFrame; } @@ -401,7 +377,7 @@ public abstract class Bind extends RPrecedenceBuiltinNode { return "cbind"; } - @Specialization(guards = {"!isNullPrecedence", "oneElement"}) + @Specialization(guards = {"!isNullPrecedence(frame, args)", "oneElement(args)"}) protected Object allOneElem(VirtualFrame frame, Object deparseLevelObj, RArgsValuesAndNames args) { controlVisibility(); return allOneElem(frame, deparseLevelObj, args, true); @@ -474,7 +450,7 @@ public abstract class Bind extends RPrecedenceBuiltinNode { return "rbind"; } - @Specialization(guards = {"!isNullPrecedence", "oneElement"}) + @Specialization(guards = {"!isNullPrecedence(frame, args)", "oneElement(args)"}) protected Object allOneElem(VirtualFrame frame, Object deparseLevelObj, RArgsValuesAndNames args) { controlVisibility(); return allOneElem(frame, deparseLevelObj, args, false); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Call.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Call.java index 29f11962180179d9d11211be8602597d89081779..c90167bc5bcb265813b66f1b83830c6e9b1e37ca 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Call.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Call.java @@ -45,12 +45,12 @@ public abstract class Call extends RBuiltinNode { return new RNode[]{ConstantNode.create(RMissing.instance), ConstantNode.create(RMissing.instance)}; } - @Specialization(guards = "!isEmptyName") + @Specialization(guards = "!isEmptyName(name)") protected RLanguage call(RAbstractStringVector name, @SuppressWarnings("unused") RMissing args) { return makeCall(name.getDataAt(0), null); } - @Specialization(guards = "!isEmptyName") + @Specialization(guards = "!isEmptyName(name)") protected RLanguage call(RAbstractStringVector name, RArgsValuesAndNames args) { return makeCall(name.getDataAt(0), args); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ColMeans.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ColMeans.java index 3b795eb52a52b7b79a1f929181e2a8851b6d30cf..64576103ebed6f8e7553c869707b9f810f011495 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ColMeans.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ColMeans.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2014, Purdue University - * Copyright (c) 2014, Oracle and/or its affiliates + * Copyright (c) 2014, 2015, Oracle and/or its affiliates * * All rights reserved. */ @@ -41,7 +41,7 @@ public abstract class ColMeans extends RBuiltinNode { return arguments; } - @Specialization(guards = "!isNaRm") + @Specialization(guards = "!isNaRm(naRm)") protected RDoubleVector colMeansNaRmFalse(RDoubleVector x, int rowNum, int colNum, @SuppressWarnings("unused") byte naRm) { controlVisibility(); double[] result = new double[colNum]; @@ -67,7 +67,7 @@ public abstract class ColMeans extends RBuiltinNode { return RDataFactory.createDoubleVector(result, na.neverSeenNA() && isComplete); } - @Specialization(guards = "isNaRm") + @Specialization(guards = "isNaRm(naRm)") protected RDoubleVector colMeansNaRmTrue(RDoubleVector x, int rowNum, int colNum, @SuppressWarnings("unused") byte naRm) { controlVisibility(); double[] result = new double[colNum]; @@ -93,7 +93,7 @@ public abstract class ColMeans extends RBuiltinNode { return RDataFactory.createDoubleVector(result, isComplete); } - @Specialization(guards = "!isNaRm") + @Specialization(guards = "!isNaRm(naRm)") protected RDoubleVector colMeansNaRmFalse(RLogicalVector x, int rowNum, int colNum, @SuppressWarnings("unused") byte naRm) { controlVisibility(); double[] result = new double[colNum]; @@ -113,7 +113,7 @@ public abstract class ColMeans extends RBuiltinNode { return RDataFactory.createDoubleVector(result, na.neverSeenNA()); } - @Specialization(guards = "isNaRm") + @Specialization(guards = "isNaRm(naRm)") protected RDoubleVector colMeansNaRmTrue(RLogicalVector x, int rowNum, int colNum, @SuppressWarnings("unused") byte naRm) { controlVisibility(); double[] result = new double[colNum]; @@ -139,7 +139,7 @@ public abstract class ColMeans extends RBuiltinNode { return RDataFactory.createDoubleVector(result, isComplete); } - @Specialization(guards = "!isNaRm") + @Specialization(guards = "!isNaRm(naRm)") protected RDoubleVector colMeansNaRmFalse(RIntVector x, int rowNum, int colNum, @SuppressWarnings("unused") byte naRm) { controlVisibility(); double[] result = new double[colNum]; @@ -159,7 +159,7 @@ public abstract class ColMeans extends RBuiltinNode { return RDataFactory.createDoubleVector(result, na.neverSeenNA()); } - @Specialization(guards = "isNaRm") + @Specialization(guards = "isNaRm(naRm)") protected RDoubleVector colMeansNaRmTrue(RIntVector x, int rowNum, int colNum, @SuppressWarnings("unused") byte naRm) { controlVisibility(); double[] result = new double[colNum]; @@ -192,18 +192,8 @@ public abstract class ColMeans extends RBuiltinNode { throw RError.error(getEncapsulatingSourceSection(), RError.Message.X_NUMERIC); } - @SuppressWarnings("unused") - protected boolean isNaRm(RDoubleVector x, int rowNum, int colNum, byte naRm) { - return naRm == RRuntime.LOGICAL_TRUE; - } - - @SuppressWarnings("unused") - protected boolean isNaRm(RIntVector x, int rowNum, int colNum, byte naRm) { + protected boolean isNaRm(byte naRm) { return naRm == RRuntime.LOGICAL_TRUE; } - @SuppressWarnings("unused") - protected boolean isNaRm(RLogicalVector x, int rowNum, int colNum, byte naRm) { - return naRm == RRuntime.LOGICAL_TRUE; - } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java index 35334eb4e58b3c60ee738d3ed9e86c35b0f42949..f1f9b2a7883484384a5dce5a022cfc140b86d4e5 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java @@ -145,14 +145,14 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return (RLogicalVector) passVector(vector); } - @Specialization(guards = "!isNumericVersion") + @Specialization(guards = "!isNumericVersion(list)") protected RList pass(RList list) { return (RList) passVector(list); } private static final ArgumentsSignature SIGNATURE = ArgumentsSignature.get(new String[]{"..."}); - @Specialization(guards = "isNumericVersion") + @Specialization(guards = "isNumericVersion(list)") /** * A temporary specific hack for internal generic dispatch on "numeric_version" objects * which are {@link Rlist}s. @@ -197,73 +197,73 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return expr; } - @Specialization(guards = "noArgNames") + @Specialization(guards = "noArgNames()") protected int pass(int value) { controlVisibility(); return value; } - @Specialization(guards = "hasArgNames") + @Specialization(guards = "hasArgNames()") protected RIntVector passArgs(int value) { controlVisibility(); return RDataFactory.createIntVector(new int[]{value}, true, getSuppliedSignature().createVector()); } - @Specialization(guards = "noArgNames") + @Specialization(guards = "noArgNames()") protected double pass(double value) { controlVisibility(); return value; } - @Specialization(guards = "hasArgNames") + @Specialization(guards = "hasArgNames()") protected RDoubleVector passArgs(double value) { controlVisibility(); return RDataFactory.createDoubleVector(new double[]{value}, true, getSuppliedSignature().createVector()); } - @Specialization(guards = "noArgNames") + @Specialization(guards = "noArgNames()") protected byte pass(byte value) { controlVisibility(); return value; } - @Specialization(guards = "hasArgNames") + @Specialization(guards = "hasArgNames()") protected RLogicalVector passArgs(byte value) { controlVisibility(); return RDataFactory.createLogicalVector(new byte[]{value}, true, getSuppliedSignature().createVector()); } - @Specialization(guards = "noArgNames") + @Specialization(guards = "noArgNames()") protected String pass(String value) { controlVisibility(); return value; } - @Specialization(guards = "hasArgNames") + @Specialization(guards = "hasArgNames()") protected RStringVector passArgs(String value) { controlVisibility(); return RDataFactory.createStringVector(new String[]{value}, true, getSuppliedSignature().createVector()); } - @Specialization(guards = "noArgNames") + @Specialization(guards = "noArgNames()") protected RRaw pass(RRaw value) { controlVisibility(); return value; } - @Specialization(guards = "hasArgNames") + @Specialization(guards = "hasArgNames()") protected RRawVector passArgs(RRaw value) { controlVisibility(); return RDataFactory.createRawVector(new byte[]{value.getValue()}, getSuppliedSignature().createVector()); } - @Specialization(guards = "noArgNames") + @Specialization(guards = "noArgNames()") protected RComplex pass(RComplex value) { controlVisibility(); return value; } - @Specialization(guards = "hasArgNames") + @Specialization(guards = "hasArgNames()") protected RComplexVector passArgs(RComplex value) { controlVisibility(); return RDataFactory.createComplexVector(new double[]{value.getRealPart(), value.getImaginaryPart()}, true, getSuppliedSignature().createVector()); @@ -325,13 +325,13 @@ public abstract class Combine extends RPrecedenceBuiltinNode { } } - @Specialization(guards = "isNullPrecedence") + @Specialization(guards = "isNullPrecedence(frame, args)") protected RNull allNull(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); return RNull.instance; } - @Specialization(guards = {"!isNullPrecedence", "oneElement"}) + @Specialization(guards = {"!isNullPrecedence(frame, args)", "oneElement(args)"}) protected Object allOneElem(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); if (combineRecursive == null) { @@ -341,7 +341,7 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return combineRecursive.executeCombine(frame, args.getValues()[0]); } - @Specialization(guards = {"isLogicalPrecedence", "noArgNames", "!oneElement"}) + @Specialization(guards = {"isLogicalPrecedence(frame, args)", "noArgNames()", "!oneElement(args)"}) @ExplodeLoop protected Object allLogical(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); @@ -354,7 +354,7 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return current; } - @Specialization(guards = {"isLogicalPrecedence", "hasArgNames", "!oneElement"}) + @Specialization(guards = {"isLogicalPrecedence(frame, args)", "hasArgNames()", "!oneElement(args)"}) @ExplodeLoop protected Object allLogicalArgs(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); @@ -369,7 +369,7 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return current; } - @Specialization(guards = {"isIntegerPrecedence", "noArgNames", "!oneElement"}) + @Specialization(guards = {"isIntegerPrecedence(frame, args)", "noArgNames()", "!oneElement(args)"}) @ExplodeLoop protected Object allInt(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); @@ -382,7 +382,7 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return current; } - @Specialization(guards = {"isIntegerPrecedence", "hasArgNames", "!oneElement"}) + @Specialization(guards = {"isIntegerPrecedence(frame, args)", "hasArgNames()", "!oneElement(args)"}) @ExplodeLoop protected Object allIntArgs(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); @@ -397,7 +397,7 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return current; } - @Specialization(guards = {"isDoublePrecedence", "noArgNames", "!oneElement"}) + @Specialization(guards = {"isDoublePrecedence(frame, args)", "noArgNames()", "!oneElement(args)"}) @ExplodeLoop protected Object allDouble(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); @@ -410,7 +410,7 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return current; } - @Specialization(guards = {"isDoublePrecedence", "hasArgNames", "!oneElement"}) + @Specialization(guards = {"isDoublePrecedence(frame, args)", "hasArgNames()", "!oneElement(args)"}) @ExplodeLoop protected Object allDoubleArgs(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); @@ -425,7 +425,7 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return current; } - @Specialization(guards = {"isComplexPrecedence", "noArgNames", "!oneElement"}) + @Specialization(guards = {"isComplexPrecedence(frame, args)", "noArgNames()", "!oneElement(args)"}) @ExplodeLoop protected Object allComplex(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); @@ -438,7 +438,7 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return current; } - @Specialization(guards = {"isComplexPrecedence", "hasArgNames", "!oneElement"}) + @Specialization(guards = {"isComplexPrecedence(frame, args)", "hasArgNames()", "!oneElement(args)"}) @ExplodeLoop protected Object allComplexArgs(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); @@ -453,7 +453,7 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return current; } - @Specialization(guards = {"isStringPrecedence", "noArgNames", "!oneElement"}) + @Specialization(guards = {"isStringPrecedence(frame, args)", "noArgNames()", "!oneElement(args)"}) @ExplodeLoop protected Object allString(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); @@ -466,7 +466,7 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return current; } - @Specialization(guards = {"isStringPrecedence", "hasArgNames", "!oneElement"}) + @Specialization(guards = {"isStringPrecedence(frame, args)", "hasArgNames()", "!oneElement(args)"}) @ExplodeLoop protected Object allStringArgs(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); @@ -481,7 +481,7 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return current; } - @Specialization(guards = {"isRawPrecedence", "noArgNames", "!oneElement"}) + @Specialization(guards = {"isRawPrecedence(frame, args)", "noArgNames()", "!oneElement(args)"}) @ExplodeLoop protected Object allRaw(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); @@ -494,7 +494,7 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return current; } - @Specialization(guards = {"isRawPrecedence", "hasArgNames", "!oneElement"}) + @Specialization(guards = {"isRawPrecedence(frame, args)", "hasArgNames()", "!oneElement(args)"}) @ExplodeLoop protected Object allRawArgs(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); @@ -509,7 +509,7 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return current; } - @Specialization(guards = {"isListPrecedence", "noArgNames", "!oneElement"}) + @Specialization(guards = {"isListPrecedence(frame, args)", "noArgNames()", "!oneElement(args)"}) @ExplodeLoop protected Object list(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); @@ -522,7 +522,7 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return current; } - @Specialization(guards = {"isListPrecedence", "hasArgNames", "!oneElement"}) + @Specialization(guards = {"isListPrecedence(frame, args)", "hasArgNames()", "!oneElement(args)"}) protected Object listArgs(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); Object[] array = args.getValues(); @@ -544,7 +544,7 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return unwrapExpression.executeObject(frame, operand); } - @Specialization(guards = {"isExprPrecedence", "noArgNames", "!oneElement"}) + @Specialization(guards = {"isExprPrecedence(frame, args)", "noArgNames()", "!oneElement(args)"}) @ExplodeLoop protected Object expr(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); @@ -558,7 +558,7 @@ public abstract class Combine extends RPrecedenceBuiltinNode { return RDataFactory.createExpression(current); } - @Specialization(guards = {"isExprPrecedence", "hasArgNames", "!oneElement"}) + @Specialization(guards = {"isExprPrecedence(frame, args)", "hasArgNames()", "!oneElement(args)"}) protected Object exprArgs(VirtualFrame frame, RArgsValuesAndNames args) { controlVisibility(); Object[] array = args.getValues(); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Complex.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Complex.java index e1d12bc0ddd26611aa040c0e40e852d1eb572dca..d7d39b07f1c244139b68ed7cd4425f7f46bbd6b2 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Complex.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Complex.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 @@ -45,12 +45,12 @@ public abstract class Complex extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "resultEmpty") + @Specialization(guards = "resultEmpty(lengthOut, realAbsVec, imaginaryAbsVec)") protected RComplexVector complexEmpty(int lengthOut, RAbstractDoubleVector realAbsVec, RAbstractDoubleVector imaginaryAbsVec) { return RDataFactory.createEmptyComplexVector(); } - @Specialization(guards = "!resultEmpty") + @Specialization(guards = "!resultEmpty(lengthOut, realAbsVec, imaginaryAbsVec)") protected RComplexVector complex(int lengthOut, RAbstractDoubleVector realAbsVec, RAbstractDoubleVector imaginaryAbsVec) { controlVisibility(); RDoubleVector real = checkLength(realAbsVec); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ConnectionFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ConnectionFunctions.java index 2dce10284744228eeff93fd0b5cd62b3aaf1b279..85ae37371d2f637742785b79f1148175d1bd6120 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ConnectionFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ConnectionFunctions.java @@ -440,7 +440,7 @@ public abstract class ConnectionFunctions { } @SuppressWarnings("unused") - @Specialization(guards = "!newLineIsLogical") + @Specialization(guards = "!newLineIsLogical(newLine)") protected Object pushBack(RAbstractStringVector data, RConnection connection, RAbstractVector newLine, RAbstractIntVector type) { controlVisibility(); throw RError.error(RError.Message.INVALID_ARGUMENT, "newLine"); @@ -453,8 +453,7 @@ public abstract class ConnectionFunctions { throw RError.error(RError.Message.INVALID_CONNECTION); } - @SuppressWarnings("unused") - protected boolean newLineIsLogical(RAbstractStringVector data, RConnection connection, RAbstractVector newLine) { + protected boolean newLineIsLogical(RAbstractVector newLine) { return newLine.getElementClass() == RLogical.class; } @@ -499,20 +498,20 @@ public abstract class ConnectionFunctions { public abstract static class ReadChar extends InternalCloseHelper { @SuppressWarnings("unused") - @Specialization(guards = "ncharsEmpty") + @Specialization(guards = "ncharsEmpty(nchars)") protected RStringVector readCharNcharsEmpty(RConnection con, RAbstractIntVector nchars, RAbstractLogicalVector useBytes) { controlVisibility(); return RDataFactory.createEmptyStringVector(); } @SuppressWarnings("unused") - @Specialization(guards = "useBytesEmpty") + @Specialization(guards = "useBytesEmpty(useBytes)") protected RStringVector readCharUseBytesEmpty(RConnection con, RAbstractIntVector nchars, RAbstractLogicalVector useBytes) { controlVisibility(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_ARGUMENT, "useBytes"); } - @Specialization(guards = {"!ncharsEmpty", "!useBytesEmpty"}) + @Specialization(guards = {"!ncharsEmpty(nchars)", "!useBytesEmpty(useBytes)"}) @TruffleBoundary protected RStringVector readChar(RConnection con, RAbstractIntVector nchars, RAbstractLogicalVector useBytes) { controlVisibility(); @@ -527,12 +526,11 @@ public abstract class ConnectionFunctions { } } - boolean ncharsEmpty(@SuppressWarnings("unused") RConnection con, RAbstractIntVector nchars) { + boolean ncharsEmpty(RAbstractIntVector nchars) { return nchars.getLength() == 0; } - @SuppressWarnings("unused") - boolean useBytesEmpty(RConnection con, RAbstractIntVector nchars, RAbstractLogicalVector useBytes) { + boolean useBytesEmpty(RAbstractLogicalVector useBytes) { return useBytes.getLength() == 0; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CopyDFAttr.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CopyDFAttr.java index ddf61d023bb881d376b37ae854bbaf36c7caffad..6baec2b0f383b53fa93de6812724875376f6c9a4 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CopyDFAttr.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CopyDFAttr.java @@ -35,21 +35,21 @@ public abstract class CopyDFAttr extends RInvisibleBuiltinNode { private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - @Specialization(guards = "!isInDataFrame") + @Specialization(guards = "!isInDataFrame(in)") protected RAttributable copy(RAbstractContainer in, RAbstractVector out) { RVector res = out.materialize(); res.resetAllAttributes(false); return res.copyAttributesFrom(attrProfiles, in); } - @Specialization(guards = "!isInDataFrame") + @Specialization(guards = "!isInDataFrame(in)") protected RAttributable copy(RAbstractContainer in, RFactor out) { RVector res = out.getVector(); res.resetAllAttributes(false); return res.copyAttributesFrom(attrProfiles, in); } - @Specialization(guards = "!isInDataFrame") + @Specialization(guards = "!isInDataFrame(in)") protected RAttributable copy(RAbstractContainer in, RDataFrame out) { RVector res = out.getVector(); res.resetAllAttributes(false); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Crossprod.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Crossprod.java index 7a8de2a05591c0e2b9ab8af686a8c236c467adc8..b6f71e567d632de666e194d3c5f8847b52170940 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Crossprod.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Crossprod.java @@ -59,7 +59,7 @@ public abstract class Crossprod extends RBuiltinNode { return transpose.execute(frame, value); } - @Specialization(guards = {"isMatrix(arguments[0])", "isMatrix(arguments[1])"}) + @Specialization(guards = {"isMatrix(x)", "isMatrix(y)"}) protected RDoubleVector crossprod(RAbstractDoubleVector x, RAbstractDoubleVector y) { controlVisibility(); ensureMatMult(); @@ -96,7 +96,7 @@ public abstract class Crossprod extends RBuiltinNode { return matMult(frame, transpose(frame, x), y); } - @Specialization(guards = "isMatrix(arguments[0])") + @Specialization(guards = "isMatrix(x)") protected Object crossprodDoubleMatrix(RAbstractDoubleVector x, @SuppressWarnings("unused") RNull y) { controlVisibility(); ensureMatMult(); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Diag.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Diag.java index d97289f33f8e6b4b8c1e1785a76f4194c0f8d2b5..fb66f776bfb77f88802e7b4854c20f6f9c9dc5dc 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Diag.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Diag.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 @@ -101,7 +101,7 @@ public abstract class Diag extends RBuiltinNode { return dim(val, rows, rows); } - @Specialization(guards = "isMatrix") + @Specialization(guards = "isMatrix(vector)") protected RIntVector dimWithDimensions(RIntVector vector, Object rows, Object cols) { controlVisibility(); int size = Math.min(vector.getDimensions()[0], vector.getDimensions()[1]); @@ -118,7 +118,7 @@ public abstract class Diag extends RBuiltinNode { return RDataFactory.createIntVector(result, check.neverSeenNA()); } - @Specialization(guards = "isMatrix") + @Specialization(guards = "isMatrix(vector)") protected RDoubleVector dimWithDimensions(RDoubleVector vector, Object rows, Object cols) { controlVisibility(); int size = Math.min(vector.getDimensions()[0], vector.getDimensions()[1]); @@ -135,11 +135,11 @@ public abstract class Diag extends RBuiltinNode { return RDataFactory.createDoubleVector(result, check.neverSeenNA()); } - public static boolean isMatrix(RIntVector vector, Object rows, Object cols) { + public static boolean isMatrix(RIntVector vector) { return vector.hasDimensions() && vector.getDimensions().length == 2; } - public static boolean isMatrix(RDoubleVector vector, Object rows, Object cols) { + public static boolean isMatrix(RDoubleVector vector) { return vector.hasDimensions() && vector.getDimensions().length == 2; } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Dim.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Dim.java index b701f445f1c83b71e29cb7ed940ddaf024619fd9..61ec72e8da95982e9ef122bbba45a70452f880a3 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Dim.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Dim.java @@ -81,19 +81,19 @@ public abstract class Dim extends RBuiltinNode { return RNull.instance; } - @Specialization(guards = {"!isObject", "!hasDimensions"}) - protected RNull dim(RAbstractContainer container) { + @Specialization(guards = {"!isObject(frame, container)", "!hasDimensions(container)"}) + protected RNull dim(VirtualFrame frame, RAbstractContainer container) { controlVisibility(); return RNull.instance; } - @Specialization(guards = {"!isObject", "hasDimensions"}) - protected Object dimWithDimensions(RAbstractContainer container) { + @Specialization(guards = {"!isObject(frame, container)", "hasDimensions(container)"}) + protected Object dimWithDimensions(VirtualFrame frame, RAbstractContainer container) { controlVisibility(); return RDataFactory.createIntVector(container.getDimensions(), RDataFactory.COMPLETE_VECTOR); } - @Specialization(guards = "isObject") + @Specialization(guards = "isObject(frame, container)") protected Object dimObject(VirtualFrame frame, RAbstractContainer container) { controlVisibility(); if (dcn == null) { @@ -103,7 +103,7 @@ public abstract class Dim extends RBuiltinNode { try { return dcn.executeInternal(frame, container.getClassHierarchy(), new Object[]{container}); } catch (NoGenericMethodException e) { - return hasDimensions(container) ? dimWithDimensions(container) : RNull.instance; + return hasDimensions(container) ? dimWithDimensions(frame, container) : RNull.instance; } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DimNames.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DimNames.java index 36f1b492a5f9ebbe06795c65bee9b3b5cda24702..a4880dd23caed4b5f7830564447233dd8b159214 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DimNames.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DimNames.java @@ -51,19 +51,20 @@ public abstract class DimNames extends RBuiltinNode { return operand; } - @Specialization(guards = {"!isNull", "!isObject"}) - protected RList getDimNames(RAbstractContainer container) { + @Specialization(guards = {"!isNull(container)", "!isObject(frame, container)"}) + protected RList getDimNames(@SuppressWarnings("unused") VirtualFrame frame, RAbstractContainer container) { controlVisibility(); return container.getDimNames(); } - @Specialization(guards = {"isNull", "!isObject"}) - protected RNull getDimNamesNull(@SuppressWarnings("unused") RAbstractContainer vector) { + @Specialization(guards = {"isNull(vector)", "!isObject(frame, vector)"}) + @SuppressWarnings("unused") + protected RNull getDimNamesNull(VirtualFrame frame, RAbstractContainer vector) { controlVisibility(); return RNull.instance; } - @Specialization(guards = "isObject") + @Specialization(guards = "isObject(frame, container)") protected Object getDimNamesOnject(VirtualFrame frame, RAbstractContainer container) { controlVisibility(); if (dcn == null) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DoCall.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DoCall.java index b2f59f522526ed728066f07bc3bba67ab708aa79..a2b0c615648653748023e13a174dd66ec56b4c50 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DoCall.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DoCall.java @@ -49,7 +49,7 @@ public abstract class DoCall extends RBuiltinNode { private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - @Specialization(guards = "lengthOne") + @Specialization(guards = "fname.getLength() == 1") protected Object doDoCall(VirtualFrame frame, RAbstractStringVector fname, RList argsAsList, REnvironment env) { if (getNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -80,7 +80,4 @@ public abstract class DoCall extends RBuiltinNode { return callCache.execute(frame, func.getTarget(), callArgs); } - public static boolean lengthOne(RAbstractStringVector vec) { - return vec.getLength() == 1; - } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DuplicatedFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DuplicatedFunctions.java index b3acdca802482ac0b388e0d705a5f25ea5d68b18..dd663c9f5bc8362ad031d93b88db705d877b34ac 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DuplicatedFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DuplicatedFunctions.java @@ -98,8 +98,7 @@ public class DuplicatedFunctions { return ds; } - @SuppressWarnings("unused") - protected boolean isIncomparable(RAbstractContainer x, byte incomparables, byte fromLast) { + protected boolean isIncomparable(byte incomparables) { return incomparables == RRuntime.LOGICAL_TRUE; } @@ -132,28 +131,28 @@ public class DuplicatedFunctions { return RDataFactory.createLogicalVector(ds.dupVec, RDataFactory.COMPLETE_VECTOR); } - @Specialization(guards = {"!isIncomparable", "!empty"}) + @Specialization(guards = {"!isIncomparable(incomparables)", "!empty(x)"}) protected RLogicalVector duplicatedFalseIncomparables(RAbstractVector x, @SuppressWarnings("unused") byte incomparables, byte fromLast, @SuppressWarnings("unused") int nmax) { return analyzeAndCreateResult(x, null, fromLast); } - @Specialization(guards = {"isIncomparable", "!empty"}) + @Specialization(guards = {"isIncomparable(incomparables)", "!empty(x)"}) protected RLogicalVector duplicatedTrueIncomparables(VirtualFrame frame, RAbstractVector x, byte incomparables, byte fromLast, @SuppressWarnings("unused") int nmax) { initChildren(); - RType xType = typeof.execute(frame, x); + RType xType = typeof.execute(x); RAbstractVector vector = (RAbstractVector) (castTypeNode.execute(frame, incomparables, xType)); return analyzeAndCreateResult(x, vector, fromLast); } - @Specialization(guards = {"!empty"}) + @Specialization(guards = {"!empty(x)"}) protected RLogicalVector duplicated(VirtualFrame frame, RAbstractContainer x, RAbstractContainer incomparables, byte fromLast, @SuppressWarnings("unused") int nmax) { initChildren(); - RType xType = typeof.execute(frame, x); + RType xType = typeof.execute(x); return analyzeAndCreateResult(x, (RAbstractContainer) (castTypeNode.execute(frame, incomparables, xType)), fromLast); } @SuppressWarnings("unused") - @Specialization(guards = "empty") + @Specialization(guards = "empty(x)") protected RLogicalVector duplicatedEmpty(RAbstractContainer x, RAbstractContainer incomparables, byte fromLast, int nmax) { return RDataFactory.createLogicalVector(0); } @@ -170,28 +169,28 @@ public class DuplicatedFunctions { } @SuppressWarnings("unused") - @Specialization(guards = {"!isIncomparable", "!empty"}) + @Specialization(guards = {"!isIncomparable(incomparables)", "!empty(x)"}) protected int anyDuplicatedFalseIncomparables(RAbstractVector x, byte incomparables, byte fromLast) { return analyze(x, null, true, RRuntime.fromLogical(fromLast)).index; } - @Specialization(guards = {"isIncomparable", "!empty"}) + @Specialization(guards = {"isIncomparable(incomparables)", "!empty(x)"}) protected int anyDuplicatedTrueIncomparables(VirtualFrame frame, RAbstractVector x, byte incomparables, byte fromLast) { initChildren(); - RType xType = typeof.execute(frame, x); + RType xType = typeof.execute(x); RAbstractVector vector = (RAbstractVector) (castTypeNode.execute(frame, incomparables, xType)); return analyze(x, vector, true, RRuntime.fromLogical(fromLast)).index; } - @Specialization(guards = {"!empty"}) + @Specialization(guards = {"!empty(x)"}) protected int anyDuplicated(VirtualFrame frame, RAbstractContainer x, RAbstractContainer incomparables, byte fromLast) { initChildren(); - RType xType = typeof.execute(frame, x); + RType xType = typeof.execute(x); return analyze(x, (RAbstractContainer) (castTypeNode.execute(frame, incomparables, xType)), true, RRuntime.fromLogical(fromLast)).index; } @SuppressWarnings("unused") - @Specialization(guards = "empty") + @Specialization(guards = "empty(x)") protected int anyDuplicatedEmpty(RAbstractContainer x, RAbstractContainer incomparables, byte fromLast) { return 0; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DynLoadFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DynLoadFunctions.java index 3d44bdc04e75264443552a47128976c46a80bf4b..22e697e1b77f39e20b2b7623ecf0f2ec53c3ebf9 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DynLoadFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DynLoadFunctions.java @@ -126,7 +126,7 @@ public class DynLoadFunctions { return getResult(symbolInfo, withReg); } - @Specialization(guards = "isDLLInfo") + @Specialization(guards = "isDLLInfo(externalPtr)") @TruffleBoundary protected Object getSymbolInfo(String symbol, RExternalPtr externalPtr, byte withReg) { controlVisibility(); @@ -152,7 +152,7 @@ public class DynLoadFunctions { throw RError.error(getEncapsulatingSourceSection(), RError.Message.REQUIRES_NAME_DLLINFO); } - public static boolean isDLLInfo(@SuppressWarnings("unused") String symbol, RExternalPtr externalPtr) { + public static boolean isDLLInfo(RExternalPtr externalPtr) { return DLL.isDLLInfo(externalPtr); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EncodeString.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EncodeString.java index 86d77db8ebb79a43bc7cb1e691234f62db055e66..9ea7ab9fc494cfecb39f7bd49a3eb1ec3c173b20 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EncodeString.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EncodeString.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2014, Purdue University - * Copyright (c) 2014, Oracle and/or its affiliates + * Copyright (c) 2014, 2015, Oracle and/or its affiliates * * All rights reserved. */ @@ -85,7 +85,7 @@ public abstract class EncodeString extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = {"isValidWidth", "leftJustify", "isEncodeNA"}) + @Specialization(guards = {"isValidWidth(width)", "leftJustify(justify)", "isEncodeNA(encodeNA)"}) protected RStringVector encodeStringLeftJustifyEncodeNA(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { final String quoteEl = quote.getDataAt(0); final int maxElWidth = computeWidth(x, width, quoteEl); @@ -107,7 +107,7 @@ public abstract class EncodeString extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = {"isValidWidth", "leftJustify", "!isEncodeNA"}) + @Specialization(guards = {"isValidWidth(width)", "leftJustify(justify)", "!isEncodeNA(encodeNA)"}) protected RStringVector encodeStringLeftJustify(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { final String quoteEl = quote.getDataAt(0); final int maxElWidth = computeWidth(x, width, quoteEl); @@ -128,7 +128,7 @@ public abstract class EncodeString extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = {"isValidWidth", "rightJustify", "isEncodeNA"}) + @Specialization(guards = {"isValidWidth(width)", "rightJustify(justify)", "isEncodeNA(encodeNA)"}) protected RStringVector encodeStringRightJustifyEncodeNA(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { final String quoteEl = quote.getDataAt(0); final int maxElWidth = computeWidth(x, width, quoteEl); @@ -150,7 +150,7 @@ public abstract class EncodeString extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = {"isValidWidth", "rightJustify", "!isEncodeNA"}) + @Specialization(guards = {"isValidWidth(width)", "rightJustify(justify)", "!isEncodeNA(encodeNA)"}) protected RStringVector encodeStringRightJustify(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { final String quoteEl = quote.getDataAt(0); final int maxElWidth = computeWidth(x, width, quoteEl); @@ -171,7 +171,7 @@ public abstract class EncodeString extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = {"isValidWidth", "centerJustify", "isEncodeNA"}) + @Specialization(guards = {"isValidWidth(width)", "centerJustify(justify)", "isEncodeNA(encodeNA)"}) protected RStringVector encodeStringCenterJustifyEncodeNA(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { final String quoteEl = quote.getDataAt(0); final int maxElWidth = computeWidth(x, width, quoteEl); @@ -200,7 +200,7 @@ public abstract class EncodeString extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = {"isValidWidth", "centerJustify", "!isEncodeNA"}) + @Specialization(guards = {"isValidWidth(width)", "centerJustify(justify)", "!isEncodeNA(encodeNA)"}) protected RStringVector encodeStringCenterJustify(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { final String quoteEl = quote.getDataAt(0); final int maxElWidth = computeWidth(x, width, quoteEl); @@ -267,7 +267,7 @@ public abstract class EncodeString extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = {"isValidWidth", "noJustify", "isEncodeNA"}) + @Specialization(guards = {"isValidWidth(width)", "noJustify(width, justify)", "isEncodeNA(encodeNA)"}) protected RStringVector encodeStringNoJustifyEncodeNA(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { final String quoteEl = quote.getDataAt(0); final String[] result = new String[x.getLength()]; @@ -285,7 +285,7 @@ public abstract class EncodeString extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = {"isValidWidth", "noJustify", "!isEncodeNA"}) + @Specialization(guards = {"isValidWidth(width)", "noJustify(width, justify)", "!isEncodeNA(encodeNA)"}) protected RStringVector encodeStringNoJustify(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { final String quoteEl = quote.getDataAt(0); final String[] result = new String[x.getLength()]; @@ -305,82 +305,72 @@ public abstract class EncodeString extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "!isString") + @Specialization(guards = "!isString(x)") protected RStringVector encodeStringInvalidFirstArgument(Object x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.CHAR_VEC_ARGUMENT); } @SuppressWarnings("unused") - @Specialization(guards = "!isValidWidth") + @Specialization(guards = "!isValidWidth(width)") protected RStringVector encodeStringInvalidWidth(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_VALUE, "width"); } @SuppressWarnings("unused") - @Specialization(guards = "!isValidQuote") + @Specialization(guards = "!isValidQuote(quote)") protected RStringVector encodeStringInvalidQuote(RAbstractStringVector x, int width, Object quote, RAbstractIntVector justify, byte encodeNA) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_VALUE, "quote"); } @SuppressWarnings("unused") - @Specialization(guards = "!isValidJustify") + @Specialization(guards = "!isValidJustify(justify)") protected RStringVector encodeStringInvalidJustify(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_VALUE, "justify"); } @SuppressWarnings("unused") - @Specialization(guards = "!isValidEncodeNA") + @Specialization(guards = "!isValidEncodeNA(encodeNA)") protected RStringVector encodeStringInvalidEncodeNA(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_VALUE, "na.encode"); } - @SuppressWarnings("unused") - protected boolean isString(Object x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { + protected boolean isString(Object x) { return x.getClass() == String.class || x.getClass() == RStringVector.class; } - @SuppressWarnings("unused") - protected boolean isValidWidth(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { + protected boolean isValidWidth(int width) { return RRuntime.isNA(width) || width >= 0; } - @SuppressWarnings("unused") - protected boolean isValidQuote(RAbstractStringVector x, int width, Object quote, RAbstractIntVector justify, byte encodeNA) { + protected boolean isValidQuote(Object quote) { return quote.getClass() == String.class || (quote.getClass() == RStringVector.class && ((RStringVector) quote).getLength() == 1); } - @SuppressWarnings("unused") - protected boolean isValidJustify(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { + protected boolean isValidJustify(RAbstractIntVector justify) { return justify.getDataAt(0) >= JUSTIFY.LEFT.ordinal() && justify.getDataAt(0) <= JUSTIFY.NONE.ordinal(); } - @SuppressWarnings("unused") - protected boolean isValidEncodeNA(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { + protected boolean isValidEncodeNA(byte encodeNA) { return !RRuntime.isNA(encodeNA); } - @SuppressWarnings("unused") - protected boolean isEncodeNA(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { + protected boolean isEncodeNA(byte encodeNA) { return RRuntime.fromLogical(encodeNA); } - @SuppressWarnings("unused") - protected boolean leftJustify(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { + protected boolean leftJustify(RAbstractIntVector justify) { return justify.getDataAt(0) == JUSTIFY.LEFT.ordinal(); } - @SuppressWarnings("unused") - protected boolean rightJustify(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { + protected boolean rightJustify(RAbstractIntVector justify) { return justify.getDataAt(0) == JUSTIFY.RIGHT.ordinal(); } - @SuppressWarnings("unused") - protected boolean centerJustify(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { + protected boolean centerJustify(RAbstractIntVector justify) { return justify.getDataAt(0) == JUSTIFY.CENTER.ordinal(); } - @SuppressWarnings("unused") - protected boolean noJustify(RAbstractStringVector x, int width, RAbstractStringVector quote, RAbstractIntVector justify, byte encodeNA) { + protected boolean noJustify(int width, RAbstractIntVector justify) { return justify.getDataAt(0) == JUSTIFY.NONE.ordinal() || width == 0; } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FileFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FileFunctions.java index e80118e294c63c5cdb08209d3fc4993eff6aadb9..aac07e22f7c58843cce19f2eccec90ed4b51746f 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FileFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FileFunctions.java @@ -593,13 +593,13 @@ public class FileFunctions { } @SuppressWarnings("unused") - @Specialization(guards = "lengthZero") + @Specialization(guards = "lengthZero(vec)") @TruffleBoundary protected RStringVector doFilePathZero(RList vec, RAbstractStringVector fsep) { return RDataFactory.createEmptyStringVector(); } - @Specialization(guards = "!lengthZero") + @Specialization(guards = "!lengthZero(args)") protected RStringVector doFilePath(VirtualFrame frame, RList args, RAbstractStringVector fsepVec) { Object[] argValues = args.getDataWithoutCopying(); int resultLength = 0; @@ -648,7 +648,7 @@ public class FileFunctions { return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR); } - public static boolean lengthZero(RList list, @SuppressWarnings("unused") RAbstractStringVector fsep) { + public static boolean lengthZero(RList list) { if (list.getLength() == 0) { return true; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ForeignFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ForeignFunctions.java index 2144fd65cd00bd2e55d6ddefee3eb82c297fdf17..070cf6c38ae5344e96293097fdba5e320bf36b99 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ForeignFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ForeignFunctions.java @@ -85,7 +85,7 @@ public class ForeignFunctions { private static final RStringVector DQRDC2_NAMES = RDataFactory.createStringVector(new String[]{"qr", E, E, E, E, "rank", "qraux", "pivot", E}, RDataFactory.COMPLETE_VECTOR); @SuppressWarnings("unused") - @Specialization(guards = "dqrdc2") + @Specialization(guards = "dqrdc2(f)") protected RList fortranDqrdc2(RList f, RArgsValuesAndNames args, byte naok, byte dup, RMissing rPackage, RMissing encoding) { controlVisibility(); Object[] argValues = args.getValues(); @@ -128,7 +128,7 @@ public class ForeignFunctions { private static final RStringVector DQRCF_NAMES = RDataFactory.createStringVector(new String[]{E, E, E, E, E, E, "coef", "info"}, RDataFactory.COMPLETE_VECTOR); @SuppressWarnings("unused") - @Specialization(guards = "dqrcf") + @Specialization(guards = "dqrcf(f)") protected RList fortranDqrcf(RList f, RArgsValuesAndNames args, byte naok, byte dup, RMissing rPackage, RMissing encoding) { controlVisibility(); Object[] argValues = args.getValues(); @@ -304,7 +304,7 @@ public class ForeignFunctions { // TODO: handle more argument types (this is sufficient to run the b25 benchmarks) @SuppressWarnings("unused") - @Specialization(guards = "fft") + @Specialization(guards = "fft(f)") protected RComplexVector callFFT(VirtualFrame frame, RList f, RArgsValuesAndNames args, RMissing packageName) { controlVisibility(); Object[] argValues = args.getValues(); @@ -373,7 +373,7 @@ public class ForeignFunctions { } @SuppressWarnings("unused") - @Specialization(guards = "initMethodDispatch") + @Specialization(guards = "initMethodDispatch(f)") @TruffleBoundary protected REnvironment initMethodDispatch(RList f, RArgsValuesAndNames args, RMissing packageName) { controlVisibility(); @@ -389,7 +389,7 @@ public class ForeignFunctions { @SuppressWarnings("unused") @TruffleBoundary - @Specialization(guards = "methodsPackageMetaName") + @Specialization(guards = "methodsPackageMetaName(f)") protected String callMethodsPackageMetaName(RList f, RArgsValuesAndNames args, RMissing packageName) { controlVisibility(); Object[] argValues = args.getValues(); @@ -406,7 +406,7 @@ public class ForeignFunctions { @SuppressWarnings("unused") @TruffleBoundary - @Specialization(guards = "getClassFromCache") + @Specialization(guards = "getClassFromCache(f)") protected Object callGetClassFromCache(RList f, RArgsValuesAndNames args, RMissing packageName) { controlVisibility(); Object[] argValues = args.getValues(); @@ -425,7 +425,7 @@ public class ForeignFunctions { @SuppressWarnings("unused") @TruffleBoundary - @Specialization(guards = "setMethodDispatch") + @Specialization(guards = "setMethodDispatch(f)") protected Object callSetMethodDispatch(RList f, RArgsValuesAndNames args, RMissing packageName) { controlVisibility(); Object[] argValues = args.getValues(); @@ -458,7 +458,7 @@ public class ForeignFunctions { } @SuppressWarnings("unused") - @Specialization(guards = "isFlushconsole") + @Specialization(guards = "isFlushconsole(f)") protected RNull flushConsole(RList f, RArgsValuesAndNames args, RMissing packageName) { return RNull.instance; } @@ -468,7 +468,7 @@ public class ForeignFunctions { } @SuppressWarnings("unused") - @Specialization(guards = "isCrc64") + @Specialization(guards = "isCrc64(f)") protected String crc64(RList f, RArgsValuesAndNames args, RMissing packageName) { Object[] argValues = args.getValues(); String input = RRuntime.asString(argValues[0]); @@ -480,7 +480,7 @@ public class ForeignFunctions { } @SuppressWarnings("unused") - @Specialization(guards = "isMenu") + @Specialization(guards = "isMenu(f)") @TruffleBoundary protected int menu(RList f, RArgsValuesAndNames args, RMissing packageName) { Object[] values = args.getValues(); @@ -500,7 +500,7 @@ public class ForeignFunctions { } @SuppressWarnings("unused") - @Specialization(guards = "isCairoProps") + @Specialization(guards = "isCairoProps(f)") protected byte cairoProps(RList f, RArgsValuesAndNames args, RMissing packageName) { return RRuntime.LOGICAL_FALSE; } @@ -510,7 +510,7 @@ public class ForeignFunctions { } @SuppressWarnings("unused") - @Specialization(guards = "isMakeQuartzDefault") + @Specialization(guards = "isMakeQuartzDefault(f)") protected byte makeQuartzDefault(RList f, RArgsValuesAndNames args, RMissing packageName) { return RRuntime.LOGICAL_FALSE; } @@ -519,7 +519,7 @@ public class ForeignFunctions { return matchName(f, "makeQuartzDefault"); } - @Specialization(guards = "isCor") + @Specialization(guards = "isCor(f)") protected Object doCor(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { return doCovCor(frame, false, args); } @@ -528,7 +528,7 @@ public class ForeignFunctions { return matchName(f, "cor"); } - @Specialization(guards = "isCov") + @Specialization(guards = "isCov(f)") protected Object doCov(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { return doCovCor(frame, true, args); } @@ -555,7 +555,7 @@ public class ForeignFunctions { } - @Specialization(guards = "isSplineCoef") + @Specialization(guards = "isSplineCoef(f)") protected RList splineCoef(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { Object[] argValues = args.getValues(); int method = castInt(frame, castVector(frame, argValues[0])); @@ -568,7 +568,7 @@ public class ForeignFunctions { return matchName(f, "SplineCoef"); } - @Specialization(guards = "isSplineEval") + @Specialization(guards = "isSplineEval(f)") protected RDoubleVector splineEval(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { Object[] argValues = args.getValues(); RDoubleVector xout = (RDoubleVector) castVector(frame, argValues[0]); @@ -694,7 +694,7 @@ public class ForeignFunctions { // Transcribed from GnuR, library/utils/src/io.c @SuppressWarnings("unused") - @Specialization(guards = "isCountFields") + @Specialization(guards = "isCountFields(f)") protected Object countFields(VirtualFrame frame, RList f, RArgsValuesAndNames args, RMissing packageName) { controlVisibility(); Object[] argValues = args.getValues(); @@ -756,7 +756,7 @@ public class ForeignFunctions { return matchName(f, "countfields"); } - @Specialization(guards = "isReadTableHead") + @Specialization(guards = "isReadTableHead(f)") protected Object doReadTableHead(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { // TODO This is quite incomplete and just uses readLines, which works for some inputs controlVisibility(); @@ -775,7 +775,7 @@ public class ForeignFunctions { return matchName(f, "readtablehead"); } - @Specialization(guards = "isRnorm") + @Specialization(guards = "isRnorm(f)") protected Object doRnorm(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { controlVisibility(); Object[] argValues = args.getValues(); @@ -790,7 +790,7 @@ public class ForeignFunctions { return matchName(f, "rnorm"); } - @Specialization(guards = "isRunif") + @Specialization(guards = "isRunif(f)") protected Object doRunif(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { controlVisibility(); Object[] argValues = args.getValues(); @@ -805,7 +805,7 @@ public class ForeignFunctions { return matchName(f, "runif"); } - @Specialization(guards = "isQgamma") + @Specialization(guards = "isQgamma(f)") protected RDoubleVector doQgamma(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { controlVisibility(); Object[] argValues = args.getValues(); @@ -832,7 +832,7 @@ public class ForeignFunctions { private final BranchProfile errorProfile = BranchProfile.create(); // Transcribed from GnuR, library/utils/src/io.c - @Specialization(guards = "isWriteTable") + @Specialization(guards = "isWriteTable(f)") protected Object doWriteTable(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args) { controlVisibility(); Object[] argValues = args.getValues(); @@ -920,7 +920,7 @@ public class ForeignFunctions { } @TruffleBoundary - @Specialization(guards = "isTypeConvert") + @Specialization(guards = "isTypeConvert(f)") protected Object doTypeConvert(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args) { controlVisibility(); Object[] argValues = args.getValues(); @@ -936,7 +936,7 @@ public class ForeignFunctions { } @TruffleBoundary - @Specialization(guards = "isPar") + @Specialization(guards = "isPar(f)") protected Object doPar(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args) { controlVisibility(); return GraphicsCCalls.par(args); @@ -950,7 +950,7 @@ public class ForeignFunctions { @RBuiltin(name = ".External.graphics", kind = RBuiltinKind.PRIMITIVE, parameterNames = {".NAME", "..."}) public abstract static class DotExternalGraphics extends CastAdapter { @TruffleBoundary - @Specialization(guards = "isPlotXY") + @Specialization(guards = "isPlotXY(f)") protected RNull doPlotXY(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args) { controlVisibility(); GraphicsCCalls.plotXy((RDoubleVector) args.getValues()[0]); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Format.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Format.java index 099ce2f11e6c88158875fd1afa7916fe35cf1064..bdfe24167f01a418645ac855ac4782d958f06b80 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Format.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Format.java @@ -90,7 +90,7 @@ public abstract class Format extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "wrongArgsObject") + @Specialization(guards = "wrongArgsObject(trimVec, digitsVec, nsmallVec, widthVec, justifyVec, naEncodeVec, sciVec)") protected String formatWrongArgs(Object value, RLogicalVector trimVec, RIntVector digitsVec, RIntVector nsmallVec, RIntVector widthVec, RIntVector justifyVec, RLogicalVector naEncodeVec, RLogicalVector sciVec) { return null; @@ -111,7 +111,7 @@ public abstract class Format extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "!wrongArgs") + @Specialization(guards = "!wrongArgs(trimVec, digitsVec, nsmallVec, widthVec, justifyVec, naEncodeVec, sciVec)") protected RStringVector format(VirtualFrame frame, RAbstractLogicalVector value, RLogicalVector trimVec, RIntVector digitsVec, RIntVector nsmallVec, RIntVector widthVec, RIntVector justifyVec, RLogicalVector naEncodeVec, RAbstractVector sciVec) { if (value.getLength() == 0) { @@ -167,7 +167,7 @@ public abstract class Format extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "!wrongArgs") + @Specialization(guards = "!wrongArgs(trimVec, digitsVec, nsmallVec, widthVec, justifyVec, naEncodeVec, sciVec)") protected RStringVector format(RAbstractIntVector value, RLogicalVector trimVec, RIntVector digitsVec, RIntVector nsmallVec, RIntVector widthVec, RIntVector justifyVec, RLogicalVector naEncodeVec, RAbstractVector sciVec) { if (value.getLength() == 0) { @@ -229,7 +229,7 @@ public abstract class Format extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "!wrongArgs") + @Specialization(guards = "!wrongArgs(trimVec, digitsVec, nsmallVec, widthVec, justifyVec, naEncodeVec, sciVec)") protected RStringVector format(VirtualFrame frame, RAbstractDoubleVector value, RLogicalVector trimVec, RIntVector digitsVec, RIntVector nsmallVec, RIntVector widthVec, RIntVector justifyVec, RLogicalVector naEncodeVec, RAbstractVector sciVec) { byte trim = trimVec.getLength() > 0 ? trimVec.getDataAt(0) : RRuntime.LOGICAL_NA; @@ -248,22 +248,21 @@ public abstract class Format extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "!wrongArgs") + @Specialization(guards = "!wrongArgs(trimVec, digitsVec, nsmallVec, widthVec, justifyVec, naEncodeVec, sciVec)") protected RStringVector format(RStringVector value, RLogicalVector trimVec, RIntVector digitsVec, RIntVector nsmallVec, RIntVector widthVec, RIntVector justifyVec, RLogicalVector naEncodeVec, RAbstractVector sciVec) { // TODO: implement full semantics return value; } - @Specialization(guards = "!wrongArgs") + @Specialization(guards = "!wrongArgs(trimVec, digitsVec, nsmallVec, widthVec, justifyVec, naEncodeVec, sciVec)") protected RStringVector format(RFactor value, RLogicalVector trimVec, RIntVector digitsVec, RIntVector nsmallVec, RIntVector widthVec, RIntVector justifyVec, RLogicalVector naEncodeVec, RAbstractVector sciVec) { return format(value.getVector(), trimVec, digitsVec, nsmallVec, widthVec, justifyVec, naEncodeVec, sciVec); } // TruffleDSL bug - should not need multiple guards here - protected boolean wrongArgsObject(@SuppressWarnings("unused") Object value, RLogicalVector trimVec, RIntVector digitsVec, RIntVector nsmallVec, RIntVector widthVec, RIntVector justifyVec, - RLogicalVector naEncodeVec, RAbstractVector sciVec) { + protected boolean wrongArgsObject(RLogicalVector trimVec, RIntVector digitsVec, RIntVector nsmallVec, RIntVector widthVec, RIntVector justifyVec, RLogicalVector naEncodeVec, RAbstractVector sciVec) { if (trimVec.getLength() > 0 && RRuntime.isNA(trimVec.getDataAt(0))) { errorProfile.enter(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_ARGUMENT, "trim"); @@ -295,9 +294,8 @@ public abstract class Format extends RBuiltinNode { return false; } - protected boolean wrongArgs(RAbstractContainer value, RLogicalVector trimVec, RIntVector digitsVec, RIntVector nsmallVec, RIntVector widthVec, RIntVector justifyVec, RLogicalVector naEncodeVec, - RAbstractVector sciVec) { - return wrongArgsObject(value, trimVec, digitsVec, nsmallVec, widthVec, justifyVec, naEncodeVec, sciVec); + protected boolean wrongArgs(RLogicalVector trimVec, RIntVector digitsVec, RIntVector nsmallVec, RIntVector widthVec, RIntVector justifyVec, RLogicalVector naEncodeVec, RAbstractVector sciVec) { + return wrongArgsObject(trimVec, digitsVec, nsmallVec, widthVec, justifyVec, naEncodeVec, sciVec); } public static class Config { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GetClass.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GetClass.java index 8b154e77fa3e627444ccf4dfbf4af7a87244fad7..f103fd9bae602c077d2280cb47aef1e194b37480 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GetClass.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GetClass.java @@ -26,13 +26,13 @@ public abstract class GetClass extends RBuiltinNode { private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - @Specialization(guards = {"isObject", "!isLanguage", "!isExpression"}) + @Specialization(guards = {"isObject(arg)", "!isLanguage(arg)", "!isExpression(arg)"}) protected Object getClassForObject(RAbstractContainer arg) { controlVisibility(); return arg.getClassHierarchy(); } - @Specialization(guards = {"!isObject", "!isLanguage", "!isExpression"}) + @Specialization(guards = {"!isObject(arg)", "!isLanguage(arg)", "!isExpression(arg)"}) protected Object getClass(RAbstractContainer arg) { controlVisibility(); final String klass = arg.getClassHierarchy().getDataAt(0); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GetFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GetFunctions.java index 5b691280efba46da91fe41ffde1d60ca3be45a65..2d7499a08466d1775ef5890bdda32a9b9c5a8546 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GetFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GetFunctions.java @@ -72,18 +72,17 @@ public class GetFunctions { public abstract Object execute(VirtualFrame frame, RAbstractStringVector name, REnvironment envir, String mode, byte inherits); - @SuppressWarnings("unused") - public static boolean isInherits(RAbstractStringVector x, REnvironment envir, String mode, byte inherits) { + public static boolean isInherits(byte inherits) { return inherits == RRuntime.LOGICAL_TRUE; } - @Specialization(guards = "!isInherits") + @Specialization(guards = "!isInherits(inherits)") protected Object getNonInherit(VirtualFrame frame, RAbstractStringVector xv, REnvironment envir, String mode, @SuppressWarnings("unused") byte inherits) { controlVisibility(); return getAndCheck(frame, xv, envir, mode, true); } - @Specialization(guards = "isInherits") + @Specialization(guards = "isInherits(inherits)") protected Object getInherit(VirtualFrame frame, RAbstractStringVector xv, REnvironment envir, String mode, @SuppressWarnings("unused") byte inherits) { controlVisibility(); Object r = getAndCheck(frame, xv, envir, mode, false); @@ -131,8 +130,7 @@ public class GetFunctions { @CompilationFinal private boolean needsCallerFrame; - @SuppressWarnings("unused") - public static boolean isInherits(RStringVector xv, REnvironment envir, RAbstractStringVector mode, RList ifNotFound, byte inherits) { + public static boolean isInherits(byte inherits) { return inherits == RRuntime.LOGICAL_TRUE; } @@ -184,7 +182,7 @@ public class GetFunctions { } - @Specialization(guards = "!isInherits") + @Specialization(guards = "!isInherits(inherits)") protected RList mgetNonInherit(VirtualFrame frame, RStringVector xv, REnvironment env, RAbstractStringVector mode, RList ifNotFound, @SuppressWarnings("unused") byte inherits) { controlVisibility(); State state = checkArgs(xv, mode, ifNotFound); @@ -202,7 +200,7 @@ public class GetFunctions { return state.getResult(); } - @Specialization(guards = "isInherits") + @Specialization(guards = "isInherits(inherits)") protected RList mgetInherit(VirtualFrame frame, RStringVector xv, REnvironment envir, RAbstractStringVector mode, RList ifNotFound, @SuppressWarnings("unused") byte inherits) { controlVisibility(); State state = checkArgs(xv, mode, ifNotFound); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GrepFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GrepFunctions.java index f983a8c5c8fc15840f11e81326f2e1784c2143e0..26542304b672787192b65b7d54c519cbd81d38d7 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GrepFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GrepFunctions.java @@ -108,15 +108,10 @@ public class GrepFunctions { } } - @SuppressWarnings("unused") - protected boolean isFixed(RAbstractStringVector patternArg, RAbstractStringVector vector, byte ignoreCase, byte value, byte perl, byte fixed, byte useBytes, byte invert) { + protected boolean isTrue(byte fixed) { return RRuntime.fromLogical(fixed); } - @SuppressWarnings("unused") - protected boolean isValue(RAbstractStringVector patternArg, RAbstractStringVector vector, byte ignoreCase, byte value, byte perl, byte fixed, byte useBytes, byte invert) { - return RRuntime.fromLogical(value); - } } @RBuiltin(name = "grep", kind = INTERNAL, parameterNames = {"pattern", "x", "ignore.case", "perl", "value", "fixed", "useBytes", "invert"}) @@ -126,7 +121,7 @@ public class GrepFunctions { return vector.getLength() == 1 && RRuntime.isNA(vector.getDataAt(0)) && perl == RRuntime.LOGICAL_TRUE; } - @Specialization(guards = "!isValue") + @Specialization(guards = "!isTrue(value)") @TruffleBoundary protected RIntVector grepValueFalse(RAbstractStringVector patternArgVec, RAbstractStringVector vector, byte ignoreCase, @SuppressWarnings("unused") byte value, byte perl, byte fixed, byte useBytes, byte invert) { @@ -169,7 +164,7 @@ public class GrepFunctions { } } - @Specialization(guards = "isValue") + @Specialization(guards = "isTrue(value)") @TruffleBoundary protected RStringVector grepValueTrue(RAbstractStringVector patternArgVec, RAbstractStringVector vector, byte ignoreCase, @SuppressWarnings("unused") byte value, byte perl, byte fixed, byte useBytes, byte invert) { @@ -220,7 +215,7 @@ public class GrepFunctions { // invert is passed but is always FALSE public abstract static class GrepL extends CommonCodeAdapter { - @Specialization(guards = "!isFixed") + @Specialization(guards = "!isTrue(fixed)") @TruffleBoundary @SuppressWarnings("unused") protected Object grepl(RAbstractStringVector patternArgVec, RAbstractStringVector vector, byte ignoreCase, byte value, byte perl, byte fixed, byte useBytes, byte invert) { @@ -234,7 +229,7 @@ public class GrepFunctions { return RDataFactory.createLogicalVector(data, RDataFactory.COMPLETE_VECTOR); } - @Specialization(guards = "isFixed") + @Specialization(guards = "isTrue(fixed)") @TruffleBoundary @SuppressWarnings("unused") protected Object greplFixed(RAbstractStringVector patternArgVec, RAbstractStringVector vector, byte ignoreCase, byte value, byte perl, byte fixed, byte useBytes, byte invert) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/HiddenInternalFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/HiddenInternalFunctions.java index 54f92f60ea9dff68126694878ffa0b9b28148dbd..ac88eabf7ffdb36bad86a9b5d96f0d8de0054082 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/HiddenInternalFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/HiddenInternalFunctions.java @@ -241,7 +241,7 @@ public class HiddenInternalFunctions { throw RError.error(getEncapsulatingSourceSection(), RError.Message.NULL_DLLINFO); } - @Specialization(guards = "isDLLInfo") + @Specialization(guards = "isDLLInfo(externalPtr)") @TruffleBoundary protected RList getRegisteredRoutines(RExternalPtr externalPtr) { Object[] data = new Object[NAMES.getLength()]; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Identical.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Identical.java index b33d7677e73e35d29542ed55b8dfa00c43648a47..6e690243b17d1f17b00df9a92ac3a829aeb3d2a0 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Identical.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Identical.java @@ -103,7 +103,7 @@ public abstract class Identical extends RBuiltinNode { return x == y ? RRuntime.LOGICAL_TRUE : RRuntime.LOGICAL_FALSE; } - @Specialization(guards = "!vectorsLists") + @Specialization(guards = "!vectorsLists(x, y)") protected byte doInternalIdentialGeneric(RAbstractVector x, RAbstractVector y, // @formatter:off @SuppressWarnings("unused") byte numEq, @SuppressWarnings("unused") byte singleNA, @SuppressWarnings("unused") byte attribAsSet, 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 52bde74dd0298e31ee26a11b309d2b123bf45e49..2b496d6c1c5f5965c3697069815354cde5fe6f7a 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 @@ -143,7 +143,7 @@ public class InfixEmulationFunctions { } @ExplodeLoop - @Specialization(guards = "!argsEmpty") + @Specialization(guards = "!argsEmpty(args)") protected RArgsValuesAndNames eval(VirtualFrame frame, RArgsValuesAndNames args) { Object[] values = args.getValues(); for (int i = 0; i < values.length; i++) { @@ -152,7 +152,7 @@ public class InfixEmulationFunctions { return args; } - @Specialization(guards = "argsEmpty") + @Specialization(guards = "argsEmpty(args)") protected RArgsValuesAndNames evalEmpty(RArgsValuesAndNames args) { return args; } @@ -195,7 +195,7 @@ public class InfixEmulationFunctions { return accessNode.executeAccess(frame, vector, exact, 0, positions.execute(frame, vector, pos, exact, pos), dropDim); } - protected boolean noInd(@SuppressWarnings("unused") RAbstractContainer x, RArgsValuesAndNames inds) { + protected boolean noInd(RArgsValuesAndNames inds) { return inds.length() == 0; } @@ -222,7 +222,7 @@ public class InfixEmulationFunctions { } @SuppressWarnings("unused") - @Specialization(guards = "noInd") + @Specialization(guards = "noInd(inds)") protected Object getNoInd(RAbstractContainer x, RArgsValuesAndNames inds, Object dropVec) { return x; } @@ -249,7 +249,7 @@ public class InfixEmulationFunctions { return new RNode[]{ConstantNode.create(RMissing.instance), ConstantNode.create(RMissing.instance), ConstantNode.create(RMissing.instance)}; } - @Specialization(guards = {"!noInd", "isObject"}) + @Specialization(guards = {"!noInd(inds)", "isObject(frame, x)"}) protected Object getObj(VirtualFrame frame, RAbstractContainer x, RArgsValuesAndNames inds, RAbstractLogicalVector dropVec) { if (dcn == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -263,12 +263,12 @@ public class InfixEmulationFunctions { } @Override - @Specialization(guards = {"!noInd", "!isObject"}) + @Specialization(guards = {"!noInd(inds)", "!isObject(frame, x)"}) protected Object get(VirtualFrame frame, RAbstractContainer x, RArgsValuesAndNames inds, RAbstractLogicalVector dropVec) { return super.get(frame, x, inds, dropVec); } - @Specialization(guards = {"!noInd", "isObject"}) + @Specialization(guards = {"!noInd(inds)", "isObject(frame, x)"}) protected Object getObj(VirtualFrame frame, RAbstractContainer x, RArgsValuesAndNames inds, @SuppressWarnings("unused") RMissing dropVec) { byte drop; if (multiIndexProfile.profile(inds.length() > 1)) { @@ -289,7 +289,7 @@ public class InfixEmulationFunctions { } @Override - @Specialization(guards = {"!noInd", "!isObject"}) + @Specialization(guards = {"!noInd(inds)", "!isObject(frame, x)"}) protected Object get(VirtualFrame frame, RAbstractContainer x, RArgsValuesAndNames inds, RMissing dropVec) { return super.get(frame, x, inds, dropVec); } @@ -310,13 +310,13 @@ public class InfixEmulationFunctions { } @Override - @Specialization(guards = "!noInd") + @Specialization(guards = "!noInd(inds)") protected Object get(VirtualFrame frame, RAbstractContainer x, RArgsValuesAndNames inds, RAbstractLogicalVector dropVec) { return super.get(frame, x, inds, dropVec); } @Override - @Specialization(guards = "!noInd") + @Specialization(guards = "!noInd(inds)") protected Object get(VirtualFrame frame, RAbstractContainer x, RArgsValuesAndNames inds, RMissing dropVec) { return super.get(frame, x, inds, dropVec); } @@ -339,7 +339,7 @@ public class InfixEmulationFunctions { } @SuppressWarnings("unused") - @Specialization(guards = "noInd") + @Specialization(guards = "noInd(inds)") protected Object getNoInd(RAbstractContainer x, RArgsValuesAndNames inds, RAbstractLogicalVector exactVec) { throw RError.error(RError.Message.NO_INDEX); } @@ -365,7 +365,7 @@ public class InfixEmulationFunctions { return new RNode[]{ConstantNode.create(RMissing.instance), ConstantNode.create(RMissing.instance), ConstantNode.create(RRuntime.LOGICAL_TRUE)}; } - @Specialization(guards = {"!noInd", "isObject"}) + @Specialization(guards = {"!noInd(inds)", "isObject(frame, x)"}) protected Object getObj(VirtualFrame frame, RAbstractContainer x, RArgsValuesAndNames inds, RAbstractLogicalVector exactVec) { byte exact; if (emptyExactProfile.profile(exactVec.getLength() == 0)) { @@ -385,7 +385,7 @@ public class InfixEmulationFunctions { } @Override - @Specialization(guards = {"!noInd", "!isObject"}) + @Specialization(guards = {"!noInd(inds)", "!isObject(frame, x)"}) protected Object get(VirtualFrame frame, RAbstractContainer x, RArgsValuesAndNames inds, RAbstractLogicalVector exactVec) { return super.get(frame, x, inds, exactVec); } @@ -406,7 +406,7 @@ public class InfixEmulationFunctions { } @Override - @Specialization(guards = "!noInd") + @Specialization(guards = "!noInd(inds)") protected Object get(VirtualFrame frame, RAbstractContainer x, RArgsValuesAndNames inds, RAbstractLogicalVector exactVec) { return super.get(frame, x, inds, exactVec); } @@ -451,12 +451,12 @@ public class InfixEmulationFunctions { } @SuppressWarnings("unused") - @Specialization(guards = "noInd") + @Specialization(guards = "noInd(args)") protected Object getNoInd(RAbstractContainer x, RArgsValuesAndNames args) { throw RError.error(RError.Message.INVALID_ARG_NUMBER, "SubAssignArgs"); } - protected boolean noInd(@SuppressWarnings("unused") RAbstractContainer x, RArgsValuesAndNames args) { + protected boolean noInd(RArgsValuesAndNames args) { return args.length() == 0; } @@ -477,7 +477,7 @@ public class InfixEmulationFunctions { return new RNode[]{ConstantNode.create(RMissing.instance), ConstantNode.create(RMissing.instance), ConstantNode.create(RMissing.instance)}; } - @Specialization(guards = {"!noInd", "isObject"}) + @Specialization(guards = {"!noInd(args)", "isObject(frame, x)"}) protected Object updateObj(VirtualFrame frame, RAbstractContainer x, RArgsValuesAndNames args) { if (dcn == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -491,7 +491,7 @@ public class InfixEmulationFunctions { } } - @Specialization(guards = {"!noInd", "!isObject"}) + @Specialization(guards = {"!noInd(args)", "!isObject(frame, x)"}) protected Object update(VirtualFrame frame, RAbstractContainer x, RArgsValuesAndNames args) { Object value = args.getValues()[args.length() - 1]; return update(frame, x, args, value, IS_SUBSET); @@ -516,7 +516,7 @@ public class InfixEmulationFunctions { return new RNode[]{ConstantNode.create(RMissing.instance), ConstantNode.create(RMissing.instance), ConstantNode.create(RMissing.instance)}; } - @Specialization(guards = {"!noInd", "isObject"}) + @Specialization(guards = {"!noInd(args)", "isObject(frame, x)"}) protected Object updateObj(VirtualFrame frame, RAbstractContainer x, RArgsValuesAndNames args) { if (dcn == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -530,7 +530,7 @@ public class InfixEmulationFunctions { } } - @Specialization(guards = {"!noInd", "!isObject"}) + @Specialization(guards = {"!noInd(args)", "!isObject(frame, x)"}) protected Object update(VirtualFrame frame, RAbstractContainer x, RArgsValuesAndNames args) { Object value = args.getValues()[args.length() - 1]; return update(frame, x, args, value, IS_SUBSET); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Inherits.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Inherits.java index 785a9ea4e5064679bb78de236042c14591f64777..e8b44d10a0b6d733444a977b2bbcb2d604d3303c 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Inherits.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Inherits.java @@ -48,29 +48,8 @@ public abstract class Inherits extends RBuiltinNode { return inheritsNode; } - @SuppressWarnings("unused") - public boolean whichFalse(RAbstractContainer x, RAbstractStringVector what, byte which) { - return which != RRuntime.LOGICAL_TRUE; - } - - @SuppressWarnings("unused") - public boolean whichFalse(RConnection x, RAbstractStringVector what, byte which) { - return which != RRuntime.LOGICAL_TRUE; - } - - @SuppressWarnings("unused") - public boolean whichFalse(RFunction x, RAbstractStringVector what, byte which) { - return which != RRuntime.LOGICAL_TRUE; - } - - @SuppressWarnings("unused") - public boolean whichFalse(REnvironment x, RAbstractStringVector what, byte which) { - return which != RRuntime.LOGICAL_TRUE; - } - - @SuppressWarnings("unused") - public boolean whichFalse(RSymbol x, RAbstractStringVector what, byte which) { - return which != RRuntime.LOGICAL_TRUE; + protected static boolean isTrue(byte value) { + return RRuntime.fromLogical(value); } @SuppressWarnings("unused") @@ -79,52 +58,52 @@ public abstract class Inherits extends RBuiltinNode { return RRuntime.LOGICAL_FALSE; } - @Specialization(guards = "whichFalse") + @Specialization(guards = "!isTrue(which)") protected Object doesInherit(VirtualFrame frame, REnvironment x, RAbstractStringVector what, @SuppressWarnings("unused") byte which) { return initInheritsNode().execute(frame, x, what); } - @Specialization(guards = "!whichFalse") + @Specialization(guards = "isTrue(which)") protected Object doesInheritWT(REnvironment x, RAbstractStringVector what, @SuppressWarnings("unused") byte which) { return doDoesInherit(x.getClassAttr(attrProfiles), what); } - @Specialization(guards = "whichFalse") + @Specialization(guards = "!isTrue(which)") protected Object doesInherit(VirtualFrame frame, RFunction x, RAbstractStringVector what, @SuppressWarnings("unused") byte which) { return initInheritsNode().execute(frame, x, what); } - @Specialization(guards = "!whichFalse") + @Specialization(guards = "isTrue(which)") protected Object doesInheritWT(RFunction x, RAbstractStringVector what, @SuppressWarnings("unused") byte which) { return doDoesInherit(x.getClassAttr(attrProfiles), what); } - @Specialization(guards = "whichFalse") + @Specialization(guards = "!isTrue(which)") protected Object doesInherit(VirtualFrame frame, RSymbol x, RAbstractStringVector what, @SuppressWarnings("unused") byte which) { return initInheritsNode().execute(frame, x, what); } - @Specialization(guards = "!whichFalse") + @Specialization(guards = "isTrue(which)") protected Object doesInheritWT(RSymbol x, RAbstractStringVector what, @SuppressWarnings("unused") byte which) { return doDoesInherit(x.getClassAttr(attrProfiles), what); } - @Specialization(guards = "whichFalse") + @Specialization(guards = "!isTrue(which)") protected byte doesInherit(VirtualFrame frame, RConnection x, RAbstractStringVector what, @SuppressWarnings("unused") byte which) { return initInheritsNode().execute(frame, x, what); } - @Specialization(guards = "!whichFalse") + @Specialization(guards = "isTrue(which)") protected Object doesInheritWT(RConnection x, RAbstractStringVector what, @SuppressWarnings("unused") byte which) { return doDoesInherit(x.getClassHierarchy(), what); } - @Specialization(guards = "whichFalse") + @Specialization(guards = "!isTrue(which)") protected byte doesInherit(VirtualFrame frame, RAbstractContainer x, RAbstractStringVector what, @SuppressWarnings("unused") byte which) { return initInheritsNode().execute(frame, x, what); } - @Specialization(guards = "!whichFalse") + @Specialization(guards = "isTrue(which)") protected Object doesInherit(RAbstractVector x, RAbstractStringVector what, @SuppressWarnings("unused") byte which) { return doDoesInherit(x.getClassHierarchy(), what); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsFiniteFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsFiniteFunctions.java index 9bd4ad7886a1dc3a891ccd106adbd9b565a2cbf9..1888c4a07446f599fb7c215ec18da66e6afc7d4a 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsFiniteFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsFiniteFunctions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -25,7 +25,6 @@ package com.oracle.truffle.r.nodes.builtin.base; import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; @@ -80,12 +79,12 @@ public class IsFiniteFunctions { @Child private TypeofNode typeofNode; @Fallback - protected Object doIsFiniteOther(VirtualFrame frame, Object x) { + protected Object doIsFiniteOther(Object x) { controlVisibility(); if (typeofNode == null) { typeofNode = insert(TypeofNodeGen.create(null)); } - String type = typeofNode.execute(frame, x).getName(); + String type = typeofNode.execute(x).getName(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.DEFAULT_METHOD_NOT_IMPLEMENTED_FOR_TYPE, type); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsTypeFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsTypeFunctions.java index 3aa1c318f4dbfd823098a2507e6982a9b60fe67c..be8032943630e6ec591b61a37904a1fd3e6d8618 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsTypeFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsTypeFunctions.java @@ -96,7 +96,7 @@ public class IsTypeFunctions { return RRuntime.LOGICAL_FALSE; } - @Specialization(guards = "!isListVector") + @Specialization(guards = "!isListVector(arg)") protected byte isRecursive(RAbstractVector arg) { controlVisibility(); return RRuntime.LOGICAL_FALSE; @@ -134,7 +134,7 @@ public class IsTypeFunctions { return RRuntime.LOGICAL_TRUE; } - @Specialization(guards = "!isListVector") + @Specialization(guards = "!isListVector(arg)") protected byte isAtomic(RAbstractVector arg) { controlVisibility(); return RRuntime.LOGICAL_TRUE; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ListBuiltin.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ListBuiltin.java index 09c12c7b6cfa9b556781bb3c11984634cdccbea6..52762793236e135a6f7953fe6b8f0bc7072b093b 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ListBuiltin.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ListBuiltin.java @@ -95,13 +95,13 @@ public abstract class ListBuiltin extends RBuiltinNode { return list(new Object[]{value}); } - @Specialization(guards = "!missing") + @Specialization(guards = "!missing(args)") protected RList list(RArgsValuesAndNames args) { controlVisibility(); return RDataFactory.createList(args.getValues(), argNameVector(args.getSignature())); } - @Specialization(guards = "missing") + @Specialization(guards = "missing(args)") protected RList listMissing(@SuppressWarnings("unused") RArgsValuesAndNames args) { controlVisibility(); return list(new Object[0]); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MakeNames.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MakeNames.java index a8e8a02f01651813df183e1309e68180b4ac21ef..5850d992b3ec8fa86a1af3bc9461d8257151ab0a 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MakeNames.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MakeNames.java @@ -169,18 +169,18 @@ public abstract class MakeNames extends RBuiltinNode { } } - @Specialization(guards = "!wrongAllowUnderscore") + @Specialization(guards = "!wrongAllowUnderscore(allowUnderScoreArg)") protected RAbstractStringVector makeNames(RAbstractStringVector names, RAbstractLogicalVector allowUnderScoreArg) { return makeNames(names, allowUnderScoreArg.getDataAt(0)); } @SuppressWarnings("unused") - @Specialization(guards = "wrongAllowUnderscore") + @Specialization(guards = "wrongAllowUnderscore(allowUnderScoreArg)") protected RAbstractStringVector makeNamesWrongUnderscoreEmpty(RAbstractStringVector names, RAbstractLogicalVector allowUnderScoreArg) { throw invalidAllowValue(getEncapsulatingSourceSection()); } - protected boolean wrongAllowUnderscore(@SuppressWarnings("unused") Object names, RAbstractLogicalVector allowUnderScoreArg) { + protected static boolean wrongAllowUnderscore(RAbstractLogicalVector allowUnderScoreArg) { return allowUnderScoreArg.getLength() == 0 || RRuntime.isNA(allowUnderScoreArg.getDataAt(0)); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MakeUnique.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MakeUnique.java index 39ab414e0ce213228aa7d2e414407fec53781b97..133e6c6f14dd5a74a56d686fef6a40353b688674 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MakeUnique.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MakeUnique.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -88,20 +88,20 @@ public abstract class MakeUnique extends RBuiltinNode { return s1 + sep + index; } - @Specialization(guards = "sepIsString") + @Specialization(guards = "sepIsString(sep)") protected RAbstractStringVector makeUnique(RAbstractStringVector names, RAbstractVector sep) { return makeUnique(names, (String) sep.getDataAtAsObject(0)); } @SuppressWarnings("unused") - @Specialization(guards = "!sepIsString") + @Specialization(guards = "!sepIsString(sep)") protected RAbstractStringVector makeUniqueWrongSep(RAbstractStringVector names, RAbstractVector sep) { controlVisibility(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.MUST_BE_STRING, "sep"); } @SuppressWarnings("unused") - @Specialization(guards = "!namesIsStringVector") + @Specialization(guards = "!namesIsStringVector(names)") protected RAbstractStringVector makeUnique(RAbstractVector names, Object sep) { controlVisibility(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.NOT_CHARACTER_VECTOR, "names"); @@ -111,7 +111,7 @@ public abstract class MakeUnique extends RBuiltinNode { return names.getElementClass() == RString.class; } - protected boolean sepIsString(@SuppressWarnings("unused") Object names, RAbstractVector sep) { + protected boolean sepIsString(RAbstractVector sep) { return sep.getElementClass() == RString.class && sep.getLength() == 1; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MatMult.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MatMult.java index 508b8651884225335152242c88310d1dcf9a2553..49cd0bda2b45b3813b368557c6bbfb150d853928 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MatMult.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MatMult.java @@ -62,7 +62,7 @@ public abstract class MatMult extends RBuiltinNode { this.na = prev.na; } - @Specialization(guards = "bothZeroDim") + @Specialization(guards = "bothZeroDim(a, b)") protected RDoubleVector both0Dim(RAbstractDoubleVector a, RAbstractDoubleVector b) { controlVisibility(); int r = b.getDimensions()[1]; @@ -72,14 +72,14 @@ public abstract class MatMult extends RBuiltinNode { return result; } - @Specialization(guards = "leftHasZeroDim") + @Specialization(guards = "hasZeroDim(a)") protected RAbstractVector left0Dim(RAbstractVector a, RAbstractVector b) { controlVisibility(); int[] dim = a.getDimensions()[0] == 0 ? new int[]{0, b.getDimensions()[1]} : new int[]{b.getDimensions()[0], 0}; return a.copyWithNewDimensions(dim); } - @Specialization(guards = "rightHasZeroDim") + @Specialization(guards = "hasZeroDim(b)") protected RAbstractVector right0Dim(RAbstractVector a, RAbstractVector b) { controlVisibility(); int[] dim = b.getDimensions()[0] == 0 ? new int[]{0, a.getDimensions()[1]} : new int[]{a.getDimensions()[0], 0}; @@ -108,7 +108,7 @@ public abstract class MatMult extends RBuiltinNode { private final ConditionProfile bigProfile = ConditionProfile.createBinaryProfile(); private final BranchProfile incompleteProfile = BranchProfile.create(); - @Specialization(guards = "matmat") + @Specialization(guards = "matmat(a, b)") protected RDoubleVector matmatmult(RAbstractDoubleVector a, RAbstractDoubleVector b) { controlVisibility(); return doubleMatrixMultiply(a, b, a.getDimensions()[0], a.getDimensions()[1], b.getDimensions()[0], b.getDimensions()[1]); @@ -217,7 +217,7 @@ public abstract class MatMult extends RBuiltinNode { } } - @Specialization(guards = "vecvec") + @Specialization(guards = "vecvec(a, b)") protected RDoubleVector vecvecmult(RAbstractDoubleVector a, RAbstractDoubleVector b) { controlVisibility(); if (a.getLength() != b.getLength()) { @@ -238,7 +238,7 @@ public abstract class MatMult extends RBuiltinNode { return RDataFactory.createDoubleVector(new double[]{result}, true, new int[]{1, 1}); } - @Specialization(guards = "matvec") + @Specialization(guards = "matvec(a, b)") protected RDoubleVector matvecmult(RAbstractDoubleVector a, RAbstractDoubleVector b) { controlVisibility(); int aRows = a.getDimensions()[0]; @@ -255,7 +255,7 @@ public abstract class MatMult extends RBuiltinNode { return doubleMatrixMultiply(a, b, aRows, aCols, bRows, bCols); } - @Specialization(guards = "vecmat") + @Specialization(guards = "vecmat(a, b)") protected RDoubleVector vecmatmult(RAbstractDoubleVector a, RAbstractDoubleVector b) { controlVisibility(); int bRows = b.getDimensions()[0]; @@ -274,7 +274,7 @@ public abstract class MatMult extends RBuiltinNode { // complex-complex - @Specialization(guards = "matmat") + @Specialization(guards = "matmat(a, b)") protected RComplexVector matmatmult(RAbstractComplexVector a, RAbstractComplexVector b) { controlVisibility(); final int aCols = a.getDimensions()[1]; @@ -303,7 +303,7 @@ public abstract class MatMult extends RBuiltinNode { return RDataFactory.createComplexVector(result, na.neverSeenNA(), new int[]{aRows, bCols}); } - @Specialization(guards = "vecvec") + @Specialization(guards = "vecvec(a, b)") protected RComplexVector vecvecmult(RAbstractComplexVector a, RAbstractComplexVector b) { controlVisibility(); if (a.getLength() != b.getLength()) { @@ -320,7 +320,7 @@ public abstract class MatMult extends RBuiltinNode { return RDataFactory.createComplexVector(new double[]{result.getRealPart(), result.getImaginaryPart()}, na.neverSeenNA(), new int[]{1, 1}); } - @Specialization(guards = "matvec") + @Specialization(guards = "matvec(a, b)") protected RComplexVector matvecmult(RAbstractComplexVector a, RAbstractComplexVector b) { controlVisibility(); final int aCols = a.getDimensions()[1]; @@ -357,7 +357,7 @@ public abstract class MatMult extends RBuiltinNode { } } - @Specialization(guards = "vecmat") + @Specialization(guards = "vecmat(a, b)") protected RComplexVector vecmatmult(RAbstractComplexVector a, RAbstractComplexVector b) { controlVisibility(); final int bRows = b.getDimensions()[0]; @@ -396,7 +396,7 @@ public abstract class MatMult extends RBuiltinNode { // int-int - @Specialization(guards = "matmat") + @Specialization(guards = "matmat(a, b)") protected RIntVector matmatmult(RAbstractIntVector a, RAbstractIntVector b) { controlVisibility(); final int aCols = a.getDimensions()[1]; @@ -423,7 +423,7 @@ public abstract class MatMult extends RBuiltinNode { return RDataFactory.createIntVector(result, na.neverSeenNA(), new int[]{aRows, bCols}); } - @Specialization(guards = "vecvec") + @Specialization(guards = "vecvec(a, b)") protected RIntVector vecvecmult(RAbstractIntVector a, RAbstractIntVector b) { controlVisibility(); if (a.getLength() != b.getLength()) { @@ -439,7 +439,7 @@ public abstract class MatMult extends RBuiltinNode { return RDataFactory.createIntVector(new int[]{result}, na.neverSeenNA(), new int[]{1, 1}); } - @Specialization(guards = "matvec") + @Specialization(guards = "matvec(a, b)") protected RIntVector matvecmult(RAbstractIntVector a, RAbstractIntVector b) { controlVisibility(); final int aCols = a.getDimensions()[1]; @@ -474,7 +474,7 @@ public abstract class MatMult extends RBuiltinNode { } } - @Specialization(guards = "vecmat") + @Specialization(guards = "vecmat(a, b)") protected RIntVector vecmatmult(RAbstractIntVector a, RAbstractIntVector b) { controlVisibility(); final int bCols = b.getDimensions()[1]; @@ -511,268 +511,268 @@ public abstract class MatMult extends RBuiltinNode { // logical-logical - @Specialization(guards = "matmat") + @Specialization(guards = "matmat(a, b)") protected RIntVector matmatmult(RAbstractLogicalVector a, RAbstractLogicalVector b) { return matmatmult(RClosures.createLogicalToIntVector(a, na), RClosures.createLogicalToIntVector(b, na)); } - @Specialization(guards = "vecvec") + @Specialization(guards = "vecvec(a, b)") protected RIntVector vecvecmult(RAbstractLogicalVector a, RAbstractLogicalVector b) { return vecvecmult(RClosures.createLogicalToIntVector(a, na), RClosures.createLogicalToIntVector(b, na)); } - @Specialization(guards = "matvec") + @Specialization(guards = "matvec(a, b)") protected RIntVector matvecmult(RAbstractLogicalVector a, RAbstractLogicalVector b) { return matvecmult(RClosures.createLogicalToIntVector(a, na), RClosures.createLogicalToIntVector(b, na)); } - @Specialization(guards = "vecmat") + @Specialization(guards = "vecmat(a, b)") protected RIntVector vecmatmult(RAbstractLogicalVector a, RAbstractLogicalVector b) { return vecmatmult(RClosures.createLogicalToIntVector(a, na), RClosures.createLogicalToIntVector(b, na)); } // to int - @Specialization(guards = "matmat") + @Specialization(guards = "matmat(a, b)") protected RIntVector matmatmult(RAbstractLogicalVector a, RAbstractIntVector b) { return matmatmult(RClosures.createLogicalToIntVector(a, na), b); } - @Specialization(guards = "vecvec") + @Specialization(guards = "vecvec(a, b)") protected RIntVector vecvecmult(RAbstractLogicalVector a, RAbstractIntVector b) { return vecvecmult(RClosures.createLogicalToIntVector(a, na), b); } - @Specialization(guards = "matvec") + @Specialization(guards = "matvec(a, b)") protected RIntVector matvecmult(RAbstractLogicalVector a, RAbstractIntVector b) { return matvecmult(RClosures.createLogicalToIntVector(a, na), b); } - @Specialization(guards = "vecmat") + @Specialization(guards = "vecmat(a, b)") protected RIntVector vecmatmult(RAbstractLogicalVector a, RAbstractIntVector b) { return vecmatmult(RClosures.createLogicalToIntVector(a, na), b); } - @Specialization(guards = "matmat") + @Specialization(guards = "matmat(a, b)") protected RIntVector matmatmult(RAbstractIntVector a, RAbstractLogicalVector b) { return matmatmult(a, RClosures.createLogicalToIntVector(b, na)); } - @Specialization(guards = "vecvec") + @Specialization(guards = "vecvec(a, b)") protected RIntVector vecvecmult(RAbstractIntVector a, RAbstractLogicalVector b) { return vecvecmult(a, RClosures.createLogicalToIntVector(b, na)); } - @Specialization(guards = "matvec") + @Specialization(guards = "matvec(a, b)") protected RIntVector matvecmult(RAbstractIntVector a, RAbstractLogicalVector b) { return matvecmult(a, RClosures.createLogicalToIntVector(b, na)); } - @Specialization(guards = "vecmat") + @Specialization(guards = "vecmat(a, b)") protected RIntVector vecmatmult(RAbstractIntVector a, RAbstractLogicalVector b) { return vecmatmult(a, RClosures.createLogicalToIntVector(b, na)); } // to complex - @Specialization(guards = "matmat") + @Specialization(guards = "matmat(a, b)") protected RComplexVector matmatmult(RAbstractIntVector a, RAbstractComplexVector b) { return matmatmult(RClosures.createIntToComplexVector(a, na), b); } - @Specialization(guards = "vecvec") + @Specialization(guards = "vecvec(a, b)") protected RComplexVector vecvecmult(RAbstractIntVector a, RAbstractComplexVector b) { return vecvecmult(RClosures.createIntToComplexVector(a, na), b); } - @Specialization(guards = "matvec") + @Specialization(guards = "matvec(a, b)") protected RComplexVector matvecmult(RAbstractIntVector a, RAbstractComplexVector b) { return matvecmult(RClosures.createIntToComplexVector(a, na), b); } - @Specialization(guards = "vecmat") + @Specialization(guards = "vecmat(a, b)") protected RComplexVector vecmatmult(RAbstractIntVector a, RAbstractComplexVector b) { return vecmatmult(RClosures.createIntToComplexVector(a, na), b); } - @Specialization(guards = "matmat") + @Specialization(guards = "matmat(a, b)") protected RComplexVector matmatmult(RAbstractComplexVector a, RAbstractIntVector b) { return matmatmult(a, RClosures.createIntToComplexVector(b, na)); } - @Specialization(guards = "vecvec") + @Specialization(guards = "vecvec(a, b)") protected RComplexVector vecvecmult(RAbstractComplexVector a, RAbstractIntVector b) { return vecvecmult(a, RClosures.createIntToComplexVector(b, na)); } - @Specialization(guards = "matvec") + @Specialization(guards = "matvec(a, b)") protected RComplexVector matvecmult(RAbstractComplexVector a, RAbstractIntVector b) { return matvecmult(a, RClosures.createIntToComplexVector(b, na)); } - @Specialization(guards = "vecmat") + @Specialization(guards = "vecmat(a, b)") protected RComplexVector vecmatmult(RAbstractComplexVector a, RAbstractIntVector b) { return vecmatmult(a, RClosures.createIntToComplexVector(b, na)); } - @Specialization(guards = "matmat") + @Specialization(guards = "matmat(a, b)") protected RComplexVector matmatmult(RAbstractLogicalVector a, RAbstractComplexVector b) { return matmatmult(RClosures.createLogicalToComplexVector(a, na), b); } - @Specialization(guards = "vecvec") + @Specialization(guards = "vecvec(a, b)") protected RComplexVector vecvecmult(RAbstractLogicalVector a, RAbstractComplexVector b) { return vecvecmult(RClosures.createLogicalToComplexVector(a, na), b); } - @Specialization(guards = "matvec") + @Specialization(guards = "matvec(a, b)") protected RComplexVector matvecmult(RAbstractLogicalVector a, RAbstractComplexVector b) { return matvecmult(RClosures.createLogicalToComplexVector(a, na), b); } - @Specialization(guards = "vecmat") + @Specialization(guards = "vecmat(a, b)") protected RComplexVector vecmatmult(RAbstractLogicalVector a, RAbstractComplexVector b) { return vecmatmult(RClosures.createLogicalToComplexVector(a, na), b); } - @Specialization(guards = "matmat") + @Specialization(guards = "matmat(a, b)") protected RComplexVector matmatmult(RAbstractComplexVector a, RAbstractLogicalVector b) { return matmatmult(a, RClosures.createLogicalToComplexVector(b, na)); } - @Specialization(guards = "vecvec") + @Specialization(guards = "vecvec(a, b)") protected RComplexVector vecvecmult(RAbstractComplexVector a, RAbstractLogicalVector b) { return vecvecmult(a, RClosures.createLogicalToComplexVector(b, na)); } - @Specialization(guards = "matvec") + @Specialization(guards = "matvec(a, b)") protected RComplexVector matvecmult(RAbstractComplexVector a, RAbstractLogicalVector b) { return matvecmult(a, RClosures.createLogicalToComplexVector(b, na)); } - @Specialization(guards = "vecmat") + @Specialization(guards = "vecmat(a, b)") protected RComplexVector vecmatmult(RAbstractComplexVector a, RAbstractLogicalVector b) { return vecmatmult(a, RClosures.createLogicalToComplexVector(b, na)); } - @Specialization(guards = "matmat") + @Specialization(guards = "matmat(a, b)") protected RComplexVector matmatmult(RAbstractDoubleVector a, RAbstractComplexVector b) { return matmatmult(RClosures.createDoubleToComplexVector(a, na), b); } - @Specialization(guards = "vecvec") + @Specialization(guards = "vecvec(a, b)") protected RComplexVector vecvecmult(RAbstractDoubleVector a, RAbstractComplexVector b) { return vecvecmult(RClosures.createDoubleToComplexVector(a, na), b); } - @Specialization(guards = "matvec") + @Specialization(guards = "matvec(a, b)") protected RComplexVector matvecmult(RAbstractDoubleVector a, RAbstractComplexVector b) { return matvecmult(RClosures.createDoubleToComplexVector(a, na), b); } - @Specialization(guards = "vecmat") + @Specialization(guards = "vecmat(a, b)") protected RComplexVector vecmatmult(RAbstractDoubleVector a, RAbstractComplexVector b) { return vecmatmult(RClosures.createDoubleToComplexVector(a, na), b); } - @Specialization(guards = "matmat") + @Specialization(guards = "matmat(a, b)") protected RComplexVector matmatmult(RAbstractComplexVector a, RAbstractDoubleVector b) { return matmatmult(a, RClosures.createDoubleToComplexVector(b, na)); } - @Specialization(guards = "vecvec") + @Specialization(guards = "vecvec(a, b)") protected RComplexVector vecvecmult(RAbstractComplexVector a, RAbstractDoubleVector b) { return vecvecmult(a, RClosures.createDoubleToComplexVector(b, na)); } - @Specialization(guards = "matvec") + @Specialization(guards = "matvec(a, b)") protected RComplexVector matvecmult(RAbstractComplexVector a, RAbstractDoubleVector b) { return matvecmult(a, RClosures.createDoubleToComplexVector(b, na)); } - @Specialization(guards = "vecmat") + @Specialization(guards = "vecmat(a, b)") protected RComplexVector vecmatmult(RAbstractComplexVector a, RAbstractDoubleVector b) { return vecmatmult(a, RClosures.createDoubleToComplexVector(b, na)); } // to double - @Specialization(guards = "matmat") + @Specialization(guards = "matmat(a, b)") protected RDoubleVector matmatmult(RAbstractIntVector a, RAbstractDoubleVector b) { return matmatmult(RClosures.createIntToDoubleVector(a, na), b); } - @Specialization(guards = "vecvec") + @Specialization(guards = "vecvec(a, b)") protected RDoubleVector vecvecmult(RAbstractIntVector a, RAbstractDoubleVector b) { return vecvecmult(RClosures.createIntToDoubleVector(a, na), b); } - @Specialization(guards = "matvec") + @Specialization(guards = "matvec(a, b)") protected RDoubleVector matvecmult(RAbstractIntVector a, RAbstractDoubleVector b) { return matvecmult(RClosures.createIntToDoubleVector(a, na), b); } - @Specialization(guards = "vecmat") + @Specialization(guards = "vecmat(a, b)") protected RDoubleVector vecmatmult(RAbstractIntVector a, RAbstractDoubleVector b) { return vecmatmult(RClosures.createIntToDoubleVector(a, na), b); } - @Specialization(guards = "matmat") + @Specialization(guards = "matmat(a, b)") protected RDoubleVector matmatmult(RAbstractDoubleVector a, RAbstractIntVector b) { return matmatmult(a, RClosures.createIntToDoubleVector(b, na)); } - @Specialization(guards = "vecvec") + @Specialization(guards = "vecvec(a, b)") protected RDoubleVector vecvecmult(RAbstractDoubleVector a, RAbstractIntVector b) { return vecvecmult(a, RClosures.createIntToDoubleVector(b, na)); } - @Specialization(guards = "matvec") + @Specialization(guards = "matvec(a, b)") protected RDoubleVector matvecmult(RAbstractDoubleVector a, RAbstractIntVector b) { return matvecmult(a, RClosures.createIntToDoubleVector(b, na)); } - @Specialization(guards = "vecmat") + @Specialization(guards = "vecmat(a, b)") protected RDoubleVector vecmatmult(RAbstractDoubleVector a, RAbstractIntVector b) { return vecmatmult(a, RClosures.createIntToDoubleVector(b, na)); } - @Specialization(guards = "matmat") + @Specialization(guards = "matmat(a, b)") protected RDoubleVector matmatmult(RAbstractLogicalVector a, RAbstractDoubleVector b) { return matmatmult(RClosures.createLogicalToDoubleVector(a, na), b); } - @Specialization(guards = "vecvec") + @Specialization(guards = "vecvec(a, b)") protected RDoubleVector vecvecmult(RAbstractLogicalVector a, RAbstractDoubleVector b) { return vecvecmult(RClosures.createLogicalToDoubleVector(a, na), b); } - @Specialization(guards = "matvec") + @Specialization(guards = "matvec(a, b)") protected RDoubleVector matvecmult(RAbstractLogicalVector a, RAbstractDoubleVector b) { return matvecmult(RClosures.createLogicalToDoubleVector(a, na), b); } - @Specialization(guards = "vecmat") + @Specialization(guards = "vecmat(a, b)") protected RDoubleVector vecmatmult(RAbstractLogicalVector a, RAbstractDoubleVector b) { return vecmatmult(RClosures.createLogicalToDoubleVector(a, na), b); } - @Specialization(guards = "matmat") + @Specialization(guards = "matmat(a, b)") protected RDoubleVector matmatmult(RAbstractDoubleVector a, RAbstractLogicalVector b) { return matmatmult(a, RClosures.createLogicalToDoubleVector(b, na)); } - @Specialization(guards = "vecvec") + @Specialization(guards = "vecvec(a, b)") protected RDoubleVector vecvecmult(RAbstractDoubleVector a, RAbstractLogicalVector b) { return vecvecmult(a, RClosures.createLogicalToDoubleVector(b, na)); } - @Specialization(guards = "matvec") + @Specialization(guards = "matvec(a, b)") protected RDoubleVector matvecmult(RAbstractDoubleVector a, RAbstractLogicalVector b) { return matvecmult(a, RClosures.createLogicalToDoubleVector(b, na)); } - @Specialization(guards = "vecmat") + @Specialization(guards = "vecmat(a, b)") protected RDoubleVector vecmatmult(RAbstractDoubleVector a, RAbstractLogicalVector b) { return vecmatmult(a, RClosures.createLogicalToDoubleVector(b, na)); } @@ -821,14 +821,6 @@ public abstract class MatMult extends RBuiltinNode { return !a.isMatrix() && b.isMatrix(); } - protected static boolean leftHasZeroDim(RAbstractVector a, @SuppressWarnings("unused") RAbstractVector b) { - return hasZeroDim(a); - } - - protected static boolean rightHasZeroDim(@SuppressWarnings("unused") RAbstractVector a, RAbstractVector b) { - return hasZeroDim(b); - } - protected static boolean bothZeroDim(RAbstractVector a, RAbstractVector b) { return hasZeroDim(a) && hasZeroDim(b); } 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 4de6d49991a4374de5808c5382479240b4f705ed..c0769d17bf3f00d0607016371e7eb3f438f7fea7 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 @@ -375,7 +375,7 @@ public abstract class Match extends RBuiltinNode { return RDataFactory.createIntVector(result, setCompleteState(matchAll, nomatch)); } - @Specialization(guards = "!isStringVectorTable") + @Specialization(guards = "!isStringVectorTable(table)") @SuppressWarnings("unused") protected RIntVector match(VirtualFrame frame, RAbstractStringVector x, RAbstractVector table, Object nomatchObj, Object incomparables) { controlVisibility(); @@ -448,7 +448,7 @@ public abstract class Match extends RBuiltinNode { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MATCH_VECTOR_ARGS); } - protected boolean isStringVectorTable(@SuppressWarnings("unused") RAbstractStringVector x, RAbstractVector table) { + protected boolean isStringVectorTable(RAbstractVector table) { return table.getElementClass() == String.class; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Matrix.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Matrix.java index f5c2c5c621bf594adf57ad4e374a44fe393ea4f0..26194b032202a8863a346468bdbba8b1b069a82f 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Matrix.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Matrix.java @@ -35,7 +35,7 @@ import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; -@RBuiltin(name = "matrix", kind = INTERNAL, parameterNames = {"data", "nrow", "ncol", "byrow", "dimnames", "missingNrow", "missingNcol"}) +@RBuiltin(name = "matrix", kind = INTERNAL, parameterNames = {"data", "nrow", "ncol", "isTrue(byrow)", "dimnames", "missingNrow", "missingNcol"}) public abstract class Matrix extends RBuiltinNode { @Child private Transpose transpose; @@ -64,7 +64,7 @@ public abstract class Matrix extends RBuiltinNode { return args; } - @Specialization(guards = "!byRow") + @Specialization(guards = "!isTrue(byrow)") @SuppressWarnings("unused") protected RAbstractVector matrixbc(RAbstractVector data, int nrow, int ncol, byte byrow, RNull dimnames, byte missingNr, byte missingNc) { controlVisibility(); @@ -72,7 +72,7 @@ public abstract class Matrix extends RBuiltinNode { return data.copyResizedWithDimensions(dim); } - @Specialization(guards = "!byRow") + @Specialization(guards = "!isTrue(byrow)") @SuppressWarnings("unused") protected RAbstractVector matrixbc(VirtualFrame frame, RAbstractVector data, int nrow, int ncol, byte byrow, RList dimnames, byte missingNr, byte missingNc) { int[] dim = computeDimByCol(data.getLength(), nrow, ncol, missingNr, missingNc); @@ -82,7 +82,7 @@ public abstract class Matrix extends RBuiltinNode { return res; } - @Specialization(guards = "byRow") + @Specialization(guards = "isTrue(byrow)") @SuppressWarnings("unused") protected RAbstractVector matrixbr(VirtualFrame frame, RAbstractVector data, int nrow, int ncol, byte byrow, RNull dimnames, byte missingNr, byte missingNc) { controlVisibility(); @@ -94,7 +94,7 @@ public abstract class Matrix extends RBuiltinNode { return (RAbstractVector) transpose.execute(frame, data.copyResizedWithDimensions(dim)); } - @Specialization(guards = "byRow") + @Specialization(guards = "isTrue(byrow)") @SuppressWarnings("unused") protected RAbstractVector matrixbr(VirtualFrame frame, RAbstractVector data, int nrow, int ncol, byte byrow, RList dimnames, byte missingNr, byte missingNc) { int[] dim = computeDimByRow(data.getLength(), nrow, ncol, missingNr, missingNc); @@ -158,9 +158,8 @@ public abstract class Matrix extends RBuiltinNode { // Guards. // - @SuppressWarnings("unused") - protected static boolean byRow(RAbstractVector data, int nrow, int ncol, byte byrow) { - return byrow == RRuntime.LOGICAL_TRUE; + protected static boolean isTrue(byte byrow) { + return RRuntime.fromLogical(byrow); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NChar.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NChar.java index 761ee1bdf17f35243be9454e1753a125be50a849..06885670bc9a4aff778a538394313da137e13d36 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NChar.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NChar.java @@ -82,21 +82,21 @@ public abstract class NChar extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "lengthZero") + @Specialization(guards = "vector.getLength() == 0") protected RIntVector ncharL0(RAbstractStringVector vector, String type, byte allowNA) { controlVisibility(); return RDataFactory.createEmptyIntVector(); } @SuppressWarnings("unused") - @Specialization(guards = "lengthOne") + @Specialization(guards = "vector.getLength() == 1") protected int ncharL1(RAbstractStringVector vector, String type, byte allowNA) { controlVisibility(); return vector.getDataAt(0).length(); } @SuppressWarnings("unused") - @Specialization(guards = "lengthGT1") + @Specialization(guards = "vector.getLength() > 1") protected RIntVector nchar(RAbstractStringVector vector, String type, byte allowNA) { controlVisibility(); int len = vector.getLength(); @@ -127,19 +127,4 @@ public abstract class NChar extends RBuiltinNode { } } - @SuppressWarnings("unused") - public static boolean lengthGT1(RAbstractStringVector vector, String type, byte allowNA) { - return vector.getLength() > 1; - } - - @SuppressWarnings("unused") - public static boolean lengthOne(RAbstractStringVector vector, String type, byte allowNA) { - return vector.getLength() == 1; - } - - @SuppressWarnings("unused") - public static boolean lengthZero(RAbstractStringVector vector, String type, byte allowNA) { - return vector.getLength() == 0; - } - } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NGetText.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NGetText.java index 702340a9c78c96fb0e4c823bedafcf1bb84c05fe..1e10422a6a71549f965eee2ab381f0461fb386ef 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NGetText.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NGetText.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -49,48 +49,48 @@ public abstract class NGetText extends RBuiltinNode { return new RNode[]{CastIntegerNodeGen.create(children[0], false, false, false), children[1], children[2], children[3]}; } - @Specialization(guards = "wrongNVector") + @Specialization(guards = "wrongNVector(nVector)") protected String getTextEmpty(RAbstractIntVector nVector, String msg1, String msg2, Object domain) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_ARGUMENT, "n"); } - @Specialization(guards = "!wrongNVector") + @Specialization(guards = "!wrongNVector(nVector)") protected String getText(RAbstractIntVector nVector, String msg1, String msg2, Object domain) { int n = nVector.getDataAt(0); return n == 1 ? msg1 : msg2; } - @Specialization(guards = "!wrongNVector") + @Specialization(guards = "!wrongNVector(nVector)") protected String getTextMsg1Null(RAbstractIntVector nVector, RNull msg1, RNull msg2, Object domain) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MUST_BE_STRING, "msg1"); } - @Specialization(guards = "!wrongNVector") + @Specialization(guards = "!wrongNVector(nVector)") protected String getTextMsg1Null(RAbstractIntVector nVector, RNull msg1, RAbstractVector msg2, Object domain) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MUST_BE_STRING, "msg1"); } - @Specialization(guards = {"!wrongNVector", "!msg1StringVectorOneElem"}) + @Specialization(guards = {"!wrongNVector(nVector)", "!msgStringVectorOneElem(msg1)"}) protected String getTextMsg1WrongMsg2Null(RAbstractIntVector nVector, RAbstractVector msg1, RNull msg2, Object domain) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MUST_BE_STRING, "msg1"); } - @Specialization(guards = {"!wrongNVector", "!msg1StringVectorOneElem"}) + @Specialization(guards = {"!wrongNVector(nVector)", "!msgStringVectorOneElem(msg1)"}) protected String getTextMsg1Wrong(RAbstractIntVector nVector, RAbstractVector msg1, RAbstractVector msg2, Object domain) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MUST_BE_STRING, "msg1"); } - @Specialization(guards = {"!wrongNVector", "msg1StringVectorOneElem"}) + @Specialization(guards = {"!wrongNVector(nVector)", "msgStringVectorOneElem(msg1)"}) protected String getTextMsg1(RAbstractIntVector nVector, RAbstractVector msg1, RNull msg2, Object domain) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MUST_BE_STRING, "msg2"); } - @Specialization(guards = {"!wrongNVector", "msg1StringVectorOneElem", "!msg2StringVectorOneElem"}) + @Specialization(guards = {"!wrongNVector(nVector)", "msgStringVectorOneElem(msg1)", "!msgStringVectorOneElem(msg2)"}) protected String getTextMsg2Wrong(RAbstractIntVector nVector, RAbstractVector msg1, RAbstractVector msg2, Object domain) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MUST_BE_STRING, "msg2"); } - @Specialization(guards = {"!wrongNVector", "msg1StringVectorOneElem", "msg2StringVectorOneElem"}) + @Specialization(guards = {"!wrongNVector(nVector)", "msgStringVectorOneElem(msg1)", "msgStringVectorOneElem(msg2)"}) protected String getTextMsg1(RAbstractIntVector nVector, RAbstractVector msg1, RAbstractVector msg2, Object domain) { return getText(nVector, ((RAbstractStringVector) msg1).getDataAt(0), ((RAbstractStringVector) msg2).getDataAt(0), domain); } @@ -99,11 +99,8 @@ public abstract class NGetText extends RBuiltinNode { return nVector.getLength() == 0 || (nVector.getLength() > 0 && nVector.getDataAt(0) < 0); } - protected boolean msg1StringVectorOneElem(RAbstractIntVector nVector, RAbstractVector msg1) { + protected boolean msgStringVectorOneElem(RAbstractVector msg1) { return msg1.getElementClass() == RString.class && msg1.getLength() == 1; } - protected boolean msg2StringVectorOneElem(RAbstractIntVector nVector, RAbstractVector msg1, RAbstractVector msg2) { - return msg2.getElementClass() == RString.class && msg2.getLength() == 1; - } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Options.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Options.java index ce3ef8160afb04710d0da440f972c7c03a8c5a5f..365e3ec44ef73ef4a3f65db7beb1f7c2f1e5c605 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Options.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Options.java @@ -59,12 +59,12 @@ public abstract class Options extends RBuiltinNode { return RDataFactory.createList(data, RDataFactory.createStringVector(names, RDataFactory.COMPLETE_VECTOR)); } - @Specialization(guards = "isMissing") + @Specialization(guards = "isMissing(args)") protected Object optionsMissing(@SuppressWarnings("unused") RArgsValuesAndNames args) { return options(RMissing.instance); } - @Specialization(guards = "!isMissing") + @Specialization(guards = "!isMissing(args)") @TruffleBoundary protected Object options(RArgsValuesAndNames args) { Object[] values = args.getValues(); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Order.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Order.java index af28f1116d6a71a77cdabf927caa937e5642028f..4c4f3e9886e6d28e75c32a090d262dd9380f1ec1 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Order.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Order.java @@ -60,12 +60,12 @@ public abstract class Order extends RPrecedenceBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "noVec") + @Specialization(guards = "noVec(args)") Object orderEmpty(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { return RNull.instance; } - @Specialization(guards = {"oneVec", "isIntegerPrecedence"}) + @Specialization(guards = {"oneVec(args)", "isFirstIntegerPrecedence(frame, args)"}) Object orderInt(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { Object[] vectors = args.getValues(); RAbstractIntVector v = (RAbstractIntVector) castVector(frame, vectors[0]); @@ -93,7 +93,7 @@ public abstract class Order extends RPrecedenceBuiltinNode { return RDataFactory.createIntVector(indx, RDataFactory.COMPLETE_VECTOR); } - @Specialization(guards = {"oneVec", "isDoublePrecedence"}) + @Specialization(guards = {"oneVec(args)", "isFirstDoublePrecedence(frame, args)"}) Object orderDouble(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { Object[] vectors = args.getValues(); RAbstractDoubleVector v = (RAbstractDoubleVector) castVector(frame, vectors[0]); @@ -121,14 +121,14 @@ public abstract class Order extends RPrecedenceBuiltinNode { return RDataFactory.createIntVector(indx, RDataFactory.COMPLETE_VECTOR); } - @Specialization(guards = {"oneVec", "isLogicalPrecedence"}) + @Specialization(guards = {"oneVec(args)", "isFirstLogicalPrecedence(frame, args)"}) Object orderLogical(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { Object[] vectors = args.getValues(); vectors[0] = RClosures.createLogicalToIntVector((RAbstractLogicalVector) castVector(frame, vectors[0]), naCheck); return orderInt(frame, naLastVec, decVec, args); } - @Specialization(guards = {"oneVec", "isStringPrecedence"}) + @Specialization(guards = {"oneVec(args)", "isFirstStringPrecedence(frame, args)"}) Object orderString(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { Object[] vectors = args.getValues(); RAbstractStringVector v = (RAbstractStringVector) castVector(frame, vectors[0]); @@ -156,7 +156,7 @@ public abstract class Order extends RPrecedenceBuiltinNode { return RDataFactory.createIntVector(indx, RDataFactory.COMPLETE_VECTOR); } - @Specialization(guards = {"oneVec", "isComplexPrecedence"}) + @Specialization(guards = {"oneVec(args)", "isFirstComplexPrecedence(frame, args)"}) Object orderComplex(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { Object[] vectors = args.getValues(); RAbstractComplexVector v = (RAbstractComplexVector) castVector(frame, vectors[0]); @@ -200,7 +200,7 @@ public abstract class Order extends RPrecedenceBuiltinNode { return n; } - @Specialization(guards = {"!oneVec", "!noVec"}) + @Specialization(guards = {"!oneVec(args)", "!noVec(args)"}) Object orderMulti(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { int n = preprocessVectors(frame, args); @@ -545,38 +545,31 @@ public abstract class Order extends RPrecedenceBuiltinNode { } } - @SuppressWarnings("unused") - protected boolean isIntegerPrecedence(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { + protected boolean isFirstIntegerPrecedence(VirtualFrame frame, RArgsValuesAndNames args) { return isIntegerPrecedence(frame, args.getValues()[0]); } - @SuppressWarnings("unused") - protected boolean isDoublePrecedence(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { + protected boolean isFirstDoublePrecedence(VirtualFrame frame, RArgsValuesAndNames args) { return isDoublePrecedence(frame, args.getValues()[0]); } - @SuppressWarnings("unused") - protected boolean isLogicalPrecedence(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { + protected boolean isFirstLogicalPrecedence(VirtualFrame frame, RArgsValuesAndNames args) { return isLogicalPrecedence(frame, args.getValues()[0]); } - @SuppressWarnings("unused") - protected boolean isStringPrecedence(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { + protected boolean isFirstStringPrecedence(VirtualFrame frame, RArgsValuesAndNames args) { return isStringPrecedence(frame, args.getValues()[0]); } - @SuppressWarnings("unused") - protected boolean isComplexPrecedence(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { + protected boolean isFirstComplexPrecedence(VirtualFrame frame, RArgsValuesAndNames args) { return isComplexPrecedence(frame, args.getValues()[0]); } - @SuppressWarnings("unused") - protected boolean noVec(RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { + protected boolean noVec(RArgsValuesAndNames args) { return args.length() == 0; } - @SuppressWarnings("unused") - protected boolean oneVec(RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { + protected boolean oneVec(RArgsValuesAndNames args) { return args.length() == 1; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/PMinMax.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/PMinMax.java index 762f34426ff7385b85898178fea92dccfa225c5b..8fa84ff456e3efffd25845df02b44851cc0b2e5d 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/PMinMax.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/PMinMax.java @@ -127,12 +127,12 @@ public abstract class PMinMax extends RBuiltinNode { return length; } - @Specialization(guards = {"isIntegerPrecedence", "oneVector"}) - protected Object pMinMaxOneVecInt(@SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { + @Specialization(guards = {"isIntegerPrecedence(frame, args)", "oneVector(args)"}) + protected Object pMinMaxOneVecInt(@SuppressWarnings("unused") VirtualFrame frame, @SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { return args.getValues()[0]; } - @Specialization(guards = {"isIntegerPrecedence", "!oneVector"}) + @Specialization(guards = {"isIntegerPrecedence(frame, args)", "!oneVector(args)"}) protected RIntVector pMinMaxInt(VirtualFrame frame, byte naRm, RArgsValuesAndNames args) { int maxLength = convertToVectorAndEnableNACheck(frame, args, getIntegerCastNode()); if (lengthProfile.profile(maxLength == 0)) { @@ -169,22 +169,23 @@ public abstract class PMinMax extends RBuiltinNode { } } - @Specialization(guards = {"isLogicalPrecedence", "oneVector"}) - protected Object pMinMaxOneVecLogical(@SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { + @Specialization(guards = {"isLogicalPrecedence(frame, args)", "oneVector(args)"}) + protected Object pMinMaxOneVecLogical(@SuppressWarnings("unused") VirtualFrame frame, @SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { return args.getValues()[0]; } - @Specialization(guards = {"isLogicalPrecedence", "!oneVector"}) + @Specialization(guards = {"isLogicalPrecedence(frame, args)", "!oneVector(args)"}) protected RIntVector pMinMaxLogical(VirtualFrame frame, byte naRm, RArgsValuesAndNames args) { return pMinMaxInt(frame, naRm, args); } - @Specialization(guards = {"isDoublePrecedence", "oneVector"}) - protected Object pMinMaxOneVecDouble(@SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { + @Specialization(guards = {"isDoublePrecedence(frame, args)", "oneVector(args)"}) + @SuppressWarnings("unused") + protected Object pMinMaxOneVecDouble(VirtualFrame frame, byte naRm, RArgsValuesAndNames args) { return args.getValues()[0]; } - @Specialization(guards = {"isDoublePrecedence", "!oneVector"}) + @Specialization(guards = {"isDoublePrecedence(frame, args)", "!oneVector(args)"}) protected RDoubleVector pMinMaxDouble(VirtualFrame frame, byte naRm, RArgsValuesAndNames args) { int maxLength = convertToVectorAndEnableNACheck(frame, args, getDoubleCastNode()); if (lengthProfile.profile(maxLength == 0)) { @@ -221,12 +222,13 @@ public abstract class PMinMax extends RBuiltinNode { } } - @Specialization(guards = {"isStringPrecedence", "oneVector"}) - protected Object pMinMaxOneVecString(@SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { + @Specialization(guards = {"isStringPrecedence(frame, args)", "oneVector(args)"}) + @SuppressWarnings("unused") + protected Object pMinMaxOneVecString(VirtualFrame frame, byte naRm, RArgsValuesAndNames args) { return args.getValues()[0]; } - @Specialization(guards = {"isStringPrecedence", "!oneVector"}) + @Specialization(guards = {"isStringPrecedence(frame, args)", "!oneVector(args)"}) protected RStringVector pMinMaxString(VirtualFrame frame, byte naRm, RArgsValuesAndNames args) { int maxLength = convertToVectorAndEnableNACheck(frame, args, getStringCastNode()); if (lengthProfile.profile(maxLength == 0)) { @@ -244,14 +246,14 @@ public abstract class PMinMax extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "isComplexPrecedence") - protected RComplexVector pMinMaxComplex(byte naRm, RArgsValuesAndNames args) { + @Specialization(guards = "isComplexPrecedence(frame, args)") + protected RComplexVector pMinMaxComplex(VirtualFrame frame, byte naRm, RArgsValuesAndNames args) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_INPUT_TYPE); } @SuppressWarnings("unused") - @Specialization(guards = "isRawPrecedence") - protected RRawVector pMinMaxRaw(byte naRm, RArgsValuesAndNames args) { + @Specialization(guards = "isRawPrecedence(frame, args)") + protected RRawVector pMinMaxRaw(VirtualFrame frame, byte naRm, RArgsValuesAndNames args) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_INPUT_TYPE); } @@ -273,31 +275,31 @@ public abstract class PMinMax extends RBuiltinNode { } - protected boolean isIntegerPrecedence(VirtualFrame frame, @SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { + protected boolean isIntegerPrecedence(VirtualFrame frame, RArgsValuesAndNames args) { return precedence(frame, args) == PrecedenceNode.INT_PRECEDENCE; } - protected boolean isLogicalPrecedence(VirtualFrame frame, @SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { + protected boolean isLogicalPrecedence(VirtualFrame frame, RArgsValuesAndNames args) { return precedence(frame, args) == PrecedenceNode.LOGICAL_PRECEDENCE; } - protected boolean isDoublePrecedence(VirtualFrame frame, @SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { + protected boolean isDoublePrecedence(VirtualFrame frame, RArgsValuesAndNames args) { return precedence(frame, args) == PrecedenceNode.DOUBLE_PRECEDENCE; } - protected boolean isStringPrecedence(VirtualFrame frame, @SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { + protected boolean isStringPrecedence(VirtualFrame frame, RArgsValuesAndNames args) { return precedence(frame, args) == PrecedenceNode.STRING_PRECEDENCE; } - protected boolean isComplexPrecedence(VirtualFrame frame, @SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { + protected boolean isComplexPrecedence(VirtualFrame frame, RArgsValuesAndNames args) { return precedence(frame, args) == PrecedenceNode.COMPLEX_PRECEDENCE; } - protected boolean isRawPrecedence(VirtualFrame frame, @SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { + protected boolean isRawPrecedence(VirtualFrame frame, RArgsValuesAndNames args) { return precedence(frame, args) == PrecedenceNode.RAW_PRECEDENCE; } - protected boolean oneVector(@SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { + protected boolean oneVector(RArgsValuesAndNames args) { return args.length() == 1; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Parse.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Parse.java index ed0cf8f4abcd75d85fc7a3c00d81c9eded0569af..d62f138c34491020af422ec6a860bae7c7c5249e 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Parse.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Parse.java @@ -135,7 +135,7 @@ public abstract class Parse extends RBuiltinNode { return RDataFactory.createExpression(RDataFactory.createList()); } try { - Source source = srcFile != RNull.instance ? createSource(srcFile, coalescedLines) : createSource(conn); + Source source = srcFile != RNull.instance ? createSource(srcFile, coalescedLines) : createSource(conn, coalescedLines); RExpression exprs = RContext.getEngine().parse(source); if (n > 0 && n > exprs.getLength()) { RList list = exprs.getList(); @@ -181,7 +181,7 @@ public abstract class Parse extends RBuiltinNode { } else { path = fileName; } - return createFileSource(path); + return createFileSource(path, coalescedLines); } else { return Source.asPseudoFile(coalescedLines, "<parse>"); } @@ -190,25 +190,21 @@ public abstract class Parse extends RBuiltinNode { if (srcFileText.equals("<text>")) { return Source.asPseudoFile(coalescedLines, "<parse>"); } else { - return createFileSource(ConnectionSupport.removeFileURLPrefix(srcFileText)); + return createFileSource(ConnectionSupport.removeFileURLPrefix(srcFileText), coalescedLines); } } } - private static Source createSource(RConnection conn) { + private static Source createSource(RConnection conn, String coalescedLines) { // TODO check if file String path = ConnectionSupport.getBaseConnection(conn).getSummaryDescription(); - return createFileSource(path); + return createFileSource(path, coalescedLines); } - private static Source createFileSource(String path) { + private static Source createFileSource(String path, CharSequence chars) { try { - /* - * Although we have read the source, it will be re-read in parse as there is currently - * no way to pass the source we have to Source.fromFileName. - */ - return Source.fromFileName(path); + return Source.fromFileName(chars, path); } catch (IOException ex) { throw RInternalError.shouldNotReachHere(); } @@ -222,8 +218,8 @@ public abstract class Parse extends RBuiltinNode { int[] llocData = new int[8]; int startLine = ss.getStartLine(); int startColumn = ss.getStartColumn(); - int lastLine = source.getLineNumber(ss.getCharEndIndex() - 1); - int lastColumn = source.getColumnNumber(ss.getCharEndIndex() - 1) - 1; + int lastLine = ss.getEndLine(); + int lastColumn = ss.getEndColumn(); // no multi-byte support, so byte==line llocData[0] = startLine; llocData[1] = startColumn; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/PrettyPrinterNode.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/PrettyPrinterNode.java index 15e596d29c907877063d3800acecb5e40692159e..06820da55513abdff5024c5bf2806663353e5e09 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/PrettyPrinterNode.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/PrettyPrinterNode.java @@ -727,49 +727,49 @@ public abstract class PrettyPrinterNode extends RNode { } @TruffleBoundary - @Specialization(guards = "twoDimsOrMore") + @Specialization(guards = "twoDimsOrMore(operand)") protected String prettyPrintM(RList operand, Object listElementName, byte quote, byte right) { return printVectorMultiDim(operand, true, false, quote); } @TruffleBoundary - @Specialization(guards = "twoDimsOrMore") + @Specialization(guards = "twoDimsOrMore(operand)") protected String prettyPrintM(RAbstractStringVector operand, Object listElementName, byte quote, byte right) { return printVectorMultiDim(operand, right == RRuntime.LOGICAL_FALSE, false, quote); } @TruffleBoundary - @Specialization(guards = "twoDimsOrMore") + @Specialization(guards = "twoDimsOrMore(operand)") protected String prettyPrintM(RAbstractComplexVector operand, Object listElementName, byte quote, byte right) { return printVectorMultiDim(operand, false, true, quote); } @TruffleBoundary - @Specialization(guards = "twoDimsOrMore") + @Specialization(guards = "twoDimsOrMore(operand)") protected String prettyPrintM(RAbstractRawVector operand, Object listElementName, byte quote, byte right) { return printVectorMultiDim(operand, false, true, quote); } @TruffleBoundary - @Specialization(guards = "twoDimsOrMore") + @Specialization(guards = "twoDimsOrMore(operand)") protected String prettyPrintM(RAbstractDoubleVector operand, Object listElementName, byte quote, byte right) { return printVectorMultiDim(operand, false, false, quote); } @TruffleBoundary - @Specialization(guards = "twoDimsOrMore") + @Specialization(guards = "twoDimsOrMore(operand)") protected String prettyPrintM(RAbstractIntVector operand, Object listElementName, byte quote, byte right) { return printVectorMultiDim(operand, false, false, quote); } @TruffleBoundary - @Specialization(guards = "twoDimsOrMore") + @Specialization(guards = "twoDimsOrMore(operand)") protected String prettyPrintM(RAbstractLogicalVector operand, Object listElementName, byte quote, byte right) { return printVectorMultiDim(operand, false, false, quote); } @TruffleBoundary - @Specialization(guards = "!twoDimsOrMore") + @Specialization(guards = "!twoDimsOrMore(operand)") protected String prettyPrint(RList operand, Object listElementName, byte quote, byte right) { return prettyPrintList0(operand, listElementName, quote, right); } @@ -795,7 +795,7 @@ public abstract class PrettyPrinterNode extends RNode { } @TruffleBoundary - @Specialization(guards = "!twoDimsOrMore") + @Specialization(guards = "!twoDimsOrMore(operand)") protected String prettyPrint(RAbstractDoubleVector operand, Object listElementName, byte quote, byte right) { int length = operand.getLength(); String[] values = new String[length]; @@ -810,7 +810,7 @@ public abstract class PrettyPrinterNode extends RNode { } @TruffleBoundary - @Specialization(guards = "!twoDimsOrMore") + @Specialization(guards = "!twoDimsOrMore(operand)") protected String prettyPrint(RAbstractIntVector operand, Object listElementName, byte quote, byte right) { int length = operand.getLength(); String[] values = new String[length]; @@ -822,7 +822,7 @@ public abstract class PrettyPrinterNode extends RNode { } @TruffleBoundary - @Specialization(guards = "!twoDimsOrMore") + @Specialization(guards = "!twoDimsOrMore(operand)") protected String prettyPrint(RAbstractStringVector operand, Object listElementName, byte quote, byte right) { int length = operand.getLength(); String[] values = new String[length]; @@ -842,7 +842,7 @@ public abstract class PrettyPrinterNode extends RNode { } @TruffleBoundary - @Specialization(guards = "!twoDimsOrMore") + @Specialization(guards = "!twoDimsOrMore(operand)") protected String prettyPrint(RAbstractLogicalVector operand, Object listElementName, byte quote, byte right) { int length = operand.getLength(); String[] values = new String[length]; @@ -854,7 +854,7 @@ public abstract class PrettyPrinterNode extends RNode { } @TruffleBoundary - @Specialization(guards = "!twoDimsOrMore") + @Specialization(guards = "!twoDimsOrMore(operand)") protected String prettyPrint(RAbstractRawVector operand, Object listElementName, byte quote, byte right) { int length = operand.getLength(); String[] values = new String[length]; @@ -866,7 +866,7 @@ public abstract class PrettyPrinterNode extends RNode { } @TruffleBoundary - @Specialization(guards = "!twoDimsOrMore") + @Specialization(guards = "!twoDimsOrMore(operand)") protected String prettyPrint(RAbstractComplexVector operand, Object listElementName, byte quote, byte right) { if (re == null) { // the two are allocated side by side; checking for re is sufficient @@ -902,34 +902,6 @@ public abstract class PrettyPrinterNode extends RNode { return v.hasDimensions() && v.getDimensions().length > 1; } - protected static boolean twoDimsOrMore(RAbstractDoubleVector v) { - return v.hasDimensions() && v.getDimensions().length > 1; - } - - protected static boolean twoDimsOrMore(RAbstractIntVector v) { - return v.hasDimensions() && v.getDimensions().length > 1; - } - - protected static boolean twoDimsOrMore(RAbstractStringVector v) { - return v.hasDimensions() && v.getDimensions().length > 1; - } - - protected static boolean twoDimsOrMore(RAbstractLogicalVector v) { - return v.hasDimensions() && v.getDimensions().length > 1; - } - - protected static boolean twoDimsOrMore(RAbstractRawVector v) { - return v.hasDimensions() && v.getDimensions().length > 1; - } - - protected static boolean twoDimsOrMore(RAbstractComplexVector v) { - return v.hasDimensions() && v.getDimensions().length > 1; - } - - protected static boolean twoDimsOrMore(RList l) { - return l.hasDimensions() && l.getDimensions().length > 1; - } - protected static boolean isLengthOne(RAbstractIntVector v) { return v.getLength() == 1; } @@ -1272,13 +1244,13 @@ public abstract class PrettyPrinterNode extends RNode { } @TruffleBoundary - @Specialization(guards = {"!isLengthOne", "!isVectorList"}) + @Specialization(guards = {"operand.getLength() != 1", "!isVectorList(operand)"}) protected String prettyPrintVectorElement(RAbstractVector operand, byte isQuoted) { return prettyPrint(operand); } @TruffleBoundary - @Specialization(guards = {"isLengthOne", "!isVectorList"}) + @Specialization(guards = {"operand.getLength() == 1", "!isVectorList(operand)"}) protected String prettyPrintVectorElementLengthOne(RAbstractVector operand, byte isQuoted) { return prettyPrintRecursive(operand.getDataAtAsObject(0), isQuoted); } @@ -1430,7 +1402,7 @@ public abstract class PrettyPrinterNode extends RNode { } @TruffleBoundary - @Specialization(guards = "isEmpty") + @Specialization(guards = "vector.getLength() == 0") protected String printVector2DimEmpty(RAbstractVector vector, RIntVector dimensions, int offset, byte isListOrStringVector, byte isComplexOrRawVector, byte isQuoted) { int nrow = dimensions.getDataAt(0); int ncol = dimensions.getDataAt(1); @@ -1467,7 +1439,7 @@ public abstract class PrettyPrinterNode extends RNode { } @TruffleBoundary - @Specialization(guards = "!isEmpty") + @Specialization(guards = "vector.getLength() != 0") protected String printVector2Dim(RAbstractDoubleVector vector, RIntVector dimensions, int offset, byte isListOrStringVector, byte isComplexOrRawVector, byte isQuoted) { int nrow = dimensions.getDataAt(0); int ncol = dimensions.getDataAt(1); @@ -1529,7 +1501,7 @@ public abstract class PrettyPrinterNode extends RNode { } @TruffleBoundary - @Specialization(guards = "!isEmpty") + @Specialization(guards = "vector.getLength() != 0") protected String printVector2Dim(RAbstractComplexVector vector, RIntVector dimensions, int offset, byte isListOrStringVector, byte isComplexOrRawVector, byte isQuoted) { int nrow = dimensions.getDataAt(0); int ncol = dimensions.getDataAt(1); @@ -1584,7 +1556,7 @@ public abstract class PrettyPrinterNode extends RNode { } @TruffleBoundary - @Specialization(guards = {"!isEmpty", "notDoubleOrComplex"}) + @Specialization(guards = {"vector.getLength() != 0", "notDoubleOrComplex(vector)"}) protected String printVector2Dim(RAbstractVector vector, RIntVector dimensions, int offset, byte isListOrStringVector, byte isComplexOrRawVector, byte isQuoted) { int nrow = dimensions.getDataAt(0); int ncol = dimensions.getDataAt(1); @@ -1752,18 +1724,6 @@ public abstract class PrettyPrinterNode extends RNode { return builderToString(b); } - protected boolean isEmpty(RAbstractVector vector, RIntVector dimensions, int offset, byte isListOrStringVector, byte isComplexOrRawVector, byte isQuoted) { - return vector.getLength() == 0; - } - - protected boolean isEmpty(RAbstractDoubleVector vector, RIntVector dimensions, int offset, byte isListOrStringVector, byte isComplexOrRawVector, byte isQuoted) { - return vector.getLength() == 0; - } - - protected boolean isEmpty(RAbstractComplexVector vector, RIntVector dimensions, int offset, byte isListOrStringVector, byte isComplexOrRawVector, byte isQuoted) { - return vector.getLength() == 0; - } - } @NodeChildren({@NodeChild(value = "vector", type = RNode.class), @NodeChild(value = "isListOrStringVector", type = RNode.class), @NodeChild(value = "isComplexOrRawVector", type = RNode.class), diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ReadREnviron.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ReadREnviron.java index 9030eb8729320bc8258516765588e34bca7f6080..004ac291ecc68b73bc40f415884a55dfb6cedb75 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ReadREnviron.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ReadREnviron.java @@ -36,7 +36,7 @@ import com.oracle.truffle.r.runtime.data.model.*; public abstract class ReadREnviron extends RInvisibleBuiltinNode { @TruffleBoundary - @Specialization(guards = "lengthOneCVector") + @Specialization(guards = "lengthOneCVector(vec)") protected Object doReadEnviron(RAbstractStringVector vec) { controlVisibility(); String path = Utils.tildeExpand(vec.getDataAt(0)); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Repeat.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Repeat.java index 0eefc61dcc1300e53bd05d5bb6a5e469bb84ba2d..3d12803f9b4139ad28f35d14dace042bba705a77 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Repeat.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Repeat.java @@ -91,13 +91,7 @@ public abstract class Repeat extends RBuiltinNode { return arguments; } - @SuppressWarnings("unused") - protected static boolean eachGreaterOne(RAbstractVector x, RAbstractIntVector times, int lengthOut, int each) { - return each > 1; - } - - @SuppressWarnings("unused") - protected boolean hasNames(RAbstractVector x, RAbstractIntVector times, int lengthOut, int each) { + protected boolean hasNames(RAbstractVector x) { return x.getNames(attrProfiles) != null; } @@ -105,7 +99,7 @@ public abstract class Repeat extends RBuiltinNode { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_ARGUMENT, "times"); } - @Specialization(guards = {"eachGreaterOne", "!hasNames"}) + @Specialization(guards = {"each > 1", "!hasNames(x)"}) public RAbstractVector repEachNoNames(RAbstractVector x, RAbstractIntVector times, int lengthOut, int each) { if (times.getLength() > 1) { errorBranch.enter(); @@ -119,7 +113,7 @@ public abstract class Repeat extends RBuiltinNode { } } - @Specialization(guards = {"!eachGreaterOne", "!hasNames"}) + @Specialization(guards = {"each <= 1", "!hasNames(x)"}) public RAbstractVector repNoEachNoNames(RAbstractVector x, RAbstractIntVector times, int lengthOut, @SuppressWarnings("unused") int each) { if (lengthOutOrTimes.profile(!RRuntime.isNA(lengthOut))) { return handleLengthOut(x, lengthOut, true); @@ -128,7 +122,7 @@ public abstract class Repeat extends RBuiltinNode { } } - @Specialization(guards = {"eachGreaterOne", "hasNames"}) + @Specialization(guards = {"each > 1", "hasNames(x)"}) public RAbstractVector repEachNames(RAbstractVector x, RAbstractIntVector times, int lengthOut, int each) { if (times.getLength() > 1) { errorBranch.enter(); @@ -149,7 +143,7 @@ public abstract class Repeat extends RBuiltinNode { } } - @Specialization(guards = {"!eachGreaterOne", "hasNames"}) + @Specialization(guards = {"each <= 1", "hasNames(x)"}) public RAbstractVector repNoEachNames(RAbstractVector x, RAbstractIntVector times, int lengthOut, @SuppressWarnings("unused") int each) { if (lengthOutOrTimes.profile(!RRuntime.isNA(lengthOut))) { RStringVector names = (RStringVector) handleLengthOut(x.getNames(attrProfiles), lengthOut, true); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Round.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Round.java index 200ee439e827ef23d8f79e4153a65a0eb7cd3d1a..d9faae57f32f4d996f30256e9c77188105a306e0 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Round.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Round.java @@ -55,33 +55,25 @@ public abstract class Round extends RBuiltinNode { return arguments; } - protected static boolean hasDigits(@SuppressWarnings("unused") Object x, int digits) { - return digits != 0; - } - - protected static boolean hasDigits(@SuppressWarnings("unused") RAbstractVector x, int digits) { - return digits != 0; - } - @Specialization protected int round(int x, @SuppressWarnings("unused") int digits) { controlVisibility(); return roundOp.op(x); } - @Specialization(guards = "!hasDigits") + @Specialization(guards = "digits == 0") protected double round(double x, @SuppressWarnings("unused") int digits) { controlVisibility(); return roundOp.op(x); } - @Specialization(guards = "hasDigits") + @Specialization(guards = "digits != 0") protected double roundDigits(double x, int digits) { controlVisibility(); return roundOp.opd(x, digits); } - @Specialization(guards = "!hasDigits") + @Specialization(guards = "digits == 0") protected RDoubleVector round(RAbstractDoubleVector x, int digits) { controlVisibility(); double[] result = new double[x.getLength()]; @@ -95,7 +87,7 @@ public abstract class Round extends RBuiltinNode { return ret; } - @Specialization(guards = "hasDigits") + @Specialization(guards = "digits != 0") protected RDoubleVector roundDigits(RAbstractDoubleVector x, int digits) { controlVisibility(); double[] result = new double[x.getLength()]; @@ -109,19 +101,19 @@ public abstract class Round extends RBuiltinNode { return ret; } - @Specialization(guards = "!hasDigits") + @Specialization(guards = "digits == 0") protected RComplex round(RComplex x, @SuppressWarnings("unused") int digits) { controlVisibility(); return roundOp.op(x.getRealPart(), x.getImaginaryPart()); } - @Specialization(guards = "hasDigits") + @Specialization(guards = "digits != 0") protected RComplex roundDigits(RComplex x, int digits) { controlVisibility(); return roundOp.opd(x.getRealPart(), x.getImaginaryPart(), digits); } - @Specialization(guards = "!hasDigits") + @Specialization(guards = "digits == 0") protected RComplexVector round(RComplexVector x, int digits) { controlVisibility(); double[] result = new double[x.getLength() << 1]; @@ -138,7 +130,7 @@ public abstract class Round extends RBuiltinNode { return ret; } - @Specialization(guards = "hasDigits") + @Specialization(guards = "digits != 0") protected RComplexVector roundDigits(RComplexVector x, int digits) { controlVisibility(); double[] result = new double[x.getLength() << 1]; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/RowMeans.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/RowMeans.java index d58667a998887df29066faf12d3169e4e85e1ecc..c30176f8103bf123e0788be76cbc12882e41cdc7 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/RowMeans.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/RowMeans.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2014, Purdue University - * Copyright (c) 2014, Oracle and/or its affiliates + * Copyright (c) 2014, 2015, Oracle and/or its affiliates * * All rights reserved. */ @@ -45,7 +45,7 @@ public abstract class RowMeans extends RBuiltinNode { return arguments; } - @Specialization(guards = "!isNaRm") + @Specialization(guards = "!isNaRm(naRm)") @TruffleBoundary protected RDoubleVector rowMeansNaRmFalse(RDoubleVector x, int rowNum, int colNum, @SuppressWarnings("unused") byte naRm) { controlVisibility(); @@ -72,7 +72,7 @@ public abstract class RowMeans extends RBuiltinNode { return RDataFactory.createDoubleVector(result, na.neverSeenNA() && isComplete); } - @Specialization(guards = "isNaRm") + @Specialization(guards = "isNaRm(naRm)") @TruffleBoundary protected RDoubleVector rowMeansNaRmTrue(RDoubleVector x, int rowNum, int colNum, @SuppressWarnings("unused") byte naRm) { controlVisibility(); @@ -99,7 +99,7 @@ public abstract class RowMeans extends RBuiltinNode { return RDataFactory.createDoubleVector(result, isComplete); } - @Specialization(guards = "!isNaRm") + @Specialization(guards = "!isNaRm(naRm)") @TruffleBoundary protected RDoubleVector rowMeansNaRmFalse(RLogicalVector x, int rowNum, int colNum, @SuppressWarnings("unused") byte naRm) { controlVisibility(); @@ -120,7 +120,7 @@ public abstract class RowMeans extends RBuiltinNode { return RDataFactory.createDoubleVector(result, na.neverSeenNA()); } - @Specialization(guards = "isNaRm") + @Specialization(guards = "isNaRm(naRm)") @TruffleBoundary protected RDoubleVector rowMeansNaRmTrue(RLogicalVector x, int rowNum, int colNum, @SuppressWarnings("unused") byte naRm) { controlVisibility(); @@ -147,7 +147,7 @@ public abstract class RowMeans extends RBuiltinNode { return RDataFactory.createDoubleVector(result, isComplete); } - @Specialization(guards = "!isNaRm") + @Specialization(guards = "!isNaRm(naRm)") @TruffleBoundary protected RDoubleVector rowMeansNaRmFalse(RIntVector x, int rowNum, int colNum, @SuppressWarnings("unused") byte naRm) { controlVisibility(); @@ -168,7 +168,7 @@ public abstract class RowMeans extends RBuiltinNode { return RDataFactory.createDoubleVector(result, na.neverSeenNA()); } - @Specialization(guards = "isNaRm") + @Specialization(guards = "isNaRm(naRm)") @TruffleBoundary protected RDoubleVector rowMeansNaRmTrue(RIntVector x, int rowNum, int colNum, @SuppressWarnings("unused") byte naRm) { controlVisibility(); @@ -203,18 +203,8 @@ public abstract class RowMeans extends RBuiltinNode { throw RError.error(getEncapsulatingSourceSection(), RError.Message.X_NUMERIC); } - @SuppressWarnings("unused") - protected boolean isNaRm(RDoubleVector x, int rowNum, int colNum, byte naRm) { - return naRm == RRuntime.LOGICAL_TRUE; - } - - @SuppressWarnings("unused") - protected boolean isNaRm(RIntVector x, int rowNum, int colNum, byte naRm) { + protected boolean isNaRm(byte naRm) { return naRm == RRuntime.LOGICAL_TRUE; } - @SuppressWarnings("unused") - protected boolean isNaRm(RLogicalVector x, int rowNum, int colNum, byte naRm) { - return naRm == RRuntime.LOGICAL_TRUE; - } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Sample.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Sample.java index e3c49589daff3f6481d30bd2d1886ad8beda4ab5..e58f8ee4cd4a682272dc67469c99fca30fc35c6e 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Sample.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Sample.java @@ -26,6 +26,7 @@ import com.oracle.truffle.r.nodes.unary.CastIntegerNodeGen; import com.oracle.truffle.r.nodes.unary.CastLogicalNodeGen; 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.rng.RRNG; import static com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -49,28 +50,28 @@ public abstract class Sample extends RBuiltinNode { return arguments; } - @Specialization(guards = "invalidFirstArgument") + @Specialization(guards = "invalidFirstArgument(x, size)") @SuppressWarnings("unused") protected RIntVector doSampleInvalidFirstArg(final int x, final int size, final byte isRepeatable, final RDoubleVector prob) { CompilerDirectives.transferToInterpreter(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_FIRST_ARGUMENT); } - @Specialization(guards = "invalidProb") + @Specialization(guards = "invalidProb(x, prob)") @SuppressWarnings("unused") protected RIntVector doSampleInvalidProb(final int x, final int size, final byte isRepeatable, final RDoubleVector prob) { CompilerDirectives.transferToInterpreter(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.INCORRECT_NUM_PROB); } - @Specialization(guards = "largerPopulation") + @Specialization(guards = "largerPopulation(x, size, isRepeatable)") @SuppressWarnings("unused") protected RIntVector doSampleLargerPopulation(final int x, final int size, final byte isRepeatable, final RDoubleVector prob) { CompilerDirectives.transferToInterpreter(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.SAMPLE_LARGER_THAN_POPULATION); } - @Specialization(guards = "invalidSizeArgument") + @Specialization(guards = "invalidSizeArgument(size)") @SuppressWarnings("unused") protected RIntVector doSampleInvalidSize(final int x, final int size, final byte isRepeatable, final RDoubleVector prob) { CompilerDirectives.transferToInterpreter(); @@ -78,7 +79,7 @@ public abstract class Sample extends RBuiltinNode { } - @Specialization(guards = {"!invalidFirstArgument", "!invalidProb", "!largerPopulation", "!invalidSizeArgument", "withReplacement"}) + @Specialization(guards = {"!invalidFirstArgument(x, size)", "!invalidProb(x, prob)", "!largerPopulation(x, size, isRepeatable)", "!invalidSizeArgument(size)", "withReplacement(isRepeatable)"}) @TruffleBoundary protected RIntVector doSampleWithReplacement(final int x, final int size, final byte isRepeatable, final RDoubleVector prob) { // The following code is transcribed from GNU R src/main/random.c lines 493-501 in @@ -99,7 +100,7 @@ public abstract class Sample extends RBuiltinNode { } } - @Specialization(guards = {"!invalidFirstArgument", "!invalidProb", "!largerPopulation", "!invalidSizeArgument", "!withReplacement"}) + @Specialization(guards = {"!invalidFirstArgument(x, size)", "!invalidProb(x, prob)", "!largerPopulation(x, size, isRepeatable)", "!invalidSizeArgument(size)", "!withReplacement(isRepeatable)"}) @TruffleBoundary protected RIntVector doSampleNoReplacement(final int x, final int size, final byte isRepeatable, final RDoubleVector prob) { double[] probArray = prob.getDataCopy(); @@ -108,27 +109,27 @@ public abstract class Sample extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "invalidFirstArgumentNullProb") + @Specialization(guards = "invalidFirstArgumentNullProb(x, size)") protected RIntVector doSampleInvalidFirstArgument(final int x, final int size, final byte isRepeatable, final RNull prob) { CompilerDirectives.transferToInterpreter(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_FIRST_ARGUMENT); } @SuppressWarnings("unused") - @Specialization(guards = "invalidSizeArgument") + @Specialization(guards = "invalidSizeArgument(size)") protected RIntVector doSampleInvalidSizeArgument(final int x, final int size, final byte isRepeatable, final RNull prob) { CompilerDirectives.transferToInterpreter(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_ARGUMENT, RRuntime.intToString(size)); } @SuppressWarnings("unused") - @Specialization(guards = "largerPopulation") + @Specialization(guards = "largerPopulation(x, size, isRepeatable)") protected RIntVector doSampleInvalidLargerPopulation(final int x, final int size, final byte isRepeatable, final RNull prob) { CompilerDirectives.transferToInterpreter(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.INCORRECT_NUM_PROB); } - @Specialization(guards = {"!invalidFirstArgumentNullProb", "!invalidSizeArgument", "!largerPopulation"}) + @Specialization(guards = {"!invalidFirstArgumentNullProb(x, size)", "!invalidSizeArgument(size)", "!largerPopulation(x, size, isRepeatable)"}) @TruffleBoundary protected RIntVector doSample(final int x, final int size, final byte isRepeatable, @SuppressWarnings("unused") final RNull prob) { // TODO:Add support of long integers. @@ -156,7 +157,7 @@ public abstract class Sample extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "invalidIsRepeatable") + @Specialization(guards = "invalidIsRepeatable(isRepeatable)") protected RIntVector doSampleInvalidIsRepeatable(int x, int size, byte isRepeatable, RDoubleVector prob) { CompilerDirectives.transferToInterpreter(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_ARGUMENT, RRuntime.logicalToString(isRepeatable)); @@ -187,48 +188,31 @@ public abstract class Sample extends RBuiltinNode { } } - @SuppressWarnings("unused") - protected static boolean invalidFirstArgumentNullProb(final int x, final int size, final byte isRepeatable, final RNull prob) { + protected static boolean invalidFirstArgumentNullProb(final int x, final int size) { return !RRuntime.isFinite(x) || x < 0 || x > 4.5e15 || (size > 0 && x == 0); } - @SuppressWarnings("unused") - protected static boolean invalidSizeArgument(final int x, final int size, final byte isRepeatable, final RNull prob) { + protected static boolean invalidSizeArgument(int size) { return RRuntime.isNA(size) || size < 0; } - @SuppressWarnings("unused") - protected static boolean largerPopulation(final int x, final int size, final byte isRepeatable, final RNull prob) { + protected static boolean largerPopulation(final int x, final int size, final byte isRepeatable) { return isRepeatable == RRuntime.LOGICAL_FALSE && size > x; } - @SuppressWarnings("unused") - protected static boolean invalidFirstArgument(final int x, final int size, final byte isRepeatable, final RDoubleVector prob) { + protected static boolean invalidFirstArgument(final int x, final int size) { return RRuntime.isNA(x) || x < 0 || (size > 0 && x == 0); } - @SuppressWarnings("unused") - protected static boolean invalidSizeArgument(final int x, final int size, final byte isRepeatable, final RDoubleVector prob) { - return RRuntime.isNA(size) || size < 0; - } - - @SuppressWarnings("unused") - protected static boolean invalidProb(final int x, final int size, final byte isRepeatable, final RDoubleVector prob) { + protected static boolean invalidProb(final int x, final RAbstractVector prob) { return prob.getLength() != x; } - @SuppressWarnings("unused") - protected static boolean withReplacement(final int x, final int size, final byte isRepeatable, final RDoubleVector prob) { + protected static boolean withReplacement(final byte isRepeatable) { return isRepeatable == RRuntime.LOGICAL_TRUE; } - @SuppressWarnings("unused") - protected static boolean largerPopulation(final int x, final int size, final byte isRepeatable, final RDoubleVector prob) { - return isRepeatable == RRuntime.LOGICAL_FALSE && size > x; - } - - @SuppressWarnings("unused") - protected static boolean invalidIsRepeatable(final int x, final int size, final byte isRepeatable, final RDoubleVector prob) { + protected static boolean invalidIsRepeatable(final byte isRepeatable) { return RRuntime.isNA(isRepeatable); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Seq.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Seq.java index 7f2f1c0368c64214340bd2db2b5ebc1f77607205..4cd05501dceb444977c04050c14975b75921c0b2 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Seq.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Seq.java @@ -180,7 +180,7 @@ public abstract class Seq extends RBuiltinNode { // int vector start, missing to - @Specialization(guards = "!startEmpty") + @Specialization(guards = "!startEmpty(start)") protected RIntSequence seqFromOneArg(RAbstractIntVector start, RMissing to, RMissing stride, RMissing lengthOut, RMissing alongWith) { validateParam(start.getDataAt(0), "to"); controlVisibility(); @@ -188,33 +188,33 @@ public abstract class Seq extends RBuiltinNode { return RDataFactory.createIntSequence(1, 1, start.getLength()); } - @Specialization(guards = "startEmpty") + @Specialization(guards = "startEmpty(start)") protected RIntVector seqFromOneArgEmpty(RAbstractIntVector start, RMissing to, RMissing stride, RMissing lengthOut, RMissing alongWith) { return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = {"startLengthOne", "!lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "!lengthZero(lengthOut)"}) protected RDoubleSequence seq(RAbstractIntVector start, RMissing to, RMissing stride, int lengthOut, RMissing alongWith) { controlVisibility(); validateParam(start.getDataAt(0), "from"); return RDataFactory.createDoubleSequence(RRuntime.int2double(start.getDataAt(0)), 1, lengthOut); } - @Specialization(guards = {"startLengthOne", "!lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "!lengthZero(lengthOut)"}) protected RDoubleSequence seq(RAbstractIntVector start, RMissing to, RMissing stride, double lengthOut, RMissing alongWith) { controlVisibility(); validateParam(start.getDataAt(0), "from"); return RDataFactory.createDoubleSequence(RRuntime.int2double(start.getDataAt(0)), 1, (int) Math.ceil(lengthOut)); } - @Specialization(guards = {"startLengthOne", "lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "lengthZero(lengthOut)"}) protected RIntVector seqLengthZero(RAbstractIntVector start, RMissing to, RMissing stride, int lengthOut, RMissing alongWith) { controlVisibility(); validateParam(start.getDataAt(0), "from"); return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = {"startLengthOne", "lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "lengthZero(lengthOut)"}) protected RIntVector seqLengthZero(RAbstractIntVector start, RMissing to, RMissing stride, double lengthOut, RMissing alongWith) { controlVisibility(); validateParam(start.getDataAt(0), "from"); @@ -223,69 +223,69 @@ public abstract class Seq extends RBuiltinNode { // int vector start, int vector to - @Specialization(guards = {"startLengthOne", "toLengthOne", "zero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "zero(start, to)"}) protected int seqZero(VirtualFrame frame, RAbstractIntVector start, RAbstractIntVector to, Object stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); return 0; } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!zero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!zero(start, to)"}) protected RIntSequence seq(RAbstractIntVector start, RAbstractIntVector to, RMissing stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return RDataFactory.createIntSequence(start.getDataAt(0), ascending(start, to) ? 1 : -1, Math.abs(to.getDataAt(0) - start.getDataAt(0)) + 1); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!zero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!zero(start, to)"}) protected RIntSequence seq(RAbstractIntVector start, RAbstractIntVector to, int stride, RMissing lengthOut, RMissing alongWith) { validateParams(start, to); controlVisibility(); return RDataFactory.createIntSequence(start.getDataAt(0), stride, Math.abs((to.getDataAt(0) - start.getDataAt(0)) / stride) + 1); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!zero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!zero(start, to)"}) protected RDoubleSequence seq(RAbstractIntVector start, RAbstractIntVector to, double stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return RDataFactory.createDoubleSequence(RRuntime.int2double(start.getDataAt(0)), stride, (int) (Math.abs((to.getDataAt(0) - start.getDataAt(0)) / stride)) + 1); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!lengthZero(lengthOut)"}) protected RIntVector seq(RAbstractIntVector start, RAbstractIntVector to, RMissing stride, int lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return getVectorWithComputedStride(start.getDataAt(0), to.getDataAt(0), RRuntime.int2double(lengthOut), ascending(start, to)); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!lengthZero(lengthOut)"}) protected RIntVector seq(RAbstractIntVector start, RAbstractIntVector to, RMissing stride, double lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return getVectorWithComputedStride(start.getDataAt(0), to.getDataAt(0), lengthOut, ascending(start, to)); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "lengthZero(lengthOut)"}) protected RIntVector seqLengthZero(RAbstractIntVector start, RAbstractIntVector to, RMissing stride, int lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "lengthZero(lengthOut)"}) protected RIntVector seqLengthZero(RAbstractIntVector start, RAbstractIntVector to, RMissing stride, double lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = {"startLengthOne", "lengthZeroAlong"}) + @Specialization(guards = {"startLengthOne(start)", "lengthZeroAlong(alongWith)"}) protected RIntVector seq(RAbstractIntVector start, RMissing to, RMissing stride, Object lengthOut, RAbstractVector alongWith) { controlVisibility(); validateParam(start.getDataAt(0), "from"); return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = {"startLengthOne", "!lengthZeroAlong"}) + @Specialization(guards = {"startLengthOne(start)", "!lengthZeroAlong(alongWith)"}) protected RDoubleSequence seqLengthZero(RAbstractIntVector start, RMissing to, RMissing stride, Object lengthOut, RAbstractVector alongWith) { controlVisibility(); validateParam(start.getDataAt(0), "from"); @@ -294,20 +294,20 @@ public abstract class Seq extends RBuiltinNode { // int vector start, double vector to - @Specialization(guards = {"startLengthOne", "toLengthOne", "zero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "zero(start, to)"}) protected int seqZero(VirtualFrame frame, RAbstractIntVector start, RAbstractDoubleVector to, Object stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); return 0; } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!zero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!zero(start, to)"}) protected RIntSequence seq(RAbstractIntVector start, RAbstractDoubleVector to, RMissing stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return RDataFactory.createIntSequence(start.getDataAt(0), ascending(start, to) ? 1 : -1, (int) Math.abs(to.getDataAt(0) - start.getDataAt(0)) + 1); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!zero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!zero(start, to)"}) protected RDoubleSequence seq(RAbstractIntVector start, RAbstractDoubleVector to, int stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); @@ -318,7 +318,7 @@ public abstract class Seq extends RBuiltinNode { return RDataFactory.createDoubleSequence(start.getDataAt(0), stride, length); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!zero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!zero(start, to)"}) protected RDoubleSequence seq(RAbstractIntVector start, RAbstractDoubleVector to, double stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); @@ -329,28 +329,28 @@ public abstract class Seq extends RBuiltinNode { return RDataFactory.createDoubleSequence(start.getDataAt(0), stride, length); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "lengthZero(lengthOut)"}) protected RIntVector seqLengthZero(RAbstractIntVector start, RAbstractDoubleVector to, RMissing stride, int lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!lengthZero(lengthOut)"}) protected RDoubleVector seq(RAbstractIntVector start, RAbstractDoubleVector to, RMissing stride, int lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return getVectorWithComputedStride(RRuntime.int2double(start.getDataAt(0)), to.getDataAt(0), lengthOut, ascending(start, to)); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "lengthZero(lengthOut)"}) protected RIntVector seqLengthZero(RAbstractIntVector start, RAbstractDoubleVector to, RMissing stride, double lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!lengthZero(lengthOut)"}) protected RDoubleVector seq(RAbstractIntVector start, RAbstractDoubleVector to, RMissing stride, double lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); @@ -359,7 +359,7 @@ public abstract class Seq extends RBuiltinNode { // double vector start, missing to - @Specialization(guards = "!startEmpty") + @Specialization(guards = "!startEmpty(start)") protected RDoubleSequence seqFromOneArg(RAbstractDoubleVector start, RMissing to, RMissing stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); validateParam(start.getDataAt(0), "from"); @@ -367,47 +367,47 @@ public abstract class Seq extends RBuiltinNode { return RDataFactory.createDoubleSequence(1, 1, start.getLength()); } - @Specialization(guards = "startEmpty") + @Specialization(guards = "startEmpty(start)") protected RIntVector seqFromOneArgEmpty(RAbstractDoubleVector start, RMissing to, RMissing stride, RMissing lengthOut, RMissing alongWith) { return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = {"startLengthOne", "!lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "!lengthZero(lengthOut)"}) protected RDoubleSequence seqLengthZero(RAbstractDoubleVector start, RMissing to, RMissing stride, int lengthOut, RMissing alongWith) { controlVisibility(); validateParam(start.getDataAt(0), "from"); return RDataFactory.createDoubleSequence(start.getDataAt(0), 1, lengthOut); } - @Specialization(guards = {"startLengthOne", "!lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "!lengthZero(lengthOut)"}) protected RDoubleSequence seqLengthZero(RAbstractDoubleVector start, RMissing to, RMissing stride, double lengthOut, RMissing alongWith) { controlVisibility(); validateParam(start.getDataAt(0), "from"); return RDataFactory.createDoubleSequence(start.getDataAt(0), 1, (int) Math.ceil(lengthOut)); } - @Specialization(guards = {"startLengthOne", "lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "lengthZero(lengthOut)"}) protected RIntVector seq(RAbstractDoubleVector start, RMissing to, RMissing stride, int lengthOut, RMissing alongWith) { controlVisibility(); validateParam(start.getDataAt(0), "from"); return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = {"startLengthOne", "lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "lengthZero(lengthOut)"}) protected RIntVector seq(RAbstractDoubleVector start, RMissing to, RMissing stride, double lengthOut, RMissing alongWith) { controlVisibility(); validateParam(start.getDataAt(0), "from"); return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = {"startLengthOne", "lengthZeroAlong"}) + @Specialization(guards = {"startLengthOne(start)", "lengthZeroAlong(alongWith)"}) protected RIntVector seq(RAbstractDoubleVector start, RMissing to, RMissing stride, Object lengthOut, RAbstractVector alongWith) { controlVisibility(); validateParam(start.getDataAt(0), "from"); return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = {"startLengthOne", "!lengthZeroAlong"}) + @Specialization(guards = {"startLengthOne(start)", "!lengthZeroAlong(alongWith)"}) protected RDoubleSequence seqLengthZero(RAbstractDoubleVector start, RMissing to, RMissing stride, Object lengthOut, RAbstractVector alongWith) { controlVisibility(); validateParam(start.getDataAt(0), "from"); @@ -416,13 +416,13 @@ public abstract class Seq extends RBuiltinNode { // double vector start, int vector to - @Specialization(guards = {"startLengthOne", "toLengthOne", "zero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "zero(start, to)"}) protected int seqZero(RAbstractDoubleVector start, RAbstractIntVector to, Object stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); return 0; } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!zero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!zero(start, to)"}) protected RAbstractVector seq(RAbstractDoubleVector start, RAbstractIntVector to, RMissing stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); @@ -433,42 +433,42 @@ public abstract class Seq extends RBuiltinNode { } } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!zero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!zero(start, to)"}) protected RDoubleSequence seq(RAbstractDoubleVector start, RAbstractIntVector to, int stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return RDataFactory.createDoubleSequence(start.getDataAt(0), stride, (int) Math.abs((to.getDataAt(0) - start.getDataAt(0)) / stride) + 1); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!zero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!zero(start, to)"}) protected RDoubleSequence seq(RAbstractDoubleVector start, RAbstractIntVector to, double stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return RDataFactory.createDoubleSequence(start.getDataAt(0), stride, (int) Math.abs((to.getDataAt(0) - start.getDataAt(0)) / stride) + 1); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "lengthZero(lengthOut)"}) protected RIntVector seqLengthZero(RAbstractDoubleVector start, RAbstractIntVector to, RMissing stride, int lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!lengthZero(lengthOut)"}) protected RDoubleVector seq(RAbstractDoubleVector start, RAbstractIntVector to, RMissing stride, int lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return getVectorWithComputedStride(start.getDataAt(0), RRuntime.int2double(to.getDataAt(0)), lengthOut, ascending(start, to)); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "lengthZero(lengthOut)"}) protected RIntVector seqLengthZero(RAbstractDoubleVector start, RAbstractIntVector to, RMissing stride, double lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!lengthZero(lengthOut)"}) protected RDoubleVector seq(RAbstractDoubleVector start, RAbstractIntVector to, RMissing stride, double lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); @@ -477,13 +477,13 @@ public abstract class Seq extends RBuiltinNode { // double vector start, double vector to - @Specialization(guards = {"startLengthOne", "toLengthOne", "zero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "zero(start, to)"}) protected double seq(RAbstractDoubleVector start, RAbstractDoubleVector to, Object stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); return 0; } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!zero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!zero(start, to)"}) protected RAbstractVector seq(RAbstractDoubleVector start, RAbstractDoubleVector to, RMissing stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); @@ -494,42 +494,42 @@ public abstract class Seq extends RBuiltinNode { } } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!zero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!zero(start, to)"}) protected RDoubleSequence seq(RAbstractDoubleVector start, RAbstractDoubleVector to, int stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return RDataFactory.createDoubleSequence(start.getDataAt(0), stride, (int) (Math.abs((to.getDataAt(0) - start.getDataAt(0)) / stride) + 1)); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!zero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!zero(start, to)"}) protected RDoubleSequence seq(RAbstractDoubleVector start, RAbstractDoubleVector to, double stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return RDataFactory.createDoubleSequence(start.getDataAt(0), stride, (int) (Math.abs((to.getDataAt(0) - start.getDataAt(0)) / stride) + 1)); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!lengthZero(lengthOut)"}) protected RDoubleVector seq(RAbstractDoubleVector start, RAbstractDoubleVector to, RMissing stride, int lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return getVectorWithComputedStride(start.getDataAt(0), to.getDataAt(0), RRuntime.int2double(lengthOut), ascending(start, to)); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "lengthZero(lengthOut)"}) protected RIntVector seqLengthZero(RAbstractDoubleVector start, RAbstractDoubleVector to, RMissing stride, int lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "!lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!lengthZero(lengthOut)"}) protected RDoubleVector seq(RAbstractDoubleVector start, RAbstractDoubleVector to, RMissing stride, double lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); return getVectorWithComputedStride(start.getDataAt(0), to.getDataAt(0), lengthOut, ascending(start, to)); } - @Specialization(guards = {"startLengthOne", "toLengthOne", "lengthZero"}) + @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "lengthZero(lengthOut)"}) protected RIntVector seqLengthZero(RAbstractDoubleVector start, RAbstractDoubleVector to, RMissing stride, double lengthOut, RMissing alongWith) { controlVisibility(); validateParams(start, to); @@ -545,12 +545,12 @@ public abstract class Seq extends RBuiltinNode { return seqRecursive(frame, RClosures.createLogicalToDoubleVector(start, naCheck), RClosures.createLogicalToDoubleVector(to, naCheck), stride, lengthOut, alongWith); } - @Specialization(guards = "!toIsLogical") + @Specialization(guards = "!isLogical(to)") protected Object seq(VirtualFrame frame, RAbstractLogicalVector start, RAbstractVector to, Object stride, Object lengthOut, Object alongWith) { return seqRecursive(frame, RClosures.createLogicalToDoubleVector(start, naCheck), to, stride, lengthOut, alongWith); } - @Specialization(guards = "!startIsLogical") + @Specialization(guards = "!isLogical(start)") protected Object seq(VirtualFrame frame, RAbstractVector start, RAbstractLogicalVector to, Object stride, Object lengthOut, Object alongWith) { return seqRecursive(frame, start, RClosures.createLogicalToDoubleVector(to, naCheck), stride, lengthOut, alongWith); } @@ -565,22 +565,18 @@ public abstract class Seq extends RBuiltinNode { return seqRecursive(frame, start, RClosures.createLogicalToDoubleVector(to, naCheck), stride, lengthOut, alongWith); } - protected boolean toIsLogical(RAbstractVector start, RAbstractVector to) { - return to.getElementClass() == RLogical.class; + protected boolean isLogical(RAbstractVector v) { + return v.getElementClass() == RLogical.class; } - protected boolean startIsLogical(RAbstractVector start, RAbstractVector to) { - return start.getElementClass() == RLogical.class; - } - - // @Specialization(guards = {"startLengthOne", "toLengthOne", "zero"}) + // @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "zero(start, to)"}) // protected double seq(RAbstractLogicalVector start, RAbstractLogicalVector to, Object stride, // RMissing lengthOut, RMissing alongWith) { // controlVisibility(); // return 0; // } // -// @Specialization(guards = {"startLengthOne", "toLengthOne", "!zero"}) +// @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!zero(start, to)"}) // protected RIntSequence seq(RAbstractLogicalVector start, RAbstractLogicalVector to, RMissing // stride, RMissing lengthOut, RMissing alongWith) { // controlVisibility(); @@ -590,7 +586,7 @@ public abstract class Seq extends RBuiltinNode { // Math.abs(RRuntime.logical2int(to.getDataAt(0)) - RRuntime.logical2int(start.getDataAt(0))) + 1); // } // -// @Specialization(guards = {"startLengthOne", "toLengthOne", "!lengthZero"}) +// @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!lengthZero(lengthOut)"}) // protected RDoubleVector seq(RAbstractLogicalVector start, RAbstractLogicalVector to, RMissing // stride, int lengthOut, RMissing alongWith) { // controlVisibility(); @@ -599,7 +595,7 @@ public abstract class Seq extends RBuiltinNode { // RRuntime.logical2double(to.getDataAt(0)), RRuntime.int2double(lengthOut), ascending(start, to)); // } // -// @Specialization(guards = {"startLengthOne", "toLengthOne", "!lengthZero"}) +// @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "!lengthZero(lengthOut)"}) // protected RDoubleVector seq(RAbstractLogicalVector start, RAbstractLogicalVector to, RMissing // stride, double lengthOut, RMissing alongWith) { // controlVisibility(); @@ -608,7 +604,7 @@ public abstract class Seq extends RBuiltinNode { // RRuntime.logical2double(to.getDataAt(0)), lengthOut, ascending(start, to)); // } // -// @Specialization(guards = {"startLengthOne", "toLengthOne", "lengthZero"}) +// @Specialization(guards = {"startLengthOne(start)", "toLengthOne(to)", "lengthZero(lengthOut)"}) // protected RIntVector seqLengthZero(RAbstractLogicalVector start, RAbstractLogicalVector to, // RMissing stride, double lengthOut, RMissing alongWith) { // controlVisibility(); @@ -616,7 +612,7 @@ public abstract class Seq extends RBuiltinNode { // return RDataFactory.createEmptyIntVector(); // } // -// @Specialization(guards = "!startEmpty") +// @Specialization(guards = "!startEmpty(start)") // protected RIntSequence seqFromOneArg(RAbstractLogicalVector start, RMissing to, RMissing stride, // RMissing lengthOut, RMissing alongWith) { // controlVisibility(); @@ -625,56 +621,56 @@ public abstract class Seq extends RBuiltinNode { // return RDataFactory.createIntSequence(1, 1, start.getLength()); // } // -// @Specialization(guards = "startEmpty") +// @Specialization(guards = "startEmpty(start)") // protected RIntVector seqFromOneArgEmpty(RAbstractLogicalVector start, RMissing to, RMissing // stride, RMissing lengthOut, RMissing alongWith) { // return RDataFactory.createEmptyIntVector(); // } - @Specialization(guards = "lengthZero") + @Specialization(guards = "lengthZero(lengthOut)") protected RIntVector seqLengthZero(RMissing start, RMissing to, RMissing stride, int lengthOut, RMissing alongWith) { controlVisibility(); return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = "!lengthZero") + @Specialization(guards = "!lengthZero(lengthOut)") protected RIntSequence seq(RMissing start, RMissing to, RMissing stride, int lengthOut, RMissing alongWith) { controlVisibility(); return RDataFactory.createIntSequence(1, 1, lengthOut); } - @Specialization(guards = "lengthZero") + @Specialization(guards = "lengthZero(lengthOut)") protected RIntVector seqLengthZero(RMissing start, RMissing to, RMissing stride, double lengthOut, RMissing alongWith) { controlVisibility(); return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = "!lengthZero") + @Specialization(guards = "!lengthZero(lengthOut)") protected RIntSequence seq(RMissing start, RMissing to, RMissing stride, double lengthOut, RMissing alongWith) { controlVisibility(); return RDataFactory.createIntSequence(1, 1, (int) Math.ceil(lengthOut)); } - @Specialization(guards = "lengthZeroAlong") + @Specialization(guards = "lengthZeroAlong(alongWith)") protected RIntVector seqLengthZeroAlong(RMissing start, RMissing to, RMissing stride, Object lengthOut, RAbstractVector alongWith) { controlVisibility(); return RDataFactory.createEmptyIntVector(); } - @Specialization(guards = "!lengthZeroAlong") + @Specialization(guards = "!lengthZeroAlong(alongWith)") protected RIntSequence seq(RMissing start, RMissing to, RMissing stride, Object lengthOut, RAbstractVector alongWith) { controlVisibility(); return RDataFactory.createIntSequence(1, 1, alongWith.getLength()); } - @Specialization(guards = {"toLengthOne", "positiveLengthOut"}) + @Specialization(guards = {"toLengthOne(to)", "positiveLengthOut(lengthOut)"}) public RDoubleSequence seq(RMissing start, RAbstractIntVector to, RMissing stride, int lengthOut, RMissing alongWith) { controlVisibility(); validateParam(to.getDataAt(0), "to"); return RDataFactory.createDoubleSequence(to.getDataAt(0) - lengthOut + 1, 1, lengthOut); } - @Specialization(guards = {"toLengthOne", "positiveLengthOut"}) + @Specialization(guards = {"toLengthOne(to)", "positiveLengthOut(lengthOut)"}) public RDoubleSequence seq(RMissing start, RAbstractIntVector to, RMissing stride, double lengthOut, RMissing alongWith) { controlVisibility(); validateParam(to.getDataAt(0), "to"); @@ -682,14 +678,14 @@ public abstract class Seq extends RBuiltinNode { return RDataFactory.createDoubleSequence(to.getDataAt(0) - intLength + 1, 1, intLength); } - @Specialization(guards = {"toLengthOne", "positiveLengthOut"}) + @Specialization(guards = {"toLengthOne(to)", "positiveLengthOut(lengthOut)"}) public RDoubleSequence seq(RMissing start, RAbstractDoubleVector to, RMissing stride, double lengthOut, RMissing alongWith) { controlVisibility(); validateParam(to.getDataAt(0), "to"); return RDataFactory.createDoubleSequence(to.getDataAt(0) - lengthOut + 1, 1, (int) Math.ceil(lengthOut)); } - @Specialization(guards = "toLengthOne") + @Specialization(guards = "toLengthOne(to)") public Object seq(VirtualFrame frame, RMissing start, RAbstractVector to, Object stride, RMissing lengthOut, RMissing alongWith) { controlVisibility(); return seqRecursive(frame, 1.0, to, stride, lengthOut, alongWith); @@ -739,77 +735,40 @@ public abstract class Seq extends RBuiltinNode { return start.getLength() == 0; } - protected boolean startLengthOne(RAbstractIntVector start) { - if (start.getLength() != 1) { - throw RError.error(getEncapsulatingSourceSection(), RError.Message.MUST_BE_SCALAR, "from"); - } - return true; - } - - protected boolean startLengthOne(RAbstractLogicalVector start) { + protected boolean startLengthOne(RAbstractVector start) { if (start.getLength() != 1) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MUST_BE_SCALAR, "from"); } return true; } - protected boolean startLengthOne(RAbstractDoubleVector start) { - if (start.getLength() != 1) { - throw RError.error(getEncapsulatingSourceSection(), RError.Message.MUST_BE_SCALAR, "from"); - } - return true; - } - - protected boolean toLengthOne(RAbstractVector start, RAbstractVector to) { + protected boolean toLengthOne(RAbstractVector to) { if (to.getLength() != 1) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MUST_BE_SCALAR, "to"); } return true; } - protected boolean toLengthOne(RMissing start, RAbstractVector to) { - if (to.getLength() != 1) { - throw RError.error(getEncapsulatingSourceSection(), RError.Message.MUST_BE_SCALAR, "to"); - } - return true; - } - - protected boolean lengthZero(RAbstractVector start, Object to, Object stride, int lengthOut) { + protected boolean lengthZero(int lengthOut) { return lengthOut == 0; } - protected boolean lengthZero(RAbstractVector start, RAbstractVector to, Object stride, int lengthOut) { + protected boolean lengthZero(double lengthOut) { return lengthOut == 0; } - protected boolean lengthZero(RAbstractVector start, RAbstractVector to, Object stride, double lengthOut) { - return lengthOut == 0; - } - - protected boolean lengthZero(RMissing start, Object to, Object stride, int lengthOut) { - return lengthOut == 0; - } - - protected boolean lengthZero(Object start, Object to, Object stride, double lengthOut) { - return lengthOut == 0; - } - - protected boolean lengthZeroAlong(RAbstractVector start, Object to, Object stride, Object lengthOut, RAbstractVector v) { - return v.getLength() == 0; - } - - protected boolean lengthZeroAlong(Object start, Object to, Object stride, Object lengthOut, RAbstractVector v) { - return v.getLength() == 0; + protected boolean lengthZeroAlong(RAbstractVector alongWith) { + return alongWith.getLength() == 0; } - protected boolean positiveLengthOut(Object start, Object to, Object stride, int lengthOut, Object v) { + protected boolean positiveLengthOut(int lengthOut) { if (lengthOut < 0) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MUST_BE_POSITIVE, "length.out"); } return true; } - protected boolean positiveLengthOut(Object start, Object to, Object stride, double lengthOut, Object v) { + protected boolean positiveLengthOut(double lengthOut) { if (lengthOut < 0) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MUST_BE_POSITIVE, "length.out"); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ShortRowNames.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ShortRowNames.java index 664f9b7489c33bb6cdaad9923fd1b6a2ba4d4bd2..aa60e0f1036b8d9be5f02d412b8434e102edbff1 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ShortRowNames.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ShortRowNames.java @@ -60,7 +60,7 @@ public abstract class ShortRowNames extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "invalidType") + @Specialization(guards = "invalidType(type)") protected RNull getNamesInvalidType(RAbstractContainer operand, RAbstractIntVector type) { controlVisibility(); CompilerDirectives.transferToInterpreter(); @@ -68,13 +68,13 @@ public abstract class ShortRowNames extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!invalidType", "!returnScalar"}) + @Specialization(guards = {"!invalidType(type)", "!returnScalar(type)"}) protected Object getNamesNull(RAbstractContainer operand, RAbstractIntVector type) { controlVisibility(); return operand.getRowNames(attrProfiles); } - @Specialization(guards = {"!invalidType", "returnScalar"}) + @Specialization(guards = {"!invalidType(type)", "returnScalar(type)"}) protected int getNames(RAbstractContainer operand, RAbstractIntVector type) { controlVisibility(); int t = type.getDataAt(0); @@ -103,11 +103,11 @@ public abstract class ShortRowNames extends RBuiltinNode { return rowNames.getLength(); } - protected boolean invalidType(@SuppressWarnings("unused") RAbstractContainer operand, RAbstractIntVector type) { + protected boolean invalidType(RAbstractIntVector type) { return type.getLength() == 0 || type.getDataAt(0) < 0 || type.getDataAt(0) > 2; } - protected boolean returnScalar(@SuppressWarnings("unused") RAbstractContainer operand, RAbstractIntVector type) { + protected boolean returnScalar(RAbstractIntVector type) { return type.getDataAt(0) >= 1; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Signif.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Signif.java index 3dd7f5a73631bfb89c98f6b288f579ce8f9bd068..190c80447296dd96b2e38cd1f0121c5957f475db 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Signif.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Signif.java @@ -59,7 +59,7 @@ public abstract class Signif extends RBuiltinNode { // TODO: consider porting signif implementation from GNU R - @Specialization(guards = "digitsVecLengthOne") + @Specialization(guards = "digitsVec.getLength() == 1") protected RAbstractDoubleVector signif(RAbstractDoubleVector x, RAbstractIntVector digitsVec) { controlVisibility(); int digits = digitsVec.getDataAt(0) <= 0 ? 1 : digitsVec.getDataAt(0); @@ -87,7 +87,7 @@ public abstract class Signif extends RBuiltinNode { return ret; } - @Specialization(guards = "digitsVecLengthOne") + @Specialization(guards = "digits.getLength() == 1") protected RAbstractIntVector roundDigits(RAbstractIntVector x, @SuppressWarnings("unused") RAbstractIntVector digits) { controlVisibility(); return x; @@ -95,8 +95,4 @@ public abstract class Signif extends RBuiltinNode { // TODO: add support for digit vectors of length different than 1 - protected boolean digitsVecLengthOne(@SuppressWarnings("unused") RAbstractVector x, RAbstractIntVector digitsVec) { - return digitsVec.getLength() == 1; - } - } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Sprintf.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Sprintf.java index fe2db77ae8257c1cd3c325972f7c7b0f6055295b..0a5340983afc99f17a8c712182b95081278faf0a 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Sprintf.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Sprintf.java @@ -51,7 +51,7 @@ public abstract class Sprintf extends RBuiltinNode { return fmt; } - @Specialization(guards = "fmtLengthOne") + @Specialization(guards = "fmtLengthOne(fmt)") @TruffleBoundary protected String sprintf(RAbstractStringVector fmt, RMissing x) { return sprintf(fmt.getDataAt(0), x); @@ -64,7 +64,7 @@ public abstract class Sprintf extends RBuiltinNode { return format(fmt, x); } - @Specialization(guards = "fmtLengthOne") + @Specialization(guards = "fmtLengthOne(fmt)") @TruffleBoundary protected String sprintf(RAbstractStringVector fmt, int x) { return sprintf(fmt.getDataAt(0), x); @@ -81,7 +81,7 @@ public abstract class Sprintf extends RBuiltinNode { return RDataFactory.createStringVector(r, RDataFactory.COMPLETE_VECTOR); } - @Specialization(guards = "fmtLengthOne") + @Specialization(guards = "fmtLengthOne(fmt)") @TruffleBoundary protected RStringVector sprintf(RAbstractStringVector fmt, RAbstractIntVector x) { return sprintf(fmt.getDataAt(0), x); @@ -101,7 +101,7 @@ public abstract class Sprintf extends RBuiltinNode { return format(fmt, x); } - @Specialization(guards = "fmtLengthOne") + @Specialization(guards = "fmtLengthOne(fmt)") @TruffleBoundary protected String sprintf(RAbstractStringVector fmt, double x) { return sprintf(fmt.getDataAt(0), x); @@ -118,7 +118,7 @@ public abstract class Sprintf extends RBuiltinNode { return RDataFactory.createStringVector(r, RDataFactory.COMPLETE_VECTOR); } - @Specialization(guards = "fmtLengthOne") + @Specialization(guards = "fmtLengthOne(fmt)") @TruffleBoundary protected RStringVector sprintf(RAbstractStringVector fmt, RAbstractDoubleVector x) { return sprintf(fmt.getDataAt(0), x); @@ -131,7 +131,7 @@ public abstract class Sprintf extends RBuiltinNode { return format(fmt, x); } - @Specialization(guards = "fmtLengthOne") + @Specialization(guards = "fmtLengthOne(fmt)") @TruffleBoundary protected String sprintf(RAbstractStringVector fmt, String x) { return sprintf(fmt.getDataAt(0), x); @@ -148,20 +148,20 @@ public abstract class Sprintf extends RBuiltinNode { return RDataFactory.createStringVector(r, RDataFactory.COMPLETE_VECTOR); } - @Specialization(guards = "fmtLengthOne") + @Specialization(guards = "fmtLengthOne(fmt)") @TruffleBoundary protected RStringVector sprintf(RAbstractStringVector fmt, RAbstractStringVector x) { return sprintf(fmt.getDataAt(0), x); } - @Specialization(guards = "!oneElement") + @Specialization(guards = "!oneElement(args)") @TruffleBoundary protected String sprintf(String fmt, RArgsValuesAndNames args) { controlVisibility(); return format(fmt, args.getValues()); } - @Specialization(guards = "oneElement") + @Specialization(guards = "oneElement(args)") protected Object sprintfOneElement(VirtualFrame frame, String fmt, RArgsValuesAndNames args) { controlVisibility(); if (sprintfRecursive == null) { @@ -171,13 +171,13 @@ public abstract class Sprintf extends RBuiltinNode { return sprintfRecursive.executeObject(frame, fmt, args.getValues()[0]); } - @Specialization(guards = {"!oneElement", "fmtLengthOne"}) + @Specialization(guards = {"!oneElement(args)", "fmtLengthOne(fmt)"}) @TruffleBoundary protected String sprintf(RAbstractStringVector fmt, RArgsValuesAndNames args) { return sprintf(fmt.getDataAt(0), args); } - @Specialization(guards = {"oneElement", "fmtLengthOne"}) + @Specialization(guards = {"oneElement(args)", "fmtLengthOne(fmt)"}) protected Object sprintfOneElement(VirtualFrame frame, RAbstractStringVector fmt, RArgsValuesAndNames args) { return sprintfOneElement(frame, fmt.getDataAt(0), args); } @@ -474,7 +474,7 @@ public abstract class Sprintf extends RBuiltinNode { return fmt.getLength() == 1; } - protected boolean oneElement(@SuppressWarnings("unused") Object fmt, RArgsValuesAndNames args) { + protected boolean oneElement(RArgsValuesAndNames args) { return args.length() == 1; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Substr.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Substr.java index fb59d902229bfb6f2fc25051a5df9e964d48a40c..57a4ea8d877ce54b811f4d506a3eb1c17bef2bf5 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Substr.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Substr.java @@ -46,21 +46,21 @@ public abstract class Substr extends RBuiltinNode { private final ConditionProfile naIndexesProfile = ConditionProfile.createBinaryProfile(); @SuppressWarnings("unused") - @Specialization(guards = "emptyArg") + @Specialization(guards = "emptyArg(arg)") protected RStringVector substrEmptyArg(VirtualFrame frame, RAbstractStringVector arg, RAbstractIntVector start, RAbstractIntVector stop) { controlVisibility(); return RDataFactory.createEmptyStringVector(); } @SuppressWarnings("unused") - @Specialization(guards = {"!emptyArg", "wrongParams"}) + @Specialization(guards = {"!emptyArg(arg)", "wrongParams(start, stop)"}) @TruffleBoundary protected RNull substrWrongParams(RAbstractStringVector arg, RAbstractIntVector start, RAbstractIntVector stop) { RInternalError.shouldNotReachHere(); return RNull.instance; // dummy } - @Specialization(guards = {"!emptyArg", "!wrongParams"}) + @Specialization(guards = {"!emptyArg(arg)", "!wrongParams(start, stop)"}) @ExplodeLoop protected RStringVector substr(RAbstractStringVector arg, RAbstractIntVector start, RAbstractIntVector stop) { controlVisibility(); @@ -132,12 +132,11 @@ public abstract class Substr extends RBuiltinNode { // return x.substring(actualStart - 1, actualStop); // } - @SuppressWarnings("unused") - protected boolean emptyArg(RAbstractStringVector arg, RAbstractIntVector start, RAbstractIntVector stop) { + protected boolean emptyArg(RAbstractStringVector arg) { return arg.getLength() == 0; } - protected boolean wrongParams(@SuppressWarnings("unused") RAbstractStringVector arg, RAbstractIntVector start, RAbstractIntVector stop) { + protected boolean wrongParams(RAbstractIntVector start, RAbstractIntVector stop) { if (start.getLength() == 0 || stop.getLength() == 0) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_ARGUMENTS_NO_QUOTE, "substring"); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Switch.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Switch.java index dcb460a7b28517cd4709d3e2a5b960685411b867..3817b3737f10c459d43fc2f24ad26f4d9d0fd755 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Switch.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Switch.java @@ -53,7 +53,7 @@ public abstract class Switch extends RBuiltinNode { return new RNode[]{ConstantNode.create(RMissing.instance), ConstantNode.create(RMissing.instance)}; } - @Specialization(guards = "isLengthOne") + @Specialization(guards = "isLengthOne(x)") protected Object doSwitch(VirtualFrame frame, RAbstractStringVector x, RArgsValuesAndNames optionalArgs) { controlVisibility(); return prepareResult(doSwitchString(frame, x, optionalArgs)); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/SysFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/SysFunctions.java index 1ffc08b414bd6f4efba6f19454724c4934046262..06df90c4f0097a84e98acb2bc6725bbf2e4685fd 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/SysFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/SysFunctions.java @@ -160,7 +160,7 @@ public class SysFunctions { return RNull.instance; } - @Specialization(guards = "lengthOne") + @Specialization(guards = "lengthOne(secondsVector)") @TruffleBoundary protected Object sysSleep(RStringVector secondsVector) { controlVisibility(); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Tabulate.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Tabulate.java index b470ec801b1acc5b77d5afc09f75dd7425aab3b3..016b082d429913e711ff98f6135090952424ad58 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Tabulate.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Tabulate.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2014, Purdue University - * Copyright (c) 2014, Oracle and/or its affiliates + * Copyright (c) 2014, 2015, Oracle and/or its affiliates * * All rights reserved. */ @@ -36,7 +36,7 @@ public abstract class Tabulate extends RBuiltinNode { return arguments; } - @Specialization(guards = {"isValidNBin"}) + @Specialization(guards = {"isValidNBin(nBins)"}) @TruffleBoundary public RIntVector tabulate(RAbstractIntVector bin, int nBins) { controlVisibility(); @@ -50,7 +50,7 @@ public abstract class Tabulate extends RBuiltinNode { return RDataFactory.createIntVector(ans, RDataFactory.COMPLETE_VECTOR); } - @Specialization(guards = {"isValidNBin"}) + @Specialization(guards = {"isValidNBin(nBins)"}) @TruffleBoundary public RIntVector tabulate(RFactor bin, int nBins) { return tabulate(bin.getVector(), nBins); @@ -63,7 +63,7 @@ public abstract class Tabulate extends RBuiltinNode { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_INPUT); } - protected boolean isValidNBin(@SuppressWarnings("unused") RAbstractContainer bin, int nBins) { + protected boolean isValidNBin(int nBins) { if (RRuntime.isNA(nBins) || nBins < 0) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_ARGUMENT, "nbin"); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/TempFile.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/TempFile.java index 1fac53977890be2d1a403dbcb767a5c7bf64713d..13263f0cf79b3613a64a82428d2706a194afe1a9 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/TempFile.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/TempFile.java @@ -55,15 +55,14 @@ public abstract class TempFile extends RBuiltinNode { return "invalid '" + msg + "'"; } - @Specialization(guards = "tempDirL1") + @Specialization(guards = "tempDirL1(tempDir)") @TruffleBoundary protected RStringVector tempfile(String pattern, RAbstractStringVector tempDir, String fileExt) { controlVisibility(); return RDataFactory.createStringVector(createNonExistedFilePath(pattern, tempDir.getDataAt(0), fileExt)); } - @SuppressWarnings("unused") - public static boolean tempDirL1(String pattern, RAbstractStringVector tempDir, String fileExt) { + public static boolean tempDirL1(RAbstractStringVector tempDir) { return tempDir.getLength() == 1; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Transpose.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Transpose.java index 56322d3c2b0d435d7bf0c8463b23fbeb4aca26d2..621a1b4dc55957c85195fe510056129d1dceeb29 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Transpose.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Transpose.java @@ -71,7 +71,7 @@ public abstract class Transpose extends RBuiltinNode { return value; } - @Specialization(guards = "isEmpty2D") + @Specialization(guards = "isEmpty2D(vector)") @TruffleBoundary protected RAbstractVector transpose(RAbstractVector vector) { controlVisibility(); @@ -79,7 +79,7 @@ public abstract class Transpose extends RBuiltinNode { return vector.copyWithNewDimensions(new int[]{dim[1], dim[0]}); } - @Specialization(guards = "!isEmpty2D") + @Specialization(guards = "!isEmpty2D(vector)") @TruffleBoundary protected RIntVector transpose(RAbstractIntVector vector) { controlVisibility(); @@ -104,7 +104,7 @@ public abstract class Transpose extends RBuiltinNode { return r; } - @Specialization(guards = "!isEmpty2D") + @Specialization(guards = "!isEmpty2D(vector)") @TruffleBoundary protected RDoubleVector transpose(RAbstractDoubleVector vector) { controlVisibility(); @@ -129,7 +129,7 @@ public abstract class Transpose extends RBuiltinNode { return r; } - @Specialization(guards = "!isEmpty2D") + @Specialization(guards = "!isEmpty2D(vector)") @TruffleBoundary protected RStringVector transpose(RAbstractStringVector vector) { controlVisibility(); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Typeof.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Typeof.java index 47dff5f4ad3e9939caad52b40b606c5d230696a4..f3ea7951ec13802c73aa600b0af75c37affe904b 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Typeof.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Typeof.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 @@ -38,11 +38,11 @@ public abstract class Typeof extends RBuiltinNode { public abstract String execute(VirtualFrame frame, Object x); @Specialization - protected String typeof(VirtualFrame frame, Object obj) { + protected String typeof(Object obj) { if (typeofNode == null) { typeofNode = insert(TypeofNodeGen.create(null)); } - return typeofNode.execute(frame, obj).getName(); + return typeofNode.execute(obj).getName(); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unique.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unique.java index 869f5b2565460824fab668782820211102bfd611..f4e3c5f55157ad1741982bc22afcaa0857bd8268 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unique.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unique.java @@ -264,7 +264,7 @@ public abstract class Unique extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "lengthOne") + @Specialization(guards = "lengthOne(list)") protected RList doUnique(RList list, byte incomparables, byte fromLast, Object nmax, RArgsValuesAndNames vararg) { return (RList) list.copyDropAttributes(); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unlist.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unlist.java index 437a316c9e7aa8564a5c73e3897786573debb5a1..8e7d1eb27b2c5089793be0092a6da21926cf3c5d 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unlist.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unlist.java @@ -72,13 +72,13 @@ public abstract class Unlist extends RBuiltinNode { return 0; } - @Specialization(guards = "!isVectorList") + @Specialization(guards = "!isVectorList(vector)") @TruffleBoundary protected int getLength(RAbstractVector vector) { return vector.getLength(); } - @Specialization(guards = "isVectorList") + @Specialization(guards = "isVectorList(vector)") protected int getLengthList(VirtualFrame frame, RAbstractVector vector) { int totalSize = 0; for (int i = 0; i < vector.getLength(); ++i) { @@ -126,7 +126,7 @@ public abstract class Unlist extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "!isVectorList") + @Specialization(guards = "!isVectorList(vector)") @TruffleBoundary protected RAbstractVector unlistVector(RAbstractVector vector, byte recursive, byte useNames) { controlVisibility(); @@ -134,7 +134,7 @@ public abstract class Unlist extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "isEmpty") + @Specialization(guards = "isEmpty(list)") protected RNull unlistEmptyList(VirtualFrame frame, RList list, byte recursive, byte useNames) { controlVisibility(); return RNull.instance; @@ -142,7 +142,7 @@ public abstract class Unlist extends RBuiltinNode { // TODO: initially unlist was on the slow path - hence initial recursive implementation is on // the slow path as well; ultimately we may consider (non-recursive) optimization - @Specialization(guards = "!isEmpty") + @Specialization(guards = "!isEmpty(list)") protected RAbstractVector unlistList(VirtualFrame frame, RList list, byte recursive, byte useNames) { controlVisibility(); boolean isRecursive = RRuntime.fromLogical(recursive); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttr.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttr.java index bf1997247aef25e13c2724027a47958dfa959cca..7c61a923ce7cf891b90c90febf99f4871fa3ddae 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttr.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttr.java @@ -120,7 +120,7 @@ public abstract class UpdateAttr extends RInvisibleBuiltinNode { return name.intern(); } - @Specialization(guards = "nullValue") + @Specialization protected RAbstractContainer updateAttr(VirtualFrame frame, RAbstractContainer container, String name, RNull value) { controlVisibility(); String internedName = intern(name); @@ -158,7 +158,7 @@ public abstract class UpdateAttr extends RInvisibleBuiltinNode { throw RError.error(sourceSection, RError.Message.SET_INVALID_CLASS_ATTR); } - @Specialization(guards = "!nullValue") + @Specialization(guards = "!nullValue(value)") protected RAbstractContainer updateAttr(VirtualFrame frame, RAbstractContainer container, String name, Object value) { controlVisibility(); String internedName = intern(name); @@ -189,7 +189,7 @@ public abstract class UpdateAttr extends RInvisibleBuiltinNode { return container.getElementClass() == RDataFrame.class || container.getElementClass() == RFactor.class ? container : resultVector; } - @Specialization(guards = "!nullValue") + @Specialization(guards = "!nullValue(value)") protected RAbstractContainer updateAttr(VirtualFrame frame, RAbstractVector vector, RStringVector name, Object value) { controlVisibility(); return updateAttr(frame, vector, name.getDataAt(0), value); @@ -197,7 +197,7 @@ public abstract class UpdateAttr extends RInvisibleBuiltinNode { // the guard is necessary as RNull and Object cannot be distinguished in case of multiple // specializations, such as in: x<-1; attr(x, "dim")<-1; attr(x, "dim")<-NULL - public boolean nullValue(RAbstractContainer container, Object name, Object value) { + public boolean nullValue(Object value) { return value == RNull.instance; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateClass.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateClass.java index f0194b1ff700044d47bef1004ded29ccd68d1614..170d8355bb8ec36ff04959b5d14fbbdd98e45e3b 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateClass.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateClass.java @@ -39,7 +39,7 @@ public abstract class UpdateClass extends RBuiltinNode { public abstract Object execute(VirtualFrame frame, RAbstractContainer vector, Object o); - @Specialization(guards = "!isStringVector") + @Specialization(guards = "!isStringVector(className)") protected Object setClass(VirtualFrame frame, RAbstractContainer arg, RAbstractVector className) { controlVisibility(); if (className.getLength() == 0) { @@ -70,7 +70,7 @@ public abstract class UpdateClass extends RBuiltinNode { controlVisibility(); initTypeof(); if (!arg.isObject(attrProfiles)) { - RType argType = this.typeof.execute(frame, arg); + RType argType = this.typeof.execute(arg); if (argType.equals(className) || (RType.Numeric.getName().equals(className) && (argType == RType.Integer || argType == RType.Double))) { // "explicit" attribute might have been set (e.g. by oldClass<-) return setClass(arg, RNull.instance); @@ -185,7 +185,7 @@ public abstract class UpdateClass extends RBuiltinNode { } } - protected boolean isStringVector(@SuppressWarnings("unused") RAbstractContainer arg, RAbstractVector className) { + protected boolean isStringVector(RAbstractVector className) { return className.getElementClass() == RString.class; } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDiag.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDiag.java index 82d181436251324092c004df01873476cd66d515..a3db17b7eaec037ccfe426fc88aa95f2eb119bc4 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDiag.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDiag.java @@ -50,22 +50,12 @@ public abstract class UpdateDiag extends RInvisibleBuiltinNode { return vector.hasDimensions() && vector.getDimensions().length == 2; } - // FIXME The following two are workarounds for a Truffle-DSL bug. - - protected static boolean isMatrix(RAbstractIntVector vector) { - return isMatrix((RAbstractVector) vector); - } - - protected static boolean isMatrix(RAbstractDoubleVector vector) { - return isMatrix((RAbstractVector) vector); - } - protected static boolean correctReplacementLength(RAbstractVector matrix, RAbstractVector replacement) { return replacement.getLength() == 1 || Math.min(matrix.getDimensions()[0], matrix.getDimensions()[1]) == replacement.getLength(); } @SuppressWarnings("unused") - @Specialization(guards = "!isMatrix") + @Specialization(guards = "!isMatrix(vector)") protected RIntVector updateDiagNoMatrix(RAbstractVector vector, RAbstractVector valueVector) { controlVisibility(); CompilerDirectives.transferToInterpreter(); @@ -73,14 +63,14 @@ public abstract class UpdateDiag extends RInvisibleBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = {"isMatrix", "!correctReplacementLength"}) + @Specialization(guards = {"isMatrix(vector)", "!correctReplacementLength(vector, valueVector)"}) protected RIntVector updateDiagReplacementDiagonalLength(RAbstractVector vector, RAbstractVector valueVector) { controlVisibility(); CompilerDirectives.transferToInterpreter(); throw RError.error(this.getEncapsulatingSourceSection(), RError.Message.REPLACEMENT_DIAGONAL_LENGTH); } - @Specialization(guards = {"isMatrix", "correctReplacementLength"}) + @Specialization(guards = {"isMatrix(vector)", "correctReplacementLength(vector, valueVector)"}) @TruffleBoundary protected RAbstractIntVector updateDiag(RIntVector vector, RAbstractIntVector valueVector) { controlVisibility(); @@ -100,7 +90,7 @@ public abstract class UpdateDiag extends RInvisibleBuiltinNode { return resultVector; } - @Specialization(guards = {"isMatrix", "correctReplacementLength"}) + @Specialization(guards = {"isMatrix(vector)", "correctReplacementLength(vector, valueVector)"}) @TruffleBoundary protected RAbstractDoubleVector updateDiag(RDoubleVector vector, RAbstractDoubleVector valueVector) { controlVisibility(); @@ -120,7 +110,7 @@ public abstract class UpdateDiag extends RInvisibleBuiltinNode { return resultVector; } - @Specialization(guards = {"isMatrix", "correctReplacementLength"}) + @Specialization(guards = {"isMatrix(vector)", "correctReplacementLength(vector, valueVector)"}) protected RAbstractDoubleVector updateDiag(VirtualFrame frame, RIntVector vector, RAbstractDoubleVector valueVector) { controlVisibility(); initCastDoubleNode(); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDimNames.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDimNames.java index 95dc8f2d0efa8ef36471ea4a0ab7a813c84ec0dd..07680c3652fc5b421de8594d6e7c5fac828d7171 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDimNames.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDimNames.java @@ -93,7 +93,7 @@ public abstract class UpdateDimNames extends RInvisibleBuiltinNode { return v; } - @Specialization(guards = "isZeroLength") + @Specialization(guards = "isZeroLength(list)") @TruffleBoundary protected RAbstractVector updateDimnamesEmpty(RAbstractVector vector, RList list) { RVector v = vector.materialize(); @@ -102,7 +102,7 @@ public abstract class UpdateDimNames extends RInvisibleBuiltinNode { return v; } - @Specialization(guards = "!isZeroLength") + @Specialization(guards = "!isZeroLength(list)") protected RAbstractVector updateDimnames(VirtualFrame frame, RAbstractVector vector, RList list) { RVector v = vector.materialize(); v.setDimNames(convertToListOfStrings(frame, list), getEncapsulatingSourceSection()); @@ -110,7 +110,7 @@ public abstract class UpdateDimNames extends RInvisibleBuiltinNode { return v; } - @Specialization(guards = "!isVectorList") + @Specialization(guards = "!isVectorList(v)") protected RAbstractVector updateDimnamesError(RAbstractVector vector, RAbstractVector v) { controlVisibility(); CompilerDirectives.transferToInterpreter(); @@ -124,11 +124,11 @@ public abstract class UpdateDimNames extends RInvisibleBuiltinNode { throw RError.error(getEncapsulatingSourceSection(), RError.Message.DIMNAMES_LIST); } - protected boolean isVectorList(RAbstractVector vector, RAbstractVector v) { + protected boolean isVectorList(RAbstractVector v) { return v instanceof RList; } - protected boolean isZeroLength(VirtualFrame frame, RAbstractVector vector, RList list) { + protected boolean isZeroLength(RList list) { return list.getLength() == 0; } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateLength.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateLength.java index eb660f127842cd54c1fb1f72b766b731411d8806..500429f2f618dc8fb607c5092b2aca63d73e098d 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateLength.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateLength.java @@ -51,7 +51,7 @@ public abstract class UpdateLength extends RInvisibleBuiltinNode { return arguments; } - @Specialization(guards = {"isLengthOne", "isObject"}) + @Specialization(guards = {"isLengthOne(lengthVector)", "isObject(frame, container)"}) protected Object updateLengthObject(VirtualFrame frame, RAbstractContainer container, RAbstractIntVector lengthVector) { if (dcn == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -60,13 +60,13 @@ public abstract class UpdateLength extends RInvisibleBuiltinNode { try { return dcn.executeInternal(frame, container.getClassHierarchy(), new Object[]{container, lengthVector}); } catch (NoGenericMethodException e) { - return updateLength(container, lengthVector); + return updateLength(frame, container, lengthVector); } } - @Specialization(guards = {"isLengthOne", "!isObject"}) - protected RAbstractContainer updateLength(RAbstractContainer container, RAbstractIntVector lengthVector) { + @Specialization(guards = {"isLengthOne(lengthVector)", "!isObject(frame, container)"}) + protected RAbstractContainer updateLength(@SuppressWarnings("unused") VirtualFrame frame, RAbstractContainer container, RAbstractIntVector lengthVector) { controlVisibility(); int length = lengthVector.getDataAt(0); // TODO: we can potentially avoid making a copy during materialization and then during @@ -76,7 +76,7 @@ public abstract class UpdateLength extends RInvisibleBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "!isLengthOne") + @Specialization(guards = "!isLengthOne(lengthVector)") protected RAbstractContainer updateLengthError(RAbstractContainer container, RAbstractIntVector lengthVector) { controlVisibility(); CompilerDirectives.transferToInterpreter(); @@ -91,7 +91,7 @@ public abstract class UpdateLength extends RInvisibleBuiltinNode { throw RError.error(this.getEncapsulatingSourceSection(), RError.Message.INVALID_UNNAMED_VALUE); } - protected static boolean isLengthOne(@SuppressWarnings("unused") RAbstractContainer vector, RAbstractIntVector length) { + protected static boolean isLengthOne(RAbstractIntVector length) { return length.getLength() == 1; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateOldClass.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateOldClass.java index 64f9dbf397a6c49f851a4711e65fe36d88a5af7f..f591486d7a9097c270557c2ad7308cbf4b5ad517 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateOldClass.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateOldClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -46,7 +46,7 @@ public abstract class UpdateOldClass extends RInvisibleBuiltinNode { public abstract Object execute(VirtualFrame frame, RAbstractContainer vector, Object o); - @Specialization(guards = "!isStringVector") + @Specialization(guards = "!isStringVector(className)") protected Object setOldClass(VirtualFrame frame, RAbstractContainer arg, RAbstractVector className) { controlVisibility(); if (className.getLength() == 0) { @@ -92,7 +92,7 @@ public abstract class UpdateOldClass extends RInvisibleBuiltinNode { return arg; } - protected boolean isStringVector(@SuppressWarnings("unused") RAbstractContainer arg, RAbstractVector className) { + protected boolean isStringVector(RAbstractVector className) { return className.getElementClass() == RString.class; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateStorageMode.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateStorageMode.java index fb8f20233feb7c189de301d81f5e4f8790887f7a..330df16e52d73bc82f68bc83051e1a70e8e1b015 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateStorageMode.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateStorageMode.java @@ -44,7 +44,7 @@ public abstract class UpdateStorageMode extends RBuiltinNode { throw RError.error(getEncapsulatingSourceSection(), RError.Message.USE_DEFUNCT, mode.getName(), mode == RType.DefunctSingle ? "mode<-" : "double"); } initTypeOfNode(); - RType typeX = typeof.execute(frame, x); + RType typeX = typeof.execute(x); if (typeX == mode) { return x; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateSubstr.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateSubstr.java index 44fa97f2ede97135354e9fafb78b14d3d2cd3d11..2665d82e35bcadddf7a8f5bbe71c159b9577281d 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateSubstr.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateSubstr.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -79,7 +79,7 @@ public abstract class UpdateSubstr extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "emptyArg") + @Specialization(guards = "emptyArg(arg)") @TruffleBoundary protected RStringVector substrEmptyArg(RAbstractStringVector arg, RAbstractIntVector start, RAbstractIntVector stop, Object value) { controlVisibility(); @@ -87,7 +87,7 @@ public abstract class UpdateSubstr extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!emptyArg", "wrongParams"}) + @Specialization(guards = {"!emptyArg(arg)", "wrongParams(start, stop)"}) @TruffleBoundary protected RNull substrWrongParams(RAbstractStringVector arg, RAbstractIntVector start, RAbstractIntVector stop, Object value) { RInternalError.shouldNotReachHere(); @@ -95,20 +95,20 @@ public abstract class UpdateSubstr extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!emptyArg", "!wrongParams"}) + @Specialization(guards = {"!emptyArg(arg)", "!wrongParams(start, stop)"}) @TruffleBoundary protected RStringVector substr(RAbstractStringVector arg, RAbstractIntVector start, RAbstractIntVector stop, RNull value) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_UNNAMED_VALUE); } @SuppressWarnings("unused") - @Specialization(guards = {"!emptyArg", "!wrongParams", "wrongValue"}) + @Specialization(guards = {"!emptyArg(arg)", "!wrongParams(start, stop)", "wrongValue(value)"}) protected RStringVector substr(RAbstractStringVector arg, RAbstractIntVector start, RAbstractIntVector stop, RAbstractVector value) { CompilerDirectives.transferToInterpreter(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_UNNAMED_VALUE); } - @Specialization(guards = {"!emptyArg", "!wrongParams", "!wrongValue"}) + @Specialization(guards = {"!emptyArg(arg)", "!wrongParams(start, stop)", "!wrongValue(value)"}) @TruffleBoundary protected RStringVector substr(RAbstractStringVector arg, RAbstractIntVector start, RAbstractIntVector stop, RAbstractStringVector value) { controlVisibility(); @@ -133,20 +133,18 @@ public abstract class UpdateSubstr extends RBuiltinNode { } - @SuppressWarnings("unused") - protected boolean emptyArg(RAbstractStringVector arg, RAbstractIntVector start, RAbstractIntVector stop) { + protected boolean emptyArg(RAbstractStringVector arg) { return arg.getLength() == 0; } - protected boolean wrongParams(@SuppressWarnings("unused") RAbstractStringVector arg, RAbstractIntVector start, RAbstractIntVector stop) { + protected boolean wrongParams(RAbstractIntVector start, RAbstractIntVector stop) { if (start.getLength() == 0 || stop.getLength() == 0) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_ARGUMENTS_NO_QUOTE, "substring"); } return false; } - @SuppressWarnings("unused") - protected boolean wrongValue(RAbstractStringVector arg, RAbstractIntVector start, RAbstractIntVector stop, RAbstractVector value) { + protected boolean wrongValue(RAbstractVector value) { return value.getElementClass() != RString.class || value.getLength() == 0; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/WhichFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/WhichFunctions.java index c745d788aea63c50e3d4f994180607b2ff98f725..e243c5a50f1e54df56cb38e56c7a7cd2857cec05 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/WhichFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/WhichFunctions.java @@ -55,7 +55,7 @@ public class WhichFunctions { return new RNode[]{ConstantNode.create(RMissing.instance)}; } - @Specialization(guards = "!hasNames") + @Specialization(guards = "!hasNames(x)") @TruffleBoundary protected RIntVector which(RAbstractLogicalVector x) { controlVisibility(); @@ -72,7 +72,7 @@ public class WhichFunctions { return RDataFactory.createIntVector(result, RDataFactory.COMPLETE_VECTOR); } - @Specialization(guards = "hasNames") + @Specialization(guards = "hasNames(x)") @TruffleBoundary protected RIntVector whichNames(RAbstractLogicalVector x) { controlVisibility(); diff --git a/com.oracle.truffle.r.nodes.wrapper.processor/src/com/oracle/truffle/r/nodes/wrapper/processor/WrapperProcessor.java b/com.oracle.truffle.r.nodes.wrapper.processor/src/com/oracle/truffle/r/nodes/wrapper/processor/WrapperProcessor.java index 25470315d017e2f2f1ec2720bc950381cf550b5f..d7af55f031efef2117be0ac0aed4dc58db1a2495 100644 --- a/com.oracle.truffle.r.nodes.wrapper.processor/src/com/oracle/truffle/r/nodes/wrapper/processor/WrapperProcessor.java +++ b/com.oracle.truffle.r.nodes.wrapper.processor/src/com/oracle/truffle/r/nodes/wrapper/processor/WrapperProcessor.java @@ -58,6 +58,8 @@ public class WrapperProcessor extends AbstractProcessor { if (roundEnv.processingOver()) { return true; } + System.setProperty("line.separator", "\n"); + note("CreateWrapperProcessor: analyzing classes"); createWrapperElement = processingEnv.getElementUtils().getTypeElement("com.oracle.truffle.r.nodes.instrument.CreateWrapper"); for (Element element : roundEnv.getElementsAnnotatedWith(createWrapperElement)) { @@ -108,6 +110,7 @@ public class WrapperProcessor extends AbstractProcessor { PrintWriter wr = new PrintWriter(new BufferedWriter(srcLocator.openWriter())); try { wr.println("// DO NOT EDIT, generated automatically"); + wr.println("// Checkstyle: stop"); wr.printf("package %s;%n", packageName); wr.println(); wr.printf("import com.oracle.truffle.api.instrument.Probe;%n"); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessArgumentNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessArgumentNode.java index 9281a9a702003ba5bb86bb2be688e74c8a811a2f..87982e0913130c5dd6af4624439c8267207385d0 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessArgumentNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessArgumentNode.java @@ -134,14 +134,14 @@ public abstract class AccessArgumentNode extends RNode { return promise; } - @Specialization(guards = {"!hasDefaultArg", "!isVarArgIndex"}) + @Specialization(guards = {"!hasDefaultArg()", "!isVarArgIndex()"}) public Object doArgumentNoDefaultArg(RMissing argMissing) { // Simply return missing if there's no default arg OR it represents an empty "..." // (Empty "..." defaults to missing anyway, this way we don't have to rely on ) return argMissing; } - @Specialization(guards = {"hasDefaultArg"}) + @Specialization(guards = {"hasDefaultArg()"}) public Object doArgumentDefaultArg(VirtualFrame frame, @SuppressWarnings("unused") RMissing argMissing) { Object result; if (canBeOptimized()) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessFieldNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessFieldNode.java index 53a1f4b78c9670b2dd53c5e83f245ad5aaa31db3..f108a76ac5f0ebac828798f4316852ef64b749d8 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessFieldNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessFieldNode.java @@ -50,7 +50,7 @@ public abstract class AccessFieldNode extends RNode { return RNull.instance; } - @Specialization(guards = "hasNames") + @Specialization(guards = "hasNames(object)") protected Object accessField(RList object) { int index = object.getElementIndexByName(attrProfiles, getField()); if (index == -1) { @@ -60,13 +60,13 @@ public abstract class AccessFieldNode extends RNode { return index == -1 ? RNull.instance : object.getDataAt(index); } - @Specialization(guards = "!hasNames") + @Specialization(guards = "!hasNames(object)") protected Object accessFieldNoNames(@SuppressWarnings("unused") RList object) { return RNull.instance; } // TODO: this should ultimately be a generic function - @Specialization(guards = "hasNames") + @Specialization(guards = "hasNames(object)") protected Object accessField(RDataFrame object) { int index = object.getElementIndexByName(attrProfiles, getField()); if (index == -1) { @@ -77,7 +77,7 @@ public abstract class AccessFieldNode extends RNode { return index == -1 ? RNull.instance : object.getDataAtAsObject(index); } - @Specialization(guards = "!hasNames") + @Specialization(guards = "!hasNames(object)") protected Object accessFieldNoNames(@SuppressWarnings("unused") RDataFrame object) { return RNull.instance; } @@ -93,7 +93,7 @@ public abstract class AccessFieldNode extends RNode { throw RError.error(RError.Message.DOLLAR_ATOMIC_VECTORS); } - @Specialization(guards = "hasNames") + @Specialization(guards = "hasNames(object)") protected Object accessFieldHasNames(RLanguage object) { String field = getField(); RStringVector names = object.getNames(attrProfiles); @@ -105,7 +105,7 @@ public abstract class AccessFieldNode extends RNode { return RNull.instance; } - @Specialization(guards = "!hasNames") + @Specialization(guards = "!hasNames(object)") protected Object accessField(@SuppressWarnings("unused") RLanguage object) { return RNull.instance; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/RemoveAndAnswerNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/RemoveAndAnswerNode.java index f9da6d0f57a18f8a3d6d089b3fd4e7f91d6a07f1..c53c6c6b853dd9b2ece37bd851917070e6ab1306 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/RemoveAndAnswerNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/RemoveAndAnswerNode.java @@ -108,7 +108,7 @@ public abstract class RemoveAndAnswerNode extends RNoDeparseNode { return frame.isByte(slot); } - @Specialization(guards = "isObject") + @Specialization(guards = "isObject(frame)") public Object doObject(VirtualFrame frame) { controlVisibility(); Object result; @@ -123,7 +123,7 @@ public abstract class RemoveAndAnswerNode extends RNoDeparseNode { return result; } - @Specialization(guards = "isInt") + @Specialization(guards = "isInt(frame)") public int doInt(VirtualFrame frame) { controlVisibility(); int result; @@ -138,7 +138,7 @@ public abstract class RemoveAndAnswerNode extends RNoDeparseNode { return result; } - @Specialization(guards = "isDouble") + @Specialization(guards = "isDouble(frame)") public double doDouble(VirtualFrame frame) { controlVisibility(); double result; @@ -153,7 +153,7 @@ public abstract class RemoveAndAnswerNode extends RNoDeparseNode { return result; } - @Specialization(guards = "isByte") + @Specialization(guards = "isByte(frame)") public byte doByte(VirtualFrame frame) { controlVisibility(); byte result; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/UpdateFieldNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/UpdateFieldNode.java index 02648d02495d2607b8e96789dee9f1b6adafd37a..3e950ba3b0f7407163e80f4e750138101f9a5f79 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/UpdateFieldNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/UpdateFieldNode.java @@ -54,7 +54,7 @@ public abstract class UpdateFieldNode extends RNode { @Child private CastListNode castList; - @Specialization(guards = "!isNullValue") + @Specialization(guards = "!isNull(value)") protected Object updateField(RList object, Object value) { String field = getField(); int index = object.getElementIndexByName(attrProfiles, field); @@ -91,7 +91,7 @@ public abstract class UpdateFieldNode extends RNode { return result; } - @Specialization(guards = "isNullValue") + @Specialization(guards = "isNull(value)") protected Object updateFieldNullValue(RList object, @SuppressWarnings("unused") Object value) { String field = getField(); int index = object.getElementIndexByName(attrProfiles, field); @@ -162,7 +162,7 @@ public abstract class UpdateFieldNode extends RNode { } } - protected boolean isNullValue(@SuppressWarnings("unused") RAbstractVector object, Object value) { + protected static boolean isNull(Object value) { return value == RNull.instance; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/WriteVariableNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/WriteVariableNode.java index 93dcc81b31a48c5750be291543184351983438bf..40ec9b1990f3e00fe43e80dbb26d6588f0a0f779 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/WriteVariableNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/WriteVariableNode.java @@ -22,26 +22,26 @@ */ package com.oracle.truffle.r.nodes.access; +import static com.oracle.truffle.r.runtime.env.frame.FrameSlotChangeMonitor.*; + import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.api.frame.*; -import com.oracle.truffle.r.nodes.access.WriteVariableNodeFactory.ResolvedWriteLocalVariableNodeGen; -import com.oracle.truffle.r.nodes.access.WriteVariableNodeFactory.UnresolvedWriteLocalVariableNodeGen; -import com.oracle.truffle.r.nodes.access.WriteVariableNodeFactory.WriteSuperVariableNodeGen; -import com.oracle.truffle.r.nodes.instrument.CreateWrapper; -import com.oracle.truffle.api.instrument.ProbeNode; +import com.oracle.truffle.api.instrument.*; import com.oracle.truffle.api.nodes.*; import com.oracle.truffle.api.source.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.*; +import com.oracle.truffle.r.nodes.access.WriteVariableNodeFactory.ResolvedWriteLocalVariableNodeGen; +import com.oracle.truffle.r.nodes.access.WriteVariableNodeFactory.UnresolvedWriteLocalVariableNodeGen; +import com.oracle.truffle.r.nodes.access.WriteVariableNodeFactory.WriteSuperVariableNodeGen; +import com.oracle.truffle.r.nodes.instrument.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.RDeparse.State; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.env.*; import com.oracle.truffle.r.runtime.env.frame.*; -import static com.oracle.truffle.r.runtime.env.frame.FrameSlotChangeMonitor.findOrAddFrameSlot; - @NodeChild(value = "rhs", type = RNode.class) @NodeFields({@NodeField(name = "argWrite", type = boolean.class), @NodeField(name = "name", type = String.class)}) @CreateWrapper @@ -241,21 +241,21 @@ public abstract class WriteVariableNode extends RNode implements VisibilityContr return ResolvedWriteLocalVariableNodeGen.create(rhs, isArgWrite, name, frameSlot, mode); } - @Specialization(guards = "isFrameLogicalKind") + @Specialization(guards = "isLogicalKind(frame, frameSlot)") protected byte doLogical(VirtualFrame frame, FrameSlot frameSlot, byte value) { controlVisibility(); FrameSlotChangeMonitor.setByteAndInvalidate(frame, frameSlot, value, false, invalidateProfile); return value; } - @Specialization(guards = "isFrameIntegerKind") + @Specialization(guards = "isIntegerKind(frame, frameSlot)") protected int doInteger(VirtualFrame frame, FrameSlot frameSlot, int value) { controlVisibility(); FrameSlotChangeMonitor.setIntAndInvalidate(frame, frameSlot, value, false, invalidateProfile); return value; } - @Specialization(guards = "isFrameDoubleKind") + @Specialization(guards = "isDoubleKind(frame, frameSlot)") protected double doDouble(VirtualFrame frame, FrameSlot frameSlot, double value) { controlVisibility(); FrameSlotChangeMonitor.setDoubleAndInvalidate(frame, frameSlot, value, false, invalidateProfile); @@ -270,18 +270,6 @@ public abstract class WriteVariableNode extends RNode implements VisibilityContr return value; } - protected boolean isFrameLogicalKind(FrameSlot frameSlot, @SuppressWarnings("unused") byte value) { - return isLogicalKind(frameSlot); - } - - protected boolean isFrameIntegerKind(FrameSlot frameSlot, @SuppressWarnings("unused") int value) { - return isIntegerKind(frameSlot); - } - - protected boolean isFrameDoubleKind(FrameSlot frameSlot, @SuppressWarnings("unused") double value) { - return isDoubleKind(frameSlot); - } - @Override public void deparse(State state) { deparseHelper(state, " <- "); @@ -430,21 +418,21 @@ public abstract class WriteVariableNode extends RNode implements VisibilityContr public abstract Mode getMode(); - @Specialization(guards = "isFrameLogicalKind") + @Specialization(guards = "isLogicalKind(frame, frameSlot)") protected byte doLogical(VirtualFrame frame, byte value, MaterializedFrame enclosingFrame, FrameSlot frameSlot) { controlVisibility(); FrameSlotChangeMonitor.setByteAndInvalidate(enclosingFrameProfile.profile(enclosingFrame), frameSlot, value, true, invalidateProfile); return value; } - @Specialization(guards = "isFrameIntegerKind") + @Specialization(guards = "isIntegerKind(frame, frameSlot)") protected int doInteger(VirtualFrame frame, int value, MaterializedFrame enclosingFrame, FrameSlot frameSlot) { controlVisibility(); FrameSlotChangeMonitor.setIntAndInvalidate(enclosingFrameProfile.profile(enclosingFrame), frameSlot, value, true, invalidateProfile); return value; } - @Specialization(guards = "isFrameDoubleKind") + @Specialization(guards = "isDoubleKind(frame, frameSlot)") protected double doDouble(VirtualFrame frame, double value, MaterializedFrame enclosingFrame, FrameSlot frameSlot) { controlVisibility(); FrameSlotChangeMonitor.setDoubleAndInvalidate(enclosingFrameProfile.profile(enclosingFrame), frameSlot, value, true, invalidateProfile); @@ -460,28 +448,20 @@ public abstract class WriteVariableNode extends RNode implements VisibilityContr return value; } - protected boolean isFrameLogicalKind(byte arg0, MaterializedFrame arg1, FrameSlot frameSlot) { - return isLogicalKind(frameSlot); - } - - protected boolean isFrameIntegerKind(int arg0, MaterializedFrame arg1, FrameSlot frameSlot) { - return isIntegerKind(frameSlot); - } - - protected boolean isFrameDoubleKind(double arg0, MaterializedFrame arg1, FrameSlot frameSlot) { - return isDoubleKind(frameSlot); - } } - protected boolean isLogicalKind(FrameSlot frameSlot) { + @SuppressWarnings("unused") + protected boolean isLogicalKind(VirtualFrame frame, FrameSlot frameSlot) { return isKind(frameSlot, FrameSlotKind.Boolean); } - protected boolean isIntegerKind(FrameSlot frameSlot) { + @SuppressWarnings("unused") + protected boolean isIntegerKind(VirtualFrame frame, FrameSlot frameSlot) { return isKind(frameSlot, FrameSlotKind.Int); } - protected boolean isDoubleKind(FrameSlot frameSlot) { + @SuppressWarnings("unused") + protected boolean isDoubleKind(VirtualFrame frame, FrameSlot frameSlot) { return isKind(frameSlot, FrameSlotKind.Double); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/ArrayPositionCast.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/ArrayPositionCast.java index 5b33cb2dca2ca3661fb3d2dd34c474469c10d8b4..599453b574709093d13710c82f38b66850471d40 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/ArrayPositionCast.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/ArrayPositionCast.java @@ -53,13 +53,6 @@ abstract class ArrayPositionsCastBase extends RNode { this.isSubset = isSubset; } - protected ArrayPositionsCastBase(ArrayPositionsCastBase other) { - this.dimension = other.dimension; - this.numDimensions = other.numDimensions; - this.assignment = other.assignment; - this.isSubset = other.isSubset; - } - private final ConditionProfile nameConditionProfile = ConditionProfile.createBinaryProfile(); private final BranchProfile naValueMet = BranchProfile.create(); private final BranchProfile intVectorMet = BranchProfile.create(); @@ -138,10 +131,6 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { super(dimension, numDimensions, assignment, isSubset); } - protected ArrayPositionCast(ArrayPositionCast other) { - super(other); - } - @Specialization protected RIntVector doMissingVector(RNull vector, RAbstractIntVector operand) { return operand.materialize(); @@ -268,10 +257,6 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { super(dimension, numDimensions, assignment, isSubset); } - protected OperatorConverterNode(OperatorConverterNode other) { - super(other); - } - private void initConvertCast() { if (operatorConvertRecursive == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -427,13 +412,13 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { return 0; } - @Specialization(guards = "isAssignment") + @Specialization(guards = "assignment") protected RIntVector doStringNullVecAssignment(RNull vector, String operand, Object exact) { RStringVector resNames = RDataFactory.createStringVector(new String[]{operand}, !RRuntime.isNA(operand)); return RDataFactory.createIntVector(new int[]{1}, RDataFactory.COMPLETE_VECTOR, resNames); } - @Specialization(guards = "!isAssignment") + @Specialization(guards = "!assignment") protected int doStringOneDimAssignment(RNull vector, String operand, Object exact) { return RRuntime.INT_NA; } @@ -455,17 +440,17 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } } - @Specialization(guards = "!opString") + @Specialization(guards = "!opString(operand)") protected Object doMissingVectorOp(VirtualFrame frame, RNull vector, RAbstractVector operand, Object exact) { return castInteger(frame, operand); } - @Specialization(guards = "indNA") + @Specialization(guards = "indNA(operand)") protected Object doIntNA(RList vector, int operand, Object exact) { return numDimensions != 1 || isSubset ? operand : RNull.instance; } - @Specialization(guards = {"indNA", "!isVectorList"}) + @Specialization(guards = {"indNA(operand)", "!isVectorList(container)"}) protected int doIntNA(RAbstractContainer container, int operand, Object exact) { if (isSubset) { return operand; @@ -477,7 +462,7 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } } - @Specialization(guards = "!indNA") + @Specialization(guards = "!indNA(operand)") protected Object doInt(VirtualFrame frame, RAbstractContainer container, int operand, Object exact) { int dimSize = getDimensionSize(frame, container); @@ -538,12 +523,12 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } } - @Specialization(guards = "!isNegative") + @Specialization(guards = "!isNegative(operand)") protected Object doDouble(VirtualFrame frame, RAbstractContainer container, double operand, Object exact) { return convertOperatorRecursive(frame, container, castInteger(frame, operand), exact); } - @Specialization(guards = "isNegative") + @Specialization(guards = "isNegative(operand)") protected Object doDoubleNegative(VirtualFrame frame, RAbstractContainer container, double operand, Object exact) { // returns object as it may return either int or RIntVector due to conversion return convertOperatorRecursive(frame, container, castInteger(frame, Math.abs(operand) > container.getLength() ? operand - 1 : operand), exact); @@ -554,17 +539,17 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { // removal of the third element. } - @Specialization(guards = {"indNA", "numDimensionsOne", "!isSubset"}) + @Specialization(guards = {"indNA(operand)", "numDimensions == 1", "!isSubset"}) protected RNull doLogicalDimLengthOne(RList vector, byte operand, Object exact) { return RNull.instance; } - @Specialization(guards = {"indNA", "numDimensionsOne", "!isSubset", "!isVectorList"}) + @Specialization(guards = {"indNA(operand)", "numDimensions == 1", "!isSubset", "!isVectorList(container)"}) protected int doLogicalDimLengthOne(RAbstractContainer container, byte operand, Object exact) { return RRuntime.INT_NA; } - @Specialization(guards = "indNA") + @Specialization(guards = "indNA(operand)") protected Object doLogicalNA(VirtualFrame frame, RAbstractContainer container, byte operand, Object exact) { if (isSubset && !assignment) { int dimLength = numDimensions == 1 ? (container.getLength() == 0 ? 1 : container.getLength()) : getDimensions(container)[dimension]; @@ -576,7 +561,7 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } } - @Specialization(guards = {"indTrue", "isSubset"}) + @Specialization(guards = {"indTrue(operand)", "isSubset"}) protected RIntVector doLogicalIndTrue(VirtualFrame frame, RAbstractContainer container, byte operand, Object exact) { int dimLength = numDimensions == 1 ? container.getLength() : getDimensions(container)[dimension]; int[] data = new int[dimLength]; @@ -586,12 +571,12 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { return RDataFactory.createIntVector(data, RDataFactory.COMPLETE_VECTOR); } - @Specialization(guards = {"indFalse", "isSubset"}) + @Specialization(guards = {"indFalse(operand)", "isSubset"}) protected int doLogicalIndFalse(RAbstractContainer container, byte operand, Object exact) { return 0; } - @Specialization(guards = {"!indNA", "!isSubset"}) + @Specialization(guards = {"!indNA(operand)", "!isSubset"}) protected int doLogical(RAbstractContainer container, byte operand, Object exact) { return RRuntime.logical2intNoCheck(operand); } @@ -679,7 +664,7 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { return RDataFactory.createIntVector(new int[]{position}, RDataFactory.COMPLETE_VECTOR, resNames); } - @Specialization(guards = "indNA") + @Specialization(guards = "indNA(operand)") protected Object doStringNA(VirtualFrame frame, RAbstractContainer container, String operand, Object exact) { if (numDimensions == 1) { if (assignment) { @@ -745,7 +730,7 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } } - @Specialization(guards = "!indNA") + @Specialization(guards = "!indNA(operand)") protected Object doString(VirtualFrame frame, RAbstractContainer container, String operand, Object exact) { boolean findExact = true; RAbstractLogicalVector exactVec = (RAbstractLogicalVector) castLogical(frame, castVector(frame, exact)); @@ -1162,7 +1147,7 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } } - protected boolean opString(RNull container, RAbstractVector operand) { + protected boolean opString(RAbstractVector operand) { return operand.getElementClass() == RString.class; } @@ -1176,43 +1161,31 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { return container instanceof RList; } - protected static boolean indNA(RAbstractContainer container, int operand) { + protected static boolean indNA(int operand) { return RRuntime.isNA(operand); } - protected static boolean indNA(RAbstractContainer container, byte operand) { + protected static boolean indNA(byte operand) { return RRuntime.isNA(operand); } - protected static boolean indNA(RAbstractContainer container, String operand) { + protected static boolean indNA(String operand) { return RRuntime.isNA(operand); } - protected static boolean indTrue(RAbstractContainer container, byte operand) { + protected static boolean indTrue(byte operand) { return operand == RRuntime.LOGICAL_TRUE; } - protected static boolean indFalse(RAbstractContainer container, byte operand) { + protected static boolean indFalse(byte operand) { return operand == RRuntime.LOGICAL_FALSE; } - protected boolean isNegative(RAbstractContainer container, double operand) { + protected boolean isNegative(double operand) { return operand < 0; } - protected boolean numDimensionsOne() { - return numDimensions == 1; - } - - protected boolean isSubset() { - return isSubset; - } - - protected boolean isAssignment() { - return assignment; - } - - protected boolean operandHasNames(RNull vector, RAbstractIntVector operand) { + protected boolean operandHasNames(RAbstractIntVector operand) { return operand.getNames(attrProfiles) != null; } } @@ -1245,12 +1218,12 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { return castString.executeCast(frame, operand); } - @Specialization(guards = "!isDataFrame") + @Specialization(guards = "!isDataFrame(container)") RList getDim(RAbstractContainer container) { return container.getDimNames(); } - @Specialization(guards = "isDataFrame") + @Specialization(guards = "isDataFrame(container)") RList getDimDataFrame(VirtualFrame frame, RAbstractContainer container) { return RDataFactory.createList(new Object[]{castString(frame, getContainerRowNames(frame, container)), container.getNames(attrProfiles)}); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/ContainerRowNamesGet.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/ContainerRowNamesGet.java index a2b663571235c3db637a37efb814a71834b3e4c4..efbdfc70f196df5069bf5ef3ba1a73f8187f0178 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/ContainerRowNamesGet.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/ContainerRowNamesGet.java @@ -51,7 +51,7 @@ public abstract class ContainerRowNamesGet extends RNode { } } - @Specialization(guards = "!isDataFrame") + @Specialization(guards = "!isDataFrame(container)") Object getRowNames(RAbstractContainer container) { return container.getRowNames(attrProfiles); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/AccessArrayNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/AccessArrayNode.java index 2d6a3de77183b2881e8cdb2776b0b1d1a984e5e1..b18e7c70d56f96df7232750fc39408148961d390 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/AccessArrayNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/AccessArrayNode.java @@ -37,8 +37,8 @@ import com.oracle.truffle.r.nodes.function.*; import com.oracle.truffle.r.nodes.function.DispatchedCallNode.DispatchType; import com.oracle.truffle.r.nodes.function.DispatchedCallNode.NoGenericMethodException; import com.oracle.truffle.r.nodes.unary.*; -import com.oracle.truffle.r.runtime.RDeparse.State; import com.oracle.truffle.r.runtime.*; +import com.oracle.truffle.r.runtime.RDeparse.State; import com.oracle.truffle.r.runtime.RError.Message; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; @@ -245,7 +245,7 @@ public abstract class AccessArrayNode extends RNode { private static final ArgumentsSignature DROP_SIGNATURE = ArgumentsSignature.get(new String[]{"", "", "drop"}); private static final ArgumentsSignature EXACT_SIGNATURE = ArgumentsSignature.get(new String[]{"", "", "exact"}); - @Specialization(guards = {"isObject", "isSubset"}) + @Specialization(guards = {"isObject(container)", "isSubset()"}) protected Object accessObjectSubset(VirtualFrame frame, RAbstractContainer container, Object exact, int recLevel, Object position, Object dropDim) { Object inds = position instanceof Object[] ? new RArgsValuesAndNames((Object[]) position, ArgumentsSignature.empty(((Object[]) position).length)) : position; try { @@ -267,7 +267,7 @@ public abstract class AccessArrayNode extends RNode { } } - @Specialization(guards = {"isObject", "!isSubset"}) + @Specialization(guards = {"isObject(container)", "!isSubset()"}) protected Object accessObject(VirtualFrame frame, RAbstractContainer container, Object exact, int recLevel, Object position, Object dropDim) { if (dcn == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -281,24 +281,24 @@ public abstract class AccessArrayNode extends RNode { } } - @Specialization(guards = "!isObject") + @Specialization(guards = "!isObject(factor)") protected Object accessFactor(VirtualFrame frame, RFactor factor, Object exact, int recLevel, Object position, Object dropDim) { return accessRecursive(frame, factor.getVector(), exact, position, recLevel, dropDim); } - @Specialization(guards = "!isObject") + @Specialization(guards = "!isObject(dataFrame)") protected Object accessFactor(VirtualFrame frame, RDataFrame dataFrame, Object exact, int recLevel, Object position, Object dropDim) { return accessRecursive(frame, dataFrame.getVector(), exact, position, recLevel, dropDim); } @SuppressWarnings("unused") - @Specialization(guards = {"inRecursion", "isFirstPositionPositive"}) + @Specialization(guards = {"inRecursion(recLevel)", "isFirstPositionPositive(positions)"}) protected RNull accessNullInRecursionPosPositive(RNull vector, Object exact, int recLevel, RAbstractIntVector positions, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SUBSCRIPT_BOUNDS); } @SuppressWarnings("unused") - @Specialization(guards = {"inRecursion", "!isFirstPositionPositive"}) + @Specialization(guards = {"inRecursion(recLevel)", "!isFirstPositionPositive(positions)"}) protected RNull accessNullInRecursion(RNull vector, Object exact, int recLevel, RAbstractIntVector positions, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_LESS_1); } @@ -310,25 +310,25 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"inRecursion", "isFirstPositionOne"}) + @Specialization(guards = {"inRecursion(recLevel)", "isFirstPositionOne(positions)"}) protected RNull accessFunctionInRecursionPosOne(RFunction vector, Object exact, int recLevel, RAbstractIntVector positions, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_TYPE_LENGTH, "closure", 1); } @SuppressWarnings("unused") - @Specialization(guards = {"inRecursion", "isFirstPositionPositive", "!isFirstPositionOne"}) + @Specialization(guards = {"inRecursion(recLevel)", "isFirstPositionPositive(positions)", "!isFirstPositionOne(positions)"}) protected RNull accessFunctionInRecursionPosPositive(RFunction vector, Object exact, int recLevel, RAbstractIntVector positions, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SUBSCRIPT_BOUNDS); } @SuppressWarnings("unused") - @Specialization(guards = {"inRecursion", "!isFirstPositionPositive"}) + @Specialization(guards = {"inRecursion(recLevel)", "!isFirstPositionPositive(positions)"}) protected RNull accessFunctionInRecursion(RFunction vector, Object exact, int recLevel, RAbstractIntVector positions, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_LESS_1); } @SuppressWarnings("unused") - @Specialization(guards = "inRecursion") + @Specialization(guards = "inRecursion(recLevel)") protected RNull accessFunctionInRecursionString(RFunction vector, Object exact, int recLevel, RAbstractStringVector positions, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SUBSCRIPT_BOUNDS); } @@ -340,7 +340,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = "!isObject") + @Specialization(guards = "!isObject(container)") protected RNull access(RAbstractContainer container, Object exact, int recLevel, RNull positions, Object dropDim) { // this is a special case (see ArrayPositionCast) - RNull can only appear to represent the // x[NA] case which has to return null and not a null vector @@ -348,7 +348,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = "!isObject") + @Specialization(guards = "!isObject(container)") protected Object access(RAbstractContainer container, Object exact, int recLevel, RMissing positions, Object dropDim) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_SUBSCRIPT_TYPE, "symbol"); @@ -358,13 +358,13 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "wrongDimensions"}) + @Specialization(guards = {"!isObject(container)", "wrongDimensions(container, positions)"}) protected Object access(RAbstractVector container, Object exact, int recLevel, Object[] positions, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INCORRECT_DIMENSIONS); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isPositionNA", "!isSubset"}) + @Specialization(guards = {"!isObject(container)", "isPositionNA(position)", "!isSubset()"}) protected RIntVector accessNA(RAbstractContainer container, Object exact, int recLevel, int position, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SUBSCRIPT_BOUNDS); } @@ -479,12 +479,12 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "hasDimNames(vector)"}) protected RList accessNames(VirtualFrame frame, RList vector, Object exact, int recLevel, Object[] positions, RMissing dropDim) { return accessNamesInternal(frame, vector, exact, recLevel, positions, RRuntime.LOGICAL_TRUE); } - @Specialization(guards = {"!isObject", "hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "hasDimNames(vector)"}) protected RList accessNames(VirtualFrame frame, RList vector, Object exact, int recLevel, Object[] positions, RAbstractLogicalVector dropDim) { return accessNamesInternal(frame, vector, exact, recLevel, positions, dropDim.getLength() == 0 ? RRuntime.LOGICAL_TRUE : dropDim.getDataAt(0)); } @@ -513,7 +513,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasDimNames(vector)"}) protected RList access(VirtualFrame frame, RList vector, Object exact, int recLevel, Object[] positions, RMissing dropDim) { DimsAndResultLength res = getDimsAndResultLength(positions, RRuntime.LOGICAL_TRUE); Object[] data = accessInternal(frame, res, vector, positions); @@ -521,7 +521,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasDimNames(vector)"}) protected RList access(VirtualFrame frame, RList vector, Object exact, int recLevel, Object[] positions, RAbstractLogicalVector dropDim) { DimsAndResultLength res = getDimsAndResultLength(positions, dropDim.getLength() == 0 ? RRuntime.LOGICAL_TRUE : dropDim.getDataAt(0)); Object[] data = accessInternal(frame, res, vector, positions); @@ -544,7 +544,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isSubset", "hasNames"}) + @Specialization(guards = {"!isObject(vector)", "isSubset()", "hasNames(vector)"}) protected RList accessSubsetNames(RList vector, Object exact, int recLevel, RIntVector p, Object dropDim) { Object[] data = accessSubsetInternal(vector, p); RStringVector names = getNamesVector(vector.getNames(attrProfiles), p, p.getLength(), namesNACheck); @@ -552,7 +552,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isSubset", "!hasNames"}) + @Specialization(guards = {"!isObject(vector)", "isSubset()", "!hasNames(vector)"}) protected RList accessSubset(RList vector, Object exact, int recLevel, RIntVector p, Object dropDim) { Object[] data = accessSubsetInternal(vector, p); return RDataFactory.createList(data); @@ -582,12 +582,12 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!hasNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasNames(vector)"}) protected RList accessStringNoNames(RList vector, Object exact, int recLevel, RStringVector p, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.NO_SUCH_INDEX, 1); } - @Specialization(guards = {"!isObject", "hasNames", "!isSubset", "twoPosition"}) + @Specialization(guards = {"!isObject(vector)", "hasNames(vector)", "!isSubset()", "twoPosition(p)"}) protected Object accessStringTwoPosRec(VirtualFrame frame, RList vector, Object exact, int recLevel, RStringVector p, Object dropDim) { int position = getPositionInRecursion(vector, p.getDataAt(0), recLevel, getEncapsulatingSourceSection(), error, attrProfiles); Object newVector = castVector(frame, vector.getDataAt(position - 1)); @@ -595,7 +595,7 @@ public abstract class AccessArrayNode extends RNode { return accessRecursive(frame, newVector, exact, newPosition, recLevel + 1, dropDim); } - @Specialization(guards = {"!isObject", "hasNames", "!isSubset", "!twoPosition"}) + @Specialization(guards = {"!isObject(vector)", "hasNames(vector)", "!isSubset()", "!twoPosition(p)"}) protected Object accessString(VirtualFrame frame, RList vector, Object exact, int recLevel, RStringVector p, Object dropDim) { int position = getPositionInRecursion(vector, p.getDataAt(0), recLevel, getEncapsulatingSourceSection(), error, attrProfiles); RStringVector newP = popHead(p, posNACheck); @@ -603,7 +603,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isSubset", "onePosition", "!inRecursion"}) + @Specialization(guards = {"!isObject(vector)", "!isSubset()", "onePosition(p)", "!inRecursion(recLevel)"}) protected Object accessOnePos(RList vector, Object exact, int recLevel, RIntVector p, Object dropDim) { int position = p.getDataAt(0); if (RRuntime.isNA(position)) { @@ -623,8 +623,8 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isSubset", "noPosition"}) - protected Object accessNoPos(RList vector, Object exact, int recLevel, RIntVector p, Object dropDim) { + @Specialization(guards = {"!isObject(vector)", "!isSubset()", "noPosition(positions)"}) + protected Object accessNoPos(RList vector, Object exact, int recLevel, RIntVector positions, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_LESS_1); } @@ -659,32 +659,32 @@ public abstract class AccessArrayNode extends RNode { return position; } - @Specialization(guards = {"!isObject", "!isSubset", "onePosition", "inRecursion"}) - protected Object accessSubscript(RList vector, @SuppressWarnings("unused") Object exact, int recLevel, RIntVector p, @SuppressWarnings("unused") Object dropDim) { - int position = p.getDataAt(0); + @Specialization(guards = {"!isObject(vector)", "!isSubset()", "onePosition(positions)", "inRecursion(recLevel)"}) + protected Object accessSubscript(RList vector, @SuppressWarnings("unused") Object exact, int recLevel, RIntVector positions, @SuppressWarnings("unused") Object dropDim) { + int position = positions.getDataAt(0); position = getPositionInRecursion(vector, position, recLevel); return vector.getDataAt(position - 1); } - @Specialization(guards = {"!isObject", "!isSubset", "twoPosition"}) - protected Object accessTwoPosRec(VirtualFrame frame, RList vector, Object exact, int recLevel, RIntVector p, Object dropDim) { - int position = p.getDataAt(0); + @Specialization(guards = {"!isObject(vector)", "!isSubset()", "twoPosition(positions)"}) + protected Object accessTwoPosRec(VirtualFrame frame, RList vector, Object exact, int recLevel, RIntVector positions, Object dropDim) { + int position = positions.getDataAt(0); position = getPositionInRecursion(vector, position, recLevel); Object newVector = castVector(frame, vector.getDataAt(position - 1)); - Object newPosition = castPosition(frame, newVector, convertOperand(frame, newVector, p.getDataAt(1), exact)); + Object newPosition = castPosition(frame, newVector, convertOperand(frame, newVector, positions.getDataAt(1), exact)); return accessRecursive(frame, newVector, exact, newPosition, recLevel + 1, dropDim); } - @Specialization(guards = {"!isObject", "!isSubset", "multiPos"}) - protected Object access(VirtualFrame frame, RList vector, Object exact, int recLevel, RIntVector p, Object dropDim) { - int position = p.getDataAt(0); + @Specialization(guards = {"!isObject(vector)", "!isSubset()", "multiPos(positions)"}) + protected Object access(VirtualFrame frame, RList vector, Object exact, int recLevel, RIntVector positions, Object dropDim) { + int position = positions.getDataAt(0); position = getPositionInRecursion(vector, position, recLevel); - RIntVector newP = popHead(p, posNACheck); + RIntVector newP = popHead(positions, posNACheck); return accessRecursive(frame, vector.getDataAt(position - 1), exact, newP, recLevel + 1, dropDim); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isPositionNA", "isSubset"}) + @Specialization(guards = {"!isObject(vector)", "isPositionNA(position)", "isSubset()"}) protected RList accessNA(RList vector, Object exact, int recLevel, int position, Object dropDim) { if (vector.getNames(attrProfiles) == null) { return RDataFactory.createList(new Object[]{RNull.instance}); @@ -694,56 +694,58 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionNA", "isPositionNegative", "!outOfBoundsNegative"}) + @Specialization(guards = {"!isObject(container)", "!isPositionNA(position)", "isPositionNegative(position)", "!outOfBoundsNegative(container, position)"}) protected RList accessNegativeInBounds(RAbstractContainer container, Object exact, int recLevel, int position, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_MORE_1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionNA", "isPositionNegative", "outOfBoundsNegative", "oneElemVector"}) + @Specialization(guards = {"!isObject(container)", "!isPositionNA(position)", "isPositionNegative(position)", "outOfBoundsNegative(container, position)", "oneElemVector(container)"}) protected RList accessNegativeOutOfBoundsOneElemVector(RAbstractContainer container, Object exact, int recLevel, int position, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_LESS_1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionNA", "isPositionNegative", "outOfBoundsNegative", "!oneElemVector"}) + @Specialization(guards = {"!isObject(container)", "!isPositionNA(position)", "isPositionNegative(position)", "outOfBoundsNegative(container, position)", "!oneElemVector(container)"}) protected RList accessNegativeOutOfBounds(RAbstractContainer container, Object exact, int recLevel, int position, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_MORE_1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "hasNames", "isSubset", "!isPositionNA", "!isPositionNegative"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "hasNames(vector)", "isSubset()", "!isPositionNA(position)", "!isPositionNegative(position)"}) protected RList accessNamesSubset(RList vector, Object exact, int recLevel, int position, Object dropDim) { Object val = vector.getDataAt(position - 1); return RDataFactory.createList(new Object[]{val}, getName(vector, position)); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "hasNames", "!isSubset", "!isPositionNA", "!isPositionNegative", "!outOfBounds"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "hasNames(vector)", "!isSubset()", "!isPositionNA(position)", "!isPositionNegative(position)", + "!outOfBounds(vector, position)"}) protected Object accessNames(RList vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!hasNames", "isSubset", "!isPositionNA", "!isPositionNegative"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!hasNames(vector)", "isSubset()", "!isPositionNA(position)", "!isPositionNegative(position)"}) protected RList accessSubset(RList vector, Object exact, int recLevel, int position, Object dropDim) { return RDataFactory.createList(new Object[]{vector.getDataAt(position - 1)}); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!hasNames", "!isSubset", "!isPositionNA", "!isPositionNegative", "!outOfBounds"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!hasNames(vector)", "!isSubset()", "!isPositionNA(position)", "!isPositionNegative(position)", + "!outOfBounds(vector, position)"}) protected Object access(RList vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isSubset", "outOfBounds"}) + @Specialization(guards = {"!isObject(vector)", "!isSubset()", "outOfBounds(vector, position)"}) protected Object accessOutOfBounds(RList vector, Object exact, int recLevel, int position, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SUBSCRIPT_BOUNDS); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isPositionZero"}) + @Specialization(guards = {"!isObject(vector)", "isPositionZero(position)"}) protected RList accessPosZero(RList vector, Object exact, int recLevel, int position, Object dropDim) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_LESS_1); @@ -756,14 +758,14 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isSubset", "inRecursion", "multiPos", "!isVectorList"}) - protected Object accessRecFailedRec(RAbstractContainer container, Object exact, int recLevel, RIntVector p, Object dropDim) { + @Specialization(guards = {"!isObject(container)", "!isSubset()", "inRecursion(recLevel)", "multiPos(positions)", "!isVectorList(container)"}) + protected Object accessRecFailedRec(RAbstractContainer container, Object exact, int recLevel, RIntVector positions, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.RECURSIVE_INDEXING_FAILED, recLevel + 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isSubset", "!inRecursion", "multiPos", "!isVectorList"}) - protected Object accessRecFailed(RAbstractContainer container, Object exact, int recLevel, RIntVector p, Object dropDim) { + @Specialization(guards = {"!isObject(container)", "!isSubset()", "!inRecursion(recLevel)", "multiPos(positions)", "!isVectorList(container)"}) + protected Object accessRecFailed(RAbstractContainer container, Object exact, int recLevel, RIntVector positions, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_MORE_1); } @@ -792,12 +794,12 @@ public abstract class AccessArrayNode extends RNode { return data; } - @Specialization(guards = {"!isObject", "hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "hasDimNames(vector)"}) protected RIntVector accessNames(VirtualFrame frame, RAbstractIntVector vector, Object exact, int recLevel, Object[] positions, @SuppressWarnings("unused") RMissing dropDim) { return accessNamesInternal(frame, vector, exact, recLevel, positions, RRuntime.LOGICAL_TRUE); } - @Specialization(guards = {"!isObject", "hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "hasDimNames(vector)"}) protected RIntVector accessNames(VirtualFrame frame, RAbstractIntVector vector, Object exact, int recLevel, Object[] positions, RAbstractLogicalVector dropDim) { return accessNamesInternal(frame, vector, exact, recLevel, positions, dropDim.getLength() == 0 ? RRuntime.LOGICAL_TRUE : dropDim.getDataAt(0)); } @@ -825,7 +827,7 @@ public abstract class AccessArrayNode extends RNode { } } - @Specialization(guards = {"!isObject", "!hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasDimNames(vector)"}) protected RIntVector access(VirtualFrame frame, RAbstractIntVector vector, @SuppressWarnings("unused") Object exact, @SuppressWarnings("unused") int recLevel, Object[] positions, @SuppressWarnings("unused") RMissing dropDim) { DimsAndResultLength res = getDimsAndResultLength(positions, RRuntime.LOGICAL_TRUE); @@ -833,7 +835,7 @@ public abstract class AccessArrayNode extends RNode { return RDataFactory.createIntVector(data, elementNACheck.neverSeenNA(), res.dimensions); } - @Specialization(guards = {"!isObject", "!hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasDimNames(vector)"}) protected RIntVector access(VirtualFrame frame, RAbstractIntVector vector, @SuppressWarnings("unused") Object exact, @SuppressWarnings("unused") int recLevel, Object[] positions, RAbstractLogicalVector dropDim) { DimsAndResultLength res = getDimsAndResultLength(positions, dropDim.getLength() == 0 ? RRuntime.LOGICAL_TRUE : dropDim.getDataAt(0)); @@ -863,7 +865,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "hasNames"}) + @Specialization(guards = {"!isObject(vector)", "hasNames(vector)"}) protected RIntVector accessNames(RAbstractIntVector vector, Object exact, int recLevel, RIntVector p, Object dropDim) { int[] data = accessInternal(vector, p); RStringVector names = getNamesVector(vector.getNames(attrProfiles), p, p.getLength(), namesNACheck); @@ -871,14 +873,14 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!hasNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasNames(vector)"}) protected RIntVector access(RAbstractIntVector vector, Object exact, int recLevel, RIntVector p, Object dropDim) { int[] data = accessInternal(vector, p); return RDataFactory.createIntVector(data, elementNACheck.neverSeenNA()); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isPositionNA", "isSubset"}) + @Specialization(guards = {"!isObject(vector)", "isPositionNA(position)", "isSubset()"}) protected RIntVector accessNA(RAbstractIntVector vector, Object exact, int recLevel, int position, Object dropDim) { if (vector.getNames(attrProfiles) == null) { return RDataFactory.createIntVector(new int[]{RRuntime.INT_NA}, RDataFactory.INCOMPLETE_VECTOR); @@ -888,7 +890,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "hasNames", "isSubset"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "hasNames(vector)", "isSubset()"}) protected RIntVector accessNames(RAbstractIntVector vector, Object exact, int recLevel, int position, Object dropDim) { int val = vector.getDataAt(position - 1); elementNACheck.check(val); @@ -896,25 +898,25 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "hasNames", "!isSubset"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "hasNames(vector)", "!isSubset()"}) protected int accessNoSubset(RAbstractIntVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "!hasNames"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "!hasNames(vector)"}) protected int accessNoNames(RAbstractIntVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)"}) protected int access(RAbstractIntVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isPositionZero"}) + @Specialization(guards = {"!isObject(vector)", "isPositionZero(position)"}) protected RIntVector accessPosZero(RAbstractIntVector vector, Object exact, int recLevel, int position, Object dropDim) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_LESS_1); @@ -951,12 +953,12 @@ public abstract class AccessArrayNode extends RNode { return data; } - @Specialization(guards = {"!isObject", "hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "hasDimNames(vector)"}) protected RDoubleVector accessNames(VirtualFrame frame, RAbstractDoubleVector vector, Object exact, int recLevel, Object[] positions, @SuppressWarnings("unused") RMissing dropDim) { return accessNamesInternal(frame, vector, exact, recLevel, positions, RRuntime.LOGICAL_TRUE); } - @Specialization(guards = {"!isObject", "hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "hasDimNames(vector)"}) protected RDoubleVector accessNames(VirtualFrame frame, RAbstractDoubleVector vector, Object exact, int recLevel, Object[] positions, RAbstractLogicalVector dropDim) { return accessNamesInternal(frame, vector, exact, recLevel, positions, dropDim.getLength() == 0 ? RRuntime.LOGICAL_TRUE : dropDim.getDataAt(0)); } @@ -984,7 +986,7 @@ public abstract class AccessArrayNode extends RNode { } } - @Specialization(guards = {"!isObject", "!hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasDimNames(vector)"}) protected RDoubleVector access(VirtualFrame frame, RAbstractDoubleVector vector, @SuppressWarnings("unused") Object exact, @SuppressWarnings("unused") int recLevel, Object[] positions, @SuppressWarnings("unused") RMissing dropDim) { DimsAndResultLength res = getDimsAndResultLength(positions, RRuntime.LOGICAL_TRUE); @@ -992,7 +994,7 @@ public abstract class AccessArrayNode extends RNode { return RDataFactory.createDoubleVector(data, elementNACheck.neverSeenNA(), res.dimensions); } - @Specialization(guards = {"!isObject", "!hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasDimNames(vector)"}) protected RDoubleVector access(VirtualFrame frame, RAbstractDoubleVector vector, @SuppressWarnings("unused") Object exact, @SuppressWarnings("unused") int recLevel, Object[] positions, RAbstractLogicalVector dropDim) { DimsAndResultLength res = getDimsAndResultLength(positions, dropDim.getLength() == 0 ? RRuntime.LOGICAL_TRUE : dropDim.getDataAt(0)); @@ -1017,7 +1019,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "hasNames"}) + @Specialization(guards = {"!isObject(vector)", "hasNames(vector)"}) protected RDoubleVector accessNames(RAbstractDoubleVector vector, Object exact, int recLevel, RIntVector p, Object dropDim) { double[] data = accessInternal(vector, p); RStringVector names = getNamesVector(vector.getNames(attrProfiles), p, p.getLength(), namesNACheck); @@ -1025,14 +1027,14 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!hasNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasNames(vector)"}) protected RDoubleVector access(RAbstractDoubleVector vector, Object exact, int recLevel, RIntVector p, Object dropDim) { double[] data = accessInternal(vector, p); return RDataFactory.createDoubleVector(data, elementNACheck.neverSeenNA()); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isPositionNA", "isSubset"}) + @Specialization(guards = {"!isObject(vector)", "isPositionNA(position)", "isSubset()"}) protected RDoubleVector accessNA(RAbstractDoubleVector vector, Object exact, int recLevel, int position, Object dropDim) { if (vector.getNames(attrProfiles) == null) { return RDataFactory.createDoubleVector(new double[]{RRuntime.DOUBLE_NA}, RDataFactory.INCOMPLETE_VECTOR); @@ -1042,7 +1044,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "hasNames", "isSubset"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "hasNames(vector)", "isSubset()"}) protected RDoubleVector accessNames(RAbstractDoubleVector vector, Object exact, int recLevel, int position, Object dropDim) { double val = vector.getDataAt(position - 1); elementNACheck.check(val); @@ -1050,25 +1052,25 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "hasNames", "!isSubset"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "hasNames(vector)", "!isSubset()"}) protected double accessNoSubset(RAbstractDoubleVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "!hasNames"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "!hasNames(vector)"}) protected double accessNoNames(RAbstractDoubleVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)"}) protected double access(RAbstractDoubleVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isPositionZero"}) + @Specialization(guards = {"!isObject(vector)", "isPositionZero(position)"}) protected RDoubleVector accessPosZero(RAbstractDoubleVector vector, Object exact, int recLevel, int position, Object dropDim) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_LESS_1); @@ -1105,12 +1107,12 @@ public abstract class AccessArrayNode extends RNode { return data; } - @Specialization(guards = {"!isObject", "hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "hasDimNames(vector)"}) protected RLogicalVector accessNames(VirtualFrame frame, RLogicalVector vector, Object exact, int recLevel, Object[] positions, @SuppressWarnings("unused") RMissing dropDim) { return accessNamesInternal(frame, vector, exact, recLevel, positions, RRuntime.LOGICAL_TRUE); } - @Specialization(guards = {"!isObject", "hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "hasDimNames(vector)"}) protected RLogicalVector accessNames(VirtualFrame frame, RLogicalVector vector, Object exact, int recLevel, Object[] positions, RAbstractLogicalVector dropDim) { return accessNamesInternal(frame, vector, exact, recLevel, positions, dropDim.getLength() == 0 ? RRuntime.LOGICAL_TRUE : dropDim.getDataAt(0)); } @@ -1139,7 +1141,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasDimNames(vector)"}) protected RLogicalVector access(VirtualFrame frame, RLogicalVector vector, Object exact, int recLevel, Object[] positions, RMissing dropDim) { DimsAndResultLength res = getDimsAndResultLength(positions, RRuntime.LOGICAL_TRUE); byte[] data = accessInternal(frame, res, vector, positions); @@ -1147,7 +1149,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasDimNames(vector)"}) protected RLogicalVector access(VirtualFrame frame, RLogicalVector vector, Object exact, int recLevel, Object[] positions, RAbstractLogicalVector dropDim) { DimsAndResultLength res = getDimsAndResultLength(positions, dropDim.getLength() == 0 ? RRuntime.LOGICAL_TRUE : dropDim.getDataAt(0)); byte[] data = accessInternal(frame, res, vector, positions); @@ -1171,7 +1173,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "hasNames"}) + @Specialization(guards = {"!isObject(vector)", "hasNames(vector)"}) protected RLogicalVector accessNames(RLogicalVector vector, Object exact, int recLevel, RIntVector p, Object dropDim) { byte[] data = accessInternal(vector, p); RStringVector names = getNamesVector(vector.getNames(attrProfiles), p, p.getLength(), namesNACheck); @@ -1179,14 +1181,14 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!hasNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasNames(vector)"}) protected RLogicalVector access(RLogicalVector vector, Object exact, int recLevel, RIntVector p, Object dropDim) { byte[] data = accessInternal(vector, p); return RDataFactory.createLogicalVector(data, elementNACheck.neverSeenNA()); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isPositionNA", "isSubset"}) + @Specialization(guards = {"!isObject(vector)", "isPositionNA(position)", "isSubset()"}) protected RLogicalVector accessNA(RLogicalVector vector, Object exact, int recLevel, int position, Object dropDim) { if (vector.getNames(attrProfiles) == null) { return RDataFactory.createLogicalVector(new byte[]{RRuntime.LOGICAL_NA}, RDataFactory.INCOMPLETE_VECTOR); @@ -1196,7 +1198,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "hasNames", "isSubset"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "hasNames(vector)", "isSubset()"}) protected RLogicalVector accessNames(RAbstractLogicalVector vector, Object exact, int recLevel, int position, Object dropDim) { byte val = vector.getDataAt(position - 1); elementNACheck.check(val); @@ -1204,25 +1206,25 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "hasNames", "!isSubset"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "hasNames(vector)", "!isSubset()"}) protected byte accessNoSubset(RLogicalVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "!hasNames"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "!hasNames(vector)"}) protected byte accessNoNames(RLogicalVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)"}) protected byte access(RLogicalVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isPositionZero"}) + @Specialization(guards = {"!isObject(vector)", "isPositionZero(position)"}) protected RLogicalVector accessPosZero(RLogicalVector vector, Object exact, int recLevel, int position, Object dropDim) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_LESS_1); @@ -1259,12 +1261,12 @@ public abstract class AccessArrayNode extends RNode { return data; } - @Specialization(guards = {"!isObject", "hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "hasDimNames(vector)"}) protected RStringVector accessNames(VirtualFrame frame, RStringVector vector, Object exact, int recLevel, Object[] positions, @SuppressWarnings("unused") RMissing dropDim) { return accessNamesInternal(frame, vector, exact, recLevel, positions, RRuntime.LOGICAL_TRUE); } - @Specialization(guards = {"!isObject", "hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "hasDimNames(vector)"}) protected RStringVector accessNames(VirtualFrame frame, RStringVector vector, Object exact, int recLevel, Object[] positions, RAbstractLogicalVector dropDim) { return accessNamesInternal(frame, vector, exact, recLevel, positions, dropDim.getLength() == 0 ? RRuntime.LOGICAL_TRUE : dropDim.getDataAt(0)); } @@ -1292,7 +1294,7 @@ public abstract class AccessArrayNode extends RNode { } } - @Specialization(guards = {"!isObject", "!hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasDimNames(vector)"}) protected RStringVector access(VirtualFrame frame, RStringVector vector, @SuppressWarnings("unused") Object exact, @SuppressWarnings("unused") int recLevel, Object[] positions, @SuppressWarnings("unused") RMissing dropDim) { DimsAndResultLength res = getDimsAndResultLength(positions, RRuntime.LOGICAL_TRUE); @@ -1301,7 +1303,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasDimNames(vector)"}) protected RStringVector access(VirtualFrame frame, RStringVector vector, Object exact, int recLevel, Object[] positions, RAbstractLogicalVector dropDim) { DimsAndResultLength res = getDimsAndResultLength(positions, dropDim.getLength() == 0 ? RRuntime.LOGICAL_TRUE : dropDim.getDataAt(0)); String[] data = accessInternal(frame, res, vector, positions); @@ -1325,7 +1327,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "hasNames"}) + @Specialization(guards = {"!isObject(vector)", "hasNames(vector)"}) protected RStringVector accessNames(RStringVector vector, Object exact, int recLevel, RIntVector p, Object dropDim) { String[] data = accessInternal(vector, p); RStringVector names = getNamesVector(vector.getNames(attrProfiles), p, p.getLength(), namesNACheck); @@ -1333,14 +1335,14 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!hasNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasNames(vector)"}) protected RStringVector access(RStringVector vector, Object exact, int recLevel, RIntVector p, Object dropDim) { String[] data = accessInternal(vector, p); return RDataFactory.createStringVector(data, elementNACheck.neverSeenNA()); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isPositionNA", "isSubset"}) + @Specialization(guards = {"!isObject(vector)", "isPositionNA(position)", "isSubset()"}) protected RStringVector accessNA(RStringVector vector, Object exact, int recLevel, int position, Object dropDim) { if (vector.getNames(attrProfiles) == null) { return RDataFactory.createNAStringVector(); @@ -1350,7 +1352,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "hasNames", "isSubset"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "hasNames(vector)", "isSubset()"}) protected RStringVector accessNames(RAbstractStringVector vector, Object exact, int recLevel, int position, Object dropDim) { String val = vector.getDataAt(position - 1); elementNACheck.check(val); @@ -1358,25 +1360,25 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "hasNames", "!isSubset"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "hasNames(vector)", "!isSubset()"}) protected String accessNoSubset(RStringVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "!hasNames"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "!hasNames(vector)"}) protected String accessNoNames(RStringVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)"}) protected String access(RStringVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isPositionZero"}) + @Specialization(guards = {"!isObject(vector)", "isPositionZero(position)"}) protected RStringVector accessPosZero(RStringVector vector, Object exact, int recLevel, int position, Object dropDim) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_LESS_1); @@ -1413,12 +1415,12 @@ public abstract class AccessArrayNode extends RNode { return data; } - @Specialization(guards = {"!isObject", "hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "hasDimNames(vector)"}) protected RComplexVector accessNames(VirtualFrame frame, RComplexVector vector, Object exact, int recLevel, Object[] positions, @SuppressWarnings("unused") RMissing dropDim) { return accessNamesInternal(frame, vector, exact, recLevel, positions, RRuntime.LOGICAL_TRUE); } - @Specialization(guards = {"!isObject", "hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "hasDimNames(vector)"}) protected RComplexVector accessNames(VirtualFrame frame, RComplexVector vector, Object exact, int recLevel, Object[] positions, RAbstractLogicalVector dropDim) { return accessNamesInternal(frame, vector, exact, recLevel, positions, dropDim.getLength() == 0 ? RRuntime.LOGICAL_TRUE : dropDim.getDataAt(0)); } @@ -1447,7 +1449,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasDimNames(vector)"}) protected RComplexVector access(VirtualFrame frame, RComplexVector vector, Object exact, int recLevel, Object[] positions, RMissing dropDim) { DimsAndResultLength res = getDimsAndResultLength(positions, RRuntime.LOGICAL_TRUE); double[] data = accessInternal(frame, res, vector, positions); @@ -1455,7 +1457,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasDimNames(vector)"}) protected RComplexVector access(VirtualFrame frame, RComplexVector vector, Object exact, int recLevel, Object[] positions, RAbstractLogicalVector dropDim) { DimsAndResultLength res = getDimsAndResultLength(positions, dropDim.getLength() == 0 ? RRuntime.LOGICAL_TRUE : dropDim.getDataAt(0)); double[] data = accessInternal(frame, res, vector, positions); @@ -1484,7 +1486,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "hasNames"}) + @Specialization(guards = {"!isObject(vector)", "hasNames(vector)"}) protected RComplexVector accessNames(RComplexVector vector, Object exact, int recLevel, RIntVector p, Object dropDim) { double[] data = accessInternal(vector, p); RStringVector names = getNamesVector(vector.getNames(attrProfiles), p, p.getLength(), namesNACheck); @@ -1492,14 +1494,14 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!hasNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasNames(vector)"}) protected RComplexVector access(RComplexVector vector, Object exact, int recLevel, RIntVector p, Object dropDim) { double[] data = accessInternal(vector, p); return RDataFactory.createComplexVector(data, elementNACheck.neverSeenNA()); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isPositionNA", "isSubset"}) + @Specialization(guards = {"!isObject(vector)", "isPositionNA(position)", "isSubset()"}) protected RComplexVector accessNA(RComplexVector vector, Object exact, int recLevel, int position, Object dropDim) { if (vector.getNames(attrProfiles) == null) { return RDataFactory.createComplexVector(new double[]{RRuntime.COMPLEX_NA_REAL_PART, RRuntime.COMPLEX_NA_IMAGINARY_PART}, RDataFactory.INCOMPLETE_VECTOR); @@ -1510,7 +1512,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "hasNames", "isSubset"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "hasNames(vector)", "isSubset()"}) protected RComplexVector accessNames(RAbstractComplexVector vector, Object exact, int recLevel, int position, Object dropDim) { RComplex val = vector.getDataAt(position - 1); elementNACheck.check(val); @@ -1518,25 +1520,25 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "hasNames", "!isSubset"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "hasNames(vector)", "!isSubset()"}) protected RComplex accessNoSubset(RComplexVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "!hasNames"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "!hasNames(vector)"}) protected RComplex accessNoNames(RComplexVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)"}) protected RComplex access(RComplexVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isPositionZero"}) + @Specialization(guards = {"!isObject(vector)", "isPositionZero(position)"}) protected RComplexVector accessPosZero(RComplexVector vector, Object exact, int recLevel, int position, Object dropDim) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_LESS_1); @@ -1573,12 +1575,12 @@ public abstract class AccessArrayNode extends RNode { return data; } - @Specialization(guards = {"!isObject", "hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "hasDimNames(vector)"}) protected RRawVector accessNames(VirtualFrame frame, RRawVector vector, Object exact, int recLevel, Object[] positions, @SuppressWarnings("unused") RMissing dropDim) { return accessNamesInternal(frame, vector, exact, recLevel, positions, RRuntime.LOGICAL_TRUE); } - @Specialization(guards = {"!isObject", "hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "hasDimNames(vector)"}) protected RRawVector accessNames(VirtualFrame frame, RRawVector vector, Object exact, int recLevel, Object[] positions, RAbstractLogicalVector dropDim) { return accessNamesInternal(frame, vector, exact, recLevel, positions, dropDim.getLength() == 0 ? RRuntime.LOGICAL_TRUE : dropDim.getDataAt(0)); } @@ -1606,7 +1608,7 @@ public abstract class AccessArrayNode extends RNode { } } - @Specialization(guards = {"!isObject", "!hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasDimNames(vector)"}) protected RRawVector access(VirtualFrame frame, RRawVector vector, @SuppressWarnings("unused") Object exact, @SuppressWarnings("unused") int recLevel, Object[] positions, @SuppressWarnings("unused") RMissing dropDim) { DimsAndResultLength res = getDimsAndResultLength(positions, RRuntime.LOGICAL_TRUE); @@ -1614,7 +1616,7 @@ public abstract class AccessArrayNode extends RNode { return RDataFactory.createRawVector(data, res.dimensions); } - @Specialization(guards = {"!isObject", "!hasDimNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasDimNames(vector)"}) protected RRawVector access(VirtualFrame frame, RRawVector vector, @SuppressWarnings("unused") Object exact, @SuppressWarnings("unused") int recLevel, Object[] positions, RAbstractLogicalVector dropDim) { DimsAndResultLength res = getDimsAndResultLength(positions, dropDim.getLength() == 0 ? RRuntime.LOGICAL_TRUE : dropDim.getDataAt(0)); @@ -1639,7 +1641,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "hasNames"}) + @Specialization(guards = {"!isObject(vector)", "hasNames(vector)"}) protected RRawVector accessNames(RRawVector vector, Object exact, int recLevel, RIntVector p, Object dropDim) { byte[] data = accessInternal(vector, p); RStringVector names = getNamesVector(vector.getNames(attrProfiles), p, p.getLength(), namesNACheck); @@ -1647,14 +1649,14 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!hasNames"}) + @Specialization(guards = {"!isObject(vector)", "!hasNames(vector)"}) protected RRawVector access(RRawVector vector, Object exact, int recLevel, RIntVector p, Object dropDim) { byte[] data = accessInternal(vector, p); return RDataFactory.createRawVector(data); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isPositionNA", "isSubset"}) + @Specialization(guards = {"!isObject(vector)", "isPositionNA(position)", "isSubset()"}) protected RRawVector accessNA(RRawVector vector, Object exact, int recLevel, int position, Object dropDim) { if (vector.getNames(attrProfiles) == null) { return RDataFactory.createRawVector(new byte[]{0}); @@ -1664,32 +1666,32 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "hasNames", "isSubset"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "hasNames(vector)", "isSubset()"}) protected RRawVector accessNames(RAbstractRawVector vector, Object exact, int recLevel, int position, Object dropDim) { RRaw val = vector.getDataAt(position - 1); return RDataFactory.createRawVector(new byte[]{val.getValue()}, getName(vector, position)); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "hasNames", "!isSubset"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "hasNames(vector)", "!isSubset()"}) protected RRaw accessNoSubset(RRawVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative", "!hasNames"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)", "!hasNames(vector)"}) protected RRaw accessNoNames(RRawVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "!isPositionZero", "!isPositionNA", "!isPositionNegative"}) + @Specialization(guards = {"!isObject(vector)", "!isPositionZero(position)", "!isPositionNA(position)", "!isPositionNegative(position)"}) protected RRaw access(RRawVector vector, Object exact, int recLevel, int position, Object dropDim) { return vector.getDataAt(position - 1); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "isPositionZero"}) + @Specialization(guards = {"!isObject(vector)", "isPositionZero(position)"}) protected RRawVector accessPosZero(RRawVector vector, Object exact, int recLevel, int position, Object dropDim) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_LESS_1); @@ -1702,7 +1704,7 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "noPosition"}) + @Specialization(guards = {"!isObject(container)", "noPosition(positions)"}) protected Object accessListEmptyPos(RAbstractContainer container, Object exact, int recLevel, RList positions, Object dropDim) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_LESS_1); @@ -1712,19 +1714,19 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "onePosition"}) + @Specialization(guards = {"!isObject(container)", "onePosition(positions)"}) protected Object accessListOnePos(RAbstractContainer container, Object exact, int recLevel, RList positions, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_SUBSCRIPT_TYPE, "list"); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "multiPos"}) + @Specialization(guards = {"!isObject(vector)", "multiPos(positions)"}) protected Object accessListMultiPosList(RList vector, Object exact, int recLevel, RList positions, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_SUBSCRIPT_TYPE, "list"); } @SuppressWarnings("unused") - @Specialization(guards = {"!isObject", "multiPos", "!isVectorList"}) + @Specialization(guards = {"!isObject(container)", "multiPos(positions)", "!isVectorList(container)"}) protected Object accessListMultiPos(RAbstractContainer container, Object exact, int recLevel, RList positions, Object dropDim) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_MORE_1); @@ -1734,13 +1736,13 @@ public abstract class AccessArrayNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = "!isObject") + @Specialization(guards = "!isObject(container)") protected Object accessListMultiPos(RAbstractContainer container, Object exact, int recLevel, RComplex positions, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_SUBSCRIPT_TYPE, "complex"); } @SuppressWarnings("unused") - @Specialization(guards = "!isObject") + @Specialization(guards = "!isObject(container)") protected Object accessListMultiPos(RAbstractContainer container, Object exact, int recLevel, RRaw positions, Object dropDim) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_SUBSCRIPT_TYPE, "raw"); } @@ -1790,21 +1792,19 @@ public abstract class AccessArrayNode extends RNode { return obj == null ? RNull.instance : obj; } - protected boolean outOfBounds(RList vector, @SuppressWarnings("unused") Object exact, @SuppressWarnings("unused") int recLevel, int position) { + protected boolean outOfBounds(RList vector, int position) { return position > vector.getLength(); } - protected boolean outOfBoundsNegative(RAbstractContainer container, @SuppressWarnings("unused") Object exact, @SuppressWarnings("unused") int recLevel, int position) { + protected boolean outOfBoundsNegative(RAbstractContainer container, int position) { return -position > container.getLength(); } - @SuppressWarnings("unused") - protected boolean oneElemVector(RAbstractContainer container, Object exact, int recLevel, int position) { + protected boolean oneElemVector(RAbstractContainer container) { return container.getLength() == 1; } - @SuppressWarnings("unused") - protected boolean isPositionNegative(RAbstractContainer container, Object exact, int recLevel, int position) { + protected boolean isPositionNegative(int position) { return position < 0; } @@ -1812,35 +1812,22 @@ public abstract class AccessArrayNode extends RNode { return container instanceof RList; } - protected boolean wrongDimensions(RAbstractVector container, @SuppressWarnings("unused") Object exact, @SuppressWarnings("unused") int recLevel, Object[] positions) { + protected boolean wrongDimensions(RAbstractVector container, Object[] positions) { return container.getDimensions() == null || container.getDimensions().length != positions.length; } - @SuppressWarnings("unused") - protected static boolean isFirstPositionPositive(RNull vector, Object exact, int recLevel, RAbstractIntVector positions) { - return positions.getDataAt(0) > 0; - } - - @SuppressWarnings("unused") - protected static boolean isFirstPositionPositive(RFunction vector, Object exact, int recLevel, RAbstractIntVector positions) { + protected static boolean isFirstPositionPositive(RAbstractIntVector positions) { return positions.getDataAt(0) > 0; } - @SuppressWarnings("unused") - protected static boolean isFirstPositionOne(RFunction vector, Object exact, int recLevel, RAbstractIntVector positions) { + protected static boolean isFirstPositionOne(RAbstractIntVector positions) { return positions.getDataAt(0) == 1; } - @SuppressWarnings("unused") - protected static boolean isPositionZero(RAbstractContainer container, Object exact, int recLevel, int position) { + protected static boolean isPositionZero(int position) { return position == 0; } - @SuppressWarnings("unused") - protected static boolean isPositionNA(RAbstractContainer container, Object exact, int recLevel, int position) { - return RRuntime.isNA(position); - } - protected boolean isSubset() { return isSubset; } @@ -1853,49 +1840,28 @@ public abstract class AccessArrayNode extends RNode { return container.getDimNames() != null; } - @SuppressWarnings("unused") - protected static boolean twoPosition(RAbstractContainer container, Object exact, int recLevel, RAbstractVector p) { + protected static boolean twoPosition(RAbstractVector p) { return p.getLength() == 2; } - @SuppressWarnings("unused") - protected static boolean onePosition(RAbstractContainer container, Object exact, int recLevel, RAbstractVector p) { + protected static boolean onePosition(RAbstractVector p) { return p.getLength() == 1; } - @SuppressWarnings("unused") - protected static boolean noPosition(RAbstractContainer container, Object exact, int recLevel, RAbstractVector p) { + protected static boolean noPosition(RAbstractVector p) { return p.getLength() == 0; } - @SuppressWarnings("unused") - protected static boolean multiPos(RAbstractContainer container, Object exact, int recLevel, RAbstractVector positions) { + protected static boolean multiPos(RAbstractVector positions) { return positions.getLength() > 1; } - @SuppressWarnings("unused") - protected static boolean inRecursion(RAbstractContainer container, Object exact, int recLevel, RIntVector positions) { - return recLevel > 0; - } - - @SuppressWarnings("unused") - protected static boolean inRecursion(RNull vector, Object exact, int recLevel, RAbstractIntVector positions) { + protected static boolean inRecursion(int recLevel) { return recLevel > 0; } - @SuppressWarnings("unused") - protected static boolean inRecursion(RFunction vector, Object exact, int recLevel, RAbstractIntVector positions) { - return recLevel > 0; - } - - @SuppressWarnings("unused") - protected static boolean inRecursion(RFunction vector, Object exact, int recLevel, RAbstractStringVector positions) { - return recLevel > 0; - } - - @SuppressWarnings("unused") - protected static boolean inRecursion(RFunction vector, Object exact, int recLevel, Object positions) { - return recLevel > 0; + protected static boolean isPositionNA(int position) { + return RRuntime.isNA(position); } protected boolean isObject(RAbstractContainer container) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/MultiDimPosConverterNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/MultiDimPosConverterNode.java index 6dd9e4583e14c203fab75206b00d8af41287c824..a1f38f7e3368e078fd5e7f5ae41ca3e32cc1a37e 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/MultiDimPosConverterNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/MultiDimPosConverterNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -44,12 +44,12 @@ public abstract class MultiDimPosConverterNode extends RNode { this.isSubset = other.isSubset; } - @Specialization(guards = {"!singleOpNegative", "!multiPos"}) + @Specialization(guards = {"!singleOpNegative(positions)", "!multiPos(positions)"}) protected RAbstractIntVector doIntVector(@SuppressWarnings("unused") Object vector, RAbstractIntVector positions) { return positions; } - @Specialization(guards = {"!singleOpNegative", "multiPos"}) + @Specialization(guards = {"!singleOpNegative(positions)", "multiPos(positions)"}) protected RAbstractIntVector doIntVectorMultiPos(@SuppressWarnings("unused") Object vector, RAbstractIntVector positions) { if (isSubset) { return positions; @@ -58,7 +58,7 @@ public abstract class MultiDimPosConverterNode extends RNode { } } - @Specialization(guards = {"singleOpNA"}) + @Specialization(guards = {"singleOpNA(positions)"}) protected RAbstractIntVector doIntVectorNA(Object vector, RAbstractIntVector positions) { if (isSubset || vector == RNull.instance) { return positions; @@ -68,13 +68,13 @@ public abstract class MultiDimPosConverterNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = {"singleOpNegative", "!singleOpNA"}) + @Specialization(guards = {"singleOpNegative(positions)", "!singleOpNA(positions)"}) protected RAbstractIntVector doIntVectorNegative(Object vector, RAbstractIntVector positions) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_MORE_1); } @SuppressWarnings("unused") - @Specialization(guards = "noPosition") + @Specialization(guards = "noPosition(positions)") protected Object accessListEmptyPos(RAbstractVector vector, RList positions) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_LESS_1); @@ -84,13 +84,13 @@ public abstract class MultiDimPosConverterNode extends RNode { } @SuppressWarnings("unused") - @Specialization(guards = "onePosition") + @Specialization(guards = "onePosition(positions)") protected Object accessListOnePos(RAbstractVector vector, RList positions) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_SUBSCRIPT_TYPE, "list"); } @SuppressWarnings("unused") - @Specialization(guards = "multiPos") + @Specialization(guards = "multiPos(positions)") protected Object accessListMultiPos(RAbstractVector vector, RList positions) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_MORE_1); @@ -111,33 +111,23 @@ public abstract class MultiDimPosConverterNode extends RNode { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_SUBSCRIPT_TYPE, "raw"); } - @SuppressWarnings("unused") - protected static boolean singleOpNegative(Object vector, RAbstractIntVector p) { + protected static boolean singleOpNegative(RAbstractIntVector p) { return p.getLength() == 1 && p.getDataAt(0) < 0; } - @SuppressWarnings("unused") - protected static boolean singleOpNA(Object vector, RAbstractIntVector p) { + protected static boolean singleOpNA(RAbstractIntVector p) { return p.getLength() == 1 && RRuntime.isNA(p.getDataAt(0)); } - @SuppressWarnings("unused") - protected static boolean onePosition(RAbstractVector vector, RAbstractVector p) { + protected static boolean onePosition(RAbstractVector p) { return p.getLength() == 1; } - @SuppressWarnings("unused") - protected static boolean noPosition(RAbstractVector vector, RAbstractVector p) { + protected static boolean noPosition(RAbstractVector p) { return p.getLength() == 0; } - @SuppressWarnings("unused") - protected static boolean multiPos(RAbstractVector vector, RAbstractVector positions) { - return positions.getLength() > 1; - } - - @SuppressWarnings("unused") - protected static boolean multiPos(Object vector, RAbstractVector positions) { + protected static boolean multiPos(RAbstractVector positions) { return positions.getLength() > 1; } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/CoerceVector.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/CoerceVector.java index b03051d238aeacd7a85cf0f66332aabd19eddccb..370cdb04fae10af5aca5afc6bbae0da7eaf24d13 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/CoerceVector.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/CoerceVector.java @@ -134,7 +134,7 @@ public abstract class CoerceVector extends RNode { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SUBASSIGN_TYPE_FIX, "integer", "raw"); } - @Specialization(guards = "isVectorListOrDataFrame") + @Specialization(guards = "isVectorListOrDataFrame(vector)") protected RAbstractContainer coerce(VirtualFrame frame, RAbstractIntVector value, RAbstractContainer vector, Object operand) { return vector; } @@ -208,7 +208,7 @@ public abstract class CoerceVector extends RNode { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SUBASSIGN_TYPE_FIX, "logical", "raw"); } - @Specialization(guards = "isVectorListOrDataFrame") + @Specialization(guards = "isVectorListOrDataFrame(vector)") protected RAbstractContainer coerce(VirtualFrame frame, RAbstractLogicalVector value, RAbstractContainer vector, Object operand) { return vector; } @@ -245,7 +245,7 @@ public abstract class CoerceVector extends RNode { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SUBASSIGN_TYPE_FIX, "character", "raw"); } - @Specialization(guards = "isVectorListOrDataFrame") + @Specialization(guards = "isVectorListOrDataFrame(vector)") protected RAbstractContainer coerce(VirtualFrame frame, RAbstractStringVector value, RAbstractContainer vector, Object operand) { return vector; } @@ -282,7 +282,7 @@ public abstract class CoerceVector extends RNode { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SUBASSIGN_TYPE_FIX, "complex", "raw"); } - @Specialization(guards = "isVectorListOrDataFrame") + @Specialization(guards = "isVectorListOrDataFrame(vector)") protected RAbstractContainer coerce(VirtualFrame frame, RAbstractComplexVector value, RAbstractContainer vector, Object operand) { return vector; } @@ -294,24 +294,24 @@ public abstract class CoerceVector extends RNode { return vector; } - @Specialization(guards = "!isVectorList") + @Specialization(guards = "!isVectorList(vector)") protected RRawVector coerce(RAbstractRawVector value, RAbstractVector vector, Object operand) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SUBASSIGN_TYPE_FIX, "raw", RRuntime.classToString(vector.getElementClass(), false)); } - @Specialization(guards = "isVectorListOrDataFrame") + @Specialization(guards = "isVectorListOrDataFrame(vector)") protected RAbstractContainer coerce(VirtualFrame frame, RAbstractRawVector value, RAbstractContainer vector, Object operand) { return vector; } // list vector value - @Specialization(guards = "isVectorListOrDataFrame") + @Specialization(guards = "isVectorListOrDataFrame(vector)") protected RAbstractContainer coerce(VirtualFrame frame, RList value, RAbstractContainer vector, Object operand) { return vector; } - @Specialization(guards = "!isVectorList") + @Specialization(guards = "!isVectorList(vector)") protected RList coerce(VirtualFrame frame, RList value, RAbstractVector vector, Object operand) { return (RList) castList(frame, vector); } @@ -359,11 +359,11 @@ public abstract class CoerceVector extends RNode { return vector; } - protected boolean isVectorList(RAbstractContainer value, RAbstractVector vector) { + protected boolean isVectorList(RAbstractVector vector) { return vector instanceof RList; } - protected boolean isVectorListOrDataFrame(RAbstractContainer value, RAbstractContainer vector) { + protected boolean isVectorListOrDataFrame(RAbstractContainer vector) { return vector instanceof RList || vector.getElementClass() == RDataFrame.class; } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/MultiDimPosConverterValueNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/MultiDimPosConverterValueNode.java index 8a146837a21bfc64455771dd167480c75bff234e..49872b9a17d8bdf08fd7130ffbd7d5664fc356f0 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/MultiDimPosConverterValueNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/MultiDimPosConverterValueNode.java @@ -66,7 +66,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { // ///////////// // RNull vectors - @Specialization(guards = {"!singlePosNegative"}) + @Specialization(guards = {"!singlePosNegative(positions)"}) protected RAbstractIntVector doIntVector(RNull vector, RNull value, RAbstractIntVector positions) { if (isSubset || positions.getLength() <= 1) { return positions; @@ -76,11 +76,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { } } - private static boolean singlePosNegative(RAbstractIntVector p) { - return p.getLength() == 1 && p.getDataAt(0) < 0 && !RRuntime.isNA(p.getDataAt(0)); - } - - @Specialization(guards = {"!isPosVectorInt"}) + @Specialization(guards = {"!isPosVectorInt(positions)"}) protected RAbstractVector doIntVector(RNull vector, Object value, RAbstractVector positions) { if (!isSubset || positions.getLength() <= 1) { return positions; @@ -94,7 +90,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { return value instanceof RNull || ((RAbstractVector) value).getLength() == 0; } - @Specialization(guards = {"!emptyValue"}) + @Specialization(guards = {"!emptyValue(value)"}) protected RAbstractIntVector doIntVector(RNull vector, RAbstractVector value, RAbstractIntVector positions) { if (singlePosNegative(positions)) { errorProfile.enter(); @@ -107,7 +103,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { return positions; } - @Specialization(guards = {"emptyValue", "!isPosVectorInt"}) + @Specialization(guards = {"emptyValue(value)", "!isPosVectorInt(positions)"}) protected RAbstractVector doIntVectorEmptyValue(RNull vector, RAbstractVector value, RAbstractVector positions) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.REPLACEMENT_0); @@ -152,7 +148,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { } } - @Specialization(guards = {"noPosition"}) + @Specialization(guards = {"noPosition(positions)"}) protected RAbstractVector accessListEmptyPosEmptyValue(RAbstractContainer container, Object value, RAbstractVector positions) { if (!isSubset) { RError.Message message; @@ -170,7 +166,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { } } - @Specialization(guards = {"onePosition", "emptyValue"}) + @Specialization(guards = {"onePosition(positions)", "emptyValue(value)"}) protected RAbstractVector accessListOnePosZeroEmptyValueList(RList vector, RAbstractVector value, RAbstractIntVector positions) { if (!isSubset) { if (positions.getDataAt(0) == 0) { @@ -181,7 +177,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { return positions; } - @Specialization(guards = {"onePosition"}) + @Specialization(guards = {"onePosition(positions)"}) protected RAbstractVector accessListOnePosEmptyValueList(RList vector, RNull value, RAbstractIntVector positions) { if (!isSubset) { if (positions.getDataAt(0) == 0) { @@ -192,7 +188,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { return positions; } - @Specialization(guards = {"onePosition", "emptyValue", "!isContainerList"}) + @Specialization(guards = {"onePosition(positions)", "emptyValue(value)", "!isContainerList(container)"}) protected RAbstractVector accessListOnePosEmptyValue(RAbstractContainer container, RAbstractVector value, RAbstractIntVector positions) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.REPLACEMENT_0); @@ -201,7 +197,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { } } - @Specialization(guards = {"onePosition", "!emptyValue"}) + @Specialization(guards = {"onePosition(positions)", "!emptyValue(value)"}) protected RAbstractVector accessListOnePosNonEmptyValue(RAbstractContainer container, RAbstractVector value, RAbstractIntVector positions) { if (!isSubset) { if (positions.getDataAt(0) == 0) { @@ -212,7 +208,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { return positions; } - @Specialization(guards = {"onePosition", "valueLongerThanOne", "!isContainerList"}) + @Specialization(guards = {"onePosition(positions)", "valueLongerThanOne(value)", "!isContainerList(container)"}) protected RAbstractVector accessListOnePosValueLongerThanOne(RAbstractContainer container, RAbstractVector value, RAbstractIntVector positions) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MORE_SUPPLIED_REPLACE); @@ -221,7 +217,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { } } - @Specialization(guards = {"onePosition", "!isContainerList"}) + @Specialization(guards = {"onePosition(positions)", "!isContainerList(container)"}) protected RAbstractVector accessListOnePosValueLongerThanOne(RAbstractContainer container, RNull value, RAbstractIntVector positions) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MORE_SUPPLIED_REPLACE); @@ -230,7 +226,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { } } - @Specialization(guards = {"onePosition", "emptyValue", "!isPosVectorInt"}) + @Specialization(guards = {"onePosition(positions)", "emptyValue(value)", "!isPosVectorInt(positions)"}) protected RAbstractVector accessListOnePosEmptyValueList(RList vector, RAbstractVector value, RAbstractVector positions) { if (positions instanceof RList) { errorProfile.enter(); @@ -240,7 +236,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { } } - @Specialization(guards = {"onePosition", "!isPosVectorInt"}) + @Specialization(guards = {"onePosition(positions)", "!isPosVectorInt(positions)"}) protected RAbstractVector accessListOnePosEmptyValueList(RList vector, RNull value, RAbstractVector positions) { if (positions instanceof RList) { errorProfile.enter(); @@ -250,7 +246,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { } } - @Specialization(guards = {"onePosition", "emptyValue", "!isContainerList", "!isPosVectorInt"}) + @Specialization(guards = {"onePosition(positions)", "emptyValue(value)", "!isContainerList(container)", "!isPosVectorInt(positions)"}) protected RAbstractVector accessListOnePosEmptyValue(RAbstractContainer container, RAbstractVector value, RAbstractVector positions) { if (!isSubset) { errorProfile.enter(); @@ -263,7 +259,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { } } - @Specialization(guards = {"onePosition", "valueLengthOne", "!isPosVectorInt"}) + @Specialization(guards = {"onePosition(positions)", "valueLengthOne(value)", "!isPosVectorInt(positions)"}) protected RAbstractVector accessListOnePosValueLengthOne(RAbstractContainer container, RAbstractVector value, RAbstractVector positions) { if (positions instanceof RList) { errorProfile.enter(); @@ -273,7 +269,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { } } - @Specialization(guards = {"onePosition", "valueLongerThanOne", "!isPosVectorInt"}) + @Specialization(guards = {"onePosition(positions)", "valueLongerThanOne(value)", "!isPosVectorInt(positions)"}) protected RAbstractVector accessListOnePosValueLongerThanOneList(RList vector, RAbstractVector value, RAbstractVector positions) { if (positions instanceof RList) { errorProfile.enter(); @@ -283,7 +279,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { } } - @Specialization(guards = {"onePosition", "valueLongerThanOne", "!isPosVectorInt", "!isContainerList"}) + @Specialization(guards = {"onePosition(positions)", "valueLongerThanOne(value)", "!isPosVectorInt(positions)", "!isContainerList(container)"}) protected RAbstractVector accessListOnePosValueLongerThanOne(RAbstractContainer container, RAbstractVector value, RAbstractVector positions) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MORE_SUPPLIED_REPLACE); @@ -294,7 +290,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { } } - @Specialization(guards = {"onePosition", "!isContainerList", "!isPosVectorInt"}) + @Specialization(guards = {"onePosition(positions)", "!isContainerList(container)", "!isPosVectorInt(positions)"}) protected RAbstractVector accessListOnePosValueLongerThanOne(RAbstractContainer container, RNull value, RAbstractVector positions) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MORE_SUPPLIED_REPLACE); @@ -306,7 +302,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { } } - @Specialization(guards = "multiPos") + @Specialization(guards = "multiPos(positions)") protected RAbstractVector accessListMultiPos(RAbstractContainer container, Object value, RAbstractVector positions) { if (!isSubset) { RError.Message message; @@ -324,11 +320,11 @@ public abstract class MultiDimPosConverterValueNode extends RNode { } } - protected boolean singlePosNegative(Object vector, Object value, RAbstractIntVector p) { + protected static boolean singlePosNegative(RAbstractIntVector p) { return p.getLength() == 1 && p.getDataAt(0) < 0 && !RRuntime.isNA(p.getDataAt(0)); } - protected boolean firstPosZero(Object vector, Object value, RAbstractIntVector p) { + protected boolean firstPosZero(RAbstractIntVector p) { return p.getDataAt(0) == 0; } @@ -336,31 +332,31 @@ public abstract class MultiDimPosConverterValueNode extends RNode { return container instanceof RList; } - protected boolean isPosVectorInt(Object vector, Object value, RAbstractVector p) { + protected boolean isPosVectorInt(RAbstractVector p) { return p instanceof RAbstractIntVector; } - protected boolean noPosition(RAbstractContainer container, Object value, RAbstractVector p) { + protected boolean noPosition(RAbstractVector p) { return p.getLength() == 0; } - protected boolean onePosition(Object vector, Object value, RAbstractVector p) { + protected boolean onePosition(RAbstractVector p) { return p.getLength() == 1; } - protected boolean multiPos(Object vector, Object value, RAbstractVector p) { + protected boolean multiPos(RAbstractVector p) { return p.getLength() > 1; } - protected boolean emptyValue(Object vector, RAbstractVector value) { + protected boolean emptyValue(RAbstractVector value) { return value.getLength() == 0; } - protected boolean valueLengthOne(Object vector, RAbstractVector value) { + protected boolean valueLengthOne(RAbstractVector value) { return value.getLength() == 1; } - protected boolean valueLongerThanOne(Object vector, RAbstractVector value) { + protected boolean valueLongerThanOne(RAbstractVector value) { return value.getLength() > 1; } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/UpdateArrayHelperNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/UpdateArrayHelperNode.java index c510387a56167249c17dfc7b6f45de2c08009969..1bd16fe4ac7f24896bcf2ae99230eea8ff1fa00f 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/UpdateArrayHelperNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/UpdateArrayHelperNode.java @@ -52,7 +52,7 @@ import com.oracle.truffle.r.runtime.ops.na.*; @NodeChild(value = "vector", type = CoerceVector.class, executeWith = {"newValue", "v", "positions"})}) public abstract class UpdateArrayHelperNode extends RNode { - private final boolean isSubset; + protected final boolean isSubset; public final boolean forObjects; private final NACheck elementNACheck = NACheck.create(); @@ -248,7 +248,7 @@ public abstract class UpdateArrayHelperNode extends RNode { private static final ArgumentsSignature VALUE_SIGNATURE = ArgumentsSignature.get(new String[]{"", "", "value"}); - @Specialization(guards = {"isObject", "isSubset"}) + @Specialization(guards = {"isObject(container)", "isSubset"}) protected Object updateObjectSubset(VirtualFrame frame, Object v, Object value, int recLevel, Object positions, RAbstractContainer container) { if (dcn == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -262,7 +262,7 @@ public abstract class UpdateArrayHelperNode extends RNode { } } - @Specialization(guards = {"isObject", "!isSubset"}) + @Specialization(guards = {"isObject(container)", "!isSubset"}) protected Object updateObject(VirtualFrame frame, Object v, Object value, int recLevel, Object positions, RAbstractContainer container) { if (dcn == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -291,7 +291,7 @@ public abstract class UpdateArrayHelperNode extends RNode { return updateRecursive(frame, v, value.getVector(), vector, positions, recLevel); } - @Specialization(guards = {"!isObject", "!isObject", "emptyValue"}) + @Specialization(guards = {"!isObject(vector)", "emptyValue(value)"}) protected RAbstractVector update(Object v, RAbstractVector value, int recLevel, Object[] positions, RAbstractVector vector) { if (isSubset) { int replacementLength = getReplacementLength(positions, value, false); @@ -309,7 +309,7 @@ public abstract class UpdateArrayHelperNode extends RNode { } @TruffleBoundary - @Specialization(guards = "!isObject") + @Specialization(guards = "!isObject(vector)") protected RAbstractVector update(Object v, RNull value, int recLevel, Object[] positions, RList vector) { if (isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.NOT_MULTIPLE_REPLACEMENT); @@ -318,7 +318,7 @@ public abstract class UpdateArrayHelperNode extends RNode { } } - @Specialization(guards = {"!isObject", "isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "isPosZero(position)"}) protected RAbstractVector updateNAOrZero(Object v, RNull value, int recLevel, int position, RList vector) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_LESS_1); @@ -328,7 +328,7 @@ public abstract class UpdateArrayHelperNode extends RNode { } @TruffleBoundary - @Specialization(guards = "!isObject") + @Specialization(guards = "!isObject(vector)") protected RAbstractVector update(Object v, RNull value, int recLevel, Object[] positions, RAbstractVector vector) { if (isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.NOT_MULTIPLE_REPLACEMENT); @@ -338,24 +338,24 @@ public abstract class UpdateArrayHelperNode extends RNode { } @TruffleBoundary - @Specialization(guards = {"!isObject", "emptyValue", "!isPosZero", "!isPosNA", "!isVectorList"}) + @Specialization(guards = {"!isObject(vector)", "emptyValue(value)", "!isPosZero(position)", "!isPosNA(position)", "!isVectorList(vector)"}) protected RAbstractVector update(Object v, RAbstractVector value, int recLevel, int position, RAbstractVector vector) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.REPLACEMENT_0); } @TruffleBoundary - @Specialization(guards = "!isObject") + @Specialization(guards = "!isObject(vector)") protected RAbstractVector updateVectorLongerThanOne(Object v, RNull value, int recLevel, RNull position, RList vector) { throw RError.error(getEncapsulatingSourceSection(), vector.getLength() > 1 ? RError.Message.SELECT_MORE_1 : RError.Message.SELECT_LESS_1); } @TruffleBoundary - @Specialization(guards = "!isObject") + @Specialization(guards = "!isObject(vector)") protected RAbstractVector update(Object v, RAbstractVector value, int recLevel, RNull position, RAbstractVector vector) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SELECT_MORE_1); } - @Specialization(guards = {"!isObject", "isPosNA", "isValueLengthOne"}) + @Specialization(guards = {"!isObject(vector)", "isPosNA(position)", "isValueLengthOne(value)"}) protected RAbstractVector updateNAValueLengthOneLongVector(Object v, RAbstractVector value, int recLevel, int position, RAbstractVector vector) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), vector.getLength() > 1 ? RError.Message.SELECT_MORE_1 : RError.Message.SELECT_LESS_1); @@ -365,7 +365,7 @@ public abstract class UpdateArrayHelperNode extends RNode { } @TruffleBoundary - @Specialization(guards = {"!isObject", "isPosNA", "!isValueLengthOne"}) + @Specialization(guards = {"!isObject(vector)", "isPosNA(position)", "!isValueLengthOne(value)"}) protected RAbstractVector updateNA(Object v, RAbstractVector value, int recLevel, int position, RAbstractVector vector) { if (isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.NA_SUBSCRIPTED); @@ -385,7 +385,7 @@ public abstract class UpdateArrayHelperNode extends RNode { } } - @Specialization(guards = {"!isObject", "isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "isPosZero(position)"}) protected RAbstractVector updatePosZero(Object v, RAbstractVector value, int recLevel, int position, RAbstractVector vector) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), getErrorForValueLength(value)); @@ -494,12 +494,12 @@ public abstract class UpdateArrayHelperNode extends RNode { return vector; } - @Specialization(guards = {"!wrongDimensionsMatrix", "!wrongDimensions"}) + @Specialization(guards = {"!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RNull updateWrongDimensions(Object v, RAbstractVector value, int recLevel, Object[] positions, RNull vector) { return vector; } - @Specialization(guards = "emptyValue") + @Specialization(guards = "emptyValue(value)") protected RNull updatePosZero(Object v, RAbstractVector value, int recLevel, int position, RNull vector) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.REPLACEMENT_0); @@ -507,7 +507,7 @@ public abstract class UpdateArrayHelperNode extends RNode { return vector; } - @Specialization(guards = "emptyValue") + @Specialization(guards = "emptyValue(value)") protected RNull updatePosZero(Object v, RAbstractVector value, int recLevel, RIntVector positions, RNull vector) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.REPLACEMENT_0); @@ -515,7 +515,7 @@ public abstract class UpdateArrayHelperNode extends RNode { return vector; } - @Specialization(guards = "!emptyValue") + @Specialization(guards = "!emptyValue(value)") protected RIntVector update(Object v, RAbstractIntVector value, int recLevel, RIntVector positions, RNull vector) { int highestPos = getHighestPos(positions); int[] data = new int[highestPos]; @@ -523,7 +523,7 @@ public abstract class UpdateArrayHelperNode extends RNode { return updateSingleDimVector(value, 0, RDataFactory.createIntVector(data, RDataFactory.INCOMPLETE_VECTOR), positions); } - @Specialization(guards = {"!emptyValue", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!emptyValue(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RIntVector update(Object v, RAbstractIntVector value, int recLevel, int position, RNull vector) { if (multiPosProfile.profile(position > 1)) { int[] data = new int[position]; @@ -534,7 +534,7 @@ public abstract class UpdateArrayHelperNode extends RNode { } } - @Specialization(guards = "!emptyValue") + @Specialization(guards = "!emptyValue(value)") protected RDoubleVector update(Object v, RAbstractDoubleVector value, int recLevel, RIntVector positions, RNull vector) { int highestPos = getHighestPos(positions); double[] data = new double[highestPos]; @@ -542,7 +542,7 @@ public abstract class UpdateArrayHelperNode extends RNode { return updateSingleDimVector(value, 0, RDataFactory.createDoubleVector(data, RDataFactory.INCOMPLETE_VECTOR), positions); } - @Specialization(guards = {"!emptyValue", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!emptyValue(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RDoubleVector update(Object v, RAbstractDoubleVector value, int recLevel, int position, RNull vector) { if (multiPosProfile.profile(position > 1)) { double[] data = new double[position]; @@ -553,7 +553,7 @@ public abstract class UpdateArrayHelperNode extends RNode { } } - @Specialization(guards = "!emptyValue") + @Specialization(guards = "!emptyValue(value)") protected RLogicalVector update(Object v, RAbstractLogicalVector value, int recLevel, RIntVector positions, RNull vector) { int highestPos = getHighestPos(positions); byte[] data = new byte[highestPos]; @@ -561,7 +561,7 @@ public abstract class UpdateArrayHelperNode extends RNode { return updateSingleDimVector(value, 0, RDataFactory.createLogicalVector(data, RDataFactory.INCOMPLETE_VECTOR), positions); } - @Specialization(guards = {"!emptyValue", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!emptyValue(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RLogicalVector update(Object v, RAbstractLogicalVector value, int recLevel, int position, RNull vector) { if (multiPosProfile.profile(position > 1)) { byte[] data = new byte[position]; @@ -572,7 +572,7 @@ public abstract class UpdateArrayHelperNode extends RNode { } } - @Specialization(guards = "!emptyValue") + @Specialization(guards = "!emptyValue(value)") protected RStringVector update(Object v, RAbstractStringVector value, int recLevel, RIntVector positions, RNull vector) { int highestPos = getHighestPos(positions); String[] data = new String[highestPos]; @@ -580,7 +580,7 @@ public abstract class UpdateArrayHelperNode extends RNode { return updateSingleDimVector(value, 0, RDataFactory.createStringVector(data, RDataFactory.INCOMPLETE_VECTOR), positions); } - @Specialization(guards = {"!emptyValue", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!emptyValue(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RStringVector update(Object v, RAbstractStringVector value, int recLevel, int position, RNull vector) { if (multiPosProfile.profile(position > 1)) { String[] data = new String[position]; @@ -591,7 +591,7 @@ public abstract class UpdateArrayHelperNode extends RNode { } } - @Specialization(guards = "!emptyValue") + @Specialization(guards = "!emptyValue(value)") protected RComplexVector update(Object v, RAbstractComplexVector value, int recLevel, RIntVector positions, RNull vector) { int highestPos = getHighestPos(positions); double[] data = new double[highestPos << 1]; @@ -603,7 +603,7 @@ public abstract class UpdateArrayHelperNode extends RNode { return updateSingleDimVector(value, 0, RDataFactory.createComplexVector(data, RDataFactory.INCOMPLETE_VECTOR), positions); } - @Specialization(guards = {"!emptyValue", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!emptyValue(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RComplexVector update(VirtualFrame frame, Object v, RAbstractComplexVector value, int recLevel, int position, RNull vector) { if (multiPosProfile.profile(position > 1)) { double[] data = new double[position << 1]; @@ -618,24 +618,24 @@ public abstract class UpdateArrayHelperNode extends RNode { } } - @Specialization(guards = "!emptyValue") + @Specialization(guards = "!emptyValue(value)") protected RRawVector update(Object v, RAbstractRawVector value, int recLevel, RIntVector positions, RNull vector) { return updateSingleDimVector(value, 0, RDataFactory.createRawVector(getHighestPos(positions)), positions); } - @Specialization(guards = {"!emptyValue", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!emptyValue(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RRawVector update(Object v, RAbstractRawVector value, int recLevel, int position, RNull vector) { return updateSingleDim(value, RDataFactory.createRawVector(position), position); } @TruffleBoundary - @Specialization(guards = {"!isObject", "!isPosNA", "isPositionNegative", "!isVectorList"}) + @Specialization(guards = {"!isObject(vector)", "!isPosNA(position)", "isPositionNegative(position)", "!isVectorList(vector)"}) protected RList updateNegativeNull(Object v, RNull value, int recLevel, int position, RAbstractVector vector) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MORE_SUPPLIED_REPLACE); } @TruffleBoundary - @Specialization(guards = {"!isObject", "!isPosNA", "isPositionNegative"}) + @Specialization(guards = {"!isObject(vector)", "!isPosNA(position)", "isPositionNegative(position)"}) protected RList updateNegativeNull(Object v, Object value, int recLevel, int position, RAbstractVector vector) { throw RError.error(getEncapsulatingSourceSection(), -position <= vector.getLength() || vector.getLength() != 1 ? RError.Message.SELECT_MORE_1 : RError.Message.SELECT_LESS_1); } @@ -803,60 +803,60 @@ public abstract class UpdateArrayHelperNode extends RNode { return resultList; } - @Specialization(guards = {"!isObject", "multiDim", "!wrongDimensionsMatrix", "!wrongDimensions"}) + @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RList update(VirtualFrame frame, Object v, RAbstractContainer value, int recLevel, Object[] positions, RList vector) { return updateVector(frame, value, vector, positions); } - @Specialization(guards = "!isObject") + @Specialization(guards = "!isObject(vector)") protected Object updateString(VirtualFrame frame, Object v, RNull value, int recLevel, RStringVector positions, RList vector) { return updateListRecursive(frame, v, value, vector, recLevel, positions); } - @Specialization(guards = "!isObject") + @Specialization(guards = "!isObject(vector)") protected Object updateString(VirtualFrame frame, Object v, RAbstractContainer value, int recLevel, RStringVector positions, RList vector) { return updateListRecursive(frame, v, value, vector, recLevel, positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "multiPos"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) protected RList update(Object v, RAbstractContainer value, int recLevel, RIntVector positions, RList vector) { return updateSingleDimVector(value, vector.getLength(), getResultVector(vector, getHighestPos(positions), false), positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "onePosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) protected Object updateOne(VirtualFrame frame, Object v, RAbstractContainer value, int recLevel, RIntVector positions, RList vector) { return updateRecursive(frame, v, value, vector, positions.getDataAt(0), recLevel); } - @Specialization(guards = {"!isObject", "isSubset", "posNames"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "posNames(positions)"}) protected RList updateNames(Object v, RAbstractContainer value, int recLevel, RIntVector positions, RList vector) { return updateSingleDimVector(value, vector.getLength(), getResultVector(vector, getHighestPos(positions), false), positions); } - @Specialization(guards = {"!isObject", "!isValueLengthOne", "isSubset", "!isPosNA", "!isPosZero", "!isPositionNegative"}) + @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)", "!isPositionNegative(position)"}) protected RList updateTooManyValuesSubset(Object v, RAbstractContainer value, int recLevel, int position, RList vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); return updateSingleDim(value, getResultVector(vector, position, false), position); } - @Specialization(guards = {"!isObject", "isValueLengthOne", "isSubset", "!isPosNA", "!isPosZero", "!isPositionNegative"}) + @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)", "!isPositionNegative(position)"}) protected RList update(Object v, RAbstractContainer value, int recLevel, int position, RList vector) { return updateSingleDim(value, getResultVector(vector, position, false), position); } - @Specialization(guards = {"!isObject", "!isSubset", "!isPosNA", "!isPosZero", "!isPositionNegative"}) + @Specialization(guards = {"!isObject(vector)", "!isSubset", "!isPosNA(position)", "!isPosZero(position)", "!isPositionNegative(position)"}) protected RList updateTooManyValuesSubscript(Object v, RAbstractContainer value, int recLevel, int position, RList vector) { RList resultVector = getResultVector(vector, position, false); resultVector.updateDataAt(position - 1, adjustRhsStateOnAssignment(value), null); return resultVector; } - @Specialization(guards = {"!isObject", "isPosNA"}) + @Specialization(guards = {"!isObject(vector)", "isPosNA(position)"}) protected RList updateListNullValue(Object v, RNull value, int recLevel, int position, RList vector) { return vector; } - @Specialization(guards = {"!isObject", "!isPosZero", "emptyList", "!isPosNA", "!isPositionNegative"}) + @Specialization(guards = {"!isObject(vector)", "!isPosZero(position)", "emptyList(vector)", "!isPosNA(position)", "!isPositionNegative(position)"}) protected RList updateEmptyList(Object v, RNull value, int recLevel, int position, RList vector) { return vector; } @@ -897,19 +897,19 @@ public abstract class UpdateArrayHelperNode extends RNode { return result; } - @Specialization(guards = {"!isObject", "!isPosZero", "!emptyList", "!isPosNA", "!isPositionNegative"}) + @Specialization(guards = {"!isObject(vector)", "!isPosZero(position)", "!emptyList(vector)", "!isPosNA(position)", "!isPositionNegative(position)"}) protected RList update(Object v, RNull value, int recLevel, int position, RList vector) { return removeElement(vector, position, false, isSubset); } private static final Object DELETE_MARKER = new Object(); - @Specialization(guards = {"!isObject", "isSubset", "noPosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "noPosition(positions)"}) protected RList updateEmptyPos(Object v, RNull value, int recLevel, RIntVector positions, RList vector) { return vector; } - @Specialization(guards = {"!isObject", "isSubset", "!noPosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!noPosition(positions)"}) protected RList update(Object v, RNull value, int recLevel, RIntVector positions, RList vector) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MORE_SUPPLIED_REPLACE); @@ -1002,54 +1002,54 @@ public abstract class UpdateArrayHelperNode extends RNode { return resultList; } - @Specialization(guards = {"!isObject", "!isSubset", "multiPos"}) - protected Object access(VirtualFrame frame, Object v, RNull value, int recLevel, RIntVector p, RList vector) { - return updateListRecursive(frame, v, value, vector, recLevel, p); + @Specialization(guards = {"!isObject(vector)", "!isSubset", "multiPos(positions)"}) + protected Object access(VirtualFrame frame, Object v, RNull value, int recLevel, RIntVector positions, RList vector) { + return updateListRecursive(frame, v, value, vector, recLevel, positions); } - @Specialization(guards = {"!isObject", "!isSubset", "multiPos"}) - protected Object access(VirtualFrame frame, Object v, RAbstractContainer value, int recLevel, RIntVector p, RList vector) { - return updateListRecursive(frame, v, value, vector, recLevel, p); + @Specialization(guards = {"!isObject(vector)", "!isSubset", "multiPos(positions)"}) + protected Object access(VirtualFrame frame, Object v, RAbstractContainer value, int recLevel, RIntVector positions, RList vector) { + return updateListRecursive(frame, v, value, vector, recLevel, positions); } - @Specialization(guards = {"!isObject", "!isSubset", "inRecursion", "multiPos"}) - protected Object accessRecFailed(Object v, RAbstractContainer value, int recLevel, RIntVector p, RAbstractVector vector) { + @Specialization(guards = {"!isObject(vector)", "!isSubset", "inRecursion(recLevel)", "multiPos(positions)"}) + protected Object accessRecFailed(Object v, RAbstractContainer value, int recLevel, RIntVector positions, RAbstractVector vector) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.RECURSIVE_INDEXING_FAILED, recLevel + 1); } - @Specialization(guards = {"!isObject", "!isSubset", "!multiPos"}) - protected Object accessSubscriptListValue(Object v, RList value, int recLevel, RIntVector p, RList vector) { - int position = getPositionInRecursion(vector, p.getDataAt(0), recLevel, true); - return updateSingleDimRec(value, getResultVector(vector, position, false), p, recLevel); + @Specialization(guards = {"!isObject(vector)", "!isSubset", "!multiPos(positions)"}) + protected Object accessSubscriptListValue(Object v, RList value, int recLevel, RIntVector positions, RList vector) { + int position = getPositionInRecursion(vector, positions.getDataAt(0), recLevel, true); + return updateSingleDimRec(value, getResultVector(vector, position, false), positions, recLevel); } - @Specialization(guards = {"!isObject", "!isSubset", "inRecursion", "!multiPos"}) - protected Object accessSubscriptNullValueInRecursion(Object v, RNull value, int recLevel, RIntVector p, RList vector) { - int position = getPositionInRecursion(vector, p.getDataAt(0), recLevel, true); + @Specialization(guards = {"!isObject(vector)", "!isSubset", "inRecursion(recLevel)", "!multiPos(positions)"}) + protected Object accessSubscriptNullValueInRecursion(Object v, RNull value, int recLevel, RIntVector positions, RList vector) { + int position = getPositionInRecursion(vector, positions.getDataAt(0), recLevel, true); return removeElement(vector, position, true, false); } - @Specialization(guards = {"!isObject", "!isSubset", "!inRecursion", "!multiPos"}) - protected Object accessSubscriptNullValue(Object v, RNull value, int recLevel, RIntVector p, RList vector) { - int position = getPositionInRecursion(vector, p.getDataAt(0), recLevel, true); + @Specialization(guards = {"!isObject(vector)", "!isSubset", "!inRecursion(recLevel)", "!multiPos(positions)"}) + protected Object accessSubscriptNullValue(Object v, RNull value, int recLevel, RIntVector positions, RList vector) { + int position = getPositionInRecursion(vector, positions.getDataAt(0), recLevel, true); return removeElement(vector, position, false, false); } - @Specialization(guards = {"!isObject", "!isSubset", "!multiPos"}) - protected Object accessSubscript(Object v, RAbstractContainer value, int recLevel, RIntVector p, RList vector) { - int position = getPositionInRecursion(vector, p.getDataAt(0), recLevel, true); - return updateSingleDimRec(value, getResultVector(vector, position, false), p, recLevel); + @Specialization(guards = {"!isObject(vector)", "!isSubset", "!multiPos(positions)"}) + protected Object accessSubscript(Object v, RAbstractContainer value, int recLevel, RIntVector positions, RList vector) { + int position = getPositionInRecursion(vector, positions.getDataAt(0), recLevel, true); + return updateSingleDimRec(value, getResultVector(vector, position, false), positions, recLevel); } @TruffleBoundary - @Specialization(guards = {"!isObject", "!isValueLengthOne", "!emptyValue", "!isSubset", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "!emptyValue(value)", "!isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RAbstractVector updateTooManyValues(Object v, RAbstractContainer value, int recLevel, int position, RAbstractVector vector) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MORE_SUPPLIED_REPLACE); } // null value (with vectors) - @Specialization(guards = {"!isObject", "isPosZero", "!isVectorList"}) + @Specialization(guards = {"!isObject(vector)", "isPosZero(position)", "!isVectorList(vector)"}) protected RAbstractVector updatePosZero(Object v, RNull value, int recLevel, int position, RAbstractVector vector) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.REPLACEMENT_0); @@ -1058,7 +1058,7 @@ public abstract class UpdateArrayHelperNode extends RNode { } @TruffleBoundary - @Specialization(guards = {"!isObject", "!isPosZero", "!isPosNA", "!isVectorList"}) + @Specialization(guards = {"!isObject(vector)", "!isPosZero(position)", "!isPosNA(position)", "!isVectorList(vector)"}) protected RAbstractVector update(Object v, RNull value, int recLevel, int position, RAbstractVector vector) { if (!isSubset) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.MORE_SUPPLIED_REPLACE); @@ -1067,19 +1067,19 @@ public abstract class UpdateArrayHelperNode extends RNode { } } - @Specialization(guards = {"!isObject", "isSubset", "!isVectorList", "noPosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!isVectorList(vector)", "noPosition(positions)"}) protected RAbstractVector updateNullSubsetNoPos(Object v, RNull value, int recLevel, RIntVector positions, RAbstractVector vector) { return vector; } @TruffleBoundary - @Specialization(guards = {"!isObject", "isSubset", "!isVectorList", "!noPosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!isVectorList(vector)", "!noPosition(positions)"}) protected RAbstractVector updateNullSubset(Object v, RNull value, int recLevel, RIntVector positions, RAbstractVector vector) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.REPLACEMENT_0); } @TruffleBoundary - @Specialization(guards = {"!isObject", "!isSubset", "!isVectorList"}) + @Specialization(guards = {"!isObject(vector)", "!isSubset", "!isVectorList(vector)"}) protected RAbstractVector updateNullNoPos(Object v, RNull value, int recLevel, RIntVector positions, RAbstractVector vector) { RError.Message message = positions.getLength() <= 1 ? RError.Message.MORE_SUPPLIED_REPLACE : (positions.getLength() == 2 && positions.getDataAt(0) == 0) ? RError.Message.SELECT_LESS_1 : RError.Message.SELECT_MORE_1; @@ -1089,7 +1089,7 @@ public abstract class UpdateArrayHelperNode extends RNode { // int vector @TruffleBoundary - @Specialization(guards = {"!isObject", "!isSubset", "!isVectorList", "!posNames", "multiPos"}) + @Specialization(guards = {"!isObject(vector)", "!isSubset", "!isVectorList(vector)", "!posNames(positions)", "multiPos(positions)"}) protected Object update(Object v, RAbstractVector value, int recLevel, RIntVector positions, RAbstractVector vector) { throw RError.error(getEncapsulatingSourceSection(), positions.getLength() == 2 && positions.getDataAt(0) == 0 ? RError.Message.SELECT_LESS_1 : RError.Message.SELECT_MORE_1); } @@ -1170,63 +1170,63 @@ public abstract class UpdateArrayHelperNode extends RNode { return resultVector; } - @Specialization(guards = {"!isObject", "multiDim", "!wrongDimensionsMatrix", "!wrongDimensions"}) + @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RIntVector update(VirtualFrame frame, Object v, RAbstractIntVector value, int recLevel, Object[] positions, RAbstractIntVector vector) { return updateVector(frame, value, vector, positions); } - @Specialization(guards = {"!isObject", "multiDim", "!wrongDimensionsMatrix", "!wrongDimensions"}) + @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RIntVector update(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, Object[] positions, RAbstractIntVector vector) { return updateVector(frame, castInteger(frame, value), vector, positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "multiPos"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) protected RAbstractIntVector updateSubset(Object v, RAbstractIntVector value, int recLevel, RIntVector positions, RAbstractIntVector vector) { return updateSingleDimVector(value, vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "multiPos"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) protected RAbstractIntVector updateSubset(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, RIntVector positions, RAbstractIntVector vector) { return updateSubset(v, castInteger(frame, value), recLevel, positions, vector); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "onePosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) protected Object updateSubsetOne(VirtualFrame frame, Object v, RAbstractIntVector value, int recLevel, RIntVector positions, RAbstractIntVector vector) { return updateRecursive(frame, v, value, vector, positions.getDataAt(0), recLevel); } - @Specialization(guards = {"!isObject", "posNames"}) + @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) protected RAbstractIntVector updateNames(Object v, RAbstractIntVector value, int recLevel, RIntVector positions, RAbstractIntVector vector) { return updateSingleDimVector(value, vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "posNames"}) + @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) protected RAbstractIntVector updateNames(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, RIntVector positions, RAbstractIntVector vector) { return updateNames(v, castInteger(frame, value), recLevel, positions, vector); } - @Specialization(guards = {"!isObject", "!isValueLengthOne", "isSubset", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RIntVector updateTooManyValuesSubset(Object v, RAbstractIntVector value, int recLevel, int position, RAbstractIntVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); return updateSingleDim(value, getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "!isValueLengthOne", "isSubset", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RIntVector updateTooManyValuesSubset(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, int position, RAbstractIntVector vector) { return updateTooManyValuesSubset(v, castInteger(frame, value), recLevel, position, vector); } - @Specialization(guards = {"!isObject", "isValueLengthOne", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RIntVector update(Object v, RAbstractIntVector value, int recLevel, int position, RAbstractIntVector vector) { return updateSingleDim(value, getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "onePosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) protected Object updateSubsetOne(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, RIntVector positions, RAbstractIntVector vector) { return updateRecursive(frame, v, value, vector, positions.getDataAt(0), recLevel); } - @Specialization(guards = {"!isObject", "isValueLengthOne", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RIntVector update(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, int position, RAbstractIntVector vector) { return updateSingleDim(castInteger(frame, value), getResultVector(vector, position), position); } @@ -1312,95 +1312,95 @@ public abstract class UpdateArrayHelperNode extends RNode { return resultVector; } - @Specialization(guards = {"!isObject", "multiDim", "!wrongDimensionsMatrix", "!wrongDimensions"}) + @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RDoubleVector update(VirtualFrame frame, Object v, RAbstractIntVector value, int recLevel, Object[] positions, RAbstractDoubleVector vector) { return updateVector(frame, castDouble(frame, value), vector, positions); } - @Specialization(guards = {"!isObject", "multiDim", "!wrongDimensionsMatrix", "!wrongDimensions"}) + @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RDoubleVector update(VirtualFrame frame, Object v, RAbstractDoubleVector value, int recLevel, Object[] positions, RAbstractDoubleVector vector) { return updateVector(frame, value, vector, positions); } - @Specialization(guards = {"!isObject", "multiDim", "!wrongDimensionsMatrix", "!wrongDimensions"}) + @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RDoubleVector update(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, Object[] positions, RAbstractDoubleVector vector) { return updateVector(frame, castDouble(frame, value), vector, positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "multiPos"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) protected RAbstractDoubleVector updateSubset(VirtualFrame frame, Object v, RAbstractIntVector value, int recLevel, RIntVector positions, RAbstractDoubleVector vector) { return updateSingleDimVector(castDouble(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "onePosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) protected Object updateSubsetOne(VirtualFrame frame, Object v, RAbstractIntVector value, int recLevel, RIntVector positions, RAbstractDoubleVector vector) { return updateRecursive(frame, v, value, vector, positions.getDataAt(0), recLevel); } - @Specialization(guards = {"!isObject", "posNames"}) + @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) protected RAbstractDoubleVector updateNames(VirtualFrame frame, Object v, RAbstractIntVector value, int recLevel, RIntVector positions, RAbstractDoubleVector vector) { return updateSingleDimVector(castDouble(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "!isValueLengthOne", "isSubset", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RDoubleVector updateTooManyValuesSubset(VirtualFrame frame, Object v, RAbstractIntVector value, int recLevel, int position, RAbstractDoubleVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); return updateSingleDim(castDouble(frame, value), getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isValueLengthOne", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RDoubleVector update(VirtualFrame frame, Object v, RAbstractIntVector value, int recLevel, int position, RAbstractDoubleVector vector) { return updateSingleDim(castDouble(frame, value), getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "multiPos"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) protected RAbstractDoubleVector updateSubset(Object v, RAbstractDoubleVector value, int recLevel, RIntVector positions, RAbstractDoubleVector vector) { return updateSingleDimVector(value, vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "onePosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) protected Object updateSubsetOne(VirtualFrame frame, Object v, RAbstractDoubleVector value, int recLevel, RIntVector positions, RAbstractDoubleVector vector) { return updateRecursive(frame, v, value, vector, positions.getDataAt(0), recLevel); } - @Specialization(guards = {"!isObject", "posNames"}) + @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) protected RAbstractDoubleVector updateNames(Object v, RAbstractDoubleVector value, int recLevel, RIntVector positions, RAbstractDoubleVector vector) { return updateSingleDimVector(value, vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "!isValueLengthOne", "isSubset", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RDoubleVector updateTooManyValuesSubset(Object v, RAbstractDoubleVector value, int recLevel, int position, RAbstractDoubleVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); return updateSingleDim(value, getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isValueLengthOne", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RDoubleVector update(Object v, RAbstractDoubleVector value, int recLevel, int position, RAbstractDoubleVector vector) { return updateSingleDim(value, getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "multiPos"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) protected RAbstractDoubleVector updateSubset(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, RIntVector positions, RAbstractDoubleVector vector) { return updateSingleDimVector(castDouble(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "onePosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) protected Object updateSubsetOne(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, RIntVector positions, RAbstractDoubleVector vector) { return updateRecursive(frame, v, value, vector, positions.getDataAt(0), recLevel); } - @Specialization(guards = {"!isObject", "posNames"}) + @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) protected RAbstractDoubleVector updateNames(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, RIntVector positions, RAbstractDoubleVector vector) { return updateSingleDimVector(castDouble(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "!isValueLengthOne", "isSubset", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RDoubleVector updateTooManyValuesSubset(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, int position, RAbstractDoubleVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); return updateSingleDim(castDouble(frame, value), getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isValueLengthOne", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RDoubleVector update(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, int position, RAbstractDoubleVector vector) { return updateSingleDim(castDouble(frame, value), getResultVector(vector, position), position); } @@ -1483,33 +1483,33 @@ public abstract class UpdateArrayHelperNode extends RNode { return resultVector; } - @Specialization(guards = {"!isObject", "multiDim", "!wrongDimensionsMatrix", "!wrongDimensions"}) + @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RLogicalVector update(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, Object[] positions, RLogicalVector vector) { return updateVector(frame, value, vector, positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "multiPos"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) protected RAbstractLogicalVector updateSubset(Object v, RAbstractLogicalVector value, int recLevel, RIntVector positions, RLogicalVector vector) { return updateSingleDimVector(value, vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "onePosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) protected Object updateSubsetOne(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, RIntVector positions, RLogicalVector vector) { return updateRecursive(frame, v, value, vector, positions.getDataAt(0), recLevel); } - @Specialization(guards = {"!isObject", "posNames"}) + @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) protected RAbstractLogicalVector updateNames(Object v, RAbstractLogicalVector value, int recLevel, RIntVector positions, RLogicalVector vector) { return updateSingleDimVector(value, vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "!isValueLengthOne", "isSubset", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RLogicalVector updateTooManyValuesSubset(Object v, RAbstractLogicalVector value, int recLevel, int position, RLogicalVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); return updateSingleDim(value, getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isValueLengthOne", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RLogicalVector update(Object v, RAbstractLogicalVector value, int recLevel, int position, RLogicalVector vector) { return updateSingleDim(value, getResultVector(vector, position), position); } @@ -1592,64 +1592,64 @@ public abstract class UpdateArrayHelperNode extends RNode { return resultVector; } - @Specialization(guards = {"!isObject", "multiDim", "!wrongDimensionsMatrix", "!wrongDimensions"}) + @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RStringVector update(VirtualFrame frame, Object v, RAbstractStringVector value, int recLevel, Object[] positions, RStringVector vector) { return updateVector(frame, value, vector, positions); } - @Specialization(guards = {"!isObject", "multiDim", "!wrongDimensionsMatrix", "!wrongDimensions"}) + @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RStringVector update(VirtualFrame frame, Object v, RAbstractVector value, int recLevel, Object[] positions, RStringVector vector) { return updateVector(frame, castString(frame, value), vector, positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "multiPos"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) protected RAbstractStringVector updateSubset(Object v, RAbstractStringVector value, int recLevel, RIntVector positions, RStringVector vector) { return updateSingleDimVector(value, vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "onePosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) protected Object updateSubsetOne(VirtualFrame frame, Object v, RAbstractStringVector value, int recLevel, RIntVector positions, RStringVector vector) { return updateRecursive(frame, v, value, vector, positions.getDataAt(0), recLevel); } - @Specialization(guards = {"!isObject", "posNames"}) + @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) protected RAbstractStringVector updateNames(Object v, RAbstractStringVector value, int recLevel, RIntVector positions, RStringVector vector) { return updateSingleDimVector(value, vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "!isValueLengthOne", "isSubset", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RStringVector updateTooManyValuesSubset(Object v, RAbstractStringVector value, int recLevel, int position, RStringVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); return updateSingleDim(value, getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isValueLengthOne", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RStringVector update(Object v, RAbstractStringVector value, int recLevel, int position, RStringVector vector) { return updateSingleDim(value, getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "multiPos"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) protected RAbstractStringVector updateSubset(VirtualFrame frame, Object v, RAbstractVector value, int recLevel, RIntVector positions, RStringVector vector) { return updateSingleDimVector(castString(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "onePosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) protected Object updateSubsetOne(VirtualFrame frame, Object v, RAbstractVector value, int recLevel, RIntVector positions, RStringVector vector) { return updateRecursive(frame, v, value, vector, positions.getDataAt(0), recLevel); } - @Specialization(guards = {"!isObject", "posNames"}) + @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) protected RAbstractStringVector updateSubsetNames(VirtualFrame frame, Object v, RAbstractVector value, int recLevel, RIntVector positions, RStringVector vector) { return updateSingleDimVector(castString(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "!isValueLengthOne", "isSubset", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RStringVector updateTooManyValuesSubset(VirtualFrame frame, Object v, RAbstractVector value, int recLevel, int position, RStringVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); return updateSingleDim(castString(frame, value), getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isValueLengthOne", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RStringVector update(VirtualFrame frame, Object v, RAbstractVector value, int recLevel, int position, RStringVector vector) { return updateSingleDim(castString(frame, value), getResultVector(vector, position), position); } @@ -1732,126 +1732,126 @@ public abstract class UpdateArrayHelperNode extends RNode { return resultVector; } - @Specialization(guards = {"!isObject", "multiDim", "!wrongDimensionsMatrix", "!wrongDimensions"}) + @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RComplexVector update(VirtualFrame frame, Object v, RAbstractIntVector value, int recLevel, Object[] positions, RComplexVector vector) { return updateVector(frame, castComplex(frame, value), vector, positions); } - @Specialization(guards = {"!isObject", "multiDim", "!wrongDimensionsMatrix", "!wrongDimensions"}) + @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RComplexVector update(VirtualFrame frame, Object v, RAbstractDoubleVector value, int recLevel, Object[] positions, RComplexVector vector) { return updateVector(frame, castComplex(frame, value), vector, positions); } - @Specialization(guards = {"!isObject", "multiDim", "!wrongDimensionsMatrix", "!wrongDimensions"}) + @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RComplexVector update(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, Object[] positions, RComplexVector vector) { return updateVector(frame, castComplex(frame, value), vector, positions); } - @Specialization(guards = {"!isObject", "multiDim", "!wrongDimensionsMatrix", "!wrongDimensions"}) + @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RComplexVector update(VirtualFrame frame, Object v, RAbstractComplexVector value, int recLevel, Object[] positions, RComplexVector vector) { return updateVector(frame, value, vector, positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "multiPos"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) protected RAbstractComplexVector updateSubset(VirtualFrame frame, Object v, RAbstractIntVector value, int recLevel, RIntVector positions, RComplexVector vector) { return updateSingleDimVector(castComplex(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "onePosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) protected Object updateSubsetOne(VirtualFrame frame, Object v, RAbstractIntVector value, int recLevel, RIntVector positions, RComplexVector vector) { return updateRecursive(frame, v, value, vector, positions.getDataAt(0), recLevel); } - @Specialization(guards = {"!isObject", "posNames"}) + @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) protected RAbstractComplexVector updateNames(VirtualFrame frame, Object v, RAbstractIntVector value, int recLevel, RIntVector positions, RComplexVector vector) { return updateSingleDimVector(castComplex(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "!isValueLengthOne", "isSubset", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RComplexVector updateTooManyValuesSubset(VirtualFrame frame, Object v, RAbstractIntVector value, int recLevel, int position, RComplexVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); return updateSingleDim(frame, castComplex(frame, value), getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isValueLengthOne", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RComplexVector update(VirtualFrame frame, Object v, RAbstractIntVector value, int recLevel, int position, RComplexVector vector) { return updateSingleDim(frame, castComplex(frame, value), getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "multiPos"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) protected RAbstractComplexVector updateSubset(VirtualFrame frame, Object v, RAbstractDoubleVector value, int recLevel, RIntVector positions, RComplexVector vector) { return updateSingleDimVector(castComplex(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "onePosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) protected Object updateSubsetOne(VirtualFrame frame, Object v, RAbstractDoubleVector value, int recLevel, RIntVector positions, RComplexVector vector) { return updateRecursive(frame, v, value, vector, positions.getDataAt(0), recLevel); } - @Specialization(guards = {"!isObject", "posNames"}) + @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) protected RAbstractComplexVector updateNames(VirtualFrame frame, Object v, RAbstractDoubleVector value, int recLevel, RIntVector positions, RComplexVector vector) { return updateSingleDimVector(castComplex(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "!isValueLengthOne", "isSubset", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RComplexVector updateTooManyValuesSubset(VirtualFrame frame, Object v, RAbstractDoubleVector value, int recLevel, int position, RComplexVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); return updateSingleDim(frame, castComplex(frame, value), getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isValueLengthOne", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RComplexVector update(VirtualFrame frame, Object v, RAbstractDoubleVector value, int recLevel, int position, RComplexVector vector) { return updateSingleDim(frame, castComplex(frame, value), getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "multiPos"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) protected RAbstractComplexVector updateSubset(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, RIntVector positions, RComplexVector vector) { return updateSingleDimVector(castComplex(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "onePosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) protected Object updateSubsetOne(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, RIntVector positions, RComplexVector vector) { return updateRecursive(frame, v, value, vector, positions.getDataAt(0), recLevel); } - @Specialization(guards = {"!isObject", "posNames"}) + @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) protected RAbstractComplexVector updateNames(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, RIntVector positions, RComplexVector vector) { return updateSingleDimVector(castComplex(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "!isValueLengthOne", "isSubset", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RComplexVector updateTooManyValuesSubset(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, int position, RComplexVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); return updateSingleDim(frame, castComplex(frame, value), getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isValueLengthOne", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RComplexVector update(VirtualFrame frame, Object v, RAbstractLogicalVector value, int recLevel, int position, RComplexVector vector) { return updateSingleDim(frame, castComplex(frame, value), getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "multiPos"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) protected RAbstractComplexVector updateSubset(Object v, RAbstractComplexVector value, int recLevel, RIntVector positions, RComplexVector vector) { return updateSingleDimVector(value, vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "onePosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) protected Object updateSubsetOne(VirtualFrame frame, Object v, RAbstractComplexVector value, int recLevel, RIntVector positions, RComplexVector vector) { return updateRecursive(frame, v, value, vector, positions.getDataAt(0), recLevel); } - @Specialization(guards = {"!isObject", "posNames"}) + @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) protected RAbstractComplexVector updateNames(Object v, RAbstractComplexVector value, int recLevel, RIntVector positions, RComplexVector vector) { return updateSingleDimVector(value, vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "!isValueLengthOne", "isSubset", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RComplexVector updateTooManyValuesSubset(VirtualFrame frame, Object v, RAbstractComplexVector value, int recLevel, int position, RComplexVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); return updateSingleDim(frame, value, getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isValueLengthOne", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RComplexVector update(VirtualFrame frame, Object v, RAbstractComplexVector value, int recLevel, int position, RComplexVector vector) { return updateSingleDim(frame, value, getResultVector(vector, position), position); } @@ -1933,33 +1933,33 @@ public abstract class UpdateArrayHelperNode extends RNode { return resultVector; } - @Specialization(guards = {"!isObject", "multiDim", "!wrongDimensionsMatrix", "!wrongDimensions"}) + @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RRawVector update(VirtualFrame frame, Object v, RAbstractRawVector value, int recLevel, Object[] positions, RRawVector vector) { return updateVector(frame, value, vector, positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "multiPos"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) protected RAbstractRawVector updateSubset(Object v, RAbstractRawVector value, int recLevel, RIntVector positions, RRawVector vector) { return updateSingleDimVector(value, vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "isSubset", "!posNames", "onePosition"}) + @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) protected Object updateSubsetOne(VirtualFrame frame, Object v, RAbstractRawVector value, int recLevel, RIntVector positions, RRawVector vector) { return updateRecursive(frame, v, value, vector, positions.getDataAt(0), recLevel); } - @Specialization(guards = {"!isObject", "posNames"}) + @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) protected RAbstractRawVector updateSubsetNames(Object v, RAbstractRawVector value, int recLevel, RIntVector positions, RRawVector vector) { return updateSingleDimVector(value, vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } - @Specialization(guards = {"!isObject", "!isValueLengthOne", "isSubset", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RRawVector updateTooManyValuesSubset(Object v, RAbstractRawVector value, int recLevel, int position, RRawVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); return updateSingleDim(value, getResultVector(vector, position), position); } - @Specialization(guards = {"!isObject", "isValueLengthOne", "!isPosNA", "!isPosZero"}) + @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RRawVector update(Object v, RAbstractRawVector value, int recLevel, int position, RRawVector vector) { return updateSingleDim(value, getResultVector(vector, position), position); } @@ -1970,7 +1970,7 @@ public abstract class UpdateArrayHelperNode extends RNode { } @TruffleBoundary - @Specialization(guards = "!isObject") + @Specialization(guards = "!isObject(vector)") protected Object accessListPosition(Object v, Object value, int recLevel, RList positions, RAbstractVector vector) { if (!isSubset) { if (vector instanceof RList) { @@ -1996,7 +1996,7 @@ public abstract class UpdateArrayHelperNode extends RNode { } @TruffleBoundary - @Specialization(guards = "!isObject") + @Specialization(guards = "!isObject(vector)") protected Object accessComplexPosition(Object v, Object value, int recLevel, RComplex position, RAbstractVector vector) { if (isSubset || vector instanceof RList || getValueLength(value) == 1) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_SUBSCRIPT_TYPE, "complex"); @@ -2006,7 +2006,7 @@ public abstract class UpdateArrayHelperNode extends RNode { } @TruffleBoundary - @Specialization(guards = "!isObject") + @Specialization(guards = "!isObject(vector)") protected Object accessRawPosition(Object v, Object value, int recLevel, RRaw position, RAbstractVector vector) { if (isSubset || vector instanceof RList || getValueLength(value) == 1) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_SUBSCRIPT_TYPE, "raw"); @@ -2015,47 +2015,47 @@ public abstract class UpdateArrayHelperNode extends RNode { } } - protected boolean firstPosZero(Object v, Object value, int recLevel, RIntVector positions) { + protected boolean firstPosZero(RIntVector positions) { return positions.getDataAt(0) == 0; } - protected boolean outOfBoundsNegative(Object v, Object value, int recLevel, int position, RAbstractVector vector) { + protected boolean outOfBoundsNegative(int position, RAbstractVector vector) { return -position > vector.getLength(); } - protected boolean oneElemVector(Object v, Object value, int recLevel, Object positions, RAbstractVector vector) { + protected boolean oneElemVector(RAbstractVector vector) { return vector.getLength() == 1; } - protected boolean posNames(Object v, RAbstractContainer value, int recLevel, RIntVector positions) { + protected boolean posNames(RIntVector positions) { return positions.getNames(attrProfiles) != null; } - protected boolean isPositionNegative(Object v, Object value, int recLevel, int position) { + protected boolean isPositionNegative(int position) { return position < 0; } - protected boolean isVectorList(Object v, Object value, int recLevel, Object positions, RAbstractVector vector) { + protected boolean isVectorList(RAbstractVector vector) { return vector instanceof RList; } - protected boolean isVectorLongerThanOne(Object v, Object value, int recLevel, Object positions, RAbstractVector vector) { + protected boolean isVectorLongerThanOne(RAbstractVector vector) { return vector.getLength() > 1; } - protected boolean emptyValue(Object v, RAbstractContainer value) { + protected boolean emptyValue(RAbstractContainer value) { return value.getLength() == 0; } - protected boolean valueLengthOne(Object v, RAbstractContainer value) { + protected boolean valueLengthOne(RAbstractContainer value) { return value.getLength() == 1; } - protected boolean valueLongerThanOne(Object v, RAbstractContainer value) { + protected boolean valueLongerThanOne(RAbstractContainer value) { return value.getLength() > 1; } - protected boolean wrongDimensionsMatrix(Object v, Object value, int recLevel, Object[] positions, RAbstractVector vector) { + protected boolean wrongDimensionsMatrix(Object[] positions, RAbstractVector vector) { if (positions.length == 2 && (vector.getDimensions() == null || vector.getDimensions().length != positions.length)) { error.enter(); if (isSubset) { @@ -2067,7 +2067,7 @@ public abstract class UpdateArrayHelperNode extends RNode { return false; } - protected boolean wrongDimensionsMatrix(Object v, Object value, int recLevel, Object[] positions, RNull vector) { + protected boolean wrongDimensionsMatrix(Object[] positions, RNull vector) { if (positions.length == 2) { error.enter(); if (isSubset) { @@ -2079,7 +2079,7 @@ public abstract class UpdateArrayHelperNode extends RNode { return false; } - protected boolean wrongDimensions(Object v, Object value, int recLevel, Object[] positions, RAbstractVector vector) { + protected boolean wrongDimensions(Object[] positions, RAbstractVector vector) { if (!((vector.getDimensions() == null && positions.length == 1) || vector.getDimensions().length == positions.length)) { error.enter(); if (isSubset) { @@ -2091,7 +2091,7 @@ public abstract class UpdateArrayHelperNode extends RNode { return false; } - protected boolean wrongDimensions(Object v, RAbstractContainer value, int recLevel, Object[] positions, RNull vector) { + protected boolean wrongDimensions(Object[] positions, RNull vector) { if (positions.length > 2) { error.enter(); if (isSubset) { @@ -2103,62 +2103,58 @@ public abstract class UpdateArrayHelperNode extends RNode { return false; } - protected boolean multiDim(Object v, RAbstractContainer value, int recLevel, Object[] positions, RAbstractVector vector) { + protected boolean multiDim(RAbstractVector vector) { return vector.getDimensions() != null && vector.getDimensions().length > 1; } - protected boolean wrongLength(Object v, RAbstractContainer value, int recLevel, RIntVector positions, RAbstractVector vector) { + protected boolean wrongLength(RAbstractContainer value, RIntVector positions, RAbstractVector vector) { int valLength = value.getLength(); int posLength = positions.getLength(); return valLength > posLength || (posLength % valLength != 0); } - protected boolean isPosNA(Object v, Object value, int recLevel, int position) { + protected boolean isPosNA(int position) { return RRuntime.isNA(position); } - protected boolean isPosZero(Object v, Object value, int recLevel, int position) { + protected boolean isPosZero(int position) { return position == 0; } - protected boolean isValueLengthOne(Object v, RAbstractContainer value) { + protected boolean isValueLengthOne(RAbstractContainer value) { return value.getLength() == 1; } - protected boolean twoPositions(Object v, Object value, int recLevel, RAbstractVector position) { + protected boolean twoPositions(RAbstractVector position) { return position.getLength() == 2; } - protected boolean onePosition(Object v, Object value, int recLevel, RAbstractVector position) { + protected boolean onePosition(RAbstractVector position) { return position.getLength() == 1; } - protected boolean noPosition(Object v, Object value, int recLevel, RAbstractVector position) { + protected boolean noPosition(RAbstractVector position) { return position.getLength() == 0; } - protected boolean isSubset() { - return isSubset; - } - - protected boolean inRecursion(Object v, Object value, int recLevel) { + protected boolean inRecursion(int recLevel) { return recLevel > 0; } - protected boolean multiPos(Object v, Object value, int recLevel, RIntVector positions) { + protected boolean multiPos(RIntVector positions) { return positions.getLength() > 1; } - protected boolean moreThanTwoPos(Object v, Object value, int recLevel, RList positions) { + protected boolean moreThanTwoPos(RList positions) { return positions.getLength() > 2; } - protected boolean emptyList(Object v, RNull value, int recLevel, int positions, RList vector) { + protected boolean emptyList(RList vector) { return vector.getLength() == 0; } - protected boolean isObject(Object v, Object value, int recLevel, Object positions, RAbstractContainer container) { - return container.isObject(attrProfiles) && forObjects; + protected boolean isObject(RAbstractContainer vector) { + return vector.isObject(attrProfiles) && forObjects; } /** diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryArithmeticNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryArithmeticNode.java index 5ef866121e3d836098d1e7e419d786b6322dc175..4d9ae16648c611df121e3357c394536529ca4cdd 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryArithmeticNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryArithmeticNode.java @@ -43,7 +43,6 @@ import com.oracle.truffle.r.runtime.ops.BinaryArithmetic.Add; import com.oracle.truffle.r.runtime.ops.BinaryArithmetic.Multiply; import com.oracle.truffle.r.runtime.ops.na.*; -@GenerateNodeFactory public abstract class BinaryArithmeticNode extends RBuiltinNode { @Child private BinaryArithmetic arithmetic; @@ -104,44 +103,44 @@ public abstract class BinaryArithmeticNode extends RBuiltinNode { return arithmetic instanceof Multiply; } - @Specialization(guards = "isAdd") + @Specialization(guards = "isAdd()") protected RIntSequence doIntAdd(int left, RIntSequence right) { // TODO: handle cases that exit the int range return RDataFactory.createIntSequence(right.getStart() + left, right.getStride(), right.getLength()); } - @Specialization(guards = "isMul") + @Specialization(guards = "isMul()") protected RIntSequence doIntMul(RIntSequence left, int right) { // TODO: handle cases that exit the int range return RDataFactory.createIntSequence(left.getStart() * right, left.getStride() * right, left.getLength()); } - @Specialization(guards = "isAdd") + @Specialization(guards = "isAdd()") protected RDoubleSequence doDoubleAdd(int left, RDoubleSequence right) { return RDataFactory.createDoubleSequence(right.getStart() + left, right.getStride(), right.getLength()); } - @Specialization(guards = "isMul") + @Specialization(guards = "isMul()") protected RDoubleSequence doDoubleMul(RDoubleSequence left, int right) { return RDataFactory.createDoubleSequence(left.getStart() * right, left.getStride() * right, left.getLength()); } - @Specialization(guards = "isAdd") + @Specialization(guards = "isAdd()") protected RDoubleSequence doDoubleAdd(double left, RDoubleSequence right) { return RDataFactory.createDoubleSequence(right.getStart() + left, right.getStride(), right.getLength()); } - @Specialization(guards = "isMul") + @Specialization(guards = "isMul()") protected RDoubleSequence doDoubleMul(RDoubleSequence left, double right) { return RDataFactory.createDoubleSequence(left.getStart() * right, left.getStride() * right, left.getLength()); } - @Specialization(guards = "isAdd") + @Specialization(guards = "isAdd()") protected RDoubleSequence doDoubleAdd(double left, RIntSequence right) { return RDataFactory.createDoubleSequence(right.getStart() + left, right.getStride(), right.getLength()); } - @Specialization(guards = "isMul") + @Specialization(guards = "isMul()") protected RDoubleSequence doDoubleMul(RIntSequence left, double right) { return RDataFactory.createDoubleSequence(left.getStart() * right, left.getStride() * right, left.getLength()); } @@ -189,7 +188,7 @@ public abstract class BinaryArithmeticNode extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "nonNumeric") + @Specialization(guards = "nonNumeric(right)") protected RComplexVector doLeftNull(RNull left, RAbstractVector right) { throw RError.error(getSourceSection(), RError.Message.NON_NUMERIC_BINARY); } @@ -224,7 +223,7 @@ public abstract class BinaryArithmeticNode extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "nonNumeric") + @Specialization(guards = "nonNumeric(left)") protected RComplexVector doRightNull(RAbstractVector left, RNull right) { throw RError.error(getSourceSection(), RError.Message.NON_NUMERIC_BINARY); } @@ -235,24 +234,24 @@ public abstract class BinaryArithmeticNode extends RBuiltinNode { return RDataFactory.createEmptyDoubleVector(); } - @Specialization(guards = "!isFactorRight") + @Specialization(guards = "!isFactor(right)") protected Object doLeftString(RAbstractStringVector left, RAbstractContainer right) { return doRightString(right, left); } @SuppressWarnings("unused") - @Specialization(guards = "!isFactorLeft") + @Specialization(guards = "!isFactor(left)") protected Object doRightString(RAbstractContainer left, RAbstractStringVector right) { throw RError.error(getSourceSection(), RError.Message.NON_NUMERIC_BINARY); } - @Specialization(guards = "!isFactorRight") + @Specialization(guards = "!isFactor(right)") protected Object doLeftRaw(RAbstractRawVector left, RAbstractContainer right) { return doRightRaw(right, left); } @SuppressWarnings("unused") - @Specialization(guards = "!isFactorLeft") + @Specialization(guards = "!isFactor(left)") protected Object doRightRaw(RAbstractContainer left, RAbstractRawVector right) { throw RError.error(getSourceSection(), RError.Message.NON_NUMERIC_BINARY); } @@ -263,7 +262,7 @@ public abstract class BinaryArithmeticNode extends RBuiltinNode { // int - @Specialization(guards = {"supportsIntResult"}) + @Specialization(guards = {"supportsIntResult()"}) public int doInt(int left, int right) { leftNACheck.enable(left); rightNACheck.enable(right); @@ -284,14 +283,14 @@ public abstract class BinaryArithmeticNode extends RBuiltinNode { return performArithmeticDoubleEnableNACheck(left, rightNACheck.check(right) ? RRuntime.DOUBLE_NA : RRuntime.int2doubleNoCheck(right)); } - @Specialization(guards = {"supportsIntResult"}) + @Specialization(guards = {"supportsIntResult()"}) protected int doInt(int left, byte right) { leftNACheck.enable(left); rightNACheck.enable(right); return performArithmeticEnableNACheck(left, rightNACheck.check(right) ? RRuntime.INT_NA : RRuntime.logical2intNoCheck(right)); } - @Specialization(guards = {"supportsIntResult"}) + @Specialization(guards = {"supportsIntResult()"}) protected int doInt(byte left, int right) { leftNACheck.enable(left); rightNACheck.enable(right); @@ -308,17 +307,17 @@ public abstract class BinaryArithmeticNode extends RBuiltinNode { return performArithmeticComplexEnableNACheck(left, RRuntime.int2complex(right)); } - @Specialization(guards = {"!supportsIntResult"}) + @Specialization(guards = {"!supportsIntResult()"}) protected double doIntDouble(int left, int right) { return performArithmeticIntIntDoubleEnableNACheck(left, right); } - @Specialization(guards = {"!supportsIntResult"}) + @Specialization(guards = {"!supportsIntResult()"}) protected double doIntDouble(int left, byte right) { return performArithmeticIntIntDoubleEnableNACheck(left, RRuntime.logical2int(right)); } - @Specialization(guards = {"!supportsIntResult"}) + @Specialization(guards = {"!supportsIntResult()"}) protected double doIntDouble(byte left, int right) { return performArithmeticIntIntDoubleEnableNACheck(RRuntime.logical2int(left), right); } @@ -358,7 +357,7 @@ public abstract class BinaryArithmeticNode extends RBuiltinNode { // logical - @Specialization(guards = {"supportsIntResult"}) + @Specialization(guards = {"supportsIntResult()"}) protected int doLogical(byte left, byte right) { leftNACheck.enable(left); rightNACheck.enable(right); @@ -376,7 +375,7 @@ public abstract class BinaryArithmeticNode extends RBuiltinNode { return performArithmeticComplexEnableNACheck(left, RRuntime.logical2complex(right)); } - @Specialization(guards = {"!supportsIntResult"}) + @Specialization(guards = {"!supportsIntResult()"}) protected double doLogicalDouble(byte left, byte right) { return performArithmeticIntIntDoubleEnableNACheck(RRuntime.logical2int(left), RRuntime.logical2int(right)); } @@ -407,7 +406,7 @@ public abstract class BinaryArithmeticNode extends RBuiltinNode { } @SuppressWarnings("unused") - @Specialization(guards = "differentDimensions") + @Specialization(guards = "differentDimensions(left, right)") protected RLogicalVector doIntVectorDifferentLength(RAbstractVector left, RAbstractVector right) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.NON_CONFORMABLE_ARRAYS); } @@ -418,128 +417,128 @@ public abstract class BinaryArithmeticNode extends RBuiltinNode { return vector.isTemporary(); } - @Specialization(guards = {"supportsIntResult", "isTemporary(arguments[0])"}) + @Specialization(guards = {"supportsIntResult()", "isTemporary(left)"}) protected RIntVector doIntVectorScalar(RIntVector left, int right) { leftNACheck.enable(left); rightNACheck.enable(right); return performOpVectorScalar(left, RIntVector::getDataWithoutCopying, RDataFactory::createEmptyIntVector, (array, i) -> array[i] = performArithmetic(array[i], right)); } - @Specialization(guards = {"supportsIntResult", "isTemporary(arguments[1])"}) + @Specialization(guards = {"supportsIntResult()", "isTemporary(right)"}) protected RIntVector doIntVectorScalar(int left, RIntVector right) { leftNACheck.enable(left); rightNACheck.enable(right); return performOpVectorScalar(right, RIntVector::getDataWithoutCopying, RDataFactory::createEmptyIntVector, (array, i) -> array[i] = performArithmetic(left, array[i])); } - @Specialization(guards = "!supportsIntResult") + @Specialization(guards = "!supportsIntResult()") protected RDoubleVector doIntVectorScalar(RIntVector left, double right) { return performOpDifferentLength(left, double[]::new, RDataFactory::createEmptyDoubleVector, RDataFactory::createDoubleVector, (array, i) -> array[i] = performArithmeticDouble(leftNACheck.convertIntToDouble(left.getDataAt(i)), right)); } - @Specialization(guards = "!supportsIntResult") + @Specialization(guards = "!supportsIntResult()") protected RDoubleVector doIntVectorScalar(double left, RIntVector right) { return performOpDifferentLength(right, double[]::new, RDataFactory::createEmptyDoubleVector, RDataFactory::createDoubleVector, (array, i) -> array[i] = performArithmeticDouble(left, rightNACheck.convertIntToDouble(right.getDataAt(i)))); } - @Specialization(guards = {"!areSameLength", "supportsIntResult", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "supportsIntResult()", "!differentDimensions(left, right)"}) protected RIntVector doIntVectorDifferentLength(RAbstractIntVector left, RAbstractIntVector right) { return performIntVectorOpDifferentLength(left, right); } - @Specialization(guards = {"areSameLength", "supportsIntResult", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "supportsIntResult()", "!differentDimensions(left, right)"}) protected RIntVector doIntVectorSameLength(RAbstractIntVector left, RAbstractIntVector right) { return performIntVectorOpSameLength(left, right); } - @Specialization(guards = {"!areSameLength", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "!differentDimensions(left, right)"}) protected RDoubleVector doIntVectorDifferentLength(RAbstractIntVector left, RAbstractDoubleVector right) { return performDoubleVectorOpDifferentLength(RClosures.createIntToDoubleVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "!differentDimensions(left, right)"}) protected RDoubleVector doIntVectorSameLength(RAbstractIntVector left, RAbstractDoubleVector right) { return performDoubleVectorOpSameLength(RClosures.createIntToDoubleVector(left, leftNACheck), right); } - @Specialization(guards = {"!areSameLength", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "!differentDimensions(left, right)"}) protected RDoubleVector doIntVectorDifferentLength(RAbstractDoubleVector left, RAbstractIntVector right) { return performDoubleVectorOpDifferentLength(left, RClosures.createIntToDoubleVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "!differentDimensions(left, right)"}) protected RDoubleVector doIntVectorIntVectorSameLength(RAbstractDoubleVector left, RAbstractIntVector right) { return performDoubleVectorOpSameLength(left, RClosures.createIntToDoubleVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "supportsIntResult", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "supportsIntResult()", "!differentDimensions(left, right)"}) protected RIntVector doIntVectorDifferentLength(RAbstractIntVector left, RAbstractLogicalVector right) { return performIntVectorOpDifferentLength(left, RClosures.createLogicalToIntVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "supportsIntResult"}) + @Specialization(guards = {"areSameLength(left, right)", "supportsIntResult()"}) protected RIntVector doIntVectorSameLength(RAbstractIntVector left, RAbstractLogicalVector right) { return performIntVectorOpSameLength(left, RClosures.createLogicalToIntVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "supportsIntResult"}) + @Specialization(guards = {"!areSameLength(left, right)", "supportsIntResult()"}) protected RIntVector doIntVectorDifferentLength(RAbstractLogicalVector left, RAbstractIntVector right) { return performIntVectorOpDifferentLength(RClosures.createLogicalToIntVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "supportsIntResult"}) + @Specialization(guards = {"areSameLength(left, right)", "supportsIntResult()"}) protected RIntVector doIntVectorSameLength(RAbstractLogicalVector left, RAbstractIntVector right) { return performIntVectorOpSameLength(RClosures.createLogicalToIntVector(left, leftNACheck), right); } - @Specialization(guards = "!areSameLength") + @Specialization(guards = "!areSameLength(left, right)") protected RComplexVector doIntVectorDifferentLength(RAbstractIntVector left, RAbstractComplexVector right) { return performComplexVectorOpDifferentLength(RClosures.createIntToComplexVector(left, leftNACheck), right); } - @Specialization(guards = "areSameLength") + @Specialization(guards = "areSameLength(left, right)") protected RComplexVector doIntVectorSameLength(RAbstractIntVector left, RAbstractComplexVector right) { return performComplexVectorOpSameLength(RClosures.createIntToComplexVector(left, leftNACheck), right); } - @Specialization(guards = "!areSameLength") + @Specialization(guards = "!areSameLength(left, right)") protected RComplexVector doIntVectorDifferentLength(RAbstractComplexVector left, RAbstractIntVector right) { return performComplexVectorOpDifferentLength(left, RClosures.createIntToComplexVector(right, rightNACheck)); } - @Specialization(guards = "areSameLength") + @Specialization(guards = "areSameLength(left, right)") protected RComplexVector doIntVectorSameLength(RAbstractComplexVector left, RAbstractIntVector right) { return performComplexVectorOpSameLength(left, RClosures.createIntToComplexVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "!supportsIntResult"}) + @Specialization(guards = {"!areSameLength(left, right)", "!supportsIntResult()"}) protected RDoubleVector doIntVectorDoubleDifferentLength(RAbstractIntVector left, RAbstractIntVector right) { return performIntVectorOpDoubleDifferentLength(left, right); } - @Specialization(guards = {"areSameLength", "!supportsIntResult"}) + @Specialization(guards = {"areSameLength(left, right)", "!supportsIntResult()"}) protected RDoubleVector doIntVectorDoubleSameLength(RAbstractIntVector left, RAbstractIntVector right) { return performIntVectorOpDoubleSameLength(left, right); } - @Specialization(guards = {"!areSameLength", "!supportsIntResult"}) + @Specialization(guards = {"!areSameLength(left, right)", "!supportsIntResult()"}) protected RDoubleVector doIntVectorDoubleDifferentLength(RAbstractIntVector left, RAbstractLogicalVector right) { return performIntVectorOpDoubleDifferentLength(left, RClosures.createLogicalToIntVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "!supportsIntResult"}) + @Specialization(guards = {"areSameLength(left, right)", "!supportsIntResult()"}) protected RDoubleVector doIntVectorDoubleSameLength(RAbstractIntVector left, RAbstractLogicalVector right) { return performIntVectorOpDoubleSameLength(left, RClosures.createLogicalToIntVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "!supportsIntResult"}) + @Specialization(guards = {"!areSameLength(left, right)", "!supportsIntResult()"}) protected RDoubleVector doIntVectorDoubleDifferentLength(RAbstractLogicalVector left, RAbstractIntVector right) { return performIntVectorOpDoubleDifferentLength(RClosures.createLogicalToIntVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "!supportsIntResult"}) + @Specialization(guards = {"areSameLength(left, right)", "!supportsIntResult()"}) protected RDoubleVector doIntVectorDoubleSameLength(RAbstractLogicalVector left, RAbstractIntVector right) { return performIntVectorOpDoubleSameLength(RClosures.createLogicalToIntVector(left, leftNACheck), right); } @@ -550,14 +549,14 @@ public abstract class BinaryArithmeticNode extends RBuiltinNode { return vector.isTemporary(); } - @Specialization(guards = "isTemporary(arguments[0])") + @Specialization(guards = "isTemporary(left)") protected RDoubleVector doDoubleVectorScalarTempLeft(RDoubleVector left, double right) { leftNACheck.enable(left); rightNACheck.enable(right); return performOpVectorScalar(left, RDoubleVector::getDataWithoutCopying, RDataFactory::createEmptyDoubleVector, (array, i) -> array[i] = performArithmeticDouble(array[i], right)); } - @Specialization(guards = "isTemporary(arguments[1])") + @Specialization(guards = "isTemporary(right)") protected RDoubleVector doDoubleVectorScalarTempRight(double left, RDoubleVector right) { leftNACheck.enable(left); rightNACheck.enable(right); @@ -580,118 +579,118 @@ public abstract class BinaryArithmeticNode extends RBuiltinNode { (array, i) -> array[i] = performArithmeticDouble(left, right.getDataAt(i))); } - @Specialization(guards = "!areSameLength") + @Specialization(guards = "!areSameLength(left, right)") protected RDoubleVector doDoubleVectorDifferentLength(RAbstractDoubleVector left, RAbstractDoubleVector right) { return performDoubleVectorOpDifferentLength(left, right); } - @Specialization(guards = {"areSameLength", "isTemporary(arguments[0])"}) + @Specialization(guards = {"areSameLength(left, right)", "isTemporary(left)"}) protected RDoubleVector doDoubleVectorTempLeft(RDoubleVector left, RDoubleVector right) { double[] rightArray = right.getDataWithoutCopying(); return performOpVectorScalar(left, RDoubleVector::getDataWithoutCopying, RDataFactory::createEmptyDoubleVector, (array, i) -> array[i] = performArithmeticDouble(array[i], rightArray[i])); } - @Specialization(guards = {"areSameLength", "isTemporary(arguments[1])"}) + @Specialization(guards = {"areSameLength(left, right)", "isTemporary(right)"}) protected RDoubleVector doDoubleVectorTempRight(RDoubleVector left, RDoubleVector right) { double[] leftArray = left.getDataWithoutCopying(); return performOpVectorScalar(right, RDoubleVector::getDataWithoutCopying, RDataFactory::createEmptyDoubleVector, (array, i) -> array[i] = performArithmeticDouble(leftArray[i], array[i])); } - @Specialization(guards = "areSameLength") + @Specialization(guards = "areSameLength(left, right)") protected RDoubleVector doDoubleVectorSameLength(RAbstractDoubleVector left, RAbstractDoubleVector right) { return performDoubleVectorOpSameLength(left, right); } - @Specialization(guards = "!areSameLength") + @Specialization(guards = "!areSameLength(left, right)") protected RDoubleVector doDoubleVectorDifferentLength(RAbstractDoubleVector left, RAbstractLogicalVector right) { return performDoubleVectorOpDifferentLength(left, RClosures.createLogicalToDoubleVector(right, rightNACheck)); } - @Specialization(guards = "areSameLength") + @Specialization(guards = "areSameLength(left, right)") protected RDoubleVector doDoubleVectorSameLength(RAbstractDoubleVector left, RAbstractLogicalVector right) { return performDoubleVectorOpSameLength(left, RClosures.createLogicalToDoubleVector(right, rightNACheck)); } - @Specialization(guards = "!areSameLength") + @Specialization(guards = "!areSameLength(left, right)") protected RDoubleVector doDoubleVectorDifferentLength(RAbstractLogicalVector left, RAbstractDoubleVector right) { return performDoubleVectorOpDifferentLength(RClosures.createLogicalToDoubleVector(left, leftNACheck), right); } - @Specialization(guards = "areSameLength") + @Specialization(guards = "areSameLength(left, right)") protected RDoubleVector doDoubleVectorSameLength(RAbstractLogicalVector left, RAbstractDoubleVector right) { return performDoubleVectorOpSameLength(RClosures.createLogicalToDoubleVector(left, leftNACheck), right); } - @Specialization(guards = "!areSameLength") + @Specialization(guards = "!areSameLength(left, right)") protected RComplexVector doDoubleVectorDifferentLength(RAbstractDoubleVector left, RAbstractComplexVector right) { return performComplexVectorOpDifferentLength(RClosures.createDoubleToComplexVector(left, leftNACheck), right); } - @Specialization(guards = "areSameLength") + @Specialization(guards = "areSameLength(left, right)") protected RComplexVector doDoubleVectorSameLength(RAbstractDoubleVector left, RAbstractComplexVector right) { return performComplexVectorOpSameLength(RClosures.createDoubleToComplexVector(left, leftNACheck), right); } - @Specialization(guards = "!areSameLength") + @Specialization(guards = "!areSameLength(left, right)") protected RComplexVector doDoubleVectorDifferentLength(RAbstractComplexVector left, RAbstractDoubleVector right) { return performComplexVectorOpDifferentLength(left, RClosures.createDoubleToComplexVector(right, rightNACheck)); } - @Specialization(guards = "areSameLength") + @Specialization(guards = "areSameLength(left, right)") protected RComplexVector doDoubleVectorSameLength(RAbstractComplexVector left, RAbstractDoubleVector right) { return performComplexVectorOpSameLength(left, RClosures.createDoubleToComplexVector(right, rightNACheck)); } // logical vector and vectors - @Specialization(guards = {"!areSameLength", "supportsIntResult"}) + @Specialization(guards = {"!areSameLength(left, right)", "supportsIntResult()"}) protected RIntVector doLogicalVectorDifferentLength(RAbstractLogicalVector left, RAbstractLogicalVector right) { return performIntVectorOpDifferentLength(RClosures.createLogicalToIntVector(left, leftNACheck), RClosures.createLogicalToIntVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "supportsIntResult"}) + @Specialization(guards = {"areSameLength(left, right)", "supportsIntResult()"}) protected RIntVector doLogicalVectorSameLength(RAbstractLogicalVector left, RAbstractLogicalVector right) { return performIntVectorOpSameLength(RClosures.createLogicalToIntVector(left, leftNACheck), RClosures.createLogicalToIntVector(right, rightNACheck)); } - @Specialization(guards = "!areSameLength") + @Specialization(guards = "!areSameLength(left, right)") protected RComplexVector doLogicalVectorDifferentLength(RAbstractLogicalVector left, RAbstractComplexVector right) { return performComplexVectorOpDifferentLength(RClosures.createLogicalToComplexVector(left, leftNACheck), right); } - @Specialization(guards = "areSameLength") + @Specialization(guards = "areSameLength(left, right)") protected RComplexVector doLogicalVectorSameLength(RAbstractLogicalVector left, RAbstractComplexVector right) { return performComplexVectorOpSameLength(RClosures.createLogicalToComplexVector(left, leftNACheck), right); } - @Specialization(guards = "!areSameLength") + @Specialization(guards = "!areSameLength(left, right)") protected RComplexVector doLogicalVectorDifferentLength(RAbstractComplexVector left, RAbstractLogicalVector right) { return performComplexVectorOpDifferentLength(left, RClosures.createLogicalToComplexVector(right, rightNACheck)); } - @Specialization(guards = "areSameLength") + @Specialization(guards = "areSameLength(left, right)") protected RComplexVector doLogicalVectorSameLength(RAbstractComplexVector left, RAbstractLogicalVector right) { return performComplexVectorOpSameLength(left, RClosures.createLogicalToComplexVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "!supportsIntResult"}) + @Specialization(guards = {"!areSameLength(left, right)", "!supportsIntResult()"}) protected RDoubleVector doLogicalVectorDoubleDifferentLength(RAbstractLogicalVector left, RAbstractLogicalVector right) { return performIntVectorOpDoubleDifferentLength(RClosures.createLogicalToIntVector(left, leftNACheck), RClosures.createLogicalToIntVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "!supportsIntResult"}) + @Specialization(guards = {"areSameLength(left, right)", "!supportsIntResult()"}) protected RDoubleVector doLogicalVectorDoubleSameLength(RAbstractLogicalVector left, RAbstractLogicalVector right) { return performIntVectorOpDoubleSameLength(RClosures.createLogicalToIntVector(left, leftNACheck), RClosures.createLogicalToIntVector(right, rightNACheck)); } // complex vector and vectors - @Specialization(guards = "!areSameLength") + @Specialization(guards = "!areSameLength(left, right)") protected RComplexVector doComplexVectorDifferentLength(RAbstractComplexVector left, RAbstractComplexVector right) { return performComplexVectorOpDifferentLength(left, right); } - @Specialization(guards = "areSameLength") + @Specialization(guards = "areSameLength(left, right)") protected RComplexVector doComplexVectorSameLength(RAbstractComplexVector left, RAbstractComplexVector right) { return performComplexVectorOpSameLength(left, right); } @@ -718,24 +717,12 @@ public abstract class BinaryArithmeticNode extends RBuiltinNode { return RDataFactory.createNAVector(Math.max(left.getLength(), right.getLength())); } - protected boolean nonNumeric(@SuppressWarnings("unused") RNull left, RAbstractContainer right) { - return right.getElementClass() == RString.class || right.getElementClass() == RRaw.class; + protected boolean nonNumeric(RAbstractContainer operand) { + return operand.getElementClass() == RString.class || operand.getElementClass() == RRaw.class; } - protected boolean nonNumeric(RAbstractContainer left) { - return left.getElementClass() == RString.class || left.getElementClass() == RRaw.class; - } - - protected boolean isFactorLeft(RAbstractContainer left) { - return left.getElementClass() == RFactor.class; - } - - protected boolean isFactorRight(@SuppressWarnings("unused") RAbstractStringVector left, RAbstractContainer right) { - return right.getElementClass() == RFactor.class; - } - - protected boolean isFactorRight(@SuppressWarnings("unused") RAbstractRawVector left, RAbstractContainer right) { - return right.getElementClass() == RFactor.class; + protected boolean isFactor(RAbstractContainer operand) { + return operand.getElementClass() == RFactor.class; } // implementation diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNode.java index f3bd752b4c8f38eda500b7936e7beb75fcd7c2ca..2e6271e738f7927223194bccb81fd882a04405a8 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNode.java @@ -43,7 +43,6 @@ import com.oracle.truffle.r.runtime.ops.na.*; import static com.oracle.truffle.r.runtime.RRuntime.*; @SuppressWarnings("unused") -@GenerateNodeFactory public abstract class BinaryBooleanNode extends RBuiltinNode { protected abstract Object execute(VirtualFrame frame, Object left, Object right); @@ -86,44 +85,36 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { // empty raw vectors - public static boolean isEmpty(RAbstractVector left, Object right) { + public static boolean isEmpty(RAbstractVector left) { return left.getLength() == 0; } - public static boolean isEmpty(Object left, RAbstractVector right) { - return right.getLength() == 0; - } - - public static boolean isEmpty(RAbstractVector left, RAbstractVector right) { - return left.getLength() == 0 || right.getLength() == 0; - } - - @Specialization(guards = {"isEmpty", "expectLogical"}) + @Specialization(guards = {"isEmpty(left)", "expectLogical()"}) protected RLogicalVector doEmptyLogical(RAbstractRawVector left, RRaw right) { return RDataFactory.createLogicalVector(0); } - @Specialization(guards = {"isEmpty", "expectLogical"}) + @Specialization(guards = {"isEmpty(right)", "expectLogical()"}) protected RLogicalVector doEmptyLogical(RRaw left, RAbstractRawVector right) { return RDataFactory.createLogicalVector(0); } - @Specialization(guards = {"isEmpty", "!expectLogical"}) + @Specialization(guards = {"isEmpty(left)", "!expectLogical()"}) protected RAbstractRawVector doEmptyRaw(RAbstractRawVector left, RRaw right) { return RDataFactory.createRawVector(0); } - @Specialization(guards = {"isEmpty", "!expectLogical"}) + @Specialization(guards = {"isEmpty(right)", "!expectLogical()"}) protected RAbstractRawVector doEmptyRaw(RRaw left, RAbstractRawVector right) { return RDataFactory.createRawVector(0); } - @Specialization(guards = {"isEmpty", "expectLogical"}) + @Specialization(guards = {"isEmpty(left) || isEmpty(right)", "expectLogical()"}) protected RLogicalVector doEmptyLogical(RAbstractRawVector left, RAbstractRawVector right) { return RDataFactory.createLogicalVector(0); } - @Specialization(guards = {"isEmpty", "!expectLogical"}) + @Specialization(guards = {"isEmpty(left) || isEmpty(right)", "!expectLogical()"}) protected RAbstractRawVector doEmptyRaw(RAbstractRawVector left, RAbstractRawVector right) { return RDataFactory.createRawVector(0); } @@ -212,12 +203,12 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { return logic.op(left, RRuntime.double2complex(right)); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected byte doDouble(double left, RRaw right) { return logic.op(left, RRuntime.raw2double(right)); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected byte doDouble(RRaw left, double right) { return logic.op(RRuntime.raw2double(left), right); } @@ -249,12 +240,12 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { return logic.op(left, RRuntime.logical2complex(right)); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected byte doLogical(byte left, RRaw right) { return logic.op(left, RRuntime.raw2int(right)); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected byte doLogical(RRaw left, byte right) { return logic.op(RRuntime.raw2int(left), right); } @@ -276,12 +267,12 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { return logic.op(RRuntime.complexToString(left), right); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected byte doString(String left, RRaw right) { return logic.op(left, RRuntime.rawToString(right)); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected byte doString(RRaw left, String right) { return logic.op(RRuntime.rawToString(left), right); } @@ -293,24 +284,24 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { return logic.op(left, right); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected byte doComplex(RComplex left, RRaw right) { return logic.op(left, RRuntime.raw2complex(right)); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected byte doComplex(RRaw left, RComplex right) { return logic.op(RRuntime.raw2complex(left), right); } // raw - @Specialization(guards = "!convertRawToNumeric") + @Specialization(guards = "!convertRawToNumeric()") protected RRaw doRawRaw(RRaw left, RRaw right) { return logic.op(left, right); } - @Specialization(guards = "convertRawToNumeric") + @Specialization(guards = "convertRawToNumeric()") protected byte doRawLogical(RRaw left, RRaw right) { return logic.op(RRuntime.raw2int(left), RRuntime.raw2int(right)); } @@ -322,46 +313,46 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { return RDataFactory.createLogicalVector(0); } - @Specialization(guards = "!isFactor") + @Specialization(guards = "!isFactor(right)") protected RLogicalVector doNull(RNull left, RAbstractContainer right) { return RDataFactory.createLogicalVector(0); } - @Specialization(guards = "!isFactor") + @Specialization(guards = "!isFactor(left)") protected RLogicalVector doNull(RAbstractContainer left, RNull right) { return RDataFactory.createLogicalVector(0); } - @Specialization(guards = "!meaningfulOp") + @Specialization(guards = "!meaningfulOp(left)") protected RLogicalVector doFactorOpError(RFactor left, RNull right) { RError.warning(getEncapsulatingSourceSection(), RError.Message.NOT_MEANINGFUL_FOR_FACTORS, logic.opName()); return RDataFactory.createNAVector(left.getLength() == 0 ? 1 : left.getLength()); } - @Specialization(guards = "!meaningfulOp") + @Specialization(guards = "!meaningfulOp(right)") protected RLogicalVector doFactorOpError(RNull left, RFactor right) { RError.warning(getEncapsulatingSourceSection(), RError.Message.NOT_MEANINGFUL_FOR_FACTORS, logic.opName()); return RDataFactory.createNAVector(right.getLength() == 0 ? 1 : right.getLength()); } - @Specialization(guards = "meaningfulOp") + @Specialization(guards = "meaningfulOp(left)") protected RLogicalVector doFactorOp(RFactor left, RNull right) { return RDataFactory.createLogicalVector(0); } - @Specialization(guards = "meaningfulOp") + @Specialization(guards = "meaningfulOp(right)") protected RLogicalVector doFactorOp(RNull left, RFactor right) { return RDataFactory.createLogicalVector(0); } // empty vectors - @Specialization(guards = "isEmpty") + @Specialization(guards = "isEmpty(left)") protected RLogicalVector doEmpty(RAbstractVector left, Object right) { return RDataFactory.createLogicalVector(0); } - @Specialization(guards = "isEmpty") + @Specialization(guards = "isEmpty(right)") protected RLogicalVector doEmpty(Object left, RAbstractVector right) { return RDataFactory.createLogicalVector(0); } @@ -418,12 +409,12 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { return performIntVectorOp(right, left, true); } - @Specialization(guards = "convertRawToNumericVector") + @Specialization(guards = "convertRawToNumericVector()") protected RLogicalVector doIntVectorOp(RAbstractIntVector left, RRaw right) { return performIntVectorOp(left, RRuntime.raw2double(right), false); } - @Specialization(guards = "convertRawToNumericVector") + @Specialization(guards = "convertRawToNumericVector()") protected RLogicalVector doIntVectorOp(RRaw left, RAbstractIntVector right) { return performIntVectorOp(right, RRuntime.raw2double(left), true); } @@ -480,12 +471,12 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { return performDoubleVectorOp(right, left, true); } - @Specialization(guards = "convertRawToNumericVector") + @Specialization(guards = "convertRawToNumericVector()") protected RLogicalVector doDoubleVectorOp(RAbstractDoubleVector left, RRaw right) { return performDoubleVectorOp(left, RRuntime.raw2double(right), false); } - @Specialization(guards = "convertRawToNumericVector") + @Specialization(guards = "convertRawToNumericVector()") protected RLogicalVector doDoubleVectorOp(RRaw left, RAbstractDoubleVector right) { return performDoubleVectorOp(right, RRuntime.raw2double(left), true); } @@ -542,12 +533,12 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { return performLogicalVectorOp(right, left, true); } - @Specialization(guards = "convertRawToNumericVector") + @Specialization(guards = "convertRawToNumericVector()") protected RLogicalVector doLogicalVectorOp(RLogicalVector left, RRaw right) { return performLogicalVectorOp(left, RRuntime.raw2double(right), false); } - @Specialization(guards = "convertRawToNumericVector") + @Specialization(guards = "convertRawToNumericVector()") protected RLogicalVector doLogicalVectorOp(RRaw left, RLogicalVector right) { return performLogicalVectorOp(right, RRuntime.raw2double(left), true); } @@ -604,12 +595,12 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { return performStringVectorOp(right, RRuntime.complexToString(left), true); } - @Specialization(guards = "convertRawToNumericVector") + @Specialization(guards = "convertRawToNumericVector()") protected RLogicalVector doStringVectorOp(RAbstractStringVector left, RRaw right) { return performStringVectorOp(left, RRuntime.rawToString(right), false); } - @Specialization(guards = "convertRawToNumericVector") + @Specialization(guards = "convertRawToNumericVector()") protected RLogicalVector doStringVectorOp(RRaw left, RAbstractStringVector right) { return performStringVectorOp(right, RRuntime.rawToString(left), true); } @@ -666,89 +657,89 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { return performComplexVectorOp(right, left, true); } - @Specialization(guards = "convertRawToNumericVector") + @Specialization(guards = "convertRawToNumericVector()") protected RLogicalVector doComplexVectorOp(RAbstractComplexVector left, RRaw right) { return performComplexVectorOp(left, RRuntime.raw2complex(right), false); } - @Specialization(guards = "convertRawToNumericVector") + @Specialization(guards = "convertRawToNumericVector()") protected RLogicalVector doComplexVectorOp(RRaw left, RAbstractComplexVector right) { return performComplexVectorOp(right, RRuntime.raw2complex(left), true); } // raw vector and scalar - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected RLogicalVector doRawVectorOp(RAbstractRawVector left, int right) { return performRawVectorOp(left, RRuntime.int2double(right), false); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected RLogicalVector doRawVectorOp(int left, RAbstractRawVector right) { return performRawVectorOp(right, RRuntime.int2double(left), true); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected RLogicalVector doRawVectorOp(RAbstractRawVector left, double right) { return performRawVectorOp(left, right, false); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected RLogicalVector doRawVectorOp(double left, RAbstractRawVector right) { return performRawVectorOp(right, left, true); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected RLogicalVector doRawVectorOp(RAbstractRawVector left, byte right) { return performRawVectorOp(left, RRuntime.logical2int(right), false); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected RLogicalVector doRawVectorOp(byte left, RAbstractRawVector right) { return performRawVectorOp(right, RRuntime.logical2int(left), true); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected RLogicalVector doRawVectorOp(RAbstractRawVector left, String right) { return performRawVectorOp(left, right, false); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected RLogicalVector doRawVectorOp(String left, RAbstractRawVector right) { return performRawVectorOp(right, left, true); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected RLogicalVector doRawVectorOp(RAbstractRawVector left, RComplex right) { return performRawVectorOp(left, right, false); } - @Specialization(guards = "convertRawToNumericObject") + @Specialization(guards = "convertRawToNumericObject()") protected RLogicalVector doRawVectorOp(RComplex left, RAbstractRawVector right) { return performRawVectorOp(right, left, true); } - @Specialization(guards = "convertRawToNumeric") + @Specialization(guards = "convertRawToNumeric()") protected RLogicalVector doRawVectorOpLogical(RAbstractRawVector left, RRaw right) { return performRawVectorOp(left, RRuntime.raw2int(right), false); } - @Specialization(guards = "convertRawToNumeric") + @Specialization(guards = "convertRawToNumeric()") protected RLogicalVector doRawVectorOpLogical(RRaw left, RAbstractRawVector right) { return performRawVectorOp(right, RRuntime.raw2int(left), true); } - @Specialization(guards = "!convertRawToNumeric") + @Specialization(guards = "!convertRawToNumeric()") protected RAbstractRawVector doRawVectorOpRaw(RAbstractRawVector left, RRaw right) { return performRawVectorOp(left, right, false); } - @Specialization(guards = "!convertRawToNumeric") + @Specialization(guards = "!convertRawToNumeric()") protected RAbstractRawVector doRawVectorOpRaw(RRaw left, RAbstractRawVector right) { return performRawVectorOp(right, left, true); } - @Specialization(guards = "differentDimensions") + @Specialization(guards = "differentDimensions(left, right)") protected RLogicalVector doIntVectorDifferentLength(RAbstractVector left, RAbstractVector right) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.NON_CONFORMABLE_ARRAYS); } @@ -773,362 +764,362 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { // int vector and vectors - @Specialization(guards = {"!areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorDifferentLength(RAbstractIntVector left, RAbstractIntVector right) { return performIntVectorOpDifferentLength(left, right); } - @Specialization(guards = {"areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorSameLength(RAbstractIntVector left, RAbstractIntVector right) { return performIntVectorOpSameLength(left, right); } - @Specialization(guards = {"!areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorDifferentLength(RAbstractIntVector left, RAbstractDoubleVector right) { return performDoubleVectorOpDifferentLength(RClosures.createIntToDoubleVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorSameLength(RAbstractIntVector left, RAbstractDoubleVector right) { return performDoubleVectorOpSameLength(RClosures.createIntToDoubleVector(left, leftNACheck), right); } - @Specialization(guards = {"!areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorDifferentLength(RAbstractDoubleVector left, RAbstractIntVector right) { return performDoubleVectorOpDifferentLength(left, RClosures.createIntToDoubleVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorIntVectorSameLength(RAbstractDoubleVector left, RAbstractIntVector right) { return performDoubleVectorOpSameLength(left, RClosures.createIntToDoubleVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorDifferentLength(RAbstractIntVector left, RAbstractLogicalVector right) { return performIntVectorOpDifferentLength(left, RClosures.createLogicalToIntVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorSameLength(RAbstractIntVector left, RAbstractLogicalVector right) { return performIntVectorOpSameLength(left, RClosures.createLogicalToIntVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorDifferentLength(RAbstractLogicalVector left, RAbstractIntVector right) { return performIntVectorOpDifferentLength(RClosures.createLogicalToIntVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorSameLength(RAbstractLogicalVector left, RAbstractIntVector right) { return performIntVectorOpSameLength(RClosures.createLogicalToIntVector(left, leftNACheck), right); } - @Specialization(guards = {"!areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorDifferentLength(RAbstractIntVector left, RAbstractStringVector right) { return performStringVectorOpDifferentLength(RClosures.createIntToStringVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorSameLength(RAbstractIntVector left, RAbstractStringVector right) { return performStringVectorOpSameLength(RClosures.createIntToStringVector(left, leftNACheck), right); } - @Specialization(guards = {"!areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorDifferentLength(RAbstractStringVector left, RAbstractIntVector right) { return performStringVectorOpDifferentLength(left, RClosures.createIntToStringVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorSameLength(RAbstractStringVector left, RAbstractIntVector right) { return performStringVectorOpSameLength(left, RClosures.createIntToStringVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorDifferentLength(RAbstractIntVector left, RAbstractComplexVector right) { return performComplexVectorOpDifferentLength(RClosures.createIntToComplexVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorSameLength(RAbstractIntVector left, RAbstractComplexVector right) { return performComplexVectorOpSameLength(RClosures.createIntToComplexVector(left, leftNACheck), right); } - @Specialization(guards = {"!areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorDifferentLength(RAbstractComplexVector left, RAbstractIntVector right) { return performComplexVectorOpDifferentLength(left, RClosures.createIntToComplexVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doIntVectorSameLength(RAbstractComplexVector left, RAbstractIntVector right) { return performComplexVectorOpSameLength(left, RClosures.createIntToComplexVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "convertRawToNumericVector"}) + @Specialization(guards = {"!areSameLength(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doIntVectorDifferentLength(RAbstractIntVector left, RAbstractRawVector right) { return performIntVectorOpDifferentLength(left, RClosures.createRawToIntVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "convertRawToNumericVector"}) + @Specialization(guards = {"areSameLength(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doIntVectorSameLength(RAbstractIntVector left, RAbstractRawVector right) { return performIntVectorOpSameLength(left, RClosures.createRawToIntVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "convertRawToNumericVector"}) + @Specialization(guards = {"!areSameLength(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doIntVectorDifferentLength(RAbstractRawVector left, RAbstractIntVector right) { return performIntVectorOpDifferentLength(RClosures.createRawToIntVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "convertRawToNumericVector"}) + @Specialization(guards = {"areSameLength(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doIntVectorSameLength(RAbstractRawVector left, RAbstractIntVector right) { return performIntVectorOpSameLength(RClosures.createRawToIntVector(left, leftNACheck), right); } // double vector and vectors - @Specialization(guards = {"!areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doDoubleVectorDifferentLength(RAbstractDoubleVector left, RAbstractDoubleVector right) { return performDoubleVectorOpDifferentLength(left, right); } - @Specialization(guards = {"areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doDoubleVectorSameLength(RAbstractDoubleVector left, RAbstractDoubleVector right) { return performDoubleVectorOpSameLength(left, right); } - @Specialization(guards = {"!areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doDoubleVectorDifferentLength(RAbstractDoubleVector left, RAbstractLogicalVector right) { return performDoubleVectorOpDifferentLength(left, RClosures.createLogicalToDoubleVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doDoubleVectorSameLength(RAbstractDoubleVector left, RAbstractLogicalVector right) { return performDoubleVectorOpSameLength(left, RClosures.createLogicalToDoubleVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doDoubleVectorDifferentLength(RAbstractLogicalVector left, RAbstractDoubleVector right) { return performDoubleVectorOpDifferentLength(RClosures.createLogicalToDoubleVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doDoubleVectorSameLength(RAbstractLogicalVector left, RAbstractDoubleVector right) { return performDoubleVectorOpSameLength(RClosures.createLogicalToDoubleVector(left, leftNACheck), right); } - @Specialization(guards = {"!areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doDoubleVectorDifferentLength(RAbstractDoubleVector left, RAbstractStringVector right) { return performStringVectorOpDifferentLength(RClosures.createDoubleToStringVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doDoubleVectorSameLength(RAbstractDoubleVector left, RAbstractStringVector right) { return performStringVectorOpSameLength(RClosures.createDoubleToStringVector(left, leftNACheck), right); } - @Specialization(guards = {"!areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doDoubleVectorDifferentLength(RAbstractStringVector left, RAbstractDoubleVector right) { return performStringVectorOpDifferentLength(left, RClosures.createDoubleToStringVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doDoubleVectorSameLength(RAbstractStringVector left, RAbstractDoubleVector right) { return performStringVectorOpSameLength(left, RClosures.createDoubleToStringVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doDoubleVectorDifferentLength(RAbstractDoubleVector left, RAbstractComplexVector right) { return performComplexVectorOpDifferentLength(RClosures.createDoubleToComplexVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doDoubleVectorSameLength(RAbstractDoubleVector left, RAbstractComplexVector right) { return performComplexVectorOpSameLength(RClosures.createDoubleToComplexVector(left, leftNACheck), right); } - @Specialization(guards = {"!areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doDoubleVectorDifferentLength(RAbstractComplexVector left, RAbstractDoubleVector right) { return performComplexVectorOpDifferentLength(left, RClosures.createDoubleToComplexVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "notEmpty", "!differentDimensions"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!differentDimensions(left, right)"}) protected RLogicalVector doDoubleVectorSameLength(RAbstractComplexVector left, RAbstractDoubleVector right) { return performComplexVectorOpSameLength(left, RClosures.createDoubleToComplexVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "convertRawToNumericVector"}) + @Specialization(guards = {"!areSameLength(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doDoubleVectorDifferentLength(RAbstractDoubleVector left, RAbstractRawVector right) { return performDoubleVectorOpDifferentLength(left, RClosures.createRawToDoubleVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "convertRawToNumericVector"}) + @Specialization(guards = {"areSameLength(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doDoubleVectorSameLength(RAbstractDoubleVector left, RAbstractRawVector right) { return performDoubleVectorOpSameLength(left, RClosures.createRawToDoubleVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "convertRawToNumericVector"}) + @Specialization(guards = {"!areSameLength(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doDoubleVectorDifferentLength(RAbstractRawVector left, RAbstractDoubleVector right) { return performDoubleVectorOpDifferentLength(RClosures.createRawToDoubleVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "convertRawToNumericVector"}) + @Specialization(guards = {"areSameLength(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doDoubleVectorSameLength(RAbstractRawVector left, RAbstractDoubleVector right) { return performDoubleVectorOpSameLength(RClosures.createRawToDoubleVector(left, leftNACheck), right); } // logical vector and vectors - @Specialization(guards = {"!areSameLength", "notEmpty"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doLogicalVectorDifferentLength(RLogicalVector left, RLogicalVector right) { return performIntVectorOpDifferentLength(RClosures.createLogicalToIntVector(left, leftNACheck), RClosures.createLogicalToIntVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "notEmpty"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doLogicalVectorSameLength(RLogicalVector left, RLogicalVector right) { return performIntVectorOpSameLength(RClosures.createLogicalToIntVector(left, leftNACheck), RClosures.createLogicalToIntVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "notEmpty"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doLogicalVectorDifferentLength(RAbstractLogicalVector left, RAbstractStringVector right) { return performStringVectorOpDifferentLength(RClosures.createLogicalToStringVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "notEmpty"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doLogicalVectorSameLength(RAbstractLogicalVector left, RAbstractStringVector right) { return performStringVectorOpSameLength(RClosures.createLogicalToStringVector(left, leftNACheck), right); } - @Specialization(guards = {"!areSameLength", "notEmpty"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doLogicalVectorDifferentLength(RAbstractStringVector left, RAbstractLogicalVector right) { return performStringVectorOpDifferentLength(left, RClosures.createLogicalToStringVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "notEmpty"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doLogicalVectorSameLength(RAbstractStringVector left, RAbstractLogicalVector right) { return performStringVectorOpSameLength(left, RClosures.createLogicalToStringVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "notEmpty"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doLogicalVectorDifferentLength(RAbstractLogicalVector left, RAbstractComplexVector right) { return performComplexVectorOpDifferentLength(RClosures.createLogicalToComplexVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "notEmpty"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doLogicalVectorSameLength(RAbstractLogicalVector left, RAbstractComplexVector right) { return performComplexVectorOpSameLength(RClosures.createLogicalToComplexVector(left, leftNACheck), right); } - @Specialization(guards = {"!areSameLength", "notEmpty"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doLogicalVectorDifferentLength(RAbstractComplexVector left, RAbstractLogicalVector right) { return performComplexVectorOpDifferentLength(left, RClosures.createLogicalToComplexVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "notEmpty"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doLogicalVectorSameLength(RAbstractComplexVector left, RAbstractLogicalVector right) { return performComplexVectorOpSameLength(left, RClosures.createLogicalToComplexVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "convertRawToNumericVector"}) + @Specialization(guards = {"!areSameLength(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doLogicalVectorDifferentLength(RAbstractLogicalVector left, RAbstractRawVector right) { return performIntVectorOpDifferentLength(RClosures.createLogicalToIntVector(left, leftNACheck), RClosures.createRawToIntVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "convertRawToNumericVector"}) + @Specialization(guards = {"areSameLength(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doLogicalVectorSameLength(RAbstractLogicalVector left, RAbstractRawVector right) { return performIntVectorOpSameLength(RClosures.createLogicalToIntVector(left, leftNACheck), RClosures.createRawToIntVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "convertRawToNumericVector"}) + @Specialization(guards = {"!areSameLength(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doLogicalVectorDifferentLength(RAbstractRawVector left, RAbstractLogicalVector right) { return performIntVectorOpDifferentLength(RClosures.createRawToIntVector(left, leftNACheck), RClosures.createLogicalToIntVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "convertRawToNumericVector"}) + @Specialization(guards = {"areSameLength(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doLogicalVectorSameLength(RAbstractRawVector left, RAbstractLogicalVector right) { return performIntVectorOpSameLength(RClosures.createRawToIntVector(left, leftNACheck), RClosures.createLogicalToIntVector(right, rightNACheck)); } // string vector and vectors - @Specialization(guards = {"!areSameLength", "notEmpty"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doStringVectorDifferentLength(RAbstractStringVector left, RAbstractStringVector right) { return performStringVectorOpDifferentLength(left, right); } - @Specialization(guards = {"areSameLength", "notEmpty"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doStringVectorSameLength(RAbstractStringVector left, RAbstractStringVector right) { return performStringVectorOpSameLength(left, right); } - @Specialization(guards = {"!areSameLength", "notEmpty"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doStringVectorDifferentLength(RAbstractStringVector left, RAbstractComplexVector right) { return performStringVectorOpDifferentLength(left, RClosures.createComplexToStringVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "notEmpty"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doStringVectorSameLength(RAbstractStringVector left, RAbstractComplexVector right) { return performStringVectorOpSameLength(left, RClosures.createComplexToStringVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "notEmpty"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doStringVectorDifferentLength(RAbstractComplexVector left, RAbstractStringVector right) { return performStringVectorOpDifferentLength(RClosures.createComplexToStringVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "notEmpty"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doStringVectorSameLength(RAbstractComplexVector left, RAbstractStringVector right) { return performStringVectorOpSameLength(RClosures.createComplexToStringVector(left, leftNACheck), right); } - @Specialization(guards = {"!areSameLength", "convertRawToNumericVector"}) + @Specialization(guards = {"!areSameLength(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doStringVectorDifferentLength(RAbstractStringVector left, RAbstractRawVector right) { return performStringVectorOpDifferentLength(left, RClosures.createRawToStringVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "convertRawToNumericVector"}) + @Specialization(guards = {"areSameLength(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doStringVectorSameLength(RAbstractStringVector left, RAbstractRawVector right) { return performStringVectorOpSameLength(left, RClosures.createRawToStringVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "convertRawToNumericVector"}) + @Specialization(guards = {"!areSameLength(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doStringVectorDifferentLengthRAbstractRawVector(RAbstractRawVector left, RAbstractStringVector right) { return performStringVectorOpDifferentLength(RClosures.createRawToStringVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "convertRawToNumericVector"}) + @Specialization(guards = {"areSameLength(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doStringVectorSameLengthRAbstractRawVector(RAbstractRawVector left, RAbstractStringVector right) { return performStringVectorOpSameLength(RClosures.createRawToStringVector(left, leftNACheck), right); } // factor and vectors - @Specialization(guards = "meaningfulOp") + @Specialization(guards = "meaningfulOp(left, right)") protected Object doFactorOp(VirtualFrame frame, RFactor left, RFactor right) { return recursiveOp(frame, RClosures.createFactorToVector(left, leftNACheck), RClosures.createFactorToVector(right, rightNACheck)); } - @Specialization(guards = {"meaningfulOp", "!isFactor"}) + @Specialization(guards = {"meaningfulOp(left)", "!isFactor(right)"}) protected Object doFactorOp(VirtualFrame frame, RFactor left, RAbstractContainer right) { return recursiveOp(frame, RClosures.createFactorToVector(left, leftNACheck), right); } - @Specialization(guards = {"meaningfulOp", "!isFactor"}) + @Specialization(guards = {"meaningfulOp(right)", "!isFactor(right)"}) protected Object doFactorOp(VirtualFrame frame, RAbstractContainer left, RFactor right) { return recursiveOp(frame, left, RClosures.createFactorToVector(right, rightNACheck)); } - @Specialization(guards = "!meaningfulOp") + @Specialization(guards = "!meaningfulOp(left, right)") protected RLogicalVector doFactorOpNotMeaningful(RFactor left, RFactor right) { RError.warning(getEncapsulatingSourceSection(), RError.Message.NOT_MEANINGFUL_FOR_FACTORS, logic.opName()); return RDataFactory.createNAVector(Math.max(left.getLength(), right.getLength())); } - @Specialization(guards = {"!meaningfulOp", "!isFactor"}) + @Specialization(guards = {"!meaningfulOp(left)", "!isFactor(right)"}) protected RLogicalVector doFactorOpNotMeaningful(RFactor left, RAbstractContainer right) { RError.warning(getEncapsulatingSourceSection(), RError.Message.NOT_MEANINGFUL_FOR_FACTORS, logic.opName()); return RDataFactory.createNAVector(Math.max(left.getLength(), right.getLength())); } - @Specialization(guards = {"!meaningfulOp", "!isFactor"}) + @Specialization(guards = {"!meaningfulOp(right)", "!isFactor(right)"}) protected RLogicalVector doFactorOpNotMeaningful(RAbstractContainer left, RFactor right) { RError.warning(getEncapsulatingSourceSection(), RError.Message.NOT_MEANINGFUL_FOR_FACTORS, logic.opName()); return RDataFactory.createNAVector(Math.max(left.getLength(), right.getLength())); @@ -1153,54 +1144,54 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { // complex vector and vectors - @Specialization(guards = {"!areSameLength", "notEmpty"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doComplexVectorDifferentLength(RAbstractComplexVector left, RAbstractComplexVector right) { return performComplexVectorOpDifferentLength(left, right); } - @Specialization(guards = {"areSameLength", "notEmpty"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)"}) protected RLogicalVector doComplexVectorSameLength(RAbstractComplexVector left, RAbstractComplexVector right) { return performComplexVectorOpSameLength(left, right); } - @Specialization(guards = {"!areSameLength", "notEmpty", "convertRawToNumericVector"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doComplexVectorDifferentLength(RAbstractComplexVector left, RAbstractRawVector right) { return performComplexVectorOpDifferentLength(left, RClosures.createRawToComplexVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "notEmpty", "convertRawToNumericVector"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doComplexVectorSameLength(RAbstractComplexVector left, RAbstractRawVector right) { return performComplexVectorOpSameLength(left, RClosures.createRawToComplexVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "notEmpty", "convertRawToNumericVector"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doComplexVectorDifferentLength(RAbstractRawVector left, RAbstractComplexVector right) { return performComplexVectorOpDifferentLength(RClosures.createRawToComplexVector(left, leftNACheck), right); } - @Specialization(guards = {"areSameLength", "notEmpty", "convertRawToNumericVector"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "convertRawToNumericVector()"}) protected RLogicalVector doComplexVectorSameLength(RAbstractRawVector left, RAbstractComplexVector right) { return performComplexVectorOpSameLength(RClosures.createRawToComplexVector(left, leftNACheck), right); } // raw vector and vectors - @Specialization(guards = {"!areSameLength", "notEmpty", "convertRawToNumeric"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "convertRawToNumeric()"}) protected RLogicalVector doRawVectorDifferentLengthLogical(RAbstractRawVector left, RAbstractRawVector right) { return performIntVectorOpDifferentLength(RClosures.createRawToIntVector(left, leftNACheck), RClosures.createRawToIntVector(right, rightNACheck)); } - @Specialization(guards = {"areSameLength", "notEmpty", "convertRawToNumeric"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "convertRawToNumeric()"}) protected RLogicalVector doRawVectorSameLengthLogical(RAbstractRawVector left, RAbstractRawVector right) { return performIntVectorOpSameLength(RClosures.createRawToIntVector(left, leftNACheck), RClosures.createRawToIntVector(right, rightNACheck)); } - @Specialization(guards = {"!areSameLength", "notEmpty", "!convertRawToNumeric"}) + @Specialization(guards = {"!areSameLength(left, right)", "notEmpty(left, right)", "!convertRawToNumeric()"}) protected RAbstractRawVector doRawVectorDifferentLengthRaw(RAbstractRawVector left, RAbstractRawVector right) { return performRawVectorOpDifferentLength(left, right); } - @Specialization(guards = {"areSameLength", "notEmpty", "!convertRawToNumeric"}) + @Specialization(guards = {"areSameLength(left, right)", "notEmpty(left, right)", "!convertRawToNumeric()"}) protected RAbstractRawVector doRawVectorSameLengthRaw(RAbstractRawVector left, RAbstractRawVector right) { return performRawVectorOpSameLength(left, right); } @@ -1218,7 +1209,7 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { return logic.op(left, right); } - @Specialization(guards = "rightNotAVector") + @Specialization(guards = "isNotAVector(right)") protected byte doRaw(RAbstractRawVector left, Object right) { // perhaps not the cleanest solution but others would be (unnecessarily) more verbose (e.g. // introduce another abstract method to BooleanOperation just to signal an error in one @@ -1227,7 +1218,7 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { return logic.op(left.getDataAt(0), right); } - @Specialization(guards = "leftNotAVector") + @Specialization(guards = "isNotAVector(left)") protected byte doRaw(Object left, RAbstractRawVector right) { // perhaps not the cleanest solution but others would be (unnecessarily) more verbose (e.g. // introduce another abstract method to BooleanOperation just to signal an error in one @@ -1238,28 +1229,12 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { // guards - protected static boolean rightNotAVector(RAbstractRawVector left, Object right) { - return !(right instanceof RRawVector); - } - - protected static boolean leftNotAVector(Object left, RAbstractRawVector right) { - return !(left instanceof RRawVector); - } - - public boolean isFactor(RAbstractContainer left, RNull right) { - return left.getElementClass() == RFactor.class; + protected static boolean isNotAVector(Object operand) { + return !(operand instanceof RRawVector); } - public boolean isFactor(RNull left, RAbstractContainer right) { - return right.getElementClass() == RFactor.class; - } - - public boolean isFactor(RFactor left, RAbstractContainer right) { - return right.getElementClass() == RFactor.class; - } - - public boolean isFactor(RAbstractContainer left, RFactor right) { - return left.getElementClass() == RFactor.class; + public boolean isFactor(RAbstractContainer operand) { + return operand.getElementClass() == RFactor.class; } public boolean isDataFrame(RDataFrame left, RAbstractContainer right) { @@ -1270,99 +1245,31 @@ public abstract class BinaryBooleanNode extends RBuiltinNode { return left.getElementClass() == RDataFrame.class; } - public boolean meaningfulOp(RFactor left, RFactor right) { + protected boolean meaningfulOp(RFactor left, RFactor right) { return logic instanceof BinaryCompare.Equal || logic instanceof BinaryCompare.NotEqual || (left.isOrdered() && right.isOrdered()); } - public boolean meaningfulOp(RFactor left, RNull right) { - return logic instanceof BinaryCompare.Equal || logic instanceof BinaryCompare.NotEqual || left.isOrdered(); - } - - public boolean meaningfulOp(RNull left, RFactor right) { - return logic instanceof BinaryCompare.Equal || logic instanceof BinaryCompare.NotEqual || right.isOrdered(); - } - - public boolean meaningfulOp(RFactor left, RAbstractContainer right) { - return logic instanceof BinaryCompare.Equal || logic instanceof BinaryCompare.NotEqual || left.isOrdered(); - } - - public boolean meaningfulOp(RAbstractContainer left, RFactor right) { - return logic instanceof BinaryCompare.Equal || logic instanceof BinaryCompare.NotEqual || right.isOrdered(); - } - - public boolean meaningfulOp(RFactor left, Object right) { - return logic instanceof BinaryCompare.Equal || logic instanceof BinaryCompare.NotEqual || left.isOrdered(); - } - - public boolean meaningfulOp(Object left, RFactor right) { - return logic instanceof BinaryCompare.Equal || logic instanceof BinaryCompare.NotEqual || right.isOrdered(); + protected boolean meaningfulOp(RFactor left) { + return logic instanceof BinaryCompare.Equal || logic instanceof BinaryCompare.NotEqual || (left.isOrdered()); } private boolean isVectorizedLogicalOp() { return !(logic instanceof BinaryLogic.And || logic instanceof BinaryLogic.Or); } - public boolean convertRawToNumericObject(RRaw left, Object right) { - return isVectorizedLogicalOp(); - } - - public boolean convertRawToNumericObject(Object left, RRaw right) { - return isVectorizedLogicalOp(); - } - - public boolean convertRawToNumericObject(RAbstractRawVector left, Object right) { - return isVectorizedLogicalOp(); - } - - public boolean convertRawToNumericObject(Object left, RAbstractRawVector right) { - return isVectorizedLogicalOp(); - } - - protected boolean convertRawToNumericVector(RRaw left, RAbstractVector right) { - return isVectorizedLogicalOp(); - } - - protected boolean convertRawToNumericVector(RAbstractVector left, RRaw right) { - return isVectorizedLogicalOp(); - } - - protected boolean convertRawToNumericVector(RAbstractRawVector left, RAbstractVector right) { - return isVectorizedLogicalOp(); - } - - protected boolean convertRawToNumericVector(RAbstractVector left, RAbstractRawVector right) { - return isVectorizedLogicalOp(); - } - - protected boolean convertRawToNumeric(RRaw left, RRaw right) { - return isVectorizedLogicalOp(); - } - - protected boolean convertRawToNumeric(RAbstractRawVector left, RAbstractRawVector right) { - return isVectorizedLogicalOp(); - } - - protected boolean convertRawToNumeric(RRaw left, RAbstractRawVector right) { - return isVectorizedLogicalOp(); - } - - protected boolean convertRawToNumeric(RAbstractRawVector left, RRaw right) { - return isVectorizedLogicalOp(); - } - - protected boolean expectLogical(RRaw left, RRaw right) { + protected boolean convertRawToNumericObject() { return isVectorizedLogicalOp(); } - protected boolean expectLogical(RAbstractRawVector left, RAbstractRawVector right) { + protected boolean convertRawToNumericVector() { return isVectorizedLogicalOp(); } - protected boolean expectLogical(RAbstractRawVector left, RRaw right) { + protected boolean convertRawToNumeric() { return isVectorizedLogicalOp(); } - protected boolean expectLogical(RRaw left, RAbstractRawVector right) { + protected boolean expectLogical() { return isVectorizedLogicalOp(); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNonVectorizedNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNonVectorizedNode.java index 35bbfc61b8db0c26c3577d3d86c6f6d0c35bde84..e76a307420ce38d5e6954b1852501393c4a66386 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNonVectorizedNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNonVectorizedNode.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 @@ -41,7 +41,6 @@ import com.oracle.truffle.r.runtime.ops.na.*; import static com.oracle.truffle.r.runtime.RRuntime.*; @SuppressWarnings("unused") -@GenerateNodeFactory public abstract class BinaryBooleanNonVectorizedNode extends RBuiltinNode { private final BooleanOperationFactory factory; @@ -143,12 +142,12 @@ public abstract class BinaryBooleanNonVectorizedNode extends RBuiltinNode { return left; } - @Specialization(guards = {"needsRightOperand", "!isZeroLength"}) + @Specialization(guards = {"needsRightOperand", "right.getLength() != 0"}) protected byte doLogical(byte left, boolean needsRightOperand, RAbstractIntVector right) { return logic.op(RRuntime.logical2int(left), right.getDataAt(0)); } - @Specialization(guards = {"needsRightOperand", "isZeroLength"}) + @Specialization(guards = {"needsRightOperand", "right.getLength() == 0"}) protected byte doLogicalEmpty(byte left, boolean needsRightOperand, RAbstractIntVector right) { return logic.op(RRuntime.logical2int(left), RRuntime.INT_NA); } @@ -158,12 +157,12 @@ public abstract class BinaryBooleanNonVectorizedNode extends RBuiltinNode { return left; } - @Specialization(guards = {"needsRightOperand", "!isZeroLength"}) + @Specialization(guards = {"needsRightOperand", "right.getLength() != 0"}) protected byte doLogical(byte left, boolean needsRightOperand, RAbstractDoubleVector right) { return logic.op(RRuntime.logical2double(left), right.getDataAt(0)); } - @Specialization(guards = {"needsRightOperand", "isZeroLength"}) + @Specialization(guards = {"needsRightOperand", "right.getLength() == 0"}) protected byte doLogicalEmpty(byte left, boolean needsRightOperand, RAbstractDoubleVector right) { return logic.op(RRuntime.logical2double(left), RRuntime.DOUBLE_NA); } @@ -173,12 +172,12 @@ public abstract class BinaryBooleanNonVectorizedNode extends RBuiltinNode { return left; } - @Specialization(guards = {"needsRightOperand", "!isZeroLength"}) + @Specialization(guards = {"needsRightOperand", "right.getLength() != 0"}) protected byte doLogical(byte left, boolean needsRightOperand, RAbstractLogicalVector right) { return logic.op(RRuntime.logical2int(left), RRuntime.logical2int(right.getDataAt(0))); } - @Specialization(guards = {"needsRightOperand", "isZeroLength"}) + @Specialization(guards = {"needsRightOperand", "right.getLength() == 0"}) protected byte doLogicalEmpty(byte left, boolean needsRightOperand, RAbstractLogicalVector right) { return logic.op(RRuntime.logical2int(left), RRuntime.INT_NA); } @@ -188,12 +187,12 @@ public abstract class BinaryBooleanNonVectorizedNode extends RBuiltinNode { return left; } - @Specialization(guards = {"needsRightOperand", "!isZeroLength"}) + @Specialization(guards = {"needsRightOperand", "right.getLength() != 0"}) protected byte doLogical(byte left, boolean needsRightOperand, RAbstractStringVector right) { return logic.op(RRuntime.logical2int(left), right.getDataAt(0)); } - @Specialization(guards = {"needsRightOperand", "isZeroLength"}) + @Specialization(guards = {"needsRightOperand", "right.getLength() == 0"}) protected byte doLogicalEmpty(byte left, boolean needsRightOperand, RAbstractStringVector right) { return logic.op(RRuntime.logical2int(left), RRuntime.STRING_NA); } @@ -203,12 +202,12 @@ public abstract class BinaryBooleanNonVectorizedNode extends RBuiltinNode { return left; } - @Specialization(guards = {"needsRightOperand", "!isZeroLength"}) + @Specialization(guards = {"needsRightOperand", "right.getLength() != 0"}) protected byte doLogical(byte left, boolean needsRightOperand, RAbstractComplexVector right) { return logic.op(RRuntime.logical2complex(left), right.getDataAt(0)); } - @Specialization(guards = {"needsRightOperand", "isZeroLength"}) + @Specialization(guards = {"needsRightOperand", "right.getLength() == 0"}) protected byte doLogicalEmpty(byte left, boolean needsRightOperand, RAbstractComplexVector right) { return logic.op(RRuntime.logical2complex(left), RRuntime.createComplexNA()); } @@ -218,12 +217,12 @@ public abstract class BinaryBooleanNonVectorizedNode extends RBuiltinNode { return left; } - @Specialization(guards = {"needsRightOperand", "!isZeroLength"}) + @Specialization(guards = {"needsRightOperand", "right.getLength() != 0"}) protected byte doLogical(Object left, boolean needsRightOperand, RAbstractRawVector right) { return logic.op(left, right.getDataAt(0)); } - @Specialization(guards = {"needsRightOperand", "isZeroLength"}) + @Specialization(guards = {"needsRightOperand", "right.getLength() == 0"}) protected byte doLogicalEmpty(Object left, boolean needsRightOperand, RAbstractRawVector right) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_TYPE_IN, "y", logic.opName()); } @@ -288,22 +287,22 @@ public abstract class BinaryBooleanNonVectorizedNode extends RBuiltinNode { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_TYPE_IN, "x", getOpName()); } - @Specialization(guards = {"isZeroLength", "!isStringVector", "!isRawVector"}) + @Specialization(guards = {"operand.getLength() == 0", "!isStringVector(operand)", "!isRawVector(operand)"}) protected byte doLogical(RAbstractVector operand) { return RRuntime.LOGICAL_NA; } - @Specialization(guards = "!isZeroLength") + @Specialization(guards = "operand.getLength() != 0") protected byte doLogical(RAbstractDoubleVector operand) { return RRuntime.double2logical(operand.getDataAt(0)); } - @Specialization(guards = "!isZeroLength") + @Specialization(guards = "operand.getLength() != 0") protected byte doLogical(RAbstractComplexVector operand) { return RRuntime.complex2logical(operand.getDataAt(0)); } - @Specialization(guards = "!isZeroLength") + @Specialization(guards = "operand.getLength() != 0") protected byte doLogical(RAbstractLogicalVector operand) { return operand.getDataAt(0); } @@ -318,20 +317,16 @@ public abstract class BinaryBooleanNonVectorizedNode extends RBuiltinNode { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_TYPE_IN, "x", getOpName()); } - @Specialization(guards = "!isZeroLength") + @Specialization(guards = "operand.getLength() != 0") protected byte doLogical(RAbstractIntVector operand) { return RRuntime.int2logical(operand.getDataAt(0)); } - protected boolean isZeroLength(RAbstractVector operand) { - return operand.getLength() == 0; - } - - protected boolean isStringVector(RAbstractVector vector) { + protected static boolean isStringVector(RAbstractVector vector) { return vector.getElementClass() == RString.class; } - protected boolean isRawVector(RAbstractVector vector) { + protected static boolean isRawVector(RAbstractVector vector) { return vector.getElementClass() == RRaw.class; } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/CastTypeNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/CastTypeNode.java index a5c73fb52762bfc5edabaa93691c43aeb44ebdd9..14d0d58f6b0bdfcceb968f280e259cce302f3672 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/CastTypeNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/CastTypeNode.java @@ -4,14 +4,14 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2014, Purdue University - * Copyright (c) 2014, Oracle and/or its affiliates + * Copyright (c) 2014, 2015, Oracle and/or its affiliates * * All rights reserved. */ package com.oracle.truffle.r.nodes.binary; -import com.oracle.truffle.api.*; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.unary.*; @@ -19,191 +19,70 @@ import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; +@SuppressWarnings("unused") public abstract class CastTypeNode extends BinaryNode { - @Child private CastStringNode castStringNode; - @Child private CastComplexNode castComplexNode; - @Child private CastDoubleNode castDoubleNode; - @Child private CastIntegerNode castIntegerNode; - @Child private CastLogicalNode castLogicalNode; - @Child private CastRawNode castRawNode; - @Child private CastListNode castListNode; - @Child private CastToVectorNode castToVectorNode; - @Child private TypeofNode typeof; + protected static final int NUMBER_OF_TYPES = RType.values().length; - @Child private CastTypeNode castRecursive; + @Child protected TypeofNode typeof = TypeofNodeGen.create(null); public abstract Object execute(VirtualFrame frame, Object value, RType type); - @SuppressWarnings("unused") - @Specialization(guards = "isSameType") - protected RAbstractVector doCast(VirtualFrame frame, RAbstractVector value, RType type) { + @Specialization(guards = "typeof.execute(value) == type") + protected static RAbstractVector doPass(RAbstractVector value, RType type) { return value; } - @SuppressWarnings("unused") - @Specialization(guards = {"!isSameType", "isString"}) - protected Object doCastString(VirtualFrame frame, RAbstractVector value, RType type) { - initCastString(); - return castStringNode.executeString(frame, value); + @Specialization(guards = {"typeof.execute(value) != type", "type == cachedType", "!isNull(cast)"}, limit = "NUMBER_OF_TYPES") + protected static Object doCast(VirtualFrame frame, RAbstractVector value, RType type, // + @Cached("type") RType cachedType, // + @Cached("createCast(cachedType)") CastNode cast) { + return cast.executeCast(frame, value); } - @SuppressWarnings("unused") - @Specialization(guards = {"!isSameType", "isComplex"}) - protected Object doCastComplex(VirtualFrame frame, RAbstractVector value, RType type) { - initCastComplex(); - return castComplexNode.executeComplex(frame, value); - } - - @SuppressWarnings("unused") - @Specialization(guards = {"!isSameType", "isDouble"}) - protected Object doCastDouble(VirtualFrame frame, RAbstractVector value, RType type) { - initCastDouble(); - return castDoubleNode.executeDouble(frame, value); - } - - @SuppressWarnings("unused") - @Specialization(guards = {"!isSameType", "isInteger"}) - protected Object doCastInteger(VirtualFrame frame, RAbstractVector value, RType type) { - initCastInteger(); - return castIntegerNode.executeInt(frame, value); - } - - @SuppressWarnings("unused") - @Specialization(guards = {"!isSameType", "isLogical"}) - protected Object doCastLogical(VirtualFrame frame, RAbstractVector value, RType type) { - initCastLogical(); - return castLogicalNode.executeLogical(frame, value); - } - - @SuppressWarnings("unused") - @Specialization(guards = {"!isSameType", "isRaw"}) - protected Object doCastRaw(VirtualFrame frame, RAbstractVector value, RType type) { - initCastRaw(); - return castRawNode.executeRaw(frame, value); - } - - @SuppressWarnings("unused") - @Specialization(guards = {"!isSameType", "isList"}) - protected RList doCastList(VirtualFrame frame, RAbstractVector value, RType type) { - initCastList(); - return castListNode.executeList(frame, value); - } - - @SuppressWarnings("unused") @Specialization - protected Object doCastUnknown(RAbstractVector value, RType type) { - return null; - } - - @Specialization - protected Object doCastDataFrame(VirtualFrame frame, RDataFrame value, RType type) { - initCastRecursive(); + protected static Object doCastDataFrame(VirtualFrame frame, RDataFrame value, RType type, // + @Cached("create()") CastTypeNode castRecursive) { return castRecursive.execute(frame, value.getVector(), type); } - @SuppressWarnings("unused") - protected static boolean isString(RAbstractVector value, RType type) { - return type == RType.Character; - } - - @SuppressWarnings("unused") - protected static boolean isComplex(RAbstractVector value, RType type) { - return type == RType.Complex; - } - - @SuppressWarnings("unused") - protected static boolean isDouble(final RAbstractVector value, RType type) { - return type == RType.Double || type == RType.Numeric; - } - - @SuppressWarnings("unused") - protected static boolean isInteger(RAbstractVector value, RType type) { - return type == RType.Integer; - } - - @SuppressWarnings("unused") - protected static boolean isLogical(RAbstractVector value, RType type) { - return type == RType.Logical; - } - - @SuppressWarnings("unused") - protected static boolean isRaw(RAbstractVector value, RType type) { - return type == RType.Raw; - } - - @SuppressWarnings("unused") - protected static boolean isList(RAbstractVector value, RType type) { - return type == RType.List; - } - - protected boolean isSameType(VirtualFrame frame, RAbstractVector value, RType type) { - initTypeof(); - RType givenType = typeof.execute(frame, value); - return givenType.getName().equals(type); - } - - private void initTypeof() { - if (typeof == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - typeof = insert(TypeofNodeGen.create(null)); - } - } - - private void initCastString() { - if (castStringNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - castStringNode = insert(CastStringNodeGen.create(null, false, false, false, false)); - } - } - - private void initCastComplex() { - if (castComplexNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - castComplexNode = insert(CastComplexNodeGen.create(null, false, false, false)); - } - } - - private void initCastDouble() { - if (castDoubleNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - castDoubleNode = insert(CastDoubleNodeGen.create(null, false, false, false)); - } - } - - private void initCastInteger() { - if (castIntegerNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - castIntegerNode = insert(CastIntegerNodeGen.create(null, false, false, false)); - } + @Specialization(guards = "isNull(createCast(type))") + @TruffleBoundary + protected static Object doCastUnknown(RAbstractVector value, RType type) { + // FIXME should we really return null here? + return null; } - private void initCastLogical() { - if (castLogicalNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - castLogicalNode = insert(CastLogicalNodeGen.create(null, false, false, false)); - } - } + @TruffleBoundary + protected static CastNode createCast(RType type) { + switch (type) { + case Character: + return CastStringNodeGen.create(null, false, false, false, false); + case Complex: + return CastComplexNodeGen.create(null, false, false, false); + case Double: + case Numeric: + return CastDoubleNodeGen.create(null, false, false, false); + case Integer: + return CastIntegerNodeGen.create(null, false, false, false); + case Logical: + return CastLogicalNodeGen.create(null, false, false, false); + case Raw: + return CastRawNodeGen.create(null, false, false, false); + case List: + return CastListNodeGen.create(null, false, false, false); + default: + return null; - private void initCastRaw() { - if (castRawNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - castRawNode = insert(CastRawNodeGen.create(null, false, false, false)); } } - private void initCastList() { - if (castListNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - castListNode = insert(CastListNodeGen.create(null, false, false, false)); - } + protected static boolean isNull(Object value) { + return value == null; } - private void initCastRecursive() { - if (castRecursive == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - castRecursive = insert(CastTypeNodeGen.create(null, null)); - } + public static CastTypeNode create() { + return CastTypeNodeGen.create(null, null); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/ColonNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/ColonNode.java index 04fc00df8709531318e5d6c296f2d0731fb607b1..824e290895d73fb8078567819a9d59b9ae8cf032 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/ColonNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/ColonNode.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 @@ -55,56 +55,56 @@ public abstract class ColonNode extends RNode implements VisibilityController { } } - @Specialization(guards = "isSmaller") + @Specialization(guards = "left <= right") protected RIntSequence colonAscending(int left, int right) { controlVisibility(); naCheck(RRuntime.isNA(left) || RRuntime.isNA(right)); return RDataFactory.createAscendingRange(left, right); } - @Specialization(guards = "!isSmaller") + @Specialization(guards = "left > right") protected RIntSequence colonDescending(int left, int right) { controlVisibility(); naCheck(RRuntime.isNA(left) || RRuntime.isNA(right)); return RDataFactory.createDescendingRange(left, right); } - @Specialization(guards = "isSmaller") + @Specialization(guards = "asDouble(left) <= right") protected RIntSequence colonAscending(int left, double right) { controlVisibility(); naCheck(RRuntime.isNA(left) || RRuntime.isNAorNaN(right)); return RDataFactory.createAscendingRange(left, (int) right); } - @Specialization(guards = "!isSmaller") + @Specialization(guards = "asDouble(left) > right") protected RIntSequence colonDescending(int left, double right) { controlVisibility(); naCheck(RRuntime.isNA(left) || RRuntime.isNAorNaN(right)); return RDataFactory.createDescendingRange(left, (int) right); } - @Specialization(guards = "isSmaller") + @Specialization(guards = "left <= asDouble(right)") protected RDoubleSequence colonAscending(double left, int right) { controlVisibility(); naCheck(RRuntime.isNAorNaN(left) || RRuntime.isNA(right)); return RDataFactory.createAscendingRange(left, right); } - @Specialization(guards = "!isSmaller") + @Specialization(guards = "left > asDouble(right)") protected RDoubleSequence colonDescending(double left, int right) { controlVisibility(); naCheck(RRuntime.isNAorNaN(left) || RRuntime.isNA(right)); return RDataFactory.createDescendingRange(left, right); } - @Specialization(guards = "isSmaller") + @Specialization(guards = "left <= right") protected RDoubleSequence colonAscending(double left, double right) { controlVisibility(); naCheck(RRuntime.isNAorNaN(left) || RRuntime.isNAorNaN(right)); return RDataFactory.createAscendingRange(left, right); } - @Specialization(guards = "!isSmaller") + @Specialization(guards = "left > right") protected RDoubleSequence colonDescending(double left, double right) { controlVisibility(); naCheck(RRuntime.isNAorNaN(left) || RRuntime.isNAorNaN(right)); @@ -134,20 +134,8 @@ public abstract class ColonNode extends RNode implements VisibilityController { return create(null, getLeft().substitute(env), getRight().substitute(env)); } - public static boolean isSmaller(double left, double right) { - return left <= right; - } - - public static boolean isSmaller(double left, int right) { - return left <= right; - } - - public static boolean isSmaller(int left, double right) { - return left <= right; - } - - public static boolean isSmaller(int left, int right) { - return left <= right; + protected static double asDouble(int intValue) { + return intValue; } @NodeChild("operand") @@ -157,12 +145,12 @@ public abstract class ColonNode extends RNode implements VisibilityController { public abstract RNode getOperand(); - @Specialization(guards = "isIntValue") + @Specialization(guards = "isIntValue(operand)") protected int doDoubleToInt(double operand) { return (int) operand; } - @Specialization(guards = "!isIntValue") + @Specialization(guards = "!isIntValue(operand)") protected double doDouble(double operand) { return operand; } @@ -183,7 +171,7 @@ public abstract class ColonNode extends RNode implements VisibilityController { return vector.getDataAt(0); } - @Specialization(guards = "isFirstIntValue") + @Specialization(guards = "isFirstIntValue(vector)") protected int doDoubleVectorFirstIntValue(RDoubleVector vector) { if (lengthGreaterOne.profile(vector.getLength() > 1)) { RError.warning(getEncapsulatingSourceSection(), RError.Message.ONLY_FIRST_USED, vector.getLength()); @@ -191,7 +179,7 @@ public abstract class ColonNode extends RNode implements VisibilityController { return (int) vector.getDataAt(0); } - @Specialization(guards = "!isFirstIntValue") + @Specialization(guards = "!isFirstIntValue(vector)") protected double doDoubleVector(RDoubleVector vector) { if (lengthGreaterOne.profile(vector.getLength() > 1)) { RError.warning(getEncapsulatingSourceSection(), RError.Message.ONLY_FIRST_USED, vector.getLength()); @@ -209,11 +197,11 @@ public abstract class ColonNode extends RNode implements VisibilityController { return RRuntime.logical2int(operand); } - public static boolean isIntValue(double d) { + protected static boolean isIntValue(double d) { return (((int) d)) == d; } - public static boolean isFirstIntValue(RDoubleVector d) { + protected static boolean isFirstIntValue(RDoubleVector d) { return (((int) d.getDataAt(0))) == d.getDataAt(0); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RBuiltinNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RBuiltinNode.java index 99575679f4390f10f73ef4306f500a89cfb2682c..7d0383b2df4138608c00ff93b159a06547c2bb52 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RBuiltinNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RBuiltinNode.java @@ -22,7 +22,6 @@ */ package com.oracle.truffle.r.nodes.builtin; -import java.lang.reflect.*; import java.util.*; import com.oracle.truffle.api.*; @@ -130,41 +129,6 @@ public abstract class RBuiltinNode extends LeafCallNode implements VisibilityCon return executeDouble(frame); } - /** - * WORKAROUND for recursive sharing bug. A shallow copy is insufficient because is can cause - * shared state in the {@code arguments} field to be overwritten during a re-specialization. - * This is an ugly fix that uses reflection to update the hidden {@code arguments} field, and - * should go away with an upcoming Truffle fix. - */ - @Override - public Node copy() { - RBuiltinNode copy = (RBuiltinNode) super.copy(); - RNode[] args = getArguments(); - RNode[] copyArgs = Arrays.copyOf(args, args.length); - try { - Field field = getArgumentsField(getClass()); - field.setAccessible(true); - field.set(copy, copyArgs); - } catch (IllegalAccessException | NoSuchFieldException ex) { - Utils.fatalError("failed to update RBuiltinNode.arguments"); - } - return copy; - } - - /** - * WORKAROUND support method. - */ - private Field getArgumentsField(Class<?> klass) throws NoSuchFieldException { - if (klass == RBuiltinNode.class) { - throw new NoSuchFieldException(); - } - try { - return klass.getDeclaredField("arguments"); - } catch (NoSuchFieldException ex) { - return getArgumentsField(klass.getSuperclass()); - } - } - private static RNode[] createAccessArgumentsNodes(RBuiltinFactory builtin) { int total = builtin.getRBuiltin().parameterNames().length; RNode[] args = new RNode[total]; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/REntryCounters.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/REntryCounters.java index 53080618ec090e39726c59137f887ee74af5652e..016307ce04637c61b9e91e31d5e4b424a8fba195 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/REntryCounters.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/REntryCounters.java @@ -49,7 +49,7 @@ public class REntryCounters { public final Instrument instrument; public Basic(Object tag) { - instrument = Instrument.create(new SimpleEventReceiver() { + instrument = Instrument.create(new SimpleEventListener() { @Override public void enter(Node node, VirtualFrame frame) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/RNodeTimer.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/RNodeTimer.java index eaa2e505a10874fc13ae94a245a3dfae87d13db5..45ffb38ec4bda09199fbd2610eb5ed1b4ac7fcce 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/RNodeTimer.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/RNodeTimer.java @@ -57,7 +57,7 @@ public class RNodeTimer { public final Instrument instrument; public Basic(RInstrument.NodeId tag) { - instrument = Instrument.create(new SimpleEventReceiver() { + instrument = Instrument.create(new SimpleEventListener() { @Override public void enter(Node node, VirtualFrame frame) { @@ -172,7 +172,7 @@ public class RNodeTimer { } else { long[] time = createLineTimes(fdi); int startLine = ss.getStartLine(); - int lastLine = fdi.source.getLineNumber(ss.getCharEndIndex() - 1); + int lastLine = ss.getEndLine(); for (int i = startLine; i <= lastLine; i++) { RPerfStats.out().printf("%8dms: %s%n", time[i], fdi.source.getCode(i)); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/debug/DebugHandling.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/debug/DebugHandling.java index 8b8c3d7d2e476818a4b56aad8d1cde75d91ba287..63698977082a7630c5722b4cc346e0f731f20646 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/debug/DebugHandling.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/debug/DebugHandling.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -22,34 +22,21 @@ */ package com.oracle.truffle.r.nodes.instrument.debug; -import com.oracle.truffle.api.Assumption; +import java.util.*; + +import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.frame.MaterializedFrame; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.instrument.Instrument; -import com.oracle.truffle.api.instrument.Probe; -import com.oracle.truffle.api.instrument.ProbeNode; +import com.oracle.truffle.api.frame.*; +import com.oracle.truffle.api.instrument.*; import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; -import com.oracle.truffle.api.instrument.StandardSyntaxTag; -import com.oracle.truffle.api.instrument.SyntaxTag; -import com.oracle.truffle.api.instrument.SyntaxTagTrap; -import com.oracle.truffle.api.instrument.TruffleEventReceiver; +import com.oracle.truffle.api.nodes.*; +import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.control.LoopNode; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeVisitor; -import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.utilities.CyclicAssumption; -import com.oracle.truffle.r.nodes.function.FunctionBodyNode; -import com.oracle.truffle.r.nodes.function.FunctionDefinitionNode; -import com.oracle.truffle.r.nodes.function.FunctionStatementsNode; -import com.oracle.truffle.r.nodes.function.FunctionUID; -import com.oracle.truffle.r.nodes.instrument.RInstrument; -import com.oracle.truffle.r.nodes.instrument.RSyntaxTag; +import com.oracle.truffle.r.nodes.function.*; +import com.oracle.truffle.r.nodes.instrument.*; import com.oracle.truffle.r.runtime.*; -import com.oracle.truffle.r.runtime.data.RFunction; - -import java.util.*; +import com.oracle.truffle.r.runtime.data.*; /** * The implementation of the R debug functions. @@ -172,7 +159,7 @@ public class DebugHandling { }); } - private abstract static class DebugEventReceiver implements TruffleEventReceiver { + private abstract static class DebugEventReceiver implements TruffleEventListener { protected final Object text; protected final Object condition; @@ -523,7 +510,7 @@ public class DebugHandling { static void clearTrap() { if (set) { - Probe.clearTagTrap(); + Probe.setTagTrap(null); set = false; } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/trace/TraceHandling.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/trace/TraceHandling.java index 8de84461138566896a442b6dc12c37a74e624b06..25513046b7e9d85d783243ca3adc698731e02244 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/trace/TraceHandling.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/trace/TraceHandling.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -22,24 +22,17 @@ */ package com.oracle.truffle.r.nodes.instrument.trace; +import java.util.*; + import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.instrument.Instrument; -import com.oracle.truffle.api.instrument.Probe; -import com.oracle.truffle.api.instrument.StandardSyntaxTag; -import com.oracle.truffle.api.instrument.TruffleEventReceiver; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.utilities.CyclicAssumption; -import com.oracle.truffle.r.nodes.function.FunctionDefinitionNode; -import com.oracle.truffle.r.nodes.function.FunctionStatementsNode; -import com.oracle.truffle.r.nodes.function.FunctionUID; -import com.oracle.truffle.r.nodes.instrument.RInstrument; -import com.oracle.truffle.r.runtime.RArguments; -import com.oracle.truffle.r.runtime.RContext; -import com.oracle.truffle.r.runtime.RInternalError; -import com.oracle.truffle.r.runtime.data.RFunction; - -import java.util.WeakHashMap; +import com.oracle.truffle.api.frame.*; +import com.oracle.truffle.api.instrument.*; +import com.oracle.truffle.api.nodes.*; +import com.oracle.truffle.api.utilities.*; +import com.oracle.truffle.r.nodes.function.*; +import com.oracle.truffle.r.nodes.instrument.*; +import com.oracle.truffle.r.runtime.*; +import com.oracle.truffle.r.runtime.data.*; public class TraceHandling { @@ -71,7 +64,7 @@ public class TraceHandling { return probe; } - private abstract static class TraceEventReceiver implements TruffleEventReceiver { + private abstract static class TraceEventReceiver implements TruffleEventListener { @CompilationFinal private boolean disabled; CyclicAssumption disabledUnchangedAssumption = new CyclicAssumption("trace event disabled state unchanged"); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java index 35bb8892263530bedbd7e7b83e7c55268383bc66..a2ac32a3383db3a0acb9b6d10b9d76cda2cdfe31 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java @@ -81,17 +81,17 @@ public abstract class CastStringNode extends CastNode { return toString(frame, value); } - @Specialization(guards = "isZeroLength") + @Specialization(guards = "vector.getLength() == 0") protected Object doEmptyVector(@SuppressWarnings("unused") RAbstractVector vector) { return isEmptyVectorConvertedToNull() ? RNull.instance : RDataFactory.createStringVector(0); } - @Specialization(guards = "!isZeroLength") + @Specialization(guards = "vector.getLength() != 0") protected RStringVector doStringVector(RStringVector vector) { return vector; } - @Specialization(guards = "!isZeroLength") + @Specialization(guards = "operand.getLength() != 0") protected RAbstractContainer doIntVector(VirtualFrame frame, RAbstractContainer operand) { String[] sdata = new String[operand.getLength()]; // conversions to character will not introduce new NAs @@ -111,7 +111,4 @@ public abstract class CastStringNode extends CastNode { return s.getName(); } - protected boolean isZeroLength(RAbstractContainer vector) { - return vector.getLength() == 0; - } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToVectorNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToVectorNode.java index 194ab5c5e863dba2bf713bc824cbb27d11192a1a..5443d9fd90f587efe269363af8a86c96f8c33fe1 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToVectorNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToVectorNode.java @@ -34,26 +34,22 @@ public abstract class CastToVectorNode extends CastNode { public abstract boolean isNonVectorPreserved(); - protected boolean preserveNonVector() { - return isNonVectorPreserved(); - } - - @Specialization(guards = "preserveNonVector") + @Specialization(guards = "isNonVectorPreserved()") protected RNull castNull(@SuppressWarnings("unused") RNull rnull) { return RNull.instance; } - @Specialization(guards = "!preserveNonVector") + @Specialization(guards = "!isNonVectorPreserved()") protected RAbstractVector cast(@SuppressWarnings("unused") RNull rnull) { return RDataFactory.createList(); } - @Specialization(guards = "preserveNonVector") + @Specialization(guards = "isNonVectorPreserved()") protected RFunction castFunction(RFunction f) { return f; } - @Specialization(guards = "!preserveNonVector") + @Specialization(guards = "!isNonVectorPreserved()") protected RAbstractVector cast(@SuppressWarnings("unused") RFunction f) { return RDataFactory.createList(); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/IsFactorNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/IsFactorNode.java index 2207a32e7b2f7b232eceef7a594d075cf913654b..23c21476557a2634cb7520cd0f8e0248052d1bc8 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/IsFactorNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/IsFactorNode.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2014, Purdue University - * Copyright (c) 2014, Oracle and/or its affiliates + * Copyright (c) 2014, 2015, Oracle and/or its affiliates * * All rights reserved. */ @@ -29,7 +29,7 @@ public abstract class IsFactorNode extends UnaryNode { CompilerDirectives.transferToInterpreterAndInvalidate(); typeofNode = insert(TypeofNodeGen.create(null)); } - if (typeofNode.execute(frame, x) != RType.Integer) { + if (typeofNode.execute(x) != RType.Integer) { return RRuntime.LOGICAL_FALSE; } if (inheritsNode == null) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/PrecedenceNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/PrecedenceNode.java index 2c9e2c38492368283822b95575bd3016250fa54a..af11160dc494747ff285cfc91664856c9b08a350 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/PrecedenceNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/PrecedenceNode.java @@ -30,8 +30,11 @@ import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; +import edu.umd.cs.findbugs.internalAnnotations.*; + @SuppressWarnings("unused") @NodeChild(value = "recursive", type = RNode.class) +@ImportStatic(RRuntime.class) public abstract class PrecedenceNode extends UnaryNode { public static final int NO_PRECEDENCE = -1; @@ -144,7 +147,7 @@ public abstract class PrecedenceNode extends UnaryNode { return LIST_PRECEDENCE; } - @Specialization(guards = "isRecursive") + @Specialization(guards = "recursive == LOGICAL_TRUE") protected int doListRecursive(VirtualFrame frame, RList val, byte recursive) { int precedence = -1; for (int i = 0; i < val.getLength(); ++i) { @@ -154,7 +157,7 @@ public abstract class PrecedenceNode extends UnaryNode { return precedence; } - @Specialization(guards = "!isRecursive") + @Specialization(guards = "recursive != LOGICAL_TRUE") protected int doList(RList val, byte recursive) { return LIST_PRECEDENCE; } @@ -174,7 +177,4 @@ public abstract class PrecedenceNode extends UnaryNode { return INT_PRECEDENCE; } - protected boolean isRecursive(RList val, byte recursive) { - return recursive == RRuntime.LOGICAL_TRUE; - } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/TypeofNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/TypeofNode.java index 0f160f5f47ca03dbf3d9c4a8107a77cd5fc80c4f..3902423c615c13af0422cb5328528cf7fd3f1bf3 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/TypeofNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/TypeofNode.java @@ -37,7 +37,7 @@ import com.oracle.truffle.r.runtime.env.*; @SuppressWarnings("unused") public abstract class TypeofNode extends UnaryNode { - public abstract RType execute(VirtualFrame frame, Object x); + public abstract RType execute(Object x); @Specialization protected RType typeof(RNull vector) { @@ -149,12 +149,12 @@ public abstract class TypeofNode extends UnaryNode { return RType.PairList; } - @Specialization(guards = "isFunctionBuiltin") + @Specialization(guards = "obj.isBuiltin()") protected RType typeofBuiltin(RFunction obj) { return RType.Builtin; } - @Specialization(guards = "!isFunctionBuiltin") + @Specialization(guards = "!obj.isBuiltin()") protected RType typeofClosure(RFunction obj) { return RType.Closure; } @@ -179,7 +179,4 @@ public abstract class TypeofNode extends UnaryNode { return RType.Integer; } - public static boolean isFunctionBuiltin(RFunction fun) { - return fun.isBuiltin(); - } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/UnaryArithmeticNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/UnaryArithmeticNode.java index f9395e18d5059d19854672eb618b84d5594f5f3d..bfcb8697de562dd4e965b9e668d50da42752da70 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/UnaryArithmeticNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/UnaryArithmeticNode.java @@ -82,7 +82,7 @@ public abstract class UnaryArithmeticNode extends UnaryNode { ret.copyNamesFrom(attrProfiles, v); } - @Specialization(guards = "isComplete") + @Specialization(guards = "operands.isComplete()") protected RDoubleVector doDoubleVector(RAbstractDoubleVector operands) { double[] res = new double[operands.getLength()]; for (int i = 0; i < operands.getLength(); ++i) { @@ -93,7 +93,7 @@ public abstract class UnaryArithmeticNode extends UnaryNode { return ret; } - @Specialization(guards = "!isComplete") + @Specialization(guards = "!operands.isComplete()") protected RDoubleVector doDoubleVectorNA(RAbstractDoubleVector operands) { double[] res = new double[operands.getLength()]; for (int i = 0; i < operands.getLength(); ++i) { @@ -108,7 +108,7 @@ public abstract class UnaryArithmeticNode extends UnaryNode { return ret; } - @Specialization(guards = "isComplete") + @Specialization(guards = "operands.isComplete()") protected RComplexVector doComplexVector(RAbstractComplexVector operands) { double[] res = new double[operands.getLength() * 2]; for (int i = 0; i < operands.getLength(); ++i) { @@ -121,7 +121,7 @@ public abstract class UnaryArithmeticNode extends UnaryNode { return ret; } - @Specialization(guards = "!isComplete") + @Specialization(guards = "!operands.isComplete()") protected RComplexVector doComplexVectorNA(RAbstractComplexVector operands) { double[] res = new double[operands.getLength() * 2]; for (int i = 0; i < operands.getLength(); ++i) { @@ -139,7 +139,7 @@ public abstract class UnaryArithmeticNode extends UnaryNode { return ret; } - @Specialization(guards = "isComplete") + @Specialization(guards = "operands.isComplete()") protected RIntVector doIntVector(RAbstractIntVector operands) { int[] res = new int[operands.getLength()]; for (int i = 0; i < operands.getLength(); ++i) { @@ -150,7 +150,7 @@ public abstract class UnaryArithmeticNode extends UnaryNode { return ret; } - @Specialization(guards = "!isComplete") + @Specialization(guards = "!operands.isComplete()") protected RIntVector doIntVectorNA(RAbstractIntVector operands) { int[] res = new int[operands.getLength()]; for (int i = 0; i < operands.getLength(); ++i) { @@ -165,12 +165,12 @@ public abstract class UnaryArithmeticNode extends UnaryNode { return ret; } - @Specialization(guards = "isComplete") + @Specialization(guards = "operands.isComplete()") protected RIntVector doLogicalVector(RAbstractLogicalVector operands) { return doIntVector(RClosures.createLogicalToIntVector(operands, na)); } - @Specialization(guards = "!isComplete") + @Specialization(guards = "!operands.isComplete()") protected RIntVector doLogicalVectorNA(RAbstractLogicalVector operands) { return doIntVectorNA(RClosures.createLogicalToIntVector(operands, na)); } @@ -180,7 +180,4 @@ public abstract class UnaryArithmeticNode extends UnaryNode { throw RError.error(getEncapsulatingSourceSection(), error); } - protected static boolean isComplete(RAbstractVector cv) { - return cv.isComplete(); - } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/UnaryArithmeticReduceNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/UnaryArithmeticReduceNode.java index 85e1b92140ca73f97ad461c356092d217cfeea97..f7bab57746927bedfc09d8bb386724794b13bca2 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/UnaryArithmeticReduceNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/UnaryArithmeticReduceNode.java @@ -43,7 +43,7 @@ public abstract class UnaryArithmeticReduceNode extends UnaryNode { @Child private BinaryArithmetic arithmetic; - private final ReduceSemantics semantics; + protected final ReduceSemantics semantics; private final NACheck na = NACheck.create(); @@ -70,10 +70,6 @@ public abstract class UnaryArithmeticReduceNode extends UnaryNode { return stringHandler.executeString(frame, operand, naRm, offset); } - protected boolean isNullInt() { - return semantics.isNullInt(); - } - private void emptyWarning() { if (semantics.getEmptyWarning() != null) { warningProfile.enter(); @@ -82,14 +78,14 @@ public abstract class UnaryArithmeticReduceNode extends UnaryNode { } @SuppressWarnings("unused") - @Specialization(guards = "isNullInt") + @Specialization(guards = "semantics.isNullInt()") protected int doInt(RNull operand, byte naRm) { emptyWarning(); return semantics.getIntStart(); } @SuppressWarnings("unused") - @Specialization(guards = "!isNullInt") + @Specialization(guards = "!semantics.isNullInt()") protected double doDouble(RNull operand, byte naRm) { emptyWarning(); return semantics.getDoubleStart(); @@ -336,12 +332,12 @@ public abstract class UnaryArithmeticReduceNode extends UnaryNode { } } - @Specialization(guards = "empty") + @Specialization(guards = "operand.getLength() == 0") protected String doStringVectorEmpty(RStringVector operand, byte naRm) { return doStringVectorEmptyInternal(operand, naRm, semantics, getEncapsulatingSourceSection()); } - @Specialization(guards = "lengthOne") + @Specialization(guards = "operand.getLength() == 1") protected String doStringVectorOneElem(RStringVector operand, byte naRm) { if (semantics.supportString) { boolean profiledNaRm = naRmProfile.profile(naRm == RRuntime.LOGICAL_TRUE); @@ -358,7 +354,7 @@ public abstract class UnaryArithmeticReduceNode extends UnaryNode { } } - @Specialization(guards = "longerThanOne") + @Specialization(guards = "operand.getLength() > 1") protected String doStringVector(VirtualFrame frame, RStringVector operand, byte naRm) { if (semantics.supportString) { return handleString(frame, operand, naRm, 0); @@ -373,18 +369,6 @@ public abstract class UnaryArithmeticReduceNode extends UnaryNode { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_TYPE_ARGUMENT, "raw"); } - protected boolean empty(RStringVector vector) { - return vector.getLength() == 0; - } - - protected boolean lengthOne(RStringVector vector) { - return vector.getLength() == 1; - } - - protected boolean longerThanOne(RStringVector vector) { - return vector.getLength() > 1; - } - public static final class ReduceSemantics { private final int intStart; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/UnaryNotNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/UnaryNotNode.java index d77eed2ce79507832a1efa9f79a0a058308eee74..faefd8ecba173b2719e241e6671717dacd8bfe97 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/UnaryNotNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/UnaryNotNode.java @@ -149,25 +149,21 @@ public abstract class UnaryNotNode extends RBuiltinNode { return resultVector; } - @Specialization(guards = {"isZeroLength"}) + @Specialization(guards = {"vector.getLength() == 0"}) protected RLogicalVector doStringVector(@SuppressWarnings("unused") RAbstractStringVector vector) { return RDataFactory.createEmptyLogicalVector(); } - @Specialization(guards = {"isZeroLength"}) + @Specialization(guards = {"vector.getLength() == 0"}) protected RLogicalVector doComplexVector(@SuppressWarnings("unused") RAbstractComplexVector vector) { return RDataFactory.createEmptyLogicalVector(); } - @Specialization(guards = {"isZeroLength"}) + @Specialization(guards = {"list.getLength() == 0"}) protected RLogicalVector doList(@SuppressWarnings("unused") RList list) { return RDataFactory.createEmptyLogicalVector(); } - protected boolean isZeroLength(RAbstractVector vector) { - return vector.getLength() == 0; - } - @Fallback protected Object invalidArgType(@SuppressWarnings("unused") Object operand) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_ARG_TYPE); diff --git a/com.oracle.truffle.r.parser.processor/src/com/oracle/truffle/r/parser/processor/GenerateRParserProcessor.java b/com.oracle.truffle.r.parser.processor/src/com/oracle/truffle/r/parser/processor/GenerateRParserProcessor.java index 7515cdeb28b9857b33525c72c82313d30a70a0c1..b6638fc680b65cdf54aebae9b2535d7205cef648 100644 --- a/com.oracle.truffle.r.parser.processor/src/com/oracle/truffle/r/parser/processor/GenerateRParserProcessor.java +++ b/com.oracle.truffle.r.parser.processor/src/com/oracle/truffle/r/parser/processor/GenerateRParserProcessor.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 @@ -23,12 +23,14 @@ package com.oracle.truffle.r.parser.processor; import java.io.*; +import java.nio.file.*; import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; +import javax.tools.Diagnostic.Kind; @SupportedSourceVersion(SourceVersion.RELEASE_8) @SupportedAnnotationTypes("com.oracle.truffle.r.parser.processor.GenerateRParser") @@ -58,17 +60,23 @@ public class GenerateRParserProcessor extends AbstractProcessor { // processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, e); // } - Process process = Runtime.getRuntime().exec(command, null, parserSrcDir); - int rc = process.waitFor(); - if (rc != 0) { - processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Parser generator failed: " + rc); - return false; + File tempFile = File.createTempFile("rparser", "out"); + try { + int rc = new ProcessBuilder(command).directory(parserSrcDir).redirectError(tempFile).start().waitFor(); + if (rc != 0) { + String out = new String(Files.readAllBytes(tempFile.toPath())); + processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, // + String.format("Parser failed to execute command %s. Return code %s.%nOutput:%s", Arrays.toString(command), rc, out), element); + return false; + } + } finally { + tempFile.delete(); } // Now create the actual source files, copying the ANTLR output createSourceFile(filer, pkg, "RParser", antlrGenDir); createSourceFile(filer, pkg, "RLexer", antlrGenDir); } catch (Exception ex) { - processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "exec of Parser generator failed: " + ex); + handleThrowable(ex, element); return false; } finally { if (antlrGenDir != null) { @@ -79,6 +87,20 @@ public class GenerateRParserProcessor extends AbstractProcessor { return true; } + private void handleThrowable(Throwable t, Element e) { + String message = "Uncaught error in " + getClass().getSimpleName() + " while processing " + e + " "; + processingEnv.getMessager().printMessage(Kind.ERROR, message + ": " + printException(t), e); + } + + private static String printException(Throwable e) { + StringWriter string = new StringWriter(); + PrintWriter writer = new PrintWriter(string); + e.printStackTrace(writer); + writer.flush(); + string.flush(); + return e.getMessage() + "\n" + string.toString(); + } + private static File join(File parent, String... args) { File result = parent; for (String arg : args) { @@ -94,6 +116,7 @@ public class GenerateRParserProcessor extends AbstractProcessor { try (BufferedInputStream is = new BufferedInputStream(new FileInputStream(antlrFile)); BufferedOutputStream os = new BufferedOutputStream(file.openOutputStream())) { is.read(content); os.write("// GENERATED CONTENT - DO NOT EDIT\n".getBytes()); + os.write("// Checkstyle: stop\n".getBytes()); os.write(content); } } diff --git a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g index 92878c170af3276bc5051dc875a1b580189946b1..187fea7934c69bd324b65fd9302194fe0d55a16c 100644 --- a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g +++ b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g @@ -34,7 +34,6 @@ import com.oracle.truffle.r.parser.ast.BinaryOperation.*; } @lexer::header { -//Checkstyle: stop //@formatter:off package com.oracle.truffle.r.parser; } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/REnvironment.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/REnvironment.java index adfad257cf03f3623381ed13388b806c9f93eab7..6d3781b19cc9515f60861c0b9a8d5a5fc52a2f8c 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/REnvironment.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/REnvironment.java @@ -80,11 +80,14 @@ import com.oracle.truffle.r.runtime.env.frame.*; * */ public abstract class REnvironment extends RAttributeStorage implements RAttributable { - public enum PackageKind { - PACKAGE, - IMPORTS, - NAMESPACE - } + + /** + * Controls whether a separate frame, with a different enclosing frame is created to the + * "namespace:base" environment. This is correct semantics and required to resolve unqualified + * references to names between packages, but requires a fix to {@link FrameSlotChangeMonitor} to + * work. TODO Remove once fix in place. + */ + private static final boolean NS_BASE_FRAME = false; public static class PutException extends RErrorException { private static final long serialVersionUID = 1L; @@ -190,17 +193,15 @@ public abstract class REnvironment extends RAttributeStorage implements RAttribu * The base "package" is special, it has no "imports" and the parent of its associated namespace * is {@link #globalEnv}. Unlike other packages, there is no difference between the bindings in * "package:base" and its associated namespace. The way this is implemented in FastR is that the - * {@link #frameAccess} value is identical for both environments. I.e. they share the same - * underlying frame. N.B. Although the {@link #parent} field of "namespace:base" is - * {@link #globalEnv} the {@code enclosingFrame} does NOT reference {@code globalFrame} as this - * would produce a circularity in the Truffle search logic. - * - * TODO neither of these frames really need to be a Truffle frames. + * underlying {@link MaterializedFrame} is shared. The {@link #frameAccess} value for + * "namespace:base" refers to {@link NSBaseMaterializedFrame}, which delegates all its + * operations to {@code baseFrame}, but it's "enclosingFrame" field in {@link RArguments} + * differs, referring to {@code globalFrame}. */ public static void baseInitialize(MaterializedFrame globalFrame, MaterializedFrame baseFrame) { namespaceRegistry = RDataFactory.createNewEnv(UNNAMED); - baseEnv = new Base(baseFrame); + baseEnv = new Base(baseFrame, globalFrame); globalEnv = new Global(baseEnv, globalFrame); baseEnv.namespaceEnv.parent = globalEnv; @@ -653,6 +654,9 @@ public abstract class REnvironment extends RAttributeStorage implements RAttribu private BaseNamespace(REnvironment parent, String name, REnvFrameAccess frameAccess) { super(parent, name, frameAccess); namespaceRegistry.safePut(name, this); + if (NS_BASE_FRAME) { + RArguments.setEnvironment(frameAccess.getFrame(), this); + } } @Override @@ -664,17 +668,21 @@ public abstract class REnvironment extends RAttributeStorage implements RAttribu private static final class Base extends REnvironment { private final BaseNamespace namespaceEnv; - private Base(MaterializedFrame frame) { - super(emptyEnv, "base", frame); - // The namespace parent will change to globalEnv once that is created - // (circular dependency) - this.namespaceEnv = new BaseNamespace(emptyEnv, "base", this.frameAccess); - RArguments.setEnclosingFrame(frame, parent.getFrame()); - // This is important so that "environment(func)" gives the correct - // answer for functions defined in base. The sharing of the - // frame would otherwise report "package:base" - RArguments.setEnvironment(frame, this.namespaceEnv); - + private Base(MaterializedFrame baseFrame, MaterializedFrame globalFrame) { + super(emptyEnv, "base", baseFrame); + /* + * We create the NSBaseMaterializedFrame using globalFrame as the enclosing frame. The + * namespaceEnv parent field will change to globalEnv after the latter is created + */ + MaterializedFrame nsFrame = new NSBaseMaterializedFrame(baseFrame, globalFrame); + REnvFrameAccess baseFrameAccess = NS_BASE_FRAME ? new REnvTruffleFrameAccess(nsFrame) : this.frameAccess; + this.namespaceEnv = new BaseNamespace(emptyEnv, "base", baseFrameAccess); + if (!NS_BASE_FRAME) { + // This is important so that "environment(func)" gives the correct + // answer for functions defined in base. The sharing of the + // frame would otherwise report "package:base" + RArguments.setEnvironment(baseFrame, this.namespaceEnv); + } } @Override diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/NSBaseMaterializedFrame.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/NSBaseMaterializedFrame.java new file mode 100644 index 0000000000000000000000000000000000000000..f469f0fa141195bc6e0c8a282439d8f6fec565b7 --- /dev/null +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/NSBaseMaterializedFrame.java @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.truffle.r.runtime.env.frame; + +import java.util.*; + +import com.oracle.truffle.api.CompilerDirectives.*; +import com.oracle.truffle.api.frame.*; +import com.oracle.truffle.r.runtime.*; + +/** + * This frame is used for {@code namespace:base}. It delegates all operations to + * {@link #packageBaseFrame}, however, it's enclosing frame is set to the frame for + * {@code globalenv}. + */ +public final class NSBaseMaterializedFrame implements MaterializedFrame { + + private final MaterializedFrame packageBaseFrame; + @CompilationFinal private final Object[] arguments; + + public NSBaseMaterializedFrame(MaterializedFrame packageBaseFrame, MaterializedFrame globalFrame) { + this.packageBaseFrame = packageBaseFrame; + this.arguments = Arrays.copyOf(packageBaseFrame.getArguments(), packageBaseFrame.getArguments().length); + RArguments.setEnclosingFrame(this, globalFrame); + } + + @Override + public FrameDescriptor getFrameDescriptor() { + return packageBaseFrame.getFrameDescriptor(); + } + + @Override + public Object[] getArguments() { + return arguments; + } + + @Override + public MaterializedFrame materialize() { + return this; + } + + /* + * Delegates to #originalFrame + */ + + @Override + public Object getObject(FrameSlot slot) throws FrameSlotTypeException { + return packageBaseFrame.getObject(slot); + } + + @Override + public void setObject(FrameSlot slot, Object value) { + packageBaseFrame.setObject(slot, value); + } + + @Override + public byte getByte(FrameSlot slot) throws FrameSlotTypeException { + return packageBaseFrame.getByte(slot); + } + + @Override + public void setByte(FrameSlot slot, byte value) { + packageBaseFrame.setByte(slot, value); + } + + @Override + public boolean getBoolean(FrameSlot slot) throws FrameSlotTypeException { + return packageBaseFrame.getBoolean(slot); + } + + @Override + public void setBoolean(FrameSlot slot, boolean value) { + packageBaseFrame.setBoolean(slot, value); + } + + @Override + public int getInt(FrameSlot slot) throws FrameSlotTypeException { + return packageBaseFrame.getInt(slot); + } + + @Override + public void setInt(FrameSlot slot, int value) { + packageBaseFrame.setInt(slot, value); + } + + @Override + public long getLong(FrameSlot slot) throws FrameSlotTypeException { + return packageBaseFrame.getLong(slot); + } + + @Override + public void setLong(FrameSlot slot, long value) { + packageBaseFrame.setLong(slot, value); + } + + @Override + public float getFloat(FrameSlot slot) throws FrameSlotTypeException { + return packageBaseFrame.getFloat(slot); + } + + @Override + public void setFloat(FrameSlot slot, float value) { + packageBaseFrame.setFloat(slot, value); + } + + @Override + public double getDouble(FrameSlot slot) throws FrameSlotTypeException { + return packageBaseFrame.getDouble(slot); + } + + @Override + public void setDouble(FrameSlot slot, double value) { + packageBaseFrame.setDouble(slot, value); + } + + @Override + public Object getValue(FrameSlot slot) { + return packageBaseFrame.getValue(slot); + } + + @Override + public boolean isObject(FrameSlot slot) { + return packageBaseFrame.isObject(slot); + } + + @Override + public boolean isByte(FrameSlot slot) { + return packageBaseFrame.isByte(slot); + } + + @Override + public boolean isBoolean(FrameSlot slot) { + return packageBaseFrame.isBoolean(slot); + } + + @Override + public boolean isInt(FrameSlot slot) { + return packageBaseFrame.isInt(slot); + } + + @Override + public boolean isLong(FrameSlot slot) { + return packageBaseFrame.isLong(slot); + } + + @Override + public boolean isFloat(FrameSlot slot) { + return packageBaseFrame.isFloat(slot); + } + + @Override + public boolean isDouble(FrameSlot slot) { + return packageBaseFrame.isDouble(slot); + } +} diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/REnvTruffleFrameAccess.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/REnvTruffleFrameAccess.java index 97c5e764f33efcfd62b91875a00e2f965c1093be..f55675c43e00434544534f071d76ef80183de240 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/REnvTruffleFrameAccess.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/REnvTruffleFrameAccess.java @@ -40,10 +40,6 @@ public class REnvTruffleFrameAccess extends REnvFrameAccessBindingsAdapter { private final MaterializedFrame frame; - public REnvTruffleFrameAccess(VirtualFrame frame) { - this.frame = frame.materialize(); - } - public REnvTruffleFrameAccess(MaterializedFrame frame) { this.frame = frame; } diff --git a/mx.fastr/imports b/mx.fastr/imports index 038df504b1adaf5758a28fd0dbd2b4aafa695f7a..da65b7a8ac70f3d94507e0c645f8c78532b2fc63 100644 --- a/mx.fastr/imports +++ b/mx.fastr/imports @@ -1 +1 @@ -graal,b300d1f6e8175ae3f7192b981584fdff973f2847,http://hg.openjdk.java.net/graal/graal +graal,dc7189b2bb5fe9569cce923beb261334435ae267,http://hg.openjdk.java.net/graal/graal