lojix/prolog/src/main/com/thesett/aima/logic/fol/prolog/PrologCompiler.java
public void compile(Sentence<Clause> clauseSentence) throws SourceCodeException
    {
        Clause clause = clauseSentence.getT();
        PrologCompiledClause result = new PrologCompiledClause(clause.getHead(), clause.getBody());

        // Create stack frame slots for all variables in a program.
        if (!clause.isQuery())
        {
            StackVariableTransform stackVariableTransform = new StackVariableTransform(0, result);
            result = (PrologCompiledClause) result.acceptTransformer(stackVariableTransform);

            // Set the required stack frame size on the compiled clause.
            result.setStackSize(stackVariableTransform.offset);
        }

        // Apply the built-in transformation to map any built-ins to their implementations.
        TermTransformer builtInTransformation = new BuiltInExpressionTransform(interner);
        result = (PrologCompiledClause) result.acceptTransformer(builtInTransformation);

        // Return the compiled version of the clause.
        if (clause.isQuery())
        {
            observer.onQueryCompilation(result);
        }
        else
        {
            observer.onCompilation(result);
        }
    }
public void compile(Sentence<Clause> clauseSentence) throws SourceCodeException
    {
        Clause clause = clauseSentence.getT();
        PrologCompiledClause result = new PrologCompiledClause(clause.getHead(), clause.getBody());

        // Create stack frame slots for all variables in a program.
        if (!clause.isQuery())
        {
            StackVariableTransform stackVariableTransform = new StackVariableTransform(0, result);
            result = (PrologCompiledClause) result.acceptTransformer(stackVariableTransform);

            // Set the required stack frame size on the compiled clause.
            result.setStackSize(stackVariableTransform.offset);
        }

        // Apply the built-in transformation to map any built-ins to their implementations.
        TermTransformer builtInTransformation = new BuiltInExpressionTransform(interner);
        result = (PrologCompiledClause) result.acceptTransformer(builtInTransformation);

        // Return the compiled version of the clause.
        if (clause.isQuery())
        {
            observer.onQueryCompilation(result);
        }
        else
        {
            observer.onCompilation(result);
        }
    }
public void compile ( Sentence < Clause > clauseSentence ) throws SourceCodeException { Clause clause = clauseSentence . getT ( ) ; PrologCompiledClause result = new PrologCompiledClause ( clause . getHead ( ) , clause . getBody ( ) ) ; // Create stack frame slots for all variables in a program. if ( ! clause . isQuery ( ) ) { StackVariableTransform stackVariableTransform = new StackVariableTransform ( 0 , result ) ; result = ( PrologCompiledClause ) result . acceptTransformer ( stackVariableTransform ) ; // Set the required stack frame size on the compiled clause. result . setStackSize ( stackVariableTransform . offset ) ; } // Apply the built-in transformation to map any built-ins to their implementations. TermTransformer builtInTransformation = new BuiltInExpressionTransform ( interner ) ; result = ( PrologCompiledClause ) result . acceptTransformer ( builtInTransformation ) ; // Return the compiled version of the clause. if ( clause . isQuery ( ) ) { observer . onQueryCompilation ( result ) ; } else { observer . onCompilation ( result ) ; } }
{@inheritDoc}

<p/>Compiles a clause by replacing all free variable occurrences within domain clauses with stack storage
locations. The clause is set up as the binding context supplier to these variables. Query clauses are not set up
with stack variables, as the query can have its variables bound directly.
{ @inheritDoc }