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

A missing spec added

parent 9881ef5b
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,7 @@ import com.oracle.truffle.r.runtime.data.RNull;
import com.oracle.truffle.r.runtime.data.RStringVector;
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;
import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector;
import com.oracle.truffle.r.runtime.data.model.RAbstractVector;
......@@ -175,6 +176,22 @@ public abstract class Sprintf extends RBuiltinNode.Arg2 {
return RDataFactory.createStringVector(r, RDataFactory.COMPLETE_VECTOR);
}
@Specialization(guards = "fmtLengthOne(fmt)")
@TruffleBoundary
protected RStringVector sprintf(RAbstractStringVector fmt, RAbstractLogicalVector x) {
return sprintf(fmt.getDataAt(0), x);
}
@Specialization
@TruffleBoundary
protected RStringVector sprintf(String fmt, RAbstractLogicalVector x) {
String[] r = new String[x.getLength()];
for (int k = 0; k < r.length; k++) {
r[k] = format(fmt, x.getDataAt(k));
}
return RDataFactory.createStringVector(r, RDataFactory.COMPLETE_VECTOR);
}
@Specialization(guards = "fmtLengthOne(fmt)")
@TruffleBoundary
protected RStringVector sprintf(RAbstractStringVector fmt, RAbstractStringVector x) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment