// Add field values. In the case of extending an existing record these are
// added to the record extension node as if they were further arguments in
// the application chain for the virtual function.
for (final Map.Entry<FieldName, Expression> entry : updateFieldValuesMap.entrySet()) {
FieldName fieldName = entry.getKey();
Expression valueExpr = entry.getValue();
gp.code (schemeC (valueExpr, p, d+1));
gp.code (new Instruction.I_PutRecordField(fieldName.getCalSourceForm()));
}
return gp;
}
// Is e a record extension
// e is a record extension
Expression.RecordExtension recordExtensionExpr = e.asRecordExtension();
if (recordExtensionExpr != null) {
if (CODEGEN_DIAG) {
MACHINE_LOGGER.log(Level.FINE, " Record extension:");
}
Expression baseRecordExpr = recordExtensionExpr.getBaseRecordExpr();
//FieldName -> Expression
Map<FieldName, Expression> extensionFieldsMap = recordExtensionExpr.getExtensionFieldsMap();
if (baseRecordExpr == null) {
// No base record so we create a new one.
gp.code(new Instruction.I_CreateRecord(extensionFieldsMap.size()));
} else {
// Lazy evaluation of the base record.
gp.code(schemeC (baseRecordExpr, p, d));
// Create an application of the virtual extension function to the base record.
gp.code(new Instruction.I_LazyRecordExtension());
}
// Add field values. In the case of extending an existing record these are
// added to the record extension node as if they were further arguments in
// the application chain for the virtual function.
for (final Map.Entry<FieldName, Expression> entry : extensionFieldsMap.entrySet()) {
FieldName fieldName = entry.getKey();
Expression valueExpr = entry.getValue();
gp.code (schemeC (valueExpr, p, d+1));
gp.code (new Instruction.I_PutRecordField(fieldName.getCalSourceForm()));
}
return gp;
}