public static Scalar getScalarValue(DataType dataType, int componentOrdinal,
			MemBuffer memBuffer) {
		DataTypeComponent comp = getComponent(dataType, componentOrdinal, memBuffer);
		if (comp == null) {
			throw new IllegalArgumentException("Couldn't get component " + componentOrdinal +
				" of " + dataType.getName() + " @ " + memBuffer.getAddress() + ".");
		}
		Address compAddress = getComponentAddress(comp, memBuffer);
		DataType compDt = comp.getDataType();
		int length = comp.getLength();
		DumbMemBufferImpl compMemBuffer = new DumbMemBufferImpl(memBuffer.getMemory(), compAddress);
		Object value = compDt.getValue(compMemBuffer, comp.getDefaultSettings(), length);
		if (value instanceof Scalar) {
			return (Scalar) value;
		}
		throw new IllegalArgumentException(
			"Component " + componentOrdinal + " of " + dataType.getName() + " is a " +
				compDt.getName() + " data type, which doesn't produce a Scalar value.");
	}
If the indicated component in the data type exists and is a Scalar value, this returns
the scalar value contained in that component of the data type.
@param dataType the data type whose base type is a structure and whose component's
scalar value is wanted. (i.e., The component data type referenced by the ordinal value must
be one that returns a Scalar value; such as an IntegerDataType, EnumDataType,
UndefinedDataType, etc.)
@param componentOrdinal 0-based ordinal indicating the component whose scalar value is being
determined by this method.
@param memBuffer memory buffer that starts where the indicated data type is laid down.
@return the scalar value held by indicated component in the data type when laid down on
the specified memory.
Ghidra/Features/MicrosoftCodeAnalyzer/src/main/java/ghidra/app/cmd/data/EHDataTypeUtilities.java