public OperandRepresentationList getDataValueRepresentation(Data data) {

		Reference ref = data.getPrimaryReference(0);
		OperandRepresentationList representationList = new OperandRepresentationList();

		DataType dataType = data.getDataType();
		int length = data.getLength();

		if ((length != 0 || !dataType.isZeroLength()) && dataType.getLength() > length) {
			representationList.add("Data type \"" + dataType.getDisplayName() +
				"\" is too big for available space. Size = " + dataType.getLength() +
				" bytes, available = " + length + " bytes");
			representationList.setHasError(true);
			representationList.setPrimaryReferenceHidden(ref != null);
			return representationList;
		}

		Object dataValue = data.getValue();

		DataType baseDataType = data.getBaseDataType();
		if (ref != null && !(baseDataType instanceof Composite) &&
			!(baseDataType instanceof Array)) {
			Data parent = data.getParent();
			boolean parentIsUnion = (parent != null && parent.getBaseDataType() instanceof Union);

			if (!parentIsUnion || baseDataType instanceof Pointer || dataValue instanceof Address) {
				Object refRep = getReferenceRepresentation(data, ref, null);
				if (refRep != null) {
					representationList.add(refRep);
					return representationList;
				}
			}
		}

		if (dataValue instanceof Scalar) {
			EquateTable equTable = data.getProgram().getEquateTable();
			Equate equate =
				equTable.getEquate(data.getMinAddress(), 0, ((Scalar) dataValue).getValue());
			if (equate != null) {
				representationList.add(equate);
				representationList.setPrimaryReferenceHidden(ref != null);
				return representationList;
			}
		}

		// Formatting of data deferred to the data type
		if (dataType instanceof Dynamic && ((Dynamic) dataType).canSpecifyLength()) {
			int preferredLength = ((Dynamic) dataType).getLength(data, length);
			if (preferredLength > length) {
				// data overflow
				representationList.setHasError(true);
			}
		}

		representationList.setPrimaryReferenceHidden(ref != null);

		if (data.isDefined() && dataValue == null) {
			DataType baseDt = dataType;
			if (baseDt instanceof TypeDef) {
				baseDt = ((TypeDef) dataType).getBaseDataType();
			}
			if (baseDt instanceof Pointer) {
				// Render pointer error
				PointerDataType.getAddressValue(data, baseDt.getLength(), data,
					m -> representationList.add(m));
			}
			representationList.setHasError(true);
		}

		if (representationList.isEmpty()) {
			representationList.add(dataType.getRepresentation(data, data, length));
		}

		if ((dataValue instanceof Address) && ref == null &&
			data.getProgram().getMemory().getBlock((Address) dataValue) == null) {
			representationList.setHasError(true);
		}
		return representationList;
	}
Returns a formatted data value for the specified data unit. The return
list will contain a single object which may be an instance of String,
LabelString, Address, Scalar or Equate

@param data data unit
@return representation list containing a single object.
Ghidra/Features/Base/src/main/java/ghidra/program/model/listing/CodeUnitFormat.java