// e.g. RTFunction i_Foo;
if (sharedValues.getNReferencedDCs() > 0) {
javaClassRep.addComment(new JavaStatement.MultiLineComment("Data constructor class instances for all referenced data constructors."));
}
for (final ReferencedDCInfo rfi : sharedValues.getReferencedDCs()) {
DataConstructor dc = rfi.getDC();
JavaField jf = rfi.getJField();
JavaExpression fieldInitializer;
if (dc.getArity() > 0) {
// Just invoke the regular make invocation to get the singleton SC/DC instance.
fieldInitializer =
new MethodInvocation.Static(jf.getFieldType(), "make", JavaExpression.EMPTY_JAVA_EXPRESSION_ARRAY, JavaExpression.EMPTY_TYPE_NAME_ARRAY, jf.getFieldType());
} else {
// This is a zero arity data constructor. We get the singleton instance by accessing
// the DataType class factory method if the data type has more than one zero arity DC.
TypeConstructor typeCons = dc.getTypeConstructor();
if (SCJavaDefn.isTagDC(dc, module)) {
JavaTypeName typeClass = CALToJavaNames.createTypeNameFromType(typeCons, module);
JavaTypeName tagDCTypeName = CALToJavaNames.createTypeNameForTagDCFromType(typeCons, module);
Integer ordinal = Integer.valueOf(dc.getOrdinal());
fieldInitializer = new MethodInvocation.Static(typeClass, "getTagDC", LiteralWrapper.make(ordinal), JavaTypeName.INT, tagDCTypeName);
} else {
// Just invoke the regular make invocation to get the singleton SC/DC instance.
fieldInitializer =
new MethodInvocation.Static(jf.getFieldType(), "make", JavaExpression.EMPTY_JAVA_EXPRESSION_ARRAY, JavaExpression.EMPTY_TYPE_NAME_ARRAY, jf.getFieldType());