Skip to content
Snippets Groups Projects
Commit 6cf7fd1c authored by Miloslav Metelka's avatar Miloslav Metelka
Browse files

Several builtins' casts added.

parent cceb99dd
No related branches found
No related tags found
No related merge requests found
......@@ -203,7 +203,12 @@ public class MethodsListDispatch {
@Child private AccessSlotNode accessSlotNode;
static {
Casts.noCasts(R_M_setPrimitiveMethods.class);
Casts casts = new Casts(R_M_setPrimitiveMethods.class);
casts.arg(0, "fname").asStringVector().findFirst();
casts.arg(1, "op");
casts.arg(2, "code").mustBe(stringValue()).asStringVector().findFirst();
casts.arg(3, "fundef");
casts.arg(4, "mlist");
}
private AccessSlotNode initAccessSlotNode() {
......@@ -215,12 +220,8 @@ public class MethodsListDispatch {
@Specialization
@TruffleBoundary
protected Object setPrimitiveMethods(Object fname, Object op, Object codeVec, RTypedValue fundef, Object mlist) {
String fnameString = RRuntime.asString(fname);
String codeVecString = RRuntime.asString(codeVec);
if (codeVecString == null) {
throw RError.error(this, RError.Message.GENERIC, "argument 'code' must be a character string");
}
protected Object setPrimitiveMethods(String fnameString, Object op, String codeVecString, Object fundefObj, Object mlist) {
RTypedValue fundef = (RTypedValue) fundefObj;
if (op == RNull.instance) {
byte value = RRuntime.asLogical(RContext.getInstance().allowPrimitiveMethods());
......
......@@ -20,6 +20,8 @@ import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.constant;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.findFirst;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.integerValue;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.numericValue;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.doubleValue;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.instanceOf;
import com.oracle.truffle.r.nodes.builtin.RExternalBuiltinNode;
import com.oracle.truffle.r.runtime.RError;
import static com.oracle.truffle.r.runtime.RError.Message.NA_INTRODUCED_COERCION;
......@@ -79,6 +81,12 @@ public class SplineFunctions {
public abstract static class SplineEval extends RExternalBuiltinNode.Arg2 {
static {
Casts casts = new Casts(SplineEval.class);
casts.arg(0, "xout").mustBe(doubleValue()).asDoubleVector();
casts.arg(1, "z").mustBe(instanceOf(RList.class));
}
@Specialization
@TruffleBoundary
protected Object splineEval(RAbstractDoubleVector xout, RList z) {
......
......@@ -30,6 +30,9 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.Frame;
import com.oracle.truffle.api.nodes.Node;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.doubleValue;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.instanceOf;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.stringValue;
import com.oracle.truffle.r.nodes.builtin.RExternalBuiltinNode;
import com.oracle.truffle.r.runtime.RArguments;
import com.oracle.truffle.r.runtime.RError;
......@@ -48,6 +51,13 @@ import com.oracle.truffle.r.runtime.instrument.InstrumentationState.RprofState;
public abstract class Rprofmem extends RExternalBuiltinNode.Arg3 implements RDataFactory.Listener {
static {
Casts casts = new Casts(Rprofmem.class);
casts.arg(0, "filename").mustBe(stringValue()).asStringVector();
casts.arg(1, "append").mustBe(instanceOf(byte.class));
casts.arg(2, "threshold").mustBe(doubleValue()).asDoubleVector();
}
@Specialization
@TruffleBoundary
public Object doRprofmem(RAbstractStringVector filenameVec, byte appendL, RAbstractDoubleVector thresholdVec) {
......
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