lojix/wam_prolog/src/main/com/thesett/aima/logic/fol/wam/compiler/DefaultBuiltIn.java
protected void allocateArgumentRegisters(Functor expression)
    {
        // Assign argument registers to functors appearing directly in the argument of the outermost functor.
        // Variables are never assigned directly to argument registers.
        int reg = 0;

        for (; reg < expression.getArity(); reg++)
        {
            Term term = expression.getArgument(reg);

            if (term instanceof Functor)
            {
                /*log.fine("X" + lastAllocatedTempReg + " = " + interner.getFunctorFunctorName((Functor) term));*/

                int allocation = (reg & 0xff) | (REG_ADDR << 8);
                symbolTable.put(term.getSymbolKey(), SymbolTableKeys.SYMKEY_ALLOCATION, allocation);
            }
        }
    }
protected void allocateArgumentRegisters(Functor expression)
    {
        // Assign argument registers to functors appearing directly in the argument of the outermost functor.
        // Variables are never assigned directly to argument registers.
        int reg = 0;

        for (; reg < expression.getArity(); reg++)
        {
            Term term = expression.getArgument(reg);

            if (term instanceof Functor)
            {
                /*log.fine("X" + lastAllocatedTempReg + " = " + interner.getFunctorFunctorName((Functor) term));*/

                int allocation = (reg & 0xff) | (REG_ADDR << 8);
                symbolTable.put(term.getSymbolKey(), SymbolTableKeys.SYMKEY_ALLOCATION, allocation);
            }
        }
    }
protected void allocateArgumentRegisters ( Functor expression ) { // Assign argument registers to functors appearing directly in the argument of the outermost functor. // Variables are never assigned directly to argument registers. int reg = 0 ; for ( ; reg < expression . getArity ( ) ; reg ++ ) { Term term = expression . getArgument ( reg ) ; if ( term instanceof Functor ) { /*log.fine("X" + lastAllocatedTempReg + " = " + interner.getFunctorFunctorName((Functor) term));*/ int allocation = ( reg & 0xff ) | ( REG_ADDR << 8 ) ; symbolTable . put ( term . getSymbolKey ( ) , SymbolTableKeys . SYMKEY_ALLOCATION , allocation ) ; } } }
For a predicate of arity n, the first n registers are used to receive its arguments in.

<p/>Non-variable arguments appearing directly within a functor are allocated to argument registers. This means
that they are directly referenced from the argument registers that pass them to predicate calls, or directly
referenced from the argument registers that are used to read them as call arguments.

<p/>Variables appearing as functor arguments are not allocated in this way, but are kept in registers with
positions higher than the number of arguments. The reason for this, is that a variable can appear multiple times
in an expression; it may not always be the same argument. Variables are assigned to other registers, then copied
into the argument registers as needed.

<p/>Argument registers are allocated by argument position within the functor. This means that gaps will be left
in the numbering for variables to be copied in as needed.

@param expression The clause head functor to allocate argument registers to.
For a predicate of arity n the first n registers are used to receive its arguments in .