public VariableStorage clone(ProgramArchitecture newProgramArch) throws InvalidInputException {
		if (programArch == null || newProgramArch == programArch) {
			if (getClass().equals(VariableStorage.class)) {
				return this; // only reuse if simple VariableStorage instance
			}
			if (isVoidStorage()) {
				return VOID_STORAGE;
			}
			if (isUnassignedStorage()) {
				return UNASSIGNED_STORAGE;
			}
			if (isBadStorage()) {
				return BAD_STORAGE;
			}
			return new VariableStorage(newProgramArch, varnodes);
		}
		if (!newProgramArch.getLanguage().equals(programArch.getLanguage())) {
			throw new IllegalArgumentException(
				"Variable storage incompatible with program language: " +
					newProgramArch.getLanguage().toString());
		}
		AddressFactory newAddressFactory = newProgramArch.getAddressFactory();
		Varnode[] v = getVarnodes();
		Varnode[] newVarnodes = new Varnode[v.length];
		for (int i = 0; i < v.length; i++) {
			AddressSpace newSpace = newAddressFactory.getAddressSpace(v[i].getSpace());
			AddressSpace curSpace = v[i].getAddress().getAddressSpace();
			if (newSpace == null) {
				throw new InvalidInputException(
					"Variable storage incompatible with program, address space not found: " +
						curSpace.getName());
			}
			newVarnodes[i] = new Varnode(newSpace.getAddress(v[i].getOffset()), v[i].getSize());
		}
		return new VariableStorage(newProgramArch, newVarnodes);
	}
Attempt to clone variable storage for use in a different program.
Dynamic storage characteristics will not be preserved.
@param newProgramArch target program architecture details
@return cloned storage
@throws InvalidInputException if specified varnodes violate storage restrictions
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/VariableStorage.java