private void combinePatternMask(ConstructState state, PatternExpression patternExpression,
			int patternOffset, byte[] mask) {
		if (patternExpression instanceof UnaryExpression) {
			combinePatternMask(state, ((UnaryExpression) patternExpression).getUnary(),
				patternOffset, mask);
		}
		else if (patternExpression instanceof BinaryExpression) {
			combinePatternMask(state, ((BinaryExpression) patternExpression).getLeft(),
				patternOffset, mask);
			combinePatternMask(state, ((BinaryExpression) patternExpression).getRight(),
				patternOffset, mask);
		}
		else if (patternExpression instanceof OperandValue) {
			OperandValue opVal = (OperandValue) patternExpression;
			Constructor c = opVal.getConstructor();
			int opIndex = opVal.getIndex();
			combineOperandMask(state, c.getOperand(opIndex), mask);
		}
		else if (patternExpression instanceof TokenField) {
			TokenField tf = (TokenField) patternExpression;
			//System.out.println("token: " + tf.getByteStart() + "," + tf.getByteEnd() + " " + tf.getBitStart() + "," + tf.getBitEnd());

			int size = tf.getByteEnd() + 1;

			int startByteIndex = tf.getByteStart(); // - (tf.getBitStart() / 8);
			int endByteIndex = size - 1; // - (tf.getBitStart() / 8);
			int startBit = tf.getBitStart() % 8;
			int endBit = tf.getBitEnd() % 8;
			boolean bigEndian = buf.isBigEndian();
			for (int i = startByteIndex; i <= endByteIndex; i++) {
				int firstBit = 0;
				int lastBit = 7;
				if (i == endByteIndex) {
					if (bigEndian) {
						firstBit = startBit;
					}
					else {
						lastBit = endBit;
					}
				}
				if (i == startByteIndex) {
					if (bigEndian) {
						lastBit = endBit;
					}
					else {
						firstBit = startBit;
					}
				}
				byte byteMask = (byte) ((0xff >> (7 - lastBit + firstBit)) << firstBit);
				mask[i + patternOffset] |= byteMask;
			}
		}
	}
Get the byte value mask corresponding to the specified operand.
@param opIndex operand index within the instruction representation
@return byte mask or null if operand does not have a corresponding sub-constructor or attach
@throws IllegalStateException if prototype parse failed
@throws IndexOutOfBoundsException if opIndex is not a valid operand index
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/SleighDebugLogger.java