diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/All.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/All.java index f5ca96b1a705f87d9d39d606ab3a9b0f61a16861..b3604b3037b1952cbf6d1786c60895f4578107cd 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/All.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/All.java @@ -34,7 +34,7 @@ import com.oracle.truffle.r.runtime.builtins.RBuiltin; public abstract class All extends Quantifier { static { - new QuantifierCasts(All.class); + createCasts(All.class); } @Override diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Any.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Any.java index 3cefcf6e0a0f88a8d79ffd714699daa48cd12283..30375f72c6613f1bc93bfe6845189ba73c7aec68 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Any.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Any.java @@ -27,7 +27,6 @@ import static com.oracle.truffle.r.runtime.builtins.RBehavior.PURE; import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE; import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.r.nodes.builtin.base.Quantifier.QuantifierCasts; import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.builtins.RBuiltin; @@ -35,7 +34,7 @@ import com.oracle.truffle.r.runtime.builtins.RBuiltin; public abstract class Any extends Quantifier { static { - new QuantifierCasts(Any.class); + createCasts(Any.class); } @Override 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 13da55b7f959329fcc8f821facf284c7e09b46b0..14584bfb602fe33c6aaf0ebe0e2016955e4e92c9 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 @@ -524,7 +524,6 @@ public abstract class Bind extends RBaseNode { return result; } - @SuppressWarnings("unused") @RBuiltin(name = "cbind", kind = INTERNAL, parameterNames = {"deparse.level", "..."}, behavior = COMPLEX) public abstract static class CbindInternal extends AbstractBind { public CbindInternal() { @@ -532,12 +531,10 @@ public abstract class Bind extends RBaseNode { } static { - new BindCasts(CbindInternal.class); + createCasts(CbindInternal.class); } - } - @SuppressWarnings("unused") @RBuiltin(name = "rbind", kind = INTERNAL, parameterNames = {"deparse.level", "..."}, behavior = COMPLEX) public abstract static class RbindInternal extends AbstractBind { public RbindInternal() { @@ -545,9 +542,8 @@ public abstract class Bind extends RBaseNode { } static { - new BindCasts(RbindInternal.class); + createCasts(RbindInternal.class); } - } protected abstract static class AbstractBind extends RBuiltinNode { @@ -568,11 +564,10 @@ public abstract class Bind extends RBaseNode { this.type = type; } - static final class BindCasts extends Casts { - BindCasts(Class<? extends AbstractBind> extCls) { - super(extCls); - casts.arg("deparse.level").asIntegerVector().findFirst(0); - } + protected static Casts createCasts(Class<? extends AbstractBind> extCls) { + Casts casts = new Casts(extCls); + casts.arg("deparse.level").asIntegerVector().findFirst(0); + return casts; } @Specialization 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 121a78c81fc458de9db3c1977fc98fcbc7087782..2b6583e04b69cb064a65fa9d85203447db6744c2 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 @@ -24,14 +24,13 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractLogicalVector; import com.oracle.truffle.r.runtime.ops.BinaryArithmetic; //Implements .colMeans -@SuppressWarnings("unused") @RBuiltin(name = "colMeans", kind = INTERNAL, parameterNames = {"X", "m", "n", "na.rm"}, behavior = PURE) public abstract class ColMeans extends ColSumsBase { @Child private BinaryArithmetic add = BinaryArithmetic.ADD.createOperation(); static { - new ColSumsCasts(ColMeans.class); + createCasts(ColMeans.class); } @Specialization(guards = "!naRm") diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ColSums.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ColSums.java index 7dce23f2daf123bd23abfe6ef02326ed5c06bcf4..a713374055b253babc1f0261dbe4974dc2f5a53c 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ColSums.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ColSums.java @@ -37,7 +37,6 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector; import com.oracle.truffle.r.runtime.data.model.RAbstractLogicalVector; import com.oracle.truffle.r.runtime.ops.BinaryArithmetic; -@SuppressWarnings("unused") @RBuiltin(name = "colSums", kind = INTERNAL, parameterNames = {"X", "m", "n", "na.rm"}, behavior = PURE) public abstract class ColSums extends ColSumsBase { @@ -47,7 +46,7 @@ public abstract class ColSums extends ColSumsBase { private final ValueProfile concreteVectorProfile = ValueProfile.createClassProfile(); static { - new ColSumsCasts(ColSums.class); + createCasts(ColSums.class); } @Specialization diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ColSumsBase.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ColSumsBase.java index 1f14bc7a118e1d09332675b33a4ec6add0199384..34215dc57fa37720827f7cbce88ffce610f7ee76 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ColSumsBase.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ColSumsBase.java @@ -46,14 +46,13 @@ public abstract class ColSumsBase extends RBuiltinNode { protected final NACheck na = NACheck.create(); private final ConditionProfile vectorLengthProfile = ConditionProfile.createBinaryProfile(); - static final class ColSumsCasts extends Casts { - ColSumsCasts(Class<? extends ColSumsBase> extCls) { - super(extCls); - casts.arg("X").mustBe(numericValue(), RError.SHOW_CALLER, RError.Message.X_NUMERIC); - casts.arg("m").defaultError(RError.SHOW_CALLER, INVALID_ARGUMENT, "n").asIntegerVector().findFirst().notNA(RError.NO_CALLER, RError.Message.VECTOR_SIZE_NA); - casts.arg("n").defaultError(RError.SHOW_CALLER, INVALID_ARGUMENT, "p").asIntegerVector().findFirst().notNA(RError.NO_CALLER, RError.Message.VECTOR_SIZE_NA); - casts.arg("na.rm").asLogicalVector().findFirst().notNA().map(toBoolean()); - } + protected static Casts createCasts(Class<? extends ColSumsBase> extCls) { + Casts casts = new Casts(extCls); + casts.arg("X").mustBe(numericValue(), RError.SHOW_CALLER, RError.Message.X_NUMERIC); + casts.arg("m").defaultError(RError.SHOW_CALLER, INVALID_ARGUMENT, "n").asIntegerVector().findFirst().notNA(RError.NO_CALLER, RError.Message.VECTOR_SIZE_NA); + casts.arg("n").defaultError(RError.SHOW_CALLER, INVALID_ARGUMENT, "p").asIntegerVector().findFirst().notNA(RError.NO_CALLER, RError.Message.VECTOR_SIZE_NA); + casts.arg("na.rm").asLogicalVector().findFirst().notNA().map(toBoolean()); + return casts; } protected final void checkVectorLength(RAbstractVector x, int rowNum, int colNum) { 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 579c88b0eaf9f2a68df075708607cfc4c5dfb0af..59a02ba8003fad19929e6112d91fe9f67f10fe03 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 @@ -236,14 +236,13 @@ public abstract class ConnectionFunctions { this.cType = cType; } - static final class ZZCasts extends Casts { - protected ZZCasts(Class<? extends ZZFileAdapter> extCls, RCompression.Type cType) { - super(extCls); - CastsHelper.description(this); - CastsHelper.open(this); - CastsHelper.encoding(this); - casts.arg("compression").asIntegerVector().findFirst().notNA().mustBe(gte(cType == RCompression.Type.XZ ? -9 : 0).and(lte(9))); - } + protected static Casts createCasts(Class<? extends ZZFileAdapter> extCls, RCompression.Type cType) { + Casts casts = new Casts(extCls); + CastsHelper.description(casts); + CastsHelper.open(casts); + CastsHelper.encoding(casts); + casts.arg("compression").asIntegerVector().findFirst().notNA().mustBe(gte(cType == RCompression.Type.XZ ? -9 : 0).and(lte(9))); + return casts; } @Specialization @@ -262,7 +261,6 @@ public abstract class ConnectionFunctions { } } - @SuppressWarnings("unused") @RBuiltin(name = "gzfile", kind = INTERNAL, parameterNames = {"description", "open", "encoding", "compression"}, behavior = IO) public abstract static class GZFile extends ZZFileAdapter { protected GZFile() { @@ -270,12 +268,10 @@ public abstract class ConnectionFunctions { } static { - new ZZCasts(GZFile.class, RCompression.Type.GZIP); + createCasts(GZFile.class, RCompression.Type.GZIP); } - } - @SuppressWarnings("unused") @RBuiltin(name = "bzfile", kind = INTERNAL, parameterNames = {"description", "open", "encoding", "compression"}, behavior = IO) public abstract static class BZFile extends ZZFileAdapter { protected BZFile() { @@ -283,12 +279,10 @@ public abstract class ConnectionFunctions { } static { - new ZZCasts(BZFile.class, RCompression.Type.BZIP2); + createCasts(BZFile.class, RCompression.Type.BZIP2); } - } - @SuppressWarnings("unused") @RBuiltin(name = "xzfile", kind = INTERNAL, parameterNames = {"description", "open", "encoding", "compression"}, behavior = IO) public abstract static class XZFile extends ZZFileAdapter { protected XZFile() { @@ -296,9 +290,8 @@ public abstract class ConnectionFunctions { } static { - new ZZCasts(XZFile.class, RCompression.Type.XZ); + createCasts(XZFile.class, RCompression.Type.XZ); } - } @RBuiltin(name = "textConnection", kind = INTERNAL, parameterNames = {"description", "text", "open", "env", "encoding"}, behavior = IO) diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DebugFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DebugFunctions.java index 61b783d1babb10385736fba542df72d3a78d9159..c6f3bba7160fdb8272df5c92127563eba3f7166c 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DebugFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DebugFunctions.java @@ -42,11 +42,10 @@ public class DebugFunctions { protected abstract static class ErrorAndFunAdapter extends RBuiltinNode { - static final class ErrorAndFunCasts extends Casts { - ErrorAndFunCasts(Class<? extends ErrorAndFunAdapter> extCls) { - super(extCls); - casts.arg("fun").mustBe(RFunction.class, Message.ARG_MUST_BE_CLOSURE); - } + protected static Casts createCasts(Class<? extends ErrorAndFunAdapter> extCls) { + Casts casts = new Casts(extCls); + casts.arg("fun").mustBe(RFunction.class, Message.ARG_MUST_BE_CLOSURE); + return casts; } protected void doDebug(RFunction fun, Object text, Object condition, boolean once) throws RError { @@ -59,12 +58,11 @@ public class DebugFunctions { } } - @SuppressWarnings("unused") @RBuiltin(name = "debug", visibility = OFF, kind = INTERNAL, parameterNames = {"fun", "text", "condition"}, behavior = COMPLEX) public abstract static class Debug extends ErrorAndFunAdapter { static { - new ErrorAndFunCasts(Debug.class); + createCasts(Debug.class); } @Specialization @@ -75,12 +73,11 @@ public class DebugFunctions { } } - @SuppressWarnings("unused") @RBuiltin(name = "debugonce", visibility = OFF, kind = INTERNAL, parameterNames = {"fun", "text", "condition"}, behavior = COMPLEX) public abstract static class DebugOnce extends ErrorAndFunAdapter { static { - new ErrorAndFunCasts(DebugOnce.class); + createCasts(DebugOnce.class); } @Specialization @@ -92,12 +89,11 @@ public class DebugFunctions { } } - @SuppressWarnings("unused") @RBuiltin(name = "undebug", visibility = OFF, kind = INTERNAL, parameterNames = {"fun"}, behavior = COMPLEX) public abstract static class UnDebug extends ErrorAndFunAdapter { static { - new ErrorAndFunCasts(UnDebug.class); + createCasts(UnDebug.class); } @Specialization @@ -110,12 +106,11 @@ public class DebugFunctions { } } - @SuppressWarnings("unused") @RBuiltin(name = "isdebugged", kind = INTERNAL, parameterNames = {"fun"}, behavior = PURE) public abstract static class IsDebugged extends ErrorAndFunAdapter { static { - new ErrorAndFunCasts(IsDebugged.class); + createCasts(IsDebugged.class); } @Specialization 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 7613e80ff4f84f83d6686e49cb5b001cae6c3e0c..4c096d94e544f306d1444830bd1abf3bd7affa2e 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 @@ -32,22 +32,17 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node.Child; import com.oracle.truffle.api.object.DynamicObject; -import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.api.profiles.ValueProfile; import com.oracle.truffle.r.nodes.attributes.GetFixedAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetClassAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctionsFactory.GetDimAttributeNodeGen; -import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.nodes.helpers.InheritsCheckNode; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.RType; -import com.oracle.truffle.r.runtime.RError.Message; import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.data.RAttributable; import com.oracle.truffle.r.runtime.data.RComplex; @@ -72,16 +67,14 @@ import com.oracle.truffle.r.runtime.nodes.RBaseNode; /** * Handles all builtin functions of the form {@code is.xxx}, where is {@code xxx} is a "type". */ -@SuppressWarnings("unused") public class IsTypeFunctions { protected abstract static class MissingAdapter extends RBuiltinNode { - static final class MissingAdapterCasts extends Casts { - MissingAdapterCasts(Class<? extends MissingAdapter> extCls) { - super(extCls); - casts.arg("x").mustNotBeMissing((RBaseNode) null, RError.Message.ARGUMENT_MISSING, "x"); - } + protected static Casts createCasts(Class<? extends MissingAdapter> extCls) { + Casts casts = new Casts(extCls); + casts.arg("x").mustNotBeMissing((RBaseNode) null, RError.Message.ARGUMENT_MISSING, "x"); + return casts; } } @@ -89,7 +82,7 @@ public class IsTypeFunctions { public abstract static class IsArray extends MissingAdapter { static { - new MissingAdapterCasts(IsArray.class); + createCasts(IsArray.class); } private final ConditionProfile isArrayProfile = ConditionProfile.createBinaryProfile(); @@ -103,7 +96,7 @@ public class IsTypeFunctions { } @Specialization(guards = {"!isRMissing(value)", "!isRAbstractVector(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -112,21 +105,21 @@ public class IsTypeFunctions { public abstract static class IsRecursive extends MissingAdapter { static { - new MissingAdapterCasts(IsRecursive.class); + createCasts(IsRecursive.class); } @Specialization - protected byte isRecursive(RNull arg) { + protected byte isRecursive(@SuppressWarnings("unused") RNull arg) { return RRuntime.LOGICAL_FALSE; } @Specialization(guards = {"!isRList(arg)", "!isRExpression(arg)"}) - protected byte isRecursive(RAbstractVector arg) { + protected byte isRecursive(@SuppressWarnings("unused") RAbstractVector arg) { return RRuntime.LOGICAL_FALSE; } @Specialization - protected byte isRecursive(RListBase arg) { + protected byte isRecursive(@SuppressWarnings("unused") RListBase arg) { return RRuntime.LOGICAL_TRUE; } @@ -135,7 +128,7 @@ public class IsTypeFunctions { } @Fallback - protected byte isRecursiveFallback(Object value) { + protected byte isRecursiveFallback(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_TRUE; } } @@ -146,16 +139,16 @@ public class IsTypeFunctions { @Child private InheritsCheckNode inheritsFactorCheck = new InheritsCheckNode(RRuntime.CLASS_FACTOR); static { - new MissingAdapterCasts(IsAtomic.class); + createCasts(IsAtomic.class); } @Specialization - protected byte isAtomic(RNull arg) { + protected byte isAtomic(@SuppressWarnings("unused") RNull arg) { return RRuntime.LOGICAL_TRUE; } @Specialization(guards = {"!isRList(arg)", "!isRExpression(arg)"}) - protected byte isAtomic(RAbstractVector arg) { + protected byte isAtomic(@SuppressWarnings("unused") RAbstractVector arg) { return RRuntime.LOGICAL_TRUE; } @@ -169,7 +162,7 @@ public class IsTypeFunctions { } @Specialization(guards = {"!isRMissing(value)", "!isRNull(value)", "!isFactor(value)", "!isNonListVector(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -178,16 +171,16 @@ public class IsTypeFunctions { public abstract static class IsCall extends MissingAdapter { static { - new MissingAdapterCasts(IsCall.class); + createCasts(IsCall.class); } @Specialization - protected byte isType(RLanguage lang) { + protected byte isType(@SuppressWarnings("unused") RLanguage lang) { return RRuntime.LOGICAL_TRUE; } @Specialization(guards = {"!isRMissing(value)", "!isRLanguage(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -196,11 +189,11 @@ public class IsTypeFunctions { public abstract static class IsCharacter extends MissingAdapter { static { - new MissingAdapterCasts(IsCharacter.class); + createCasts(IsCharacter.class); } @Specialization - protected byte isType(RAbstractStringVector value) { + protected byte isType(@SuppressWarnings("unused") RAbstractStringVector value) { return RRuntime.LOGICAL_TRUE; } @@ -209,7 +202,7 @@ public class IsTypeFunctions { } @Specialization(guards = {"!isRMissing(value)", "!isAnyCharacter(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -218,11 +211,11 @@ public class IsTypeFunctions { public abstract static class IsComplex extends MissingAdapter { static { - new MissingAdapterCasts(IsComplex.class); + createCasts(IsComplex.class); } @Specialization - protected byte isType(RAbstractComplexVector value) { + protected byte isType(@SuppressWarnings("unused") RAbstractComplexVector value) { return RRuntime.LOGICAL_TRUE; } @@ -231,7 +224,7 @@ public class IsTypeFunctions { } @Specialization(guards = {"!isRMissing(value)", "!isAnyComplex(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -240,11 +233,11 @@ public class IsTypeFunctions { public abstract static class IsDouble extends MissingAdapter { static { - new MissingAdapterCasts(IsDouble.class); + createCasts(IsDouble.class); } @Specialization - protected byte isType(RAbstractDoubleVector value) { + protected byte isType(@SuppressWarnings("unused") RAbstractDoubleVector value) { return RRuntime.LOGICAL_TRUE; } @@ -253,7 +246,7 @@ public class IsTypeFunctions { } @Specialization(guards = {"!isRMissing(value)", "!isAnyDouble(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -262,16 +255,16 @@ public class IsTypeFunctions { public abstract static class IsExpression extends MissingAdapter { static { - new MissingAdapterCasts(IsExpression.class); + createCasts(IsExpression.class); } @Specialization - protected byte isType(RExpression expr) { + protected byte isType(@SuppressWarnings("unused") RExpression expr) { return RRuntime.LOGICAL_TRUE; } @Specialization(guards = {"!isRMissing(value)", "!isRExpression(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -280,16 +273,16 @@ public class IsTypeFunctions { public abstract static class IsFunction extends MissingAdapter { static { - new MissingAdapterCasts(IsFunction.class); + createCasts(IsFunction.class); } @Specialization - protected byte isType(RFunction value) { + protected byte isType(@SuppressWarnings("unused") RFunction value) { return RRuntime.LOGICAL_TRUE; } @Specialization(guards = {"!isRMissing(value)", "!isRFunction(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -298,11 +291,11 @@ public class IsTypeFunctions { public abstract static class IsInteger extends MissingAdapter { static { - new MissingAdapterCasts(IsInteger.class); + createCasts(IsInteger.class); } @Specialization - protected byte isType(RAbstractIntVector value) { + protected byte isType(@SuppressWarnings("unused") RAbstractIntVector value) { return RRuntime.LOGICAL_TRUE; } @@ -311,7 +304,7 @@ public class IsTypeFunctions { } @Specialization(guards = {"!isRMissing(value)", "!isAnyInteger(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -320,26 +313,26 @@ public class IsTypeFunctions { public abstract static class IsLanguage extends MissingAdapter { static { - new MissingAdapterCasts(IsLanguage.class); + createCasts(IsLanguage.class); } @Specialization - protected byte isType(RSymbol value) { + protected byte isType(@SuppressWarnings("unused") RSymbol value) { return RRuntime.LOGICAL_TRUE; } @Specialization - protected byte isType(RExpression value) { + protected byte isType(@SuppressWarnings("unused") RExpression value) { return RRuntime.LOGICAL_TRUE; } @Specialization - protected byte isType(RLanguage value) { + protected byte isType(@SuppressWarnings("unused") RLanguage value) { return RRuntime.LOGICAL_TRUE; } @Specialization(guards = {"!isRMissing(value)", "!isRSymbol(value)", "!isRExpression(value)", "!isRLanguage(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -347,26 +340,24 @@ public class IsTypeFunctions { @RBuiltin(name = "is.list", kind = PRIMITIVE, parameterNames = {"x"}, behavior = PURE) public abstract static class IsList extends MissingAdapter { - private final ConditionProfile isListProfile = ConditionProfile.createBinaryProfile(); - static { - new MissingAdapterCasts(IsList.class); + createCasts(IsList.class); } public abstract byte execute(Object value); @Specialization - protected byte isType(RList value) { + protected byte isType(@SuppressWarnings("unused") RList value) { return RRuntime.LOGICAL_TRUE; } @Specialization - protected byte isType(RPairList pl) { + protected byte isType(@SuppressWarnings("unused") RPairList pl) { return RRuntime.LOGICAL_TRUE; } @Specialization(guards = {"!isRMissing(value)", "!isRList(value)", "!isRPairList(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -375,11 +366,11 @@ public class IsTypeFunctions { public abstract static class IsLogical extends MissingAdapter { static { - new MissingAdapterCasts(IsLogical.class); + createCasts(IsLogical.class); } @Specialization - protected byte isType(RAbstractLogicalVector value) { + protected byte isType(@SuppressWarnings("unused") RAbstractLogicalVector value) { return RRuntime.LOGICAL_TRUE; } @@ -388,7 +379,7 @@ public class IsTypeFunctions { } @Specialization(guards = {"!isRMissing(value)", "!isAnyLogical(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -400,7 +391,7 @@ public class IsTypeFunctions { @Child private GetDimAttributeNode getDim = GetDimAttributeNodeGen.create(); static { - new MissingAdapterCasts(IsMatrix.class); + createCasts(IsMatrix.class); } @Specialization @@ -409,7 +400,7 @@ public class IsTypeFunctions { } @Specialization(guards = {"!isRMissing(value)", "!isRAbstractVector(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -418,16 +409,16 @@ public class IsTypeFunctions { public abstract static class IsName extends MissingAdapter { static { - new MissingAdapterCasts(IsName.class); + createCasts(IsName.class); } @Specialization - protected byte isType(RSymbol value) { + protected byte isType(@SuppressWarnings("unused") RSymbol value) { return RRuntime.LOGICAL_TRUE; } @Specialization(guards = {"!isRMissing(value)", "!isRSymbol(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -436,21 +427,21 @@ public class IsTypeFunctions { public abstract static class IsNumeric extends MissingAdapter { static { - new MissingAdapterCasts(IsNumeric.class); + createCasts(IsNumeric.class); } @Specialization(guards = "!isFactor(value)") - protected byte isType(RAbstractIntVector value) { + protected byte isType(@SuppressWarnings("unused") RAbstractIntVector value) { return RRuntime.LOGICAL_TRUE; } @Specialization(guards = "isFactor(value)") - protected byte isTypeFactor(RAbstractIntVector value) { + protected byte isTypeFactor(@SuppressWarnings("unused") RAbstractIntVector value) { return RRuntime.LOGICAL_FALSE; } @Specialization - protected byte isType(RAbstractDoubleVector value) { + protected byte isType(@SuppressWarnings("unused") RAbstractDoubleVector value) { return RRuntime.LOGICAL_TRUE; } @@ -459,7 +450,7 @@ public class IsTypeFunctions { } @Specialization(guards = {"!isRMissing(value)", "!isAnyNumeric(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } @@ -474,16 +465,16 @@ public class IsTypeFunctions { public abstract static class IsNull extends MissingAdapter { static { - new MissingAdapterCasts(IsNull.class); + createCasts(IsNull.class); } @Specialization - protected byte isType(RNull value) { + protected byte isType(@SuppressWarnings("unused") RNull value) { return RRuntime.LOGICAL_TRUE; } @Specialization(guards = {"!isRMissing(value)", "!isRNull(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -512,7 +503,7 @@ public class IsTypeFunctions { } @Specialization(guards = {"!isRMissing(value)", "!isRAttributable(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -521,21 +512,21 @@ public class IsTypeFunctions { public abstract static class IsPairList extends MissingAdapter { static { - new MissingAdapterCasts(IsPairList.class); + createCasts(IsPairList.class); } @Specialization - protected byte isType(RNull value) { + protected byte isType(@SuppressWarnings("unused") RNull value) { return RRuntime.LOGICAL_TRUE; } @Specialization - protected byte isType(RPairList value) { + protected byte isType(@SuppressWarnings("unused") RPairList value) { return RRuntime.LOGICAL_TRUE; } @Specialization(guards = {"!isRMissing(value)", "!isRNull(value)", "!isRPairList(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -544,11 +535,11 @@ public class IsTypeFunctions { public abstract static class IsRaw extends MissingAdapter { static { - new MissingAdapterCasts(IsRaw.class); + createCasts(IsRaw.class); } @Specialization - protected byte isType(RAbstractRawVector value) { + protected byte isType(@SuppressWarnings("unused") RAbstractRawVector value) { return RRuntime.LOGICAL_TRUE; } @@ -557,7 +548,7 @@ public class IsTypeFunctions { } @Specialization(guards = {"!isRMissing(value)", "!isAnyRaw(value)"}) - protected byte isType(Object value) { + protected byte isType(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_FALSE; } } @@ -568,7 +559,6 @@ public class IsTypeFunctions { private final ConditionProfile attrNull = ConditionProfile.createBinaryProfile(); private final ConditionProfile attrEmpty = ConditionProfile.createBinaryProfile(); private final ConditionProfile attrNames = ConditionProfile.createBinaryProfile(); - private final BranchProfile namesAttrProfile = BranchProfile.create(); @Child private GetFixedAttributeNode namesGetter = GetFixedAttributeNode.createNames(); static { @@ -583,8 +573,8 @@ public class IsTypeFunctions { } @Specialization(limit = "5", guards = "cachedMode == mode") - protected byte isVectorCached(RAbstractVector x, String mode, - @Cached("mode") String cachedMode, + protected byte isVectorCached(RAbstractVector x, @SuppressWarnings("unused") String mode, + @Cached("mode") @SuppressWarnings("unused") String cachedMode, @Cached("typeFromMode(mode)") RType type) { if (namesOnlyOrNoAttr(x) && (type == RType.Any || x.getRType() == type)) { return RRuntime.LOGICAL_TRUE; @@ -599,7 +589,7 @@ public class IsTypeFunctions { } @Fallback - protected byte isVector(Object x, Object mode) { + protected byte isVector(@SuppressWarnings("unused") Object x, @SuppressWarnings("unused") Object mode) { return RRuntime.LOGICAL_FALSE; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LaFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LaFunctions.java index 96c4acfe18a082f2b7238b850872f55026dd47aa..1a27658726297e3ad2473785115c172a18586063 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LaFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LaFunctions.java @@ -86,12 +86,11 @@ public class LaFunctions { protected static final String[] NAMES = new String[]{"values", "vectors"}; protected final BranchProfile errorProfile = BranchProfile.create(); - static final class RsgCasts extends Casts { - RsgCasts(Class<? extends RsgAdapter> extClass) { - super(extClass); - casts.arg("matrix").asDoubleVector(false, true, false).mustBe(squareMatrix(), RError.Message.MUST_BE_SQUARE_NUMERIC, "x"); - casts.arg("onlyValues").defaultError(RError.Message.INVALID_ARGUMENT, "only.values").asLogicalVector().findFirst().notNA().map(toBoolean()); - } + protected static Casts createCasts(Class<? extends RsgAdapter> extClass) { + Casts casts = new Casts(extClass); + casts.arg("matrix").asDoubleVector(false, true, false).mustBe(squareMatrix(), RError.Message.MUST_BE_SQUARE_NUMERIC, "x"); + casts.arg("onlyValues").defaultError(RError.Message.INVALID_ARGUMENT, "only.values").asLogicalVector().findFirst().notNA().map(toBoolean()); + return casts; } } @@ -101,7 +100,7 @@ public class LaFunctions { private final ConditionProfile hasComplexValues = ConditionProfile.createBinaryProfile(); static { - new RsgCasts(Rg.class); + createCasts(Rg.class); } @Specialization @@ -200,7 +199,7 @@ public class LaFunctions { public abstract static class Rs extends RsgAdapter { static { - new RsgCasts(Rs.class); + createCasts(Rs.class); } @Specialization 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 89f53b790c7bc721080ae4e4fba6ebdafcd52f11..0614dd2f282a2bf7b37a984e4a075a2b8d7771b5 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 @@ -89,11 +89,10 @@ public abstract class PMinMax extends RBuiltinNode { this.op = factory.createOperation(); } - static final class PMinMaxCasts extends Casts { - PMinMaxCasts(Class<? extends PMinMax> extCls) { - super(extCls); - casts.arg("na.rm").defaultError(SHOW_CALLER, Message.INVALID_VALUE, "na.rm").mustBe(numericValue()).asLogicalVector().findFirst().mustBe(logicalNA().not()).map(toBoolean()); - } + protected static Casts createCasts(Class<? extends PMinMax> extCls) { + Casts casts = new Casts(extCls); + casts.arg("na.rm").defaultError(SHOW_CALLER, Message.INVALID_VALUE, "na.rm").mustBe(numericValue()).asLogicalVector().findFirst().mustBe(logicalNA().not()).map(toBoolean()); + return casts; } private byte handleString(Object[] argValues, boolean naRm, int offset, int ind, int maxLength, byte warning, Object data) { @@ -349,7 +348,7 @@ public abstract class PMinMax extends RBuiltinNode { } static { - new PMinMaxCasts(PMax.class); + createCasts(PMax.class); } } @@ -363,7 +362,7 @@ public abstract class PMinMax extends RBuiltinNode { } static { - new PMinMaxCasts(PMin.class); + createCasts(PMin.class); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Quantifier.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Quantifier.java index 319c2ec107b87f322a41f1df2dc86110942571b1..37bba1bf203b24d61c73dd5690a30c34f7cd44d6 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Quantifier.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Quantifier.java @@ -77,11 +77,10 @@ public abstract class Quantifier extends RBuiltinNode { return new Object[]{RArgsValuesAndNames.EMPTY, RRuntime.LOGICAL_FALSE}; } - static final class QuantifierCasts extends Casts { - QuantifierCasts(Class<? extends Quantifier> extCls) { - super(extCls); - casts.arg("na.rm").asLogicalVector().findFirst(RRuntime.LOGICAL_NA).map(toBoolean()); - } + protected static Casts createCasts(Class<? extends Quantifier> extCls) { + Casts casts = new Casts(extCls); + casts.arg("na.rm").asLogicalVector().findFirst(RRuntime.LOGICAL_NA).map(toBoolean()); + return casts; } private void createArgCast(int index) { 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 fc308351bf9b6e6695951169b4e6997652974865..b2550c98fd68c159275a784023226cc13dd70a5d 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 @@ -21,12 +21,11 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector; import com.oracle.truffle.r.runtime.data.model.RAbstractLogicalVector; // Implements .rowMeans -@SuppressWarnings("unused") @RBuiltin(name = "rowMeans", kind = INTERNAL, parameterNames = {"X", "m", "n", "na.rm"}, behavior = PURE) public abstract class RowMeans extends RowSumsBase { static { - new ColSumsCasts(RowMeans.class); + createCasts(RowMeans.class); } @Specialization diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/RowSums.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/RowSums.java index 7659e933c14eb41a10071f000d76ab8164dde69d..a87847664dbea4e6ea31849fb95ebf9d18267bd2 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/RowSums.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/RowSums.java @@ -20,12 +20,11 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractDoubleVector; import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector; import com.oracle.truffle.r.runtime.data.model.RAbstractLogicalVector; -@SuppressWarnings("unused") @RBuiltin(name = "rowSums", kind = INTERNAL, parameterNames = {"X", "m", "n", "na.rm"}, behavior = PURE) public abstract class RowSums extends RowSumsBase { static { - new ColSumsCasts(RowSums.class); + createCasts(RowSums.class); } @Specialization diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/StartsEndsWithFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/StartsEndsWithFunctions.java index ac22038d7d2c0a191a01a6ea47729d51d1b5e0f4..32242b09d479d77c98832aece324b779a1445c39 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/StartsEndsWithFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/StartsEndsWithFunctions.java @@ -28,7 +28,6 @@ import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.INTERNAL; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RRuntime; @@ -38,22 +37,20 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; import com.oracle.truffle.r.runtime.ops.na.NACheck; public class StartsEndsWithFunctions { - private static class CastsHelper { - private static void arg(CastBuilder casts, String name) { - casts.arg(name).mustBe(stringValue(), RError.SHOW_CALLER, RError.Message.NON_CHARACTER_OBJECTS).asStringVector(); - } - } private abstract static class Adapter extends RBuiltinNode { private final NACheck naCheck = NACheck.create(); private final ConditionProfile singlePrefixProfile = ConditionProfile.createBinaryProfile(); - static final class AdapterCasts extends Casts { - AdapterCasts(Class<? extends Adapter> extCls) { - super(extCls); - CastsHelper.arg(casts, "x"); - CastsHelper.arg(casts, "prefix"); - } + private static void argCast(Casts casts, String name) { + casts.arg(name).mustBe(stringValue(), RError.SHOW_CALLER, RError.Message.NON_CHARACTER_OBJECTS).asStringVector(); + } + + protected static Casts createCasts(Class<? extends Adapter> extCls) { + Casts casts = new Casts(extCls); + argCast(casts, "x"); + argCast(casts, "prefix"); + return casts; } protected Object doIt(RAbstractStringVector xVec, RAbstractStringVector prefixVec, boolean startsWith) { @@ -97,12 +94,11 @@ public class StartsEndsWithFunctions { } } - @SuppressWarnings("unused") @RBuiltin(name = "startsWith", kind = INTERNAL, parameterNames = {"x", "prefix"}, behavior = PURE) public abstract static class StartsWith extends Adapter { static { - new AdapterCasts(StartsWith.class); + createCasts(StartsWith.class); } @Specialization @@ -111,12 +107,11 @@ public class StartsEndsWithFunctions { } } - @SuppressWarnings("unused") @RBuiltin(name = "endsWith", kind = INTERNAL, parameterNames = {"x", "prefix"}, behavior = PURE) public abstract static class EndsWith extends Adapter { static { - new AdapterCasts(EndsWith.class); + createCasts(EndsWith.class); } @Specialization diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/TraceFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/TraceFunctions.java index 6ea603fb467c1a0032320ea2261f99bedbb11350..5521a01b4d0244172289017dce886884108a7391 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/TraceFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/TraceFunctions.java @@ -69,12 +69,11 @@ public class TraceFunctions { private abstract static class PrimTraceAdapter extends RBuiltinNode { @Child private GetFunctions.Get getNode; - static final class PrimTraceCasts extends Casts { - PrimTraceCasts(Class<? extends PrimTraceAdapter> extCls) { - super(extCls); - casts.arg("what").mustBe(instanceOf(RFunction.class).or(stringValue()), SHOW_CALLER, Message.ARG_MUST_BE_FUNCTION).mapIf(stringValue(), - chain(asStringVector()).with(findFirst().stringElement()).end()); - } + protected static Casts createCasts(Class<? extends PrimTraceAdapter> extCls) { + Casts casts = new Casts(extCls); + casts.arg("what").mustBe(instanceOf(RFunction.class).or(stringValue()), SHOW_CALLER, Message.ARG_MUST_BE_FUNCTION).mapIf(stringValue(), + chain(asStringVector()).with(findFirst().stringElement()).end()); + return casts; } protected Object getFunction(VirtualFrame frame, String funcName) { @@ -90,7 +89,7 @@ public class TraceFunctions { public abstract static class PrimTrace extends PrimTraceAdapter { static { - new PrimTraceCasts(PrimTrace.class); + createCasts(PrimTrace.class); } @Specialization @@ -114,7 +113,7 @@ public class TraceFunctions { public abstract static class PrimUnTrace extends PrimTraceAdapter { static { - new PrimTraceCasts(PrimUnTrace.class); + createCasts(PrimUnTrace.class); } @Specialization 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 7d0478eb4daa6ba146baad83c19c9eadf0404168..1a7797de13201002e0ffbcd5197989a1491c5b01 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 @@ -110,11 +110,10 @@ public class WhichFunctions { this.isMax = isMax; } - static final class WhichMinMaxs extends Casts { - protected WhichMinMaxs(Class<? extends WhichMinMax> extCls) { - super(extCls); - casts.arg(0, "x").asDoubleVector(true, false, false); - } + protected static Casts createCasts(Class<? extends WhichMinMax> extCls) { + Casts casts = new Casts(extCls); + casts.arg(0, "x").asDoubleVector(true, false, false); + return casts; } @Specialization @@ -159,7 +158,7 @@ public class WhichFunctions { public abstract static class WhichMax extends WhichMinMax { static { - new WhichMinMaxs(WhichMax.class); + createCasts(WhichMax.class); } protected WhichMax() { @@ -175,7 +174,7 @@ public class WhichFunctions { public abstract static class WhichMin extends WhichMinMax { static { - new WhichMinMaxs(WhichMin.class); + createCasts(WhichMin.class); } protected WhichMin() { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/UpdateField.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/UpdateField.java index dd6ee6a107f3b4dbbe310220b0e7faafc912b12b..d5ff59a1c998bf95082b0f30f173738d2e50f227 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/UpdateField.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/UpdateField.java @@ -46,7 +46,6 @@ import com.oracle.truffle.r.nodes.unary.CastListNodeGen; import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RError.Message; -import com.oracle.truffle.r.runtime.RType; import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.builtins.RSpecialFactory; import com.oracle.truffle.r.runtime.data.RList; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNode.java index 56de20fc59ab85905959cd34a4e2475b028def6e..44e7a6d2dfe803a82918c3f29d4ee2cdf9549a02 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNode.java @@ -104,9 +104,9 @@ public abstract class ExtractVectorNode extends Node { } @Specialization(guards = {"isForeignObject(object)", "positions.length == cachedLength"}) - protected Object accessField(TruffleObject object, Object[] positions, Object exact, Object dropDimensions, + protected Object accessField(TruffleObject object, Object[] positions, @SuppressWarnings("unused") Object exact, @SuppressWarnings("unused") Object dropDimensions, @Cached("createForeignRead(positions)") Node foreignRead, - @SuppressWarnings("unused") @Cached("positions.length") int cachedLength, + @Cached("positions.length") @SuppressWarnings("unused") int cachedLength, @Cached("create()") CastStringNode castNode, @Cached("createFirstString()") FirstStringNode firstString, @Cached("createClassProfile()") ValueProfile positionProfile) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveExtractSubscriptNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveExtractSubscriptNode.java index 6448ae873996615b53c11222277c52639a21e228..621139cc8a374fc495e28a0bb029665cefc392c1 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveExtractSubscriptNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveExtractSubscriptNode.java @@ -54,7 +54,7 @@ abstract class RecursiveExtractSubscriptNode extends RecursiveSubscriptNode { protected abstract Object execute(VirtualFrame frame, Object vector, Object[] positions, Object firstPosition, int positionLength, Object exact, Object dropDimensions); @Specialization(guards = "positionLength <= 1") - protected Object doDefault(VirtualFrame frame, Object vector, Object[] positions, Object firstPosition, @SuppressWarnings({"unused", "unused"}) int positionLength, Object exact, + protected Object doDefault(VirtualFrame frame, Object vector, Object[] positions, @SuppressWarnings("unused") Object firstPosition, @SuppressWarnings("unused") int positionLength, Object exact, Object dropDimensions) { try { return subscriptExtract.apply(frame, vector, positions, exact, dropDimensions); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/NodeWithArgumentCasts.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/NodeWithArgumentCasts.java index 01a7e12b531c71198c49d70b8655ed36e5be9f24..cd1b4a44df02358d9f906a802376a1a563e9abb9 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/NodeWithArgumentCasts.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/NodeWithArgumentCasts.java @@ -44,7 +44,7 @@ public interface NodeWithArgumentCasts { return casts; } - class Casts { + final class Casts { private static final ConcurrentHashMap<Class<?>, Casts> castsMap = new ConcurrentHashMap<>(); private static final Casts empty = new Casts(); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tools/RFFIUpCallMethodGenerate.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tools/RFFIUpCallMethodGenerate.java index 60881ee7aa783cb76a6fd2a395922f92b7c708df..85f600102edbe908fc920d4cf39986245b44a250 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tools/RFFIUpCallMethodGenerate.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tools/RFFIUpCallMethodGenerate.java @@ -23,13 +23,11 @@ package com.oracle.truffle.r.test.tools; import java.lang.annotation.Annotation; -import java.lang.reflect.AnnotatedType; import java.lang.reflect.Method; import java.util.Arrays; import java.util.Comparator; import com.oracle.truffle.r.nodes.ffi.RFFIUpCallMethod; -import com.oracle.truffle.r.runtime.ffi.RFFICstring; import com.oracle.truffle.r.runtime.ffi.UpCallsRFFI; /**