Skip to content

Commit ec2a964

Browse files
authored
Merge branch 'ion11' into austnwil/ion11-bytearray-bytecode-generator
2 parents 558a2b6 + 1ce55a6 commit ec2a964

16 files changed

Lines changed: 3288 additions & 1463 deletions

src/main/java/com/amazon/ion/impl/IonRawTextWriter_1_1.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ class IonRawTextWriter_1_1 internal constructor(
457457
output.appendAscii(" ")
458458
}
459459

460-
override fun stepInTaglessElementList(macroId: Int, macroName: String?) {
460+
override fun stepInTaglessElementList(macroId: Int, macroName: String?, lengthPrefixed: Boolean) {
461461
stepInList(usingLengthPrefix = false) // Arg here doesn't actually matter.
462462
writeMacroEncodingTag(macroName ?: macroId.toString())
463463
output.appendAscii(" ")
@@ -470,7 +470,7 @@ class IonRawTextWriter_1_1 internal constructor(
470470
output.appendAscii(" ")
471471
}
472472

473-
override fun stepInTaglessElementSExp(macroId: Int, macroName: String?) {
473+
override fun stepInTaglessElementSExp(macroId: Int, macroName: String?, lengthPrefixed: Boolean) {
474474
stepInSExp(usingLengthPrefix = false) // Arg here doesn't actually matter.
475475
writeMacroEncodingTag(macroName ?: macroId.toString())
476476
output.appendAscii(" ")
@@ -482,11 +482,6 @@ class IonRawTextWriter_1_1 internal constructor(
482482
currentContainer = EExpression
483483
}
484484

485-
override fun writeTaglessInt(implicitOpcode: Int, value: Int) {
486-
// TODO: Consider checking the opcode
487-
writeInt(value.toLong())
488-
}
489-
490485
override fun writeTaglessInt(implicitOpcode: Int, value: Long) {
491486
writeInt(value)
492487
}

src/main/java/com/amazon/ion/impl/_Private_RecyclingQueue.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public T next() {
5252

5353
/**
5454
* @param initialCapacity the initial capacity of the underlying collection.
55-
* @param elementFactory the factory used to create a new element on {@link #push()} when the queue has
55+
* @param elementFactory the factory used to create a new element on {@link #push(Recycler)} when the queue has
5656
* not previously grown to the new depth.
5757
*/
5858
public _Private_RecyclingQueue(int initialCapacity, ElementFactory<T> elementFactory) {
@@ -73,7 +73,7 @@ public T get(int index) {
7373
/**
7474
* Pushes an element onto the top of the queue, instantiating a new element only if the queue has not
7575
* previously grown to the new depth.
76-
* @return the element at the top of the queue after the push. This element must be initialized by the caller.
76+
* @return the index of the element at the top of the queue after the push. This element must be initialized by the caller.
7777
*/
7878
public int push(Recycler<T> recycler) {
7979
currentIndex++;
@@ -87,6 +87,23 @@ public int push(Recycler<T> recycler) {
8787
return currentIndex;
8888
}
8989

90+
/**
91+
* Pushes an element onto the top of the queue, instantiating a new element only if the queue has not
92+
* previously grown to the new depth.
93+
* @return the element at the top of the queue after the push.
94+
*/
95+
public T pushAndGet(Recycler<T> recycler) {
96+
currentIndex++;
97+
if (currentIndex >= elements.size()) {
98+
top = elementFactory.newElement();
99+
elements.add(top);
100+
} else {
101+
top = elements.get(currentIndex);
102+
}
103+
recycler.recycle(top);
104+
return top;
105+
}
106+
90107
/**
91108
* Reclaim the current element.
92109
*/
@@ -119,4 +136,4 @@ public void clear() {
119136
public int size() {
120137
return currentIndex + 1;
121138
}
122-
}
139+
}

0 commit comments

Comments
 (0)