Skip to content
Snippets Groups Projects
Commit 16eedc59 authored by Mick Jordan's avatar Mick Jordan
Browse files

add FFI up-return tracing

parent 618630e3
Branches
No related tags found
No related merge requests found
......@@ -74,20 +74,37 @@ public class RFFIUtils {
}
}
private enum CallMode {
UP("Up"),
UP_RETURN("UpReturn"),
DOWN("Down"),
DOWN_RETURN("DownReturn");
private final String printName;
CallMode(String printName) {
this.printName = printName;
}
}
public static void traceUpCall(String name, Object... args) {
traceCall(false, name, args);
traceCall(CallMode.UP, name, args);
}
public static void traceUpCallReturn(String name, Object... args) {
traceCall(CallMode.UP_RETURN, name, args);
}
public static void traceDownCall(String name, Object... args) {
traceCall(true, name, args);
traceCall(CallMode.DOWN, name, args);
}
private static void traceCall(boolean down, String name, Object... args) {
private static void traceCall(CallMode mode, String name, Object... args) {
if (alwaysTrace || FastROptions.TraceNativeCalls.getBooleanValue()) {
initialize();
StringBuffer sb = new StringBuffer();
sb.append("CallRFFI[");
sb.append(down ? "Down" : "Up");
sb.append(mode.printName);
sb.append(']');
sb.append(name);
sb.append('(');
......
......@@ -327,24 +327,27 @@ public class CallRFFIHelper {
public static RStringVector getClassHr(Object v) {
RFFIUtils.traceUpCall("getClassHr", v);
RStringVector result;
if (v instanceof RAttributable) {
return ((RAttributable) v).getClassHierarchy();
result = ((RAttributable) v).getClassHierarchy();
} else if (v instanceof Byte) {
return RLogicalVector.implicitClassHeader;
result = RLogicalVector.implicitClassHeader;
} else if (v instanceof String) {
return RStringVector.implicitClassHeader;
result = RStringVector.implicitClassHeader;
} else if (v instanceof Integer) {
return RIntVector.implicitClassHeader;
result = RIntVector.implicitClassHeader;
} else if (v instanceof Double) {
return RDoubleVector.implicitClassHeader;
result = RDoubleVector.implicitClassHeader;
} else if (v instanceof RComplex) {
return RComplexVector.implicitClassHeader;
result = RComplexVector.implicitClassHeader;
} else if (v instanceof RRaw) {
return RRawVector.implicitClassHeader;
result = RRawVector.implicitClassHeader;
} else {
guaranteeInstanceOf(v, RNull.class);
return RNull.implicitClassHeader;
result = RNull.implicitClassHeader;
}
RFFIUtils.traceUpCallReturn("getClassHr", result);
return result;
}
public static int Rf_inherits(Object x, String clazz) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment