Skip to content
Snippets Groups Projects
Commit 80161f43 authored by Zbynek Slajchrt's avatar Zbynek Slajchrt
Browse files

Empty vector handling fixed in the cumulative builtins

parent 2ce439b6
Branches
No related tags found
No related merge requests found
......@@ -35,6 +35,7 @@ import com.oracle.truffle.r.runtime.data.RDoubleVector;
import com.oracle.truffle.r.runtime.data.RIntSequence;
import com.oracle.truffle.r.runtime.data.RIntVector;
import com.oracle.truffle.r.runtime.data.RNull;
import com.oracle.truffle.r.runtime.data.model.RAbstractComplexVector;
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.RAbstractVector;
......@@ -48,8 +49,8 @@ public abstract class CumMax extends RBuiltinNode {
@Override
protected void createCasts(CastBuilder casts) {
casts.arg("x").allowNull().mustBe(complexValue().not(), RError.Message.CUMMAX_UNDEFINED_FOR_COMPLEX).mapIf(integerValue().or(logicalValue()), asIntegerVector(),
asDoubleVector());
casts.arg("x").allowNull().mustBe(complexValue().not(), RError.Message.CUMMAX_UNDEFINED_FOR_COMPLEX).mapIf(integerValue().or(logicalValue()), asIntegerVector(true, false, false),
asDoubleVector(true, false, false));
}
@Specialization
......@@ -68,7 +69,17 @@ public abstract class CumMax extends RBuiltinNode {
}
@Specialization(guards = "emptyVec.getLength()==0")
protected RAbstractVector cumEmpty(@SuppressWarnings("unused") RAbstractVector emptyVec) {
protected RAbstractVector cumEmpty(@SuppressWarnings("unused") RAbstractComplexVector emptyVec) {
return RDataFactory.createEmptyComplexVector();
}
@Specialization(guards = "emptyVec.getLength()==0")
protected RAbstractVector cumEmpty(@SuppressWarnings("unused") RAbstractIntVector emptyVec) {
return RDataFactory.createEmptyIntVector();
}
@Specialization(guards = "emptyVec.getLength()==0")
protected RAbstractVector cumEmpty(@SuppressWarnings("unused") RAbstractDoubleVector emptyVec) {
return RDataFactory.createEmptyDoubleVector();
}
......
......@@ -35,6 +35,7 @@ import com.oracle.truffle.r.runtime.data.RDoubleVector;
import com.oracle.truffle.r.runtime.data.RIntSequence;
import com.oracle.truffle.r.runtime.data.RIntVector;
import com.oracle.truffle.r.runtime.data.RNull;
import com.oracle.truffle.r.runtime.data.model.RAbstractComplexVector;
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.RAbstractVector;
......@@ -48,8 +49,8 @@ public abstract class CumMin extends RBuiltinNode {
@Override
protected void createCasts(CastBuilder casts) {
casts.arg("x").allowNull().mustBe(complexValue().not(), RError.Message.CUMMIN_UNDEFINED_FOR_COMPLEX).mapIf(integerValue().or(logicalValue()), asIntegerVector(),
asDoubleVector());
casts.arg("x").allowNull().mustBe(complexValue().not(), RError.Message.CUMMIN_UNDEFINED_FOR_COMPLEX).mapIf(integerValue().or(logicalValue()), asIntegerVector(true, false, false),
asDoubleVector(true, false, false));
}
@Specialization
......@@ -68,7 +69,17 @@ public abstract class CumMin extends RBuiltinNode {
}
@Specialization(guards = "emptyVec.getLength()==0")
protected RAbstractVector cumEmpty(@SuppressWarnings("unused") RAbstractVector emptyVec) {
protected RAbstractVector cumEmpty(@SuppressWarnings("unused") RAbstractComplexVector emptyVec) {
return RDataFactory.createEmptyComplexVector();
}
@Specialization(guards = "emptyVec.getLength()==0")
protected RAbstractVector cumEmpty(@SuppressWarnings("unused") RAbstractIntVector emptyVec) {
return RDataFactory.createEmptyIntVector();
}
@Specialization(guards = "emptyVec.getLength()==0")
protected RAbstractVector cumEmpty(@SuppressWarnings("unused") RAbstractDoubleVector emptyVec) {
return RDataFactory.createEmptyDoubleVector();
}
......
......@@ -11,12 +11,7 @@
package com.oracle.truffle.r.nodes.builtin.base;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.asDoubleVector;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.asIntegerVector;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.chain;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.complexValue;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.integerValue;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.logicalValue;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.mapIf;
import static com.oracle.truffle.r.runtime.RDispatch.MATH_GROUP_GENERIC;
import static com.oracle.truffle.r.runtime.builtins.RBehavior.PURE;
import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE;
......@@ -52,7 +47,7 @@ public abstract class CumProd extends RBuiltinNode {
@Override
protected void createCasts(CastBuilder casts) {
casts.arg("x").allowNull().mapIf(integerValue().or(logicalValue()), asIntegerVector(), chain(mapIf(complexValue().not(), asDoubleVector())).end());
casts.arg("x").allowNull().mapIf(complexValue().not(), asDoubleVector(true, false, false));
}
@Specialization
......@@ -71,7 +66,12 @@ public abstract class CumProd extends RBuiltinNode {
}
@Specialization(guards = "emptyVec.getLength()==0")
protected RAbstractVector cumEmpty(@SuppressWarnings("unused") RAbstractVector emptyVec) {
protected RAbstractVector cumEmpty(@SuppressWarnings("unused") RAbstractComplexVector emptyVec) {
return RDataFactory.createEmptyComplexVector();
}
@Specialization(guards = "emptyVec.getLength()==0")
protected RAbstractVector cumEmpty(@SuppressWarnings("unused") RAbstractDoubleVector emptyVec) {
return RDataFactory.createEmptyDoubleVector();
}
......
......@@ -65,7 +65,7 @@ public abstract class CumSum extends RBuiltinNode {
@Override
protected void createCasts(CastBuilder casts) {
casts.arg("x").allowNull().mapIf(integerValue().or(logicalValue()), asIntegerVector(), chain(mapIf(complexValue().not(), asDoubleVector())).end());
casts.arg("x").allowNull().mapIf(integerValue().or(logicalValue()), asIntegerVector(true, false, false), chain(mapIf(complexValue().not(), asDoubleVector(true, false, false))).end());
}
@Specialization
......@@ -84,7 +84,17 @@ public abstract class CumSum extends RBuiltinNode {
}
@Specialization(guards = "emptyVec.getLength()==0")
protected RAbstractVector cumEmpty(@SuppressWarnings("unused") RAbstractVector emptyVec) {
protected RAbstractVector cumEmpty(@SuppressWarnings("unused") RAbstractComplexVector emptyVec) {
return RDataFactory.createEmptyComplexVector();
}
@Specialization(guards = "emptyVec.getLength()==0")
protected RAbstractVector cumEmpty(@SuppressWarnings("unused") RAbstractIntVector emptyVec) {
return RDataFactory.createEmptyIntVector();
}
@Specialization(guards = "emptyVec.getLength()==0")
protected RAbstractVector cumEmpty(@SuppressWarnings("unused") RAbstractDoubleVector emptyVec) {
return RDataFactory.createEmptyDoubleVector();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment