Skip to content
Snippets Groups Projects
Commit 555e6319 authored by Tomas Stupka's avatar Tomas Stupka
Browse files

support RInteropScalar in print() and paste()

parent 4d4b8b91
No related branches found
No related tags found
No related merge requests found
......@@ -271,7 +271,7 @@ public abstract class Paste extends RBuiltinNode.Arg3 {
private CastNode getAsCharacterNode() {
if (asCharacterNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
asCharacterNode = insert(newCastBuilder().returnIf(nullValue(), emptyStringVector()).asStringVector().buildCastNode());
asCharacterNode = insert(newCastBuilder().castForeignObjects(true).returnIf(nullValue(), emptyStringVector()).asStringVector().buildCastNode());
}
return asCharacterNode;
}
......
......@@ -24,6 +24,7 @@ package com.oracle.truffle.r.nodes.builtin.casts;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.r.nodes.unary.CastNode;
import com.oracle.truffle.r.runtime.data.RInteropScalar;
import com.oracle.truffle.r.runtime.interop.ForeignArray2R;
public final class CastForeignNode extends CastNode {
......@@ -31,13 +32,20 @@ public final class CastForeignNode extends CastNode {
@Child private ForeignArray2R foreignArray2R = ForeignArray2R.create();
private final ConditionProfile isForeign = ConditionProfile.createBinaryProfile();
private final ConditionProfile isInteropScalar = ConditionProfile.createBinaryProfile();
@Override
protected Object execute(Object obj) {
if (isForeign.profile(foreignArray2R.isForeignVector(obj))) {
return foreignArray2R.convert(obj);
} else if (isInteropScalar.profile(isInteropScalar(obj))) {
return ((RInteropScalar) obj).getRValue();
} else {
return obj;
}
}
protected boolean isInteropScalar(Object obj) {
return obj instanceof RInteropScalar;
}
}
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