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