//the value x.f.
checkShowRecordImplementation (executor);
// Evaluat the two arguments.
NRecordValue recordDictionary = (NRecordValue) executor.internalEvaluate(arguments[0]);
NRecordValue x = (NRecordValue) executor.internalEvaluate(arguments[1]);
List<String> fieldNames = recordDictionary.fieldNames();
int nFields = fieldNames.size();
//tuple records (with 2 or more fields) are displayed using the parentheses notation where field-names are omitted.
boolean isTuple = fieldNames.size() >= 2;
for (int i = 1; isTuple && i <= fieldNames.size(); ++i) {
String fieldName = fieldNames.get(i-1);
if (!fieldName.equals("#"+i)) {
isTuple = false;
}
}
StringBuilder showResult = new StringBuilder();
if (isTuple) {
showResult.append ("(");
for (int i = 0; i < nFields; ++i) {
if (i > 0) {
showResult.append (", ");
}
//compute "Debug.show valueDictionaryThunk xValueThunk"
//this is just (after inlining Debug.show d = d)
//valueDictionaryThunk xValueThunk
String fieldName = fieldNames.get(i);
Node valueDictionaryThunk = recordDictionary.getValue(fieldName);
Node xValueThunk = x.getValue(fieldName);
Node ap = valueDictionaryThunk.apply (xValueThunk);
String apResult = (String)(executor.internalEvaluate(ap).getValue());
showResult.append(apResult);
}
showResult.append(")");
} else {
showResult.append ("{");
for (int i = 0; i < nFields; ++i) {
if (i > 0) {
showResult.append (", ");
}
String fieldName = fieldNames.get(i);
showResult.append(fieldName).append(" = ");
//compute "Debug.show valueDictionaryThunk xValueThunk"
//this is just (after inlining Debug.show d = d)
//valueDictionaryThunk xValueThunk
Node valueDictionaryThunk = recordDictionary.getValue(fieldName);
Node xValueThunk = x.getValue(fieldName);
Node ap = new NAp(valueDictionaryThunk, xValueThunk);
String apResult = (String)(executor.internalEvaluate(ap).getValue());
showResult.append(apResult);