@Override
	public Variable createVariable(String name, int offset, DataType dataType, SourceType source)
			throws DuplicateNameException, InvalidInputException {

		// WARNING! Stack parameters will be created even if calling convention
		// does not specify stack inputs

		function.manager.lock.acquire();
		try {
			checkDeleted();
			if (dataType != null) {
				dataType = dataType.clone(function.getProgram().getDataTypeManager());
			}
			Variable var = new LocalVariableImpl(name, dataType, offset, function.getProgram());
			if (isParameterOffset(offset)) {

				// Determine ordinal insertion point
				int ordinal = function.getParameterCount();
				Parameter[] params = getParameters();
				if (stackGrowsNegative) {
					for (int i = params.length - 1; i >= 0; i--) {
						if (offset <= params[i].getLastStorageVarnode().getOffset()) {
							ordinal = params[i].getOrdinal();
						}
					}
				}
				else {
					for (Parameter param : params) {
						if (offset >= param.getLastStorageVarnode().getOffset()) {
							ordinal = param.getOrdinal();
						}
					}
				}
				var = function.insertParameter(ordinal, var, source);
			}
			else {
				var = function.addLocalVariable(var, source);
			}

			if ((var instanceof Parameter) && !function.hasCustomVariableStorage() &&
				(!var.isStackVariable() || var.getStackOffset() != offset)) {
				// TODO: setting custom storage here may lock in bad stack offsets created when FunctionDB
				//   dynamically reshuffles storage to satisfy the insertParameter call above.
				//   the setDataType method below only fixes 1 variable
				function.setCustomVariableStorage(true);
				VariableStorage storage =
					new VariableStorage(function.getProgram(), offset, var.getLength());
				var.setDataType(var.getDataType(), storage, true, source);
			}

			return var;
		}
		finally {
			function.manager.lock.release();
		}
	}
Construct a function stack frame.
@param function
@param variables
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/function/FunctionStackFrame.java