public class LogicProgrammingBridge extends KahinaBridge
Logic programming systems that have been connected to Kahina using
specialized subclasses of LogicProgrammingBridge
so far include
TRALE, QType and, experimentally, SWI-Prolog and SICStus Prolog. The
connection typically involves some Prolog code that hooks into the tracer of
the respective LP system and calls Kahina's Java API via a Prolog/Java
connection layer such as Jasper or JPL.
A Kahina "session" corresponds to the execution of one query in a LP system.
A new bridge is created, and all views are cleared, when a new session is
started. A session is started by calling the
KahinaInstance.startNewSession()
method of an instance of the
KahinaInstance
subclass that is specialized for the respective LP
system. This method returns the bridge for that session. The bridge is then
used to transmit all tracing information about a query to Kahina.
Modifier and Type | Field and Description |
---|---|
protected int |
currentID |
protected int |
selectedID |
protected boolean |
skipFlag |
protected int |
skipID |
protected LogicProgrammingState |
state |
protected java.util.HashMap<java.lang.Integer,java.lang.Integer> |
stepIDConv |
protected int |
waitingForReturnFromSkip |
kahina
Constructor and Description |
---|
LogicProgrammingBridge(LogicProgrammingInstance<?,?,?,?> kahina) |
Modifier and Type | Method and Description |
---|---|
void |
call(int extID)
Called, typically following a call to
#step(int, String, Stirng, String) very soon, to indicate that
the call port of the procedure box with the given ID has been reached. |
protected boolean |
canSkipOrAutocomplete() |
protected int |
convertStepID(int extID)
convert external step IDs to internal IDs corresponding to tree nodes
uses entries in stepIDConv table, extending it together with the tree if
no entry was found
|
void |
deregister() |
void |
end(int extID)
Call this to indicate that the top query succeeded or failed, providing
the step ID of the top query.
|
void |
exception(int extID,
java.lang.String message)
Called to indicate that the exception port of the procedure box with the
given ID has been reached.
|
void |
exit(int extID,
boolean deterministic) |
void |
exit(int extID,
boolean deterministic,
java.lang.String newDescription) |
void |
exit(int extID,
boolean deterministic,
java.lang.String newDescription,
java.lang.String newConsoleMessage)
Called to indicate that the exit port of the procedure box with the given
ID has been reached.
|
void |
fail(int extID)
Called to indicate that the fail port of the procedure box with the given
ID has been reached.
|
protected LogicProgrammingStep |
generateStep() |
char |
getAction() |
char |
getBridgeState() |
protected int |
getParentCandidateID() |
protected boolean |
isPaused() |
protected boolean |
isQueryRoot(int stepID)
Call to check if a given step has the special property of being the query
root, i.e.
|
void |
linkNodes(int anchor,
int target)
Introduces a "secondary edge" to the control flow tree, e.g.
|
protected void |
maybeUpdateStepCount(boolean firstEncounter)
Update step count in GUI.
|
protected void |
performBreakAction(java.lang.String agentString) |
protected void |
performCompleteAction(java.lang.String agentString) |
protected void |
performCreepAction(java.lang.String agentString) |
protected void |
performFailAction(java.lang.String agentString) |
protected void |
performSkipAction(java.lang.String agentString) |
protected void |
processControlEvent(KahinaControlEvent e) |
void |
processEvent(KahinaEvent e) |
protected void |
processSelectionEvent(KahinaSelectionEvent e) |
protected void |
processSystemEvent(KahinaSystemEvent e) |
protected void |
processWarnEvent(KahinaWarnEvent e) |
void |
redo(int extID)
Called to indicate that the redo port of the procedure box with the given
ID has been reached.
|
void |
registerLayer(int extID,
int layer) |
void |
registerStepSourceCodeLocation(int extID,
java.lang.String absolutePath,
int lineNumber)
Registers the source code location connected to a step for display in the
source code view.
|
void |
select(int extID)
Call this to force the GUI to select the indicated step and update, e.g.
|
protected void |
selectIfPaused(int stepID)
Selects the given step and updates the GUI if the debugger is not
currently leaping or autocompleting.
|
void |
setBridgeState(char bridgeState) |
protected void |
setParentCandidateID(int parentCandidateID) |
void |
step(int extID,
java.lang.String type)
Variant of
step(int, String, String, String) that uses the same
string for type, description and console message. |
void |
step(int extID,
java.lang.String predicate,
java.lang.String description)
Variant of
step(int, String, String, String) that uses the same
string for description and console message. |
void |
step(int extID,
java.lang.String type,
java.lang.String description,
java.lang.String consoleMessage)
For each new procedure box that is created, this method or one of its
variants must first be called.
|
int |
virtualRedo(int stepID) |
void |
warning(java.lang.String message) |
protected java.util.HashMap<java.lang.Integer,java.lang.Integer> stepIDConv
protected int currentID
protected int selectedID
protected boolean skipFlag
protected int waitingForReturnFromSkip
protected int skipID
protected LogicProgrammingState state
public LogicProgrammingBridge(LogicProgrammingInstance<?,?,?,?> kahina)
public void deregister()
deregister
in class KahinaBridge
public void step(int extID, java.lang.String type, java.lang.String description, java.lang.String consoleMessage)
call(int)
for
historic reasons and for flexibility, e.g. it can be overloaded with
various arguments representing all kinds of information about a step
without touching the call method. Note however that information about a
step that is not absolutely central, such as source code locations,
should be sent to Kahina using specialized methods following the call to
the step method.extID
- An ID identifying the procedure box uniquely.type
- A string identifying the type of the step, e.g. a Prolog
predicate identifier such as append/3
. Will be used
for categorizing and counting steps in the profiler.description
- A full description of the step, such as
append([1,2],[3,4],X)
. Will be used for labeling nodes
in the control flow graph.consoleMessage
- A more extensive description of the (type of) the step, such
as a prose description of what append/3
does. Will be
displayed in the message console.public void step(int extID, java.lang.String predicate, java.lang.String description)
step(int, String, String, String)
that uses the same
string for description and console message.extID
- predicate
- description
- public void step(int extID, java.lang.String type)
step(int, String, String, String)
that uses the same
string for type, description and console message.extID
- type
- public void registerStepSourceCodeLocation(int extID, java.lang.String absolutePath, int lineNumber)
extID
- absolutePath
- lineNumber
- public void registerLayer(int extID, int layer)
public void call(int extID)
#step(int, String, Stirng, String)
very soon, to indicate that
the call port of the procedure box with the given ID has been reached.
This will cause the corresponding node to appear in Kahina's control flow
graph.extID
- public void redo(int extID)
extID
- public int virtualRedo(int stepID)
public void exit(int extID, boolean deterministic)
public void exit(int extID, boolean deterministic, java.lang.String newDescription)
public void exit(int extID, boolean deterministic, java.lang.String newDescription, java.lang.String newConsoleMessage)
extID
- deterministic
- true
if the box has exited deterministically, i.e. is
guaranteed never to be redone again. If you cannot get this
information from your LP system, the recommended default is
false
.protected boolean isQueryRoot(int stepID)
stepID
- public void fail(int extID)
extID
- public void exception(int extID, java.lang.String message)
extID
- public void warning(java.lang.String message)
public void linkNodes(int anchor, int target)
anchor
- target
- public void end(int extID)
public void select(int extID)
extID
- public char getAction()
'c'
for creep, 's'
for skip, 'f'
for
fail, 'a'
for abort and 'n'
if there is no action
available yet, e.g. because the user hasn't clicked a button yet.
In this case, clients should wait a few milliseconds and call
this method again.protected int convertStepID(int extID)
protected boolean isPaused()
protected void selectIfPaused(int stepID)
protected void maybeUpdateStepCount(boolean firstEncounter)
firstEncounter
- Should be true at call and redo goals, false otherwise. The
latter avoids unnecessary multiple updates per step.protected LogicProgrammingStep generateStep()
generateStep
in class KahinaBridge
public void processEvent(KahinaEvent e)
processEvent
in interface KahinaListener
processEvent
in class KahinaBridge
protected void processSystemEvent(KahinaSystemEvent e)
processSystemEvent
in class KahinaBridge
protected void processWarnEvent(KahinaWarnEvent e)
processWarnEvent
in class KahinaBridge
protected void processControlEvent(KahinaControlEvent e)
processControlEvent
in class KahinaBridge
protected boolean canSkipOrAutocomplete()
protected void processSelectionEvent(KahinaSelectionEvent e)
processSelectionEvent
in class KahinaBridge
protected void performSkipAction(java.lang.String agentString)
protected void performCompleteAction(java.lang.String agentString)
protected void performCreepAction(java.lang.String agentString)
protected void performFailAction(java.lang.String agentString)
protected void performBreakAction(java.lang.String agentString)
public void setBridgeState(char bridgeState)
public char getBridgeState()
protected int getParentCandidateID()
protected void setParentCandidateID(int parentCandidateID)