* @param fieldNameToStrictness (FieldName->Boolean) this map will be populated with mappings from field name to strictness
* @throws CodeGenerationException
*/
private void setCommonFieldNames(Map<FieldName, JavaTypeName> fieldNameToType, Map<FieldName, Boolean> fieldNameToStrictness) throws CodeGenerationException {
this.commonFieldNames = new LinkedHashSet<FieldName>();
DataConstructor firstDC = dataConsList.get(0);
boolean[] fieldStrictness = firstDC.getArgStrictness();
for (int i = 0; i < firstDC.getArity(); ++i) {
TypeExpr[] fieldTypes = SCJavaDefn.getFieldTypesForDC(firstDC);
FieldName fn = firstDC.getNthFieldName(i);
commonFieldNames.add(fn);
int index = firstDC.getFieldIndex(fn);
fieldNameToType.put (fn, SCJavaDefn.typeExprToTypeName(fieldTypes[index]));
fieldNameToStrictness.put (fn, Boolean.valueOf (fieldStrictness[i]));
}
for (int i = 1; i < dataConsList.size(); ++i) {
DataConstructor dc = dataConsList.get(i);
TypeExpr[] fieldTypes = SCJavaDefn.getFieldTypesForDC(dc);
fieldStrictness = dc.getArgStrictness();
Set<FieldName> commonFieldNamesClone = new HashSet<FieldName>(commonFieldNames);
for (int j = 0, dcArity = dc.getArity(); j < dcArity; ++j) {
commonFieldNamesClone.remove(dc.getNthFieldName(j));
}
for (final FieldName fieldName : commonFieldNamesClone) {
commonFieldNames.remove(fieldName);
}
HashSet<FieldName> set = new LinkedHashSet<FieldName>();
for (final FieldName fn : commonFieldNames) {
int index = dc.getFieldIndex(fn);
JavaTypeName jt = fieldNameToType.get(fn);
boolean fs = fieldNameToStrictness.get(fn).booleanValue();
if (fs == fieldStrictness[index] &&
SCJavaDefn.typeExprToTypeName(fieldTypes[index]).equals(jt)) {