lojix/wam_prolog/src/main/com/thesett/aima/logic/fol/wam/optimizer/OptimizeInstructions.java
private boolean isVoidVariable(WAMInstruction instruction)
    {
        SymbolKey symbolKey = instruction.getSymbolKeyReg1();

        if (symbolKey != null)
        {
            Integer count = (Integer) symbolTable.get(symbolKey, SymbolTableKeys.SYMKEY_VAR_OCCURRENCE_COUNT);
            Boolean nonArgPositionOnly = (Boolean) symbolTable.get(symbolKey, SymbolTableKeys.SYMKEY_VAR_NON_ARG);
            Integer allocation = (Integer) symbolTable.get(symbolKey, SymbolTableKeys.SYMKEY_ALLOCATION);

            boolean singleton = (count != null) && count.equals(1);
            boolean nonArgPosition = (nonArgPositionOnly != null) && TRUE.equals(nonArgPositionOnly);
            boolean permanent =
                (allocation != null) && ((byte) ((allocation & 0xff00) >> 8) == WAMInstruction.STACK_ADDR);

            if (singleton && nonArgPosition && !permanent)
            {
                return true;
            }
        }

        return false;
    }
private boolean isVoidVariable(WAMInstruction instruction)
    {
        SymbolKey symbolKey = instruction.getSymbolKeyReg1();

        if (symbolKey != null)
        {
            Integer count = (Integer) symbolTable.get(symbolKey, SymbolTableKeys.SYMKEY_VAR_OCCURRENCE_COUNT);
            Boolean nonArgPositionOnly = (Boolean) symbolTable.get(symbolKey, SymbolTableKeys.SYMKEY_VAR_NON_ARG);
            Integer allocation = (Integer) symbolTable.get(symbolKey, SymbolTableKeys.SYMKEY_ALLOCATION);

            boolean singleton = (count != null) && count.equals(1);
            boolean nonArgPosition = (nonArgPositionOnly != null) && TRUE.equals(nonArgPositionOnly);
            boolean permanent =
                (allocation != null) && ((byte) ((allocation & 0xff00) >> 8) == WAMInstruction.STACK_ADDR);

            if (singleton && nonArgPosition && !permanent)
            {
                return true;
            }
        }

        return false;
    }
Checks if the term argument to an instruction was a singleton, non-argument position variable. The variable must
also be non-permanent to ensure that singleton variables in queries are created.

@param  instruction The instruction to test.

@return <tt>true</tt> iff the term argument to the instruction was a singleton, non-argument position variable.