2
2
// SPDX-License-Identifier: Apache-2.0
3
3
package com .amazon .ion .impl ;
4
4
5
- import com .amazon .ion .IonCursor ;
6
- import com .amazon .ion .IonException ;
7
5
import com .amazon .ion .IonType ;
8
6
import com .amazon .ion .MacroAwareIonWriter ;
9
7
import com .amazon .ion .SymbolToken ;
19
17
20
18
import java .io .IOException ;
21
19
import java .util .Arrays ;
22
- import java .util .HashMap ;
23
20
import java .util .List ;
24
- import java .util .Map ;
25
21
26
22
/**
27
23
* An {@link LazyEExpressionArgsReader} reads an E-Expression from a {@link ReaderAdapter}, constructs
@@ -139,9 +135,8 @@ private Marker getMarker(int index) {
139
135
* Reads a single parameter to a macro invocation.
140
136
* @param parameter information about the parameter from the macro signature.
141
137
* @param parameterPresence the presence bits dedicated to this parameter (unused in text).
142
- * @param isTrailing true if this parameter is the last one in the signature; otherwise, false (unused in binary).
143
138
*/
144
- protected abstract void readParameter (Macro .Parameter parameter , long parameterPresence , boolean isTrailing );
139
+ protected abstract void readParameter (Macro .Parameter parameter , long parameterPresence );
145
140
146
141
/**
147
142
* Reads the macro's address and attempts to resolve that address to a Macro from the macro table.
@@ -231,7 +226,7 @@ protected void readValueAsExpression(boolean isImplicitRest) {
231
226
}
232
227
}
233
228
234
- private int collectAndFlattenComplexEExpression (int numberOfParameters , ExpressionTape .Core macroBodyTape , List <Macro .Parameter > signature , PresenceBitmap presenceBitmap , int markerPoolStartIndex ) {
229
+ private int collectAndFlattenComplexEExpression (ExpressionTape .Core macroBodyTape , List <Macro .Parameter > signature , PresenceBitmap presenceBitmap , int markerPoolStartIndex ) {
235
230
// TODO drop expression groups? No longer needed after the variables are resolved. Further simplifies the evaluator. Might miss validation? Also, would need to distribute field names over the elements of the group.
236
231
int macroBodyTapeIndex = 0 ;
237
232
int numberOfVariables = macroBodyTape .getNumberOfVariables ();
@@ -250,8 +245,7 @@ private int collectAndFlattenComplexEExpression(int numberOfParameters, Expressi
250
245
int startIndexInTape = expressionTape .size ();
251
246
readParameter (
252
247
signature .get (invocationOrdinal ),
253
- presenceBitmap == null ? PresenceBitmap .EXPRESSION : presenceBitmap .get (invocationOrdinal ),
254
- invocationOrdinal == (numberOfParameters - 1 )
248
+ presenceBitmap == null ? PresenceBitmap .EXPRESSION : presenceBitmap .get (invocationOrdinal )
255
249
);
256
250
Marker marker = getMarker (markerPoolStartIndex + invocationOrdinal );
257
251
marker .typeId = null ;
@@ -264,8 +258,7 @@ private int collectAndFlattenComplexEExpression(int numberOfParameters, Expressi
264
258
expressionTape = expressionTapeScratch ;
265
259
readParameter (
266
260
signature .get (invocationOrdinal ),
267
- presenceBitmap == null ? PresenceBitmap .EXPRESSION : presenceBitmap .get (invocationOrdinal ),
268
- invocationOrdinal == (numberOfParameters - 1 )
261
+ presenceBitmap == null ? PresenceBitmap .EXPRESSION : presenceBitmap .get (invocationOrdinal )
269
262
);
270
263
expressionTape = expressionTapeOrdered ;
271
264
Marker marker = getMarker (markerPoolStartIndex + invocationOrdinal );
@@ -293,7 +286,7 @@ private int collectAndFlattenComplexEExpression(int numberOfParameters, Expressi
293
286
return macroBodyTapeIndex ;
294
287
}
295
288
296
- private int collectAndFlattenSimpleEExpression (int numberOfParameters , ExpressionTape .Core macroBodyTape , List <Macro .Parameter > signature , PresenceBitmap presenceBitmap ) {
289
+ private int collectAndFlattenSimpleEExpression (ExpressionTape .Core macroBodyTape , List <Macro .Parameter > signature , PresenceBitmap presenceBitmap ) {
297
290
// TODO drop expression groups? No longer needed after the variables are resolved. Further simplifies the evaluator. Might miss validation? Also, would need to distribute field names over the elements of the group.
298
291
int macroBodyTapeIndex = 0 ;
299
292
int numberOfVariables = macroBodyTape .getNumberOfVariables ();
@@ -304,8 +297,7 @@ private int collectAndFlattenSimpleEExpression(int numberOfParameters, Expressio
304
297
// variable in the signature. This means it can be copied into the tape without using scratch space.
305
298
readParameter (
306
299
signature .get (i ),
307
- presenceBitmap == null ? PresenceBitmap .EXPRESSION : presenceBitmap .get (i ),
308
- i == (numberOfParameters - 1 )
300
+ presenceBitmap == null ? PresenceBitmap .EXPRESSION : presenceBitmap .get (i )
309
301
);
310
302
}
311
303
return macroBodyTapeIndex ;
@@ -324,9 +316,9 @@ private ExpressionTape collectAndFlattenUserEExpressionArgs(boolean isTopLevel,
324
316
return constantTape ;
325
317
}
326
318
} else if (macro .isSimple ()) {
327
- macroBodyTapeIndex = collectAndFlattenSimpleEExpression (numberOfParameters , macroBodyTape , signature , presenceBitmap );
319
+ macroBodyTapeIndex = collectAndFlattenSimpleEExpression (macroBodyTape , signature , presenceBitmap );
328
320
} else {
329
- macroBodyTapeIndex = collectAndFlattenComplexEExpression (numberOfParameters , macroBodyTape , signature , presenceBitmap , markerPoolIndex + 1 );
321
+ macroBodyTapeIndex = collectAndFlattenComplexEExpression (macroBodyTape , signature , presenceBitmap , markerPoolIndex + 1 );
330
322
}
331
323
// Copy everything after the last parameter.
332
324
expressionTape .copyFromRange (macroBodyTape , macroBodyTapeIndex , macroBodyTape .size ());
@@ -341,8 +333,7 @@ private void collectVerbatimEExpressionArgs(Macro macro, List<Macro.Parameter> s
341
333
for (int i = 0 ; i < numberOfParameters ; i ++) {
342
334
readParameter (
343
335
signature .get (i ),
344
- presenceBitmap == null ? PresenceBitmap .EXPRESSION : presenceBitmap .get (i ),
345
- i == (numberOfParameters - 1 )
336
+ presenceBitmap == null ? PresenceBitmap .EXPRESSION : presenceBitmap .get (i )
346
337
);
347
338
}
348
339
stepOutOfEExpression ();
0 commit comments