|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--se.sics.jasper.SICStus
This class encapsulates the SICStus emulator and provides the basic functionality for interacting with Prolog. The User's Manual documents in more detail how to use this class. Refer to that document for more information.
This class uses
native
methods to interface with the C-Prolog
interface of SICStus Prolog. Hence, this class cannot be used from
within an applet.
Since SICStus does not support multiple instances of the emulator in the same process, this class is only allowed to be initialized once.
Field Summary | |
java.lang.String |
bootPath
This is the path where SICStus finds the Runtime Library. |
Constructor Summary | |
SICStus()
Creates a SICStus object. |
|
SICStus(java.lang.String bootPath)
Creates a SICStus object. |
|
SICStus(java.lang.String[] argv,
java.lang.String bootPath)
Creates a SICStus object. |
Method Summary | |
void |
checkLegalCaller()
Throws an exception if the current thread is not the thread which created this instance of the SICStus object. |
void |
finalize()
Deallocates memory used by native code and calls SP_deinitialize to deallocate and unload resources
used by the emulator. |
static SICStus |
getInitializedSICStus()
Returns a pointer to the SICStus object which has been initialized in this JVM. |
boolean |
isLegalCaller()
Similar to checkLegalCaller(), but returns false instead of throwing an exception. |
void |
load(java.lang.String file)
Interface to SP_load() , which in turn calls the
Prolog predicate load_files/[1-2] (See the User's
Manual). |
static void |
main(java.lang.String[] argv)
This main-function is just a small test function. |
SPQuery |
openQuery(SPPredicate pred,
SPTerm[] args)
Open a query for obtaining multiple solutions. |
boolean |
query(SPPredicate pred,
SPTerm[] args)
Find the first solution to a query. |
boolean |
queryCutFail(SPPredicate pred,
SPTerm[] args)
Find the first solution to a query, then do a cut to remove all choicepoints and then fail, i.e. |
void |
restore(java.lang.String savFile)
Interface to SP_restore() . |
Methods inherited from class java.lang.Object |
clone,
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public java.lang.String bootPath
Constructor Detail |
public SICStus() throws SPException
SPException
public SICStus(java.lang.String bootPath) throws SPException
bootPath
- The path where SICStus should look for its
start-up files.SPException
,
SICStus(String[],String)
public SICStus(java.lang.String[] argv, java.lang.String bootPath) throws SPException
SP_initialize(argc, argv,
bootPath)
. It initializes the emulator's memory manager,
allocates WAM memory areas, etc. It also loads the SICStus
Runtime Library (sprt.sav
), also known as the
bootfile. If the bootfile cannot be found, you may
specify the exact location of it by using the system property
sicstus.path
.
This object can only be initialized once.argv
- Argument vector to the emulator.bootPath
- The path where SICStus should look for its
start-up files. The value should be a path such that
<bootPath>/bin
contains
sprt.sav
.SPException
,
getInitializedSICStus()
Method Detail |
public static void main(java.lang.String[] argv)
SICStus()
public void checkLegalCaller() throws IllegalCallerException
isLegalCaller()
public boolean isLegalCaller() throws IllegalCallerException
public static SICStus getInitializedSICStus()
SICStus sp; if (null == (sp = SICStus.getInitializedSICStus())) sp = new SICStus();
public void load(java.lang.String file) throws SPException, IllegalCallerException
SP_load()
, which in turn calls the
Prolog predicate load_files/[1-2] (See the User's
Manual).file
- The Prolog code to load. This can be a .pl-file, a
.ql-file, or a .po-file.SPException
,
restore(java.lang.String)
public void restore(java.lang.String savFile) throws SPException, IllegalCallerException
SP_restore()
. Restores the specified
.sav-file. This is the preferred way of loading Prolog code
instead of using SP_load()
. Example:
% sicstus SICStus 3.7 beta3: Tue Jun 02 12:29:02 MET DST 1998 | ?- compile(bench),save_program('bench.sav'). {compiling /home/jojo/sicstus/sicstus3/bench.pl...} {/home/jojo/sicstus/sicstus3/bench.pl compiled, 90 msec 6384 bytes} {SICStus state saved in /home/jojo/sicstus/sicstus3/bench.sav} yes | ?- halt.and then restore
bench.sav
from Java by calling
SICStus.restore()
.
restore("bench.sav");
savFile
- The .sav-file to restore.SPException
,
load(java.lang.String)
public void finalize()
SP_deinitialize
to deallocate and unload resources
used by the emulator.public boolean query(SPPredicate pred, SPTerm[] args) throws SPException, IllegalCallerException
pred
- The predicate object to use for the query.args
- The arguments to the predicate. The number of
arguments must match the functor of the predicate.openQuery(se.sics.jasper.SPPredicate, se.sics.jasper.SPTerm[])
,
SPException
,
SPPredicate
,
SPTerm
public boolean queryCutFail(SPPredicate pred, SPTerm[] args) throws SPException, IllegalCallerException
pred
- The predicate object used for the query.args
- The arguments to the predicate. The number of
arguments must match the functor of the predicate.SPException
,
SPPredicate
public SPQuery openQuery(SPPredicate pred, SPTerm[] args) throws IllegalCallerException
Multiple queries can be open at the same time. See nextSolution for details and restrictions.
pred
- The predicate-object to open a query on.args
- The arguments to the predicate. The number of
arguments must match the functor of the predicate.SPQuery.nextSolution()
,
SPException
,
SPPredicate
,
SPQuery.close()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |