Skip to content

Commit 40d167e

Browse files
committed
Add abstract base class for non-CVM CAD3 records
1 parent ecf4a94 commit 40d167e

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

convex-core/src/main/java/convex/core/data/ANonCVM.java renamed to convex-core/src/main/java/convex/core/data/ACAD3Record.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@
55
import convex.core.lang.RT;
66

77
/**
8-
* Abstract base class for non-CVM values. These should always have an encoding
9-
* since the only way to create them is load from network or storage
8+
* Abstract base class for non-CVM CAD3 Records values. These look like countable sequences to CVM code.
9+
*
10+
* These should always have an encoding since the only way to create them is load from network or storage
1011
*/
11-
public class ANonCVM extends ACell {
12+
public abstract class ACAD3Record extends ASequence<ACell> {
13+
14+
public ACAD3Record(long count) {
15+
super(count);
16+
}
1217

1318
@Override
1419
public int estimatedEncodingSize() {

convex-core/src/main/java/convex/core/data/ASequence.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,6 @@ public final boolean addAll(int index, Collection<? extends T> c) {
110110
public T get(int index) {
111111
return get((long) index);
112112
}
113-
114-
/**
115-
* Sequences are always valid CVM values
116-
*/
117-
@Override public final boolean isCVMValue() {
118-
return true;
119-
}
120113

121114
@Override
122115
public abstract T get(long index);

convex-core/src/main/java/convex/core/data/AVector.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ public final ListIterator<T> listIterator(int index) {
183183
*/
184184
@Override
185185
public abstract boolean isCanonical();
186+
187+
@Override public final boolean isCVMValue() {
188+
// Vectors are always valid CVM values
189+
return true;
190+
}
186191

187192
@Override
188193
public abstract AVector<T> updateRefs(IRefFunction func);

convex-core/src/main/java/convex/core/data/List.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ public boolean isCanonical() {
236236
return true;
237237
}
238238

239+
@Override public final boolean isCVMValue() {
240+
// Lists are always valid CVM values
241+
return true;
242+
}
243+
239244
@Override
240245
public boolean print(BlobBuilder bb, long limit) {
241246
bb.append('(');

convex-core/src/test/java/convex/core/data/CAD3Test.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class CAD3Test {
2929
@Test public void testReadEncodings() {
3030
assertSame(Address.ZERO,Reader.read("#[2100]"));
3131
assertSame(CVMLong.ZERO,Reader.read("#[10]"));
32+
assertSame(Vectors.empty(),Reader.read("#[8000]"));
3233
assertNull(Reader.read("#[00]"));
3334
assertEquals(ExtensionValue.create((byte) 0xe5, 0),Reader.read("#[e500]"));
3435
}

convex-core/src/test/java/convex/core/data/ObjectsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
*/
3030
public class ObjectsTest {
3131
/**
32-
* Generic tests for any valid CVM Value (including null). Should pass for
33-
* *any* ACell where RT.isCVM(..) returns true and validate(...) succeeds.
32+
* Generic tests for any valid Value (including null). Should pass for
33+
* *any* non-partial cell where validate(...) succeeds.
3434
*
3535
* @param a Value to test
3636
*/

0 commit comments

Comments
 (0)