Skip to content
Snippets Groups Projects
Commit 89485996 authored by Stepan Sindelar's avatar Stepan Sindelar
Browse files

[GR-2798] Minor fixes to enable lattice user story.

PullRequest: fastr/1189
parents fa0a44b1 52645645
No related branches found
No related tags found
No related merge requests found
......@@ -47,13 +47,14 @@ import com.oracle.truffle.r.runtime.data.RComplexVector;
import com.oracle.truffle.r.runtime.data.RDoubleVector;
import com.oracle.truffle.r.runtime.data.RIntVector;
import com.oracle.truffle.r.runtime.data.RLogicalVector;
import com.oracle.truffle.r.runtime.data.RNull;
import com.oracle.truffle.r.runtime.data.RRawVector;
import com.oracle.truffle.r.runtime.data.RVector;
import com.oracle.truffle.r.runtime.ffi.DLL;
import com.oracle.truffle.r.runtime.ffi.NativeFunction;
import com.oracle.truffle.r.runtime.ffi.DLL.CEntry;
import com.oracle.truffle.r.runtime.ffi.DLL.DLLInfo;
import com.oracle.truffle.r.runtime.ffi.DLL.DotSymbol;
import com.oracle.truffle.r.runtime.ffi.NativeFunction;
import com.oracle.truffle.r.runtime.ffi.UnsafeAdapter;
public class TruffleNFI_UpCallsRFFIImpl extends JavaUpCallsRFFIImpl {
......@@ -92,6 +93,8 @@ public class TruffleNFI_UpCallsRFFIImpl extends JavaUpCallsRFFIImpl {
}
public abstract static class DispatchAllocate extends Node {
private static final long EMPTY_DATA_ADDRESS = 0x1BAD;
public abstract long execute(Object vector);
@Specialization
......@@ -124,6 +127,12 @@ public class TruffleNFI_UpCallsRFFIImpl extends JavaUpCallsRFFIImpl {
return vector.allocateNativeContents();
}
@Specialization
protected static long get(RNull nullValue) {
// Note: GnuR is OK with e.g. INTEGER(RNull), it probably returns some garbage
return EMPTY_DATA_ADDRESS;
}
@Fallback
protected static long get(Object vector) {
throw RInternalError.shouldNotReachHere("invalid wrapped object " + vector.getClass().getSimpleName());
......@@ -167,33 +176,33 @@ public class TruffleNFI_UpCallsRFFIImpl extends JavaUpCallsRFFIImpl {
@Override
public Object INTEGER(Object x) {
// also handles LOGICAL
assert x instanceof RIntVector || x instanceof RLogicalVector;
return new VectorWrapper(guaranteeInstanceOf(x, RVector.class));
assert x instanceof RIntVector || x instanceof RLogicalVector || x == RNull.instance;
return new VectorWrapper(guaranteeVectorOrNull(x, RVector.class));
}
@Override
public Object LOGICAL(Object x) {
return new VectorWrapper(guaranteeInstanceOf(x, RLogicalVector.class));
return new VectorWrapper(guaranteeVectorOrNull(x, RLogicalVector.class));
}
@Override
public Object REAL(Object x) {
return new VectorWrapper(guaranteeInstanceOf(x, RDoubleVector.class));
return new VectorWrapper(guaranteeVectorOrNull(x, RDoubleVector.class));
}
@Override
public Object RAW(Object x) {
return new VectorWrapper(guaranteeInstanceOf(x, RRawVector.class));
return new VectorWrapper(guaranteeVectorOrNull(x, RRawVector.class));
}
@Override
public Object COMPLEX(Object x) {
return new VectorWrapper(guaranteeInstanceOf(x, RComplexVector.class));
return new VectorWrapper(guaranteeVectorOrNull(x, RComplexVector.class));
}
@Override
public Object R_CHAR(Object x) {
return new VectorWrapper(guaranteeInstanceOf(x, CharSXPWrapper.class));
return new VectorWrapper(guaranteeVectorOrNull(x, CharSXPWrapper.class));
}
@Override
......@@ -222,4 +231,11 @@ public class TruffleNFI_UpCallsRFFIImpl extends JavaUpCallsRFFIImpl {
private static TruffleNFI_Context getContext() {
return (TruffleNFI_Context) RContext.getInstance().getStateRFFI();
}
private static Object guaranteeVectorOrNull(Object obj, Class<?> clazz) {
if (obj == RNull.instance) {
return RNull.instance;
}
return guaranteeInstanceOf(obj, clazz);
}
}
......@@ -36,6 +36,7 @@ import com.oracle.truffle.r.runtime.data.RLogical;
import com.oracle.truffle.r.runtime.data.RObject;
import com.oracle.truffle.r.runtime.data.RRaw;
import com.oracle.truffle.r.runtime.data.RScalarList;
import com.oracle.truffle.r.runtime.data.RSequence;
public abstract class FFIWrapNode extends Node {
......@@ -101,6 +102,11 @@ public abstract class FFIWrapNode extends Node {
return value;
}
@Specialization
protected static Object wrap(RSequence seq) {
return seq.createVector();
}
@Fallback
protected static Object wrap(Object value) {
CompilerDirectives.transferToInterpreter();
......
......@@ -271,7 +271,6 @@ public class SVGDevice implements GridDevice, FileGridDevice {
if (!noFill && !ctx.getFillColor().equals(GridColor.TRANSPARENT)) {
data.append(';');
appendStyleColorAttrs("fill", ctx.getFillColor());
data.append('\'');
}
data.append('\'');
}
......
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