Calc[] calcs = calcList.toArray(new Calc[calcList.size()]);
if (elementType instanceof TupleType) {
final TupleType tupleType = (TupleType) elementType;
final Member[] nullTuple = makeNullTuple(tupleType);
if (isString) {
return new AbstractTupleCalc(call, calcs) {
public Member[] evaluateTuple(Evaluator evaluator) {
final int savepoint = evaluator.savepoint();
final TupleList list;
try {
evaluator.setNonEmpty(false);
list = listCalc.evaluateList(evaluator);
assert list != null;
} finally {
evaluator.restore(savepoint);
}
try {
String[] results = new String[stringCalcs.length];
for (int i = 0; i < stringCalcs.length; i++) {
results[i] =
stringCalcs[i].evaluateString(evaluator);
}
listLoop:
for (List<Member> members : list) {
for (int j = 0; j < results.length; j++) {
String result = results[j];
final Member member = members.get(j);
if (!matchMember(member, result)) {
continue listLoop;
}
}
// All members match. Return the current one.
return members.toArray(
new Member[members.size()]);
}
} finally {
evaluator.restore(savepoint);
}
// We use 'null' to represent the null tuple. Don't
// know why.
return null;
}
};
} else {
return new AbstractTupleCalc(call, calcs) {
public Member[] evaluateTuple(Evaluator evaluator) {
final int savepoint = evaluator.savepoint();
final TupleList list;
try {
evaluator.setNonEmpty(false);