@Override
	public boolean applyTo(Program program) {
		if (refType == null) {
			CodeUnit cu = program.getListing().getCodeUnitAt(fromAddr);
			if (cu != null) {
				refType = RefTypeFactory.getDefaultMemoryRefType(cu, opIndex, toAddr, false);
			}
		}

		ReferenceManager refMgr = program.getReferenceManager();
		Reference ref = refMgr.addMemoryReference(fromAddr, toAddr, refType, source, opIndex);
		if (setPrimary) {
			refMgr.setPrimary(ref, setPrimary);
		}
		return true;
	}
Command constructor for adding a memory reference
@param fromAddr address of the codeunit where the reference occurs
@param toAddr address of the location being referenced.
@param refType reference type - how the location is being referenced.
@param source the source of the reference
@param opIndex the operand index in the code unit where the reference occurs
@param setPrimary set the newly added reference primary
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/refs/AddMemRefCmd.java