public static Variable createVariable(Program program, Variable var, Program otherProgram)
			throws DuplicateNameException, InvalidInputException {

		Symbol parent = var.getSymbol().getParentSymbol();
		SourceType source = var.getSource();
		parent = getSymbol(parent, otherProgram);
		if (parent == null) {
			return null;
		}

// TODO: Method does not protect against duplicate variable (i.e., same offset, same first-use)

// TODO: Is it safe to use variable storage from one program into another?

		Namespace namespace = (Namespace) parent.getObject();
		if (namespace instanceof Function) {
			Function func = (Function) namespace;
			if (var instanceof Parameter) {
				return func.insertParameter(((Parameter) var).getOrdinal(), var, source);
			}
			return func.addLocalVariable(var, source);
		}

// TODO: Add GLOBAL or namespace variable support here

		return null;
	}
Given a variable for a specified program, create a comparable variable in the 
specified otherProgram if possible. An open transaction on otherProgram must exist.
@param program program which contains the specified variable instance
@param var variable to be added from program to otherProgram.
@param otherProgram other program
@return new variable for otherProgram or null if unable to create variable.
@throws DuplicateNameException if another variable already exists with 
the same name as var in the resulting function.
@throws InvalidInputException if data type is not a fixed length or variable name is invalid, etc.
@throws VariableSizeException if data type size is too large based upon storage constraints.
Ghidra/Features/Base/src/main/java/ghidra/program/util/DiffUtility.java