GNU Prolog for Java

gnu.prolog.vm.interpreter
Class InterpretedCodeCompiler

java.lang.Object
  extended by gnu.prolog.vm.interpreter.InterpretedCodeCompiler

public class InterpretedCodeCompiler
extends Object

compiler from predicate to interpreted code This version assume following


Field Summary
protected  int allocatedReserved
          number of already allocated reserved variables
static CompoundTermTag catchTag
          catch tag
protected  List<Instruction> code
          code so far compiled
protected  CompoundTermTag codeTag
          this predicate tag
protected  int currentCodePosition
          current code position
protected  List<Integer> cutPositionStack
          cut position stack
static ExceptionHandlerInfo[] exceptionHandlerArrayConstant
          array type constant ExceptionHandlerInfo.class
protected  List<ExceptionHandlerInfo> exceptionHandlers
          exception handlers
static Instruction[] instructionArrayConstant
          array type constant for Instruction.class
protected  int numberOfReserved
          number of reserved fields, one position for saving cut
protected  List<Term> passedClauses
          clauses to compile
static CompoundTermTag throwTag
          throw tag
static CompoundTermTag unifyTag
          unify tag
protected  Map<Term,Integer> variableToEnvironmentIndex
          mapping from variables to environment indexes
 
Constructor Summary
InterpretedCodeCompiler(List<Term> clauses)
          a constructor
 
Method Summary
protected  int allocReserved()
           
static PrologCode compile(List<Term> passedClauses)
          compile set of clauses to interpreted code
static Term rdereferenced(Term term)
          recursively dereference term
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

unifyTag

public static final CompoundTermTag unifyTag
unify tag


throwTag

public static final CompoundTermTag throwTag
throw tag


catchTag

public static final CompoundTermTag catchTag
catch tag


instructionArrayConstant

public static final Instruction[] instructionArrayConstant
array type constant for Instruction.class


exceptionHandlerArrayConstant

public static final ExceptionHandlerInfo[] exceptionHandlerArrayConstant
array type constant ExceptionHandlerInfo.class


code

protected List<Instruction> code
code so far compiled


exceptionHandlers

protected List<ExceptionHandlerInfo> exceptionHandlers
exception handlers


currentCodePosition

protected int currentCodePosition
current code position


allocatedReserved

protected int allocatedReserved
number of already allocated reserved variables


variableToEnvironmentIndex

protected Map<Term,Integer> variableToEnvironmentIndex
mapping from variables to environment indexes


codeTag

protected CompoundTermTag codeTag
this predicate tag


numberOfReserved

protected int numberOfReserved
number of reserved fields, one position for saving cut


cutPositionStack

protected List<Integer> cutPositionStack
cut position stack


passedClauses

protected List<Term> passedClauses
clauses to compile

Constructor Detail

InterpretedCodeCompiler

public InterpretedCodeCompiler(List<Term> clauses)
a constructor

Parameters:
clauses -
Method Detail

allocReserved

protected int allocReserved()

rdereferenced

public static Term rdereferenced(Term term)
recursively dereference term

Parameters:
term - to be recursively dereferenced
Returns:
recursively dereferenced term

compile

public static PrologCode compile(List<Term> passedClauses)
                          throws PrologException
compile set of clauses to interpreted code

Parameters:
passedClauses - clauses passed to compiler
Returns:
instance of interpreted code
Throws:
PrologException

GNU Prolog for Java