All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class prolog.ClauseCodeGen

java.lang.Object
   |
   +----prolog.ClauseCodeGen

public class ClauseCodeGen
extends Object
Generates code for a single clause. Provides macros for code generation, and is the repository for fragments of generated code.

See Also:
PredicateCodeGen

Variable Index

 o arity
 o bindings
 o canFail
Can this clause fail?
 o class_name
 o functor
 o functors
 o next
 o predicates
The set of predicates we invoke.
 o sideEffects
Does this clause contain calls to predicates with side-effects? If so, we need to retain it, even if it fails.
 o trail
 o types

Constructor Index

 o ClauseCodeGen(PredicateCodeGen)
Creates a new compilation context for a clause.

Method Index

 o addFP(BranchInstruction)
Adds a failure point to the list.
 o arg_load(short)
Load an an element of a Term[] array (reference to it on top of the stack).
 o arg_store_do()
Stores the top element of the stack into a Term[] array.
 o arg_store_prep(short)
Loads the arrayref and index in preparation for a AASTORE operation.
 o binding_create()
 o binding_unify(TermInfo, TermInfo)
Bind a Binding to something.
 o checkcast(ObjectType)
 o compile(Clause, TermInfo[], boolean)
Compiles a clause.
 o compile_call(Predicate, Term[], boolean)
Compiles a generic call to a predicate.
 o compile_eval(Compound)
Leaves a Numeric object on the stack.
 o compound_args_load()
Loads the args array of a Compound term, stores them in a new LV.
 o compound_checkFunctor(TermInfo, int)
Compare the functor_arity of a Term with type CompoundType with a given one.
 o compound_create(TermInfo)
Creates a new Compound object using the argument as a template.
 o compound_unify(TermInfo, TermInfo)
Assumptions: both have type CompoundType with identical functor/arity.
 o dup()
 o dup_x2()
 o flonum_create(FloNum)
Creates a new FloNum object.
 o if_acmpne()
 o if_icmpne()
 o ifeq()
 o ifne()
 o intnum_create(IntNum)
Creates a new IntNum object.
 o is_compile(Term, Term)
 o is_not_eq_compile(Term, Term)
 o lv_alloc(Type)
Allocates a local variable to a Term.
 o lv_load(LocalVariableGen)
 o lv_store(LocalVariableGen)
 o nop()
 o numeric_compare(TermInfo, TermInfo, int)
Compare two numbers.
 o numeric_unify(TermInfo, TermInfo)
Unify two numbers.
 o patchFP()
Patches the failure points to branch to the end of the clause.
 o pop()
 o term_getBinding()
Unravel binding chains.
 o term_getBinding_cast(ObjectType, InstructionHandle)
Unravel binding chains.
 o term_unify()
Unify two terms together.
 o toString()
 o variable_unify(TermInfo, TermInfo)
Unify a variable against some other term.

Variables

 o next
 ClauseCodeGen next
 o functor
 String functor
 o arity
 int arity
 o types
 public TypeDictionary types
 o sideEffects
 boolean sideEffects
Does this clause contain calls to predicates with side-effects? If so, we need to retain it, even if it fails.

 o canFail
 boolean canFail
Can this clause fail?

 o class_name
 String class_name
 o predicates
 Hashtable predicates
The set of predicates we invoke.

 o functors
 Hashtable functors
 o trail
 TypeTrail trail
 o bindings
 Vector bindings

Constructors

 o ClauseCodeGen
 ClauseCodeGen(PredicateCodeGen pcg)
Creates a new compilation context for a clause.

Parameters:
tid - the parent (predicate-level) namespace.

Methods

 o compile
 boolean compile(Clause clause,
                 TermInfo type[],
                 boolean ci_det)
Compiles a clause. Assumes the clause has been normalised.

Parameters:
ci_det - this clause is in a determinate situ according to the indexer.
Returns:
false if this clause fails with no side effects, true otherwise.
 o patchFP
 void patchFP()
Patches the failure points to branch to the end of the clause.

 o compile_call
 public boolean compile_call(Predicate predicate,
                             Term args[],
                             boolean lastcall)
Compiles a generic call to a predicate.

 o addFP
 public void addFP(BranchInstruction bi)
Adds a failure point to the list. It is assumed that there is a boolean value on the stack, with true == success, continue, false == branch to failure code.

 o checkcast
 public void checkcast(ObjectType t)
 o dup
 public void dup()
 o dup_x2
 public void dup_x2()
 o ifeq
 public BranchInstruction ifeq()
 o ifne
 public BranchInstruction ifne()
 o if_icmpne
 public BranchInstruction if_icmpne()
 o if_acmpne
 public BranchInstruction if_acmpne()
 o pop
 public void pop()
 o lv_alloc
 public LocalVariableGen lv_alloc(Type type)
Allocates a local variable to a Term.

 o lv_load
 public void lv_load(LocalVariableGen lv)
 o lv_store
 public void lv_store(LocalVariableGen lv)
 o nop
 public InstructionHandle nop()
 o arg_load
 void arg_load(short index)
Load an an element of a Term[] array (reference to it on top of the stack).

Stack: ..., Term[] Ref -> ..., Term

 o arg_store_prep
 void arg_store_prep(short index)
Loads the arrayref and index in preparation for a AASTORE operation. Stack: ..., Term[] ref -> ..., Term[] ref, index

 o arg_store_do
 void arg_store_do()
Stores the top element of the stack into a Term[] array.

Stack: ..., Term[] ref, index, Term -> ...

 o binding_unify
 public boolean binding_unify(TermInfo arg0,
                              TermInfo arg1)
Bind a Binding to something.

Stack: ... -> ...

 o binding_create
 public void binding_create()
 o compound_args_load
 public LocalVariableGen compound_args_load()
Loads the args array of a Compound term, stores them in a new LV. Stack: ..., CompoundRef -> ..., Term[] args

 o compound_checkFunctor
 public void compound_checkFunctor(TermInfo arg0,
                                   int functor_arity)
Compare the functor_arity of a Term with type CompoundType with a given one.

 o compound_create
 public void compound_create(TermInfo arg0)
Creates a new Compound object using the argument as a template. Allocates a local variable for the arguments array.

Stack: ... -> CompoundRef

 o compound_unify
 public boolean compound_unify(TermInfo arg0,
                               TermInfo arg1)
Assumptions: both have type CompoundType with identical functor/arity.

Stack: ... -> ...

 o flonum_create
 public void flonum_create(FloNum n)
Creates a new FloNum object.

 o intnum_create
 public void intnum_create(IntNum n)
Creates a new IntNum object.

 o numeric_compare
 public boolean numeric_compare(TermInfo arg0,
                                TermInfo arg1,
                                int mode)
Compare two numbers. Both are assumed to have type NumericType.

Parameters:
mode - if compare returns this, success, else failure.
See Also:
compare
 o numeric_unify
 public void numeric_unify(TermInfo arg0,
                           TermInfo arg1)
Unify two numbers. Both are assumed to have type NumericType.

 o is_not_eq_compile
 public boolean is_not_eq_compile(Term a0,
                                  Term a1)
 o is_compile
 public boolean is_compile(Term arg0,
                           Term arg1)
 o compile_eval
 public boolean compile_eval(Compound t)
Leaves a Numeric object on the stack.

 o variable_unify
 public boolean variable_unify(TermInfo arg0,
                               TermInfo arg1)
Unify a variable against some other term.

 o term_getBinding
 public void term_getBinding()
Unravel binding chains.

Stack: ..., TermRef -> (Term)TermRef

 o term_getBinding_cast
 public void term_getBinding_cast(ObjectType t,
                                  InstructionHandle ih)
Unravel binding chains.

Stack: ..., TermRef -> (Term)TermRef

 o term_unify
 public void term_unify()
Unify two terms together.

Stack: ..., TermRef, TermRef -> boolean

 o toString
 public String toString()
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index