// mutate the copy.
// The copy is created by a call to:
// 1) updateOrdinalField - if only ordinal fields are being updated
// 2) updateTextualField - if only textual fields are being updated
// 3) updateMixedOrdinalField - if both ordinal and textual fields are being updated
FieldValueData fieldValueData = recordUpdateExpr.getUpdateFieldsData();
SortedMap<FieldName, Expression> updateFieldValuesMap = recordUpdateExpr.getUpdateFieldValuesMap();
int fieldN = 0;
for (final Map.Entry<FieldName, Expression> entry : updateFieldValuesMap.entrySet()) {
FieldName fieldName = entry.getKey();
Expression updateExpr = entry.getValue();
//the actual updated values are not strictly evaluated, so we use the C scheme.
ExpressionContextPair updateExprContextPair = genS_C(updateExpr, variableContext);
JavaExpression javaUpdateExpr = updateExprContextPair.getJavaExpression();
recordUpdateBlock.addStatement(updateExprContextPair.getContextBlock());
if (fieldName instanceof FieldName.Ordinal) {
//we need to copy the base record only for the first update. Subsequent updates can just mutate the base.
String updateMethodName;
if (fieldN == 0) {
// If there are only ordinal field updates we call updateOrdinalField to generate
// the record copy. Otherwise we call updateMixedOrdinalField, so that it is
// safe to modify the textual fields of the copy.
if (fieldValueData.getNTextualFields() == 0) {
updateMethodName = "updateOrdinalField";
} else {
updateMethodName = "updateMixedOrdinalField";
}
} else {