private Object getVariableReferenceRepresentation(Reference ref, Variable var,
			Scalar replacedScalar) {
		if (var != null) {
			// Relies on reference-type to specify read/write access
			VariableOffset varOffset = new VariableOffset(ref, var);
			varOffset.setReplacedElement(replacedScalar, options.includeScalarReferenceAdjustment);
			return varOffset;
		}
		if (ref.isStackReference()) {
			OperandRepresentationList compoundList = new OperandRepresentationList();
			compoundList.add("Stack");
			compoundList.add('[');
			compoundList.add(new Scalar(32, ((StackReference) ref).getStackOffset(), true));
			compoundList.add(']');
			return addScalarAdjustment(compoundList, ref.getToAddress(), replacedScalar, false);
		}
		return null;
	}
Build a suitable variable or stack reference representation with optional
scalar replacement.

@param ref variable reference
@param var associated variable or null
@param replacedScalar replaced scalar object or null
@return representation object or null if var is null and ref is not a
        stack reference.
Ghidra/Features/Base/src/main/java/ghidra/program/model/listing/CodeUnitFormat.java