printDocArg(fieldId, "new " + fieldTypeName + " to set in |arg|"); printDocReturn("A new " + typeName + " with " + fieldId + " at the right place, or a core dump if |arg| did not have a " + fieldId);
printDocArg(fieldId, "new " + fieldTypeName + " to set in #arg"); printDocReturn("A new " + typeName + " with " + fieldId + " at the right place, or a core dump if #arg did not have a " + fieldId);
	private void genSetField(Type type, Field field) {		String typeId = StringConversions.makeIdentifier(type.getId());		String typeName = buildTypeName(type);		String fieldId = StringConversions.makeIdentifier(field.getId());		String fieldType = field.getType();		String fieldTypeName = buildTypeName(fieldType);		if (fieldType.equals(TypeConverter.CHARS_TYPE)				|| fieldType.equals(TypeConverter.STR_TYPE)) {			fieldTypeName = "const " + fieldTypeName;		}		String decl = typeName + " " + prefix + "set" + typeId				+ StringConversions.capitalize(fieldId) + "(" + typeName				+ " arg, " + fieldTypeName + " " + fieldId + ")";		hprintln(decl + ";");		printDocHead("Set the " + field.getId() + " of a " + typeName, "The precondition being that this " + typeName + " actually has a " + field.getId());		printDocArg("arg", "input " + typeName);		printDocArg(fieldId, "new " + fieldTypeName + " to set in |arg|");		printDocReturn("A new " + typeName + " with " + fieldId + " at the right place, or a core dump if |arg| did not have a " + fieldId);		printDocTail();		printFoldOpen(decl);		println(decl + " {");		Iterator locs = field.locationIterator();		boolean first = true;		while (locs.hasNext()) {			Location loc = (Location) locs.next();			print("  ");			if (first) {				first = false;			} else {				print("else ");			}			println("if (" + buildIsAltName(type, loc.getAltId()) + "(arg)) {");			print("    return (" + typeName + ")");			Iterator steps = loc.stepIterator();			String arg = genBuiltinToATerm(field.getType(), StringConversions					.makeIdentifier(field.getId()));			genSetterSteps(steps, new LinkedList(), arg);			println(";");			println("  }");		}		println();		println("  ATabort(\"" + typeId + " has no "				+ StringConversions.capitalize(fieldId) + ": %t\\n\", arg);");		println("  return (" + typeName + ")NULL;");		println("}");		println();		printFoldClose();	}