All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class prolog.Database

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

public class Database
extends Object
implements Cloneable, Serializable
The Prolog database.

Hash of the functors of the heads + "/" + the arity of the head.

The database is scanned for a user definition of a predicate with the given functor and arity. If this fails, an attempt is made to load an external class with the same characteristics.


Variable Index

 o asyncCompiler
Should the compiler run in a separate thread, or should we wait for it to compile something?
 o compilerQueue
The queue of predicates to compile.
 o jit
Are we just-in-time compiling clauses?

Constructor Index

 o Database(boolean)
Creates an empty database.
 o Database(boolean, int)
Creates a database with given initial size.

Method Index

 o clone()
Clones this database.
 o get(Compound)
Finds a potential unifer for a given Term.
 o get(String, int)
Finds a Predicate record with the given functor and arity.
 o load(String, int)
Loads an external class file which should subclass prolog.CompiledPredicate and have a constructor with no parameters.
 o newPredicate(int)
Create a new InterpretedPredicate record.
 o put(Clause)
Inserts a a clause into the database.
 o put(String, int, Predicate)
Inserts a predicate into the database.
 o toString()
Lists all clauses in the database.

Variables

 o jit
 public boolean jit
Are we just-in-time compiling clauses?

 o compilerQueue
 public Queue compilerQueue
The queue of predicates to compile. Contains PredicateCodeGen objects.

 o asyncCompiler
 public static final boolean asyncCompiler
Should the compiler run in a separate thread, or should we wait for it to compile something?

Constructors

 o Database
 public Database(boolean jit)
Creates an empty database.

 o Database
 public Database(boolean jit,
                 int dbsize)
Creates a database with given initial size.

Methods

 o get
 public Predicate get(Compound c)
Finds a potential unifer for a given Term.

 o get
 public Predicate get(String f,
                      int a)
Finds a Predicate record with the given functor and arity. If there isn't one in the database, attempt to load a pre-compiled one from prolog.lib.

Parameters:
f - functor
a - arity
 o load
 Predicate load(String f,
                int a)
Loads an external class file which should subclass prolog.CompiledPredicate and have a constructor with no parameters.

See Also:
CompiledPredicate
 o put
 public void put(String f,
                 int a,
                 Predicate p)
Inserts a predicate into the database.

 o put
 public void put(Clause c)
Inserts a a clause into the database. This interface should be used to set up the database (when it is immaterial whether a predicate is dynamic or not) and not for assert/1, retract/1, etc.

Parameters:
c - the clause to be inserted.
See Also:
asserta_1, assertz_1, abolish_1, retract_1
 o clone
 public Object clone()
Clones this database. This is a deep copy. Note the implementation uses the serialize/deserialize approach (i.e. it's inefficient) as cloning the graph directly is tricky and efficiency isn't really a priority for this op.

Reference: Java Tip 76: An alternative to the deep copy technique.

Overrides:
clone in class Object
 o toString
 public String toString()
Lists all clauses in the database.

Overrides:
toString in class Object
 o newPredicate
 InterpretedPredicate newPredicate(int arity)
Create a new InterpretedPredicate record.


All Packages  Class Hierarchy  This Package  Previous  Next  Index