@Override
	public boolean applyTo(Program program) {

		Function f = program.getFunctionManager().getFunctionContaining(fromAddr);
		if (f == null) {
			status = "Stack reference may only be created within a function";
			return false;
		}

		if (refType == null) {
			refType = RefTypeFactory
					.getDefaultStackRefType(program.getListing().getCodeUnitAt(fromAddr), opIndex);
		}

		Variable var = f.getStackFrame().getVariableContaining(stackOffset);
		if (var == null) {
			try {
				f.getStackFrame().createVariable(null, stackOffset, null, SourceType.DEFAULT);
			}
			catch (DuplicateNameException | InvalidInputException | AddressOutOfBoundsException e) {
				status = e.getMessage();
				return false;
			}
		}
		program.getReferenceManager()
				.addStackReference(fromAddr, opIndex, stackOffset, refType, source);
		return true;
	}
Constructs a new command for adding a stack reference.
@param fromAddr "from" address within a function
@param opIndex operand index
@param stackOffset stack offset of the reference
@param refType reference type (e.g., STACK_READ or STACK_WRITE)
@param source the source of this reference
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/refs/AddStackRefCmd.java