@Override
	public boolean applyTo(Program program) {
		if (dataType != null) {
			dataType = dataType.clone(program.getDataTypeManager());
		}
		Function f = program.getListing().getFunctionContaining(addr);
		if (f == null) {
			errMsg = "Address not contained within function: " + addr;
			return false;
		}
		StackFrame sf = f.getStackFrame();

		try {
			// TODO: Stack variables only support first use of 0
			// This limitation needs to be fixed along with stack frame editor
			if (sf.createVariable(name, stackOffset, dataType, source) == null) {
				errMsg = "Create stack variable failed";
				return false;
			}
		}
		catch (DuplicateNameException e) {
			errMsg = "Variable named " + name + " already exists";
			return false;
		}
		catch (InvalidInputException e) {
			errMsg = e.getMessage();
			return false;
		}
		return true;
	}
Constructs a new command to add a stack variable to a function.
@param addr initial declaration point of variable.
@param stackOffset offset into the stack for the new variable.
@param name name of the new variable. 
@param dataType variable data-type or null for a default data type of minimal size
@param source the source of this stack variable
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/AddStackVarCmd.java