@Override
	public AddressSpace readSpace() throws DecoderException {
		byte header1 = curPos.getNextByte();
		if ((header1 & HEADEREXTEND_MASK) != 0) {
			curPos.getNextByte();
		}
		byte typeByte = curPos.getNextByte();
		int typeCode = typeByte >> TYPECODE_SHIFT;
		AddressSpace spc = null;
		if (typeCode == TYPECODE_ADDRESSSPACE) {
			int res = (int) readInteger(typeByte & LENGTHCODE_MASK);
			if (res >= 0 && res < spaces.length) {
				spc = spaces[res];
			}
			if (spc == null) {
				throw new DecoderException("Unknown address space index");
			}
		}
		else if (typeCode == TYPECODE_SPECIALSPACE) {
			int specialCode = typeByte & LENGTHCODE_MASK;
			if (specialCode == SPECIALSPACE_STACK) {
				spc = addrFactory.getStackSpace();
			}
			else if (specialCode == SPECIALSPACE_JOIN) {
				spc = AddressSpace.VARIABLE_SPACE;
			}
			else if (specialCode == SPECIALSPACE_SPACEBASE) {
				// TODO: Add support for decompiler non-stack "register relative" spaces
				// We let the null address space get returned here.  Its as if, no space
				// attribute is given in an <addr> element, resulting in NO_ADDRESS
				// spc = null;
			}
			else {
				throw new DecoderException("Cannot marshal special address space");
			}
		}
		else {
			skipAttributeRemaining(typeByte);
			throw new DecoderException("Expecting space attribute");
		}
		attributeRead = true;
		return spc;
	}
Close stream cached by the ingestStreamAsNeeded method.
@throws IOException for low-level problems with the stream
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/PackedDecode.java