Skip to content

Commit 2b3f960

Browse files
committed
always return dimension for foreign arrays, even if resulting in list
1 parent 9d71429 commit 2b3f960

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/interop/InspectForeignArrayNode.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,17 @@ public static InspectForeignArrayNode create() {
6262
*/
6363
public ArrayInfo getArrayInfo(TruffleObject obj) {
6464
ArrayInfo info = new ArrayInfo();
65-
if (execute(obj, true, info, 0)) {
65+
if (execute(obj, true, info, 0, false)) {
6666
return info;
6767
}
6868
return null;
6969
}
7070

71-
protected abstract boolean execute(Object obj, boolean recursive, ArrayInfo data, int depth);
71+
protected abstract boolean execute(Object obj, boolean recursive, ArrayInfo data, int depth, boolean skipIfList);
7272

7373
@Specialization(guards = {"isForeignArray(obj, hasSize)"})
7474
@CompilerDirectives.TruffleBoundary
75-
protected boolean inspectArray(TruffleObject obj, boolean recursive, ArrayInfo data, int depth) {
75+
protected boolean inspectArray(TruffleObject obj, boolean recursive, ArrayInfo data, int depth, boolean skipIfList) {
7676
try {
7777
ArrayInfo arrayInfo = data == null ? new ArrayInfo() : data;
7878
int size = (int) ForeignAccess.sendGetSize(getSize, obj);
@@ -85,7 +85,7 @@ protected boolean inspectArray(TruffleObject obj, boolean recursive, ArrayInfo d
8585
boolean isArray = isForeignArray(element, hasSize);
8686

8787
if (recursive && isArray) {
88-
if (!recurse(arrayInfo, element, depth)) {
88+
if (!recurse(arrayInfo, element, depth, skipIfList)) {
8989
return false;
9090
}
9191
} else if (!recursive && isArray) {
@@ -96,7 +96,7 @@ protected boolean inspectArray(TruffleObject obj, boolean recursive, ArrayInfo d
9696
return false;
9797
} else {
9898
RType elementType = arrayInfo.typeCheck.check(getForeign2R().execute(element));
99-
if (elementType == RType.List) {
99+
if (skipIfList && elementType == RType.List) {
100100
return false;
101101
}
102102
}
@@ -110,16 +110,16 @@ protected boolean inspectArray(TruffleObject obj, boolean recursive, ArrayInfo d
110110

111111
@Fallback
112112
protected boolean fallback(@SuppressWarnings("unused") Object obj, @SuppressWarnings("unused") boolean recursive, @SuppressWarnings("unused") ArrayInfo data,
113-
@SuppressWarnings("unused") int depth) {
113+
@SuppressWarnings("unused") int depth, @SuppressWarnings("unused") boolean skipIfList) {
114114
return false;
115115
}
116116

117-
private boolean recurse(ArrayInfo arrayInfo, Object element, int depth) {
117+
private boolean recurse(ArrayInfo arrayInfo, Object element, int depth, boolean skipIfList) {
118118
if (inspectTruffleObject == null) {
119119
CompilerDirectives.transferToInterpreterAndInvalidate();
120120
inspectTruffleObject = insert(create());
121121
}
122-
return inspectTruffleObject.execute(element, true, arrayInfo, depth + 1);
122+
return inspectTruffleObject.execute(element, true, arrayInfo, depth + 1, skipIfList);
123123
}
124124

125125
public static final class ArrayInfo {
@@ -137,7 +137,7 @@ public int[] getDims() {
137137
return isRectMultiDim() ? dims.stream().mapToInt((i) -> i.intValue()).toArray() : null;
138138
}
139139

140-
private boolean isRectMultiDim() {
140+
boolean isRectMultiDim() {
141141
return canUseDims && dims.size() > 1;
142142
}
143143

0 commit comments

Comments
 (0)