Skip to content

Commit d8e06cb

Browse files
committed
Remove the scalar list and replace with regular list
1 parent 8a076f7 commit d8e06cb

File tree

7 files changed

+11
-170
lines changed

7 files changed

+11
-170
lines changed

com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedReplaceVectorNode.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
import com.oracle.truffle.r.runtime.data.RList;
5959
import com.oracle.truffle.r.runtime.data.RMissing;
6060
import com.oracle.truffle.r.runtime.data.RNull;
61-
import com.oracle.truffle.r.runtime.data.RScalarList;
6261
import com.oracle.truffle.r.runtime.data.RScalarVector;
6362
import com.oracle.truffle.r.runtime.data.RSharingAttributeStorage;
6463
import com.oracle.truffle.r.runtime.data.RStringVector;
@@ -200,7 +199,7 @@ public Object apply(RAbstractVector originalVector, Object[] originalPositions,
200199
} else {
201200
if ((castType == RType.List || castType == RType.Expression) && mode.isSubscript() && !isDeleteElements() && !(castValue instanceof RScalarVector)) {
202201
// wrap into a list when
203-
value = RScalarList.valueOf(castValue);
202+
value = RDataFactory.createListFromScalar(castValue);
204203
} else {
205204
value = (RAbstractContainer) castValue;
206205
}

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RComplex.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -86,7 +86,7 @@ public RAbstractVector castSafe(RType type, ConditionProfile isNAProfile, boolea
8686
case Character:
8787
return RString.valueOf(RContext.getRRuntimeASTAccess().encodeComplex(this));
8888
case List:
89-
return RScalarList.valueOf(this);
89+
return RDataFactory.createListFromScalar(this);
9090
default:
9191
return null;
9292
}

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RDataFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,11 @@ public static RList createList() {
11431143
return createList(new Object[0]);
11441144
}
11451145

1146+
public static RList createListFromScalar(Object value) {
1147+
assert value != null;
1148+
return new RList(new Object[]{value});
1149+
}
1150+
11461151
public static RList createList(int n) {
11471152
return createList(createRNullArray(n));
11481153
}

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RLogical.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public RAbstractVector castSafe(RType type, ConditionProfile isNAProfile, boolea
9595
case Character:
9696
return RString.valueOf(RRuntime.logicalToString(value));
9797
case List:
98-
return RScalarList.valueOf(this);
98+
return RDataFactory.createListFromScalar(this);
9999
default:
100100
return null;
101101
}

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RScalarList.java

Lines changed: 0 additions & 151 deletions
This file was deleted.

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RString.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -80,7 +80,7 @@ public RAbstractVector castSafe(RType type, ConditionProfile isNAProfile, boolea
8080
case Character:
8181
return this;
8282
case List:
83-
return RScalarList.valueOf(this);
83+
return RDataFactory.createListFromScalar(this);
8484
default:
8585
return null;
8686
}

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/FFIMaterializeNode.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import com.oracle.truffle.r.runtime.data.RRaw;
4646
import com.oracle.truffle.r.runtime.data.RRawVector;
4747
import com.oracle.truffle.r.runtime.data.RScalar;
48-
import com.oracle.truffle.r.runtime.data.RScalarList;
4948
import com.oracle.truffle.r.runtime.data.RScalarVector;
5049
import com.oracle.truffle.r.runtime.data.RSequence;
5150
import com.oracle.truffle.r.runtime.data.RString;
@@ -136,17 +135,6 @@ protected static Object wrap(RLogical value, boolean protect,
136135
}
137136
}
138137

139-
@Specialization
140-
protected static Object wrap(RScalarList value, boolean protect,
141-
@Cached("createBinaryProfile()") ConditionProfile isProtected) {
142-
if (isProtected.profile(protect)) {
143-
return protectMaterialized(value, v -> RDataFactory.createList(new Object[]{v.getValue()}));
144-
} else {
145-
return value.materialize();
146-
147-
}
148-
}
149-
150138
// Sequences: life-cycle of the materialized vector is cached and tied with the sequence via a
151139
// field inside the sequence
152140

0 commit comments

Comments
 (0)