|
Algernon Software | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.algernon.aam.Processor
This class represents a Processor in the AAM. It contains the registers, memory and code.
Field Summary | |
protected Algernon |
f_algy
|
protected Jatha |
f_lisp
|
LispValue |
FAILURE
|
LispValue |
KNOWN
|
protected boolean |
m_isProfiling
|
protected LispValue |
m_lastCommand
|
protected int |
m_oldTraceLevel
|
protected OpcodeSet |
m_opcodes
|
protected Profiler |
m_profiler
|
protected QueryHistory |
m_queryHistory
|
protected RegisterSet |
m_registers
|
protected int |
m_traceLevel
|
protected Tracer |
m_tracer
|
LispValue |
NOTHING
|
LispValue |
SUCCESS
|
Constructor Summary | |
Processor(Algernon algy)
Create a new AAM Processor. |
Method Summary | |
void |
activateClosures(Clause clause,
AlgernonKBSet kbSet,
int direction)
Activates rule closures from assertions or queries. |
void |
addClosure(Closure closure)
Adds a closure to the system. |
void |
addRule(Rule rule,
AlgernonFrame associatedFrame)
Adds a new rule. |
void |
addToActionQueue(Activation activation)
Forwards to Algernon. |
LispValue |
appendRegisterValue(LispValue registerName,
LispValue newValue)
Pushes the given value onto the end of the register. |
void |
clearHistoricalQueries()
Clears all of the query history. |
void |
clearHistoricalQueries(AlgernonFrame frame)
Clears the query history for the given frame. |
void |
clearHistoricalQueries(LispValue frame,
LispValue rel)
Clears the query history for the given frame and relation. |
void |
clearHistoricalQuery(Clause clause)
Clears one query from the history. |
Collection |
compileRule(Rule rule,
AlgernonKBSet kbSet)
Compiles the given rule and returns it. |
Processor |
copy()
Returns a new processor that contains the same global variable bindings as this one. |
AlgernonInstance |
createInstance(LispValue name,
AlgernonClass superclass)
Forwards to the current KBSet. |
AlgernonRelation |
createRelation(AlgernonKB kb,
String slotName,
Set domains,
Set ranges,
Integer minCardinality,
Integer maxCardinality,
Object defaultValue,
AlgernonRelation inverseRelation)
Creates a new relation in the given KB. |
void |
createRule(Rule rule,
AlgernonKBSet kbSet,
AlgernonFrame frame)
Creates a new rule - adds it to the RuleManager, compiles it, creates continuations and compiles them. |
Object |
evaluateExpression(String language,
LispValue expression)
Evaluates a method in the given language. |
Boolean |
evaluateExpressionAsBoolean(String language,
LispValue expression)
Evaluates a method in the given language. |
Collection |
getActivatedRules(AlgernonFrame frame,
int direction,
int type)
Returns a list of activatable rules that match the given criteria. |
Algernon |
getAlgernon()
Returns the value of Algernon. |
AlgernonCompiler |
getCompiler()
Returns the current compiler used by Algernon. |
LispValue |
getLastCommand()
Returns the value of LastCommand. |
Jatha |
getLisp()
|
int |
getNumberOfStepsForward(int currentStep)
When in (:TRACE :STEP) mode, this method reads in an integer number of steps to step forward. |
OpcodeSet |
getOpcodeSet()
|
LispValue |
getRegisterEntry(LispValue registerName,
int index)
Return the nth entry in the given register, where the topmost item is entry number zero. |
RegisterSet |
getRegisters()
Returns the RegisterSet used by this processor. |
long |
getRegisterSize(LispValue registerName)
Return the current size of the given register. |
LispValue |
getRegisterValue(LispValue registerName)
Return the value of the given register. |
Rule |
getRule(String name)
Retrieves a rule by name. |
boolean |
getStepMode()
Returns true if the tracer is in Step mode. |
int |
getTraceLevel()
Returns the value of trace level. |
LispValue |
getTraceLevelAsString()
Returns the current trace level as a symbol such as :NORMAL, :SILENT :VERBOSE, :DETAIL, :DEBUG or :ALWAYS. |
boolean |
isHistoricalQuery(Clause clause)
Returns true if the clause or a generalization of it has been made before. |
boolean |
isInstance(LispValue clause,
LispValue pattern)
Determines whether clause is an instance of pattern, returning true or false. |
void |
nextClause()
Increments the index of the clause we are examining. |
LispValue |
popRegisterValue(LispValue registerName)
Pops the register and returns the popped entry. |
LispValue |
process(LispValue code,
AlgernonKB kb,
ErrorSet errors)
Process the given code. |
LispValue |
process(LispValue code,
AlgernonKBSet kbSet,
BindingSet bindings,
Rule rule,
Process parent,
ErrorSet errors)
Process the given code. |
void |
profile(String name)
|
LispValue |
pushRegisterValue(LispValue registerName,
LispValue newValue)
Pushes the given value onto the register. |
boolean |
relationIsFull(AlgernonFrame frame,
AlgernonRelation relation)
Returns true if the frame/relation combination is full - that is, the number of values stored in the slot is equal to the slot's maximum cardinality. |
void |
resetProfiler()
Resets the statistics in the code profiler. |
void |
setAlgernon(Algernon newAlgernon)
Sets the value of Algernon. |
void |
setLastCommand(LispValue newLastCommand)
Sets the value of LastCommand. |
private void |
setOpcodeSet(OpcodeSet newSet)
|
LispValue |
setRegisterValue(LispValue registerName,
LispValue newValue)
Sets the value of the given register. |
void |
setStepMode(boolean newState)
Turns Step mode on or off. |
void |
setTraceLevel(int newTraceLevel)
Sets the value of trace level |
void |
setTraceLevel(LispValue newTraceLevelString)
Sets the value of trace level from a string such as ":NORMAL". |
void |
trace(int minLevel,
String message)
Prints or logs the message if the current system trace level is greater than or equal to the given trace level. |
void |
trace(int minLevel,
String message,
boolean newline)
Prints or logs the message if the current system trace level is greater than or equal to the given trace level. |
Closure |
tryToInstantiate(Closure closure,
Clause clause)
Returns a closure if the rule can be instantiated from the clause. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public LispValue FAILURE
public LispValue KNOWN
public LispValue NOTHING
public LispValue SUCCESS
protected RegisterSet m_registers
protected OpcodeSet m_opcodes
protected LispValue m_lastCommand
protected Algernon f_algy
protected Jatha f_lisp
protected boolean m_isProfiling
protected int m_traceLevel
protected int m_oldTraceLevel
protected Tracer m_tracer
protected Profiler m_profiler
protected QueryHistory m_queryHistory
Constructor Detail |
public Processor(Algernon algy)
Method Detail |
public Algernon getAlgernon()
public AlgernonCompiler getCompiler()
public void setAlgernon(Algernon newAlgernon)
public LispValue process(LispValue code, AlgernonKB kb, ErrorSet errors) throws AlgernonException
code
- The AAM code to be executed.kb
- The KB to be used in the query.
AlgernonException
Result
public LispValue process(LispValue code, AlgernonKBSet kbSet, BindingSet bindings, Rule rule, Process parent, ErrorSet errors) throws AlgernonException
code
- The AAM code to be executed.kbSet
- KBSet to use when processing the code.bindings
- An existing BindingSet, if any.rule
- The rule being executed (for trace purposes).parent
- The parent process if this invocation is a subroutine.errors
- Error set to place errors in during processing.
AlgernonException
public void addRule(Rule rule, AlgernonFrame associatedFrame)
public void addClosure(Closure closure)
public void activateClosures(Clause clause, AlgernonKBSet kbSet, int direction) throws AlgernonDataException
AlgernonDataException
public Closure tryToInstantiate(Closure closure, Clause clause)
public Collection compileRule(Rule rule, AlgernonKBSet kbSet)
public Collection getActivatedRules(AlgernonFrame frame, int direction, int type)
Algernon
public Rule getRule(String name)
public void createRule(Rule rule, AlgernonKBSet kbSet, AlgernonFrame frame)
public AlgernonInstance createInstance(LispValue name, AlgernonClass superclass) throws AlgernonRuntimeException
AlgernonRuntimeException
public AlgernonRelation createRelation(AlgernonKB kb, String slotName, Set domains, Set ranges, Integer minCardinality, Integer maxCardinality, Object defaultValue, AlgernonRelation inverseRelation) throws AlgernonDataException
AlgernonDataException
public Object evaluateExpression(String language, LispValue expression)
public Boolean evaluateExpressionAsBoolean(String language, LispValue expression)
public void nextClause()
public LispValue getRegisterValue(LispValue registerName)
public LispValue setRegisterValue(LispValue registerName, LispValue newValue) throws AlgernonDataException
AlgernonDataException
public LispValue getRegisterEntry(LispValue registerName, int index)
public long getRegisterSize(LispValue registerName)
public LispValue popRegisterValue(LispValue registerName)
public LispValue pushRegisterValue(LispValue registerName, LispValue newValue)
public LispValue appendRegisterValue(LispValue registerName, LispValue newValue)
public RegisterSet getRegisters()
public void trace(int minLevel, String message)
public void trace(int minLevel, String message, boolean newline)
public void addToActionQueue(Activation activation)
public boolean relationIsFull(AlgernonFrame frame, AlgernonRelation relation) throws AlgernonException
AlgernonException
public void resetProfiler()
public void profile(String name)
public LispValue getLastCommand()
public void setLastCommand(LispValue newLastCommand)
public int getTraceLevel()
public LispValue getTraceLevelAsString()
public void setTraceLevel(int newTraceLevel)
public void setTraceLevel(LispValue newTraceLevelString)
public boolean isHistoricalQuery(Clause clause)
public void clearHistoricalQueries(LispValue frame, LispValue rel)
frame
- An AlgernonFrame.rel
- An AlgernonRelation.public void clearHistoricalQueries()
public void clearHistoricalQueries(AlgernonFrame frame)
frame
- An AlgernonFrame.public void clearHistoricalQuery(Clause clause)
clause
- public boolean isInstance(LispValue clause, LispValue pattern)
public Jatha getLisp()
public OpcodeSet getOpcodeSet()
public Processor copy()
private void setOpcodeSet(OpcodeSet newSet)
public int getNumberOfStepsForward(int currentStep)
public boolean getStepMode()
(:TRACE :STEP) turns step mode on. (:TRACE :RUN) turns it off.
public void setStepMode(boolean newState)
(:TRACE :STEP) turns step mode on. (:TRACE :RUN) turns it off.
|
Algernon Software | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |