|
||||||||
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.
You should not inherit from SICStus
.
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()
Deprecated. Do not use, as of 3.8.2 this is a no-op. |
int |
debugLevel()
Currently Unsupported, see the Release Notes. |
static SICStus |
getInitializedSICStus()
Returns a pointer to the SICStus object which has been initialized in this JVM. |
boolean |
isLegalCaller()
Deprecated. Do not use, as of 3.8.2 this is always true. |
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)
Deprecated Use module and predicate name directly instead. |
SPQuery |
openQuery(java.lang.String string,
java.util.Map varMap)
Open a query, specified as a string, for obtaining multiple solutions. |
SPQuery |
openQuery(java.lang.String module,
java.lang.String name,
SPTerm[] args)
Open a query for obtaining multiple solutions. |
boolean |
query(SPPredicate pred,
SPTerm[] args)
Deprecated Use module and predicate name directly instead. |
boolean |
query(java.lang.String string,
java.util.Map varMap)
Find the first solution to a query specified as a string. |
boolean |
query(java.lang.String module,
java.lang.String name,
SPTerm[] args)
Find the first solution to a query. |
boolean |
queryCutFail(SPPredicate pred,
SPTerm[] args)
Deprecated Use module and predicate name directly instead. |
boolean |
queryCutFail(java.lang.String string,
java.util.Map varMap)
Find the first solution to a query specified as a string, then do a cut to remove all choicepoints and then fail, i.e., ignore everything but the side-effects during the first solution. |
boolean |
queryCutFail(java.lang.String module,
java.lang.String name,
SPTerm[] args)
Find the first solution to a query, then do a cut to remove all choicepoints and then fail, i.e., ignore everything but the side-effects during the first solution. |
SPTerm |
readFromString(java.lang.String string)
Equivalent to readFromString(string, null); |
SPTerm |
readFromString(java.lang.String string,
java.util.Map varMap)
Create a term by reading from a string. |
void |
restore(java.lang.String savFile)
Interface to SP_restore() . |
boolean |
reuseTermRefs()
Unsupported. |
int |
setDebugLevel(int level)
Currently Unsupported. |
boolean |
setReuseTermRefs(boolean newVal)
Unsupported, see the release notes for details. |
boolean |
setShouldCheckAge(boolean newVal)
Currently Unsupported, see the release notes for details. |
boolean |
shouldCheckAge()
Currently Unsupported, see the release notes for details. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public java.lang.String bootPath
Constructor Detail |
public SICStus() throws SPException
SICStus(null,null)
.SPException
public SICStus(java.lang.String bootPath) throws SPException
SICStus(null,bootPath)
.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 final boolean shouldCheckAge()
setShouldCheckAge(boolean)
public final boolean setShouldCheckAge(boolean newVal)
true
then the methods on SPTerm
will throw exceptions when used
in a way that may potentially create dangling pointers in the
Prolog heap. Returns the old value of the flag.
Off by default in the interest of backward compatibility since it will throw exception for some legal code. It is probably a good idea to turn this on for new code (and for existing non-production code). This flag will probably be on by default in the future, please try it and report good or bad experiences to sicstus-support@sics.se
Can be set with the
se.sics.jasper.SICStus.checkSPTermAge
system
property.
public final boolean reuseTermRefs()
setReuseTermRefs(boolean)
public final boolean setReuseTermRefs(boolean newVal)
false
then SPTerm.delete()
will not make the
Prolog side term-ref associated with the deleted SPTerm
object
available for re-use. Returns the old value of the flag.
This flag is currently on by default, there should be no reason to turn it off.
Can be set with the
se.sics.jasper.SICStus.reuseTermRefs
system property.
public final int debugLevel()
setDebugLevel(int)
public int setDebugLevel(int level)
se.sics.jasper.SICStus.debugLevel
system propery.public static void main(java.lang.String[] argv)
SICStus()
public void checkLegalCaller()
isLegalCaller()
public boolean isLegalCaller()
checkLegalCaller()
, but returns false
instead of throwing an exception.public static SICStus getInitializedSICStus()
SICStus sp; if (null == (sp = SICStus.getInitializedSICStus())) sp = new SICStus();
public void load(java.lang.String file) throws SPException
SP_load()
, which in turn calls the
Prolog predicate load_files/[1-2] (See the User's
Manual). Note: The preferred way to load
prolog code is through restore
.file
- The Prolog code to load. This can be a .pl-file, a
.ql-file, or a .po-file.restore(java.lang.String)
public void restore(java.lang.String savFile) throws SPException
SP_restore()
. Restores the specified
.sav-file. This is the preferred way of loading Prolog code
instead of using 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.load(java.lang.String)
public boolean query(java.lang.String module, java.lang.String name, SPTerm[] args) throws SPException, IllegalTermException
openQuery
.module
- The module used for the query.name
- The predicate name used for the query.args
- The arguments to the predicate. The number of
arguments must match the functor of the predicate.openQuery(java.lang.String, java.lang.String, se.sics.jasper.SPTerm[])
,
SPException
,
SPTerm
public boolean query(java.lang.String string, java.util.Map varMap) throws SPException
openQuery
.string
- The goal to use for the query, with terminating period.varMap
- The arguments to the predicate as a map from
variable names to SPTerm objects. On success varMap will get
entries added for all variables (with names not starting with
underscore) in the goal that were not already present as
input. May be null.
Allocates one SPTerm
for each
entry added to the map (and, possibly, a small number of SPTerm
objects for internal use). If varMap is null then this method
behaves as if no SPTerm objects were created.openQuery(java.lang.String, java.lang.String, se.sics.jasper.SPTerm[])
,
queryCutFail(java.lang.String, java.lang.String, se.sics.jasper.SPTerm[])
,
SPTerm
public boolean query(SPPredicate pred, SPTerm[] args) throws SPException, IllegalTermException
openQuery
.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(java.lang.String, java.lang.String, se.sics.jasper.SPTerm[])
,
SPException
,
SPPredicate
,
SPTerm
public boolean queryCutFail(java.lang.String module, java.lang.String name, SPTerm[] args) throws SPException
module
- The module used for the query.name
- The predicate name used for the query.args
- The arguments to the predicate.SPException
public boolean queryCutFail(java.lang.String string, java.util.Map varMap) throws SPException
string
- The goal to use for the query, with terminating period.varMap
- The arguments to the predicate as a map from
variable names to SPTerm objects. May be null. No bindings are
added.query(java.lang.String, java.lang.String, se.sics.jasper.SPTerm[])
public boolean queryCutFail(SPPredicate pred, SPTerm[] args) throws SPException
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(java.lang.String module, java.lang.String name, SPTerm[] args) throws IllegalTermException, SPException
nextSolution
to do
that. When no more solutions are needed, the query must be closed
using methods close
or
cut
on the query-object.
Multiple queries can be open at the same
time. See nextSolution
for details and restrictions.
module
- The module used for the query.name
- The predicate name used for the query.args
- The arguments to the predicate. The number of
arguments must match the functor of the predicate.query
object.SPQuery.nextSolution()
,
SPQuery.close()
,
SPQuery.cut()
public SPQuery openQuery(java.lang.String string, java.util.Map varMap) throws SPException
nextSolution
to do that. When no more solutions are needed,
the query must be closed using methods close
or cut
on the query-object.
Multiple queries can be open at the same time. See nextSolution
for details
and restrictions.
Allocates one SPTerm
for each entry added to the map
(and, possibly, a small number of SPTerm objects for internal
use). If varMap is null then this method behaves as if no
SPTerm objects were created. When the query is closed (or cut)
then all SPTerm objects are reclaimed.
string
- The goal to use for the query, with terminating period.varMap
- The arguments to the predicate as a map from
variable names to SPTerm objects. The map will get
entries added for all variables (with names not starting with
underscore) in the goal that were not already present as
input. May be null.query
object.SPQuery.nextSolution()
,
SPQuery.close()
,
SPQuery.cut()
public SPQuery openQuery(SPPredicate pred, SPTerm[] args) throws IllegalTermException, SPException
nextSolution
to do
that. When no more solutions are needed, the query must be closed
using methods close
or
cut
on the query-object.
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.query
object.SPQuery.nextSolution()
,
SPQuery.close()
,
SPQuery.cut()
,
SPPredicate
public SPTerm readFromString(java.lang.String string, java.util.Map varMap) throws SPException
string
- The printed representation of the term, with terminating period.varMap
- Bindings for any variables occurring in the term,
as a map from variable names to SPTerm objects. The map will
get entries added for all variables (with names not starting
with underscore) in the term that were not already present as
input. May be null.
Allocates one SPTerm
for each
entry added to the map (and, possibly, a small number of SPTerm
objects for internal use). If varMap is null then this method
behaves as if only the returned SPTerm object were created.public SPTerm readFromString(java.lang.String string) throws SPException
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |