C# Class Prolog.PrologContext

Inheritance: IDisposable
Mostrar archivo Open project: ianhorswill/UnityProlog Class Usage Examples

Public Properties

Property Type Description
IndexicalBindingStack object>>.List
Output System.IO.TextWriter
This object

Private Properties

Property Type Description
AbortWokenGoals void
GetCallArgumentsAsArray object[]
GetStackTop Structure
NewStep void
PrologContext System
PrologContext System
Prove IEnumerable
Prove IEnumerable
ProveAllWokenGoals IEnumerable
ProveWokenGoalsInternal IEnumerable
PushArguments void
PushArguments void
PushGoalStack void
WakeUpGoal void

Public Methods

Method Description
Allocate ( KnowledgeBase kb, object thisValue ) : PrologContext

Gets a context that is currently free to use. Should be relased afterward using ReleaseContext().

Dispose ( ) : void
GetStack ( int frame, int offset ) : object

Reads a value from the stack.

GoalStackGoal ( ushort frame ) : Structure

Returns the goal at the specified position on the stack

GoalStackParent ( ushort frame ) : ushort

Returns the stack position of the parent goal of the goal at the specified position on the stack

IsTrue ( Structure goal ) : bool

Test whether GOAL is provable

IsTrue ( string predicateName ) : bool

Test whether GOAL is provable

MakeFrame ( int size ) : int

Reserve space for a new frame.

MarkTrail ( ) : int

Marks a place on the trail so subsequent bindings can be undone. Present implementation does not actually modify the stack in any way.

PopFrame ( int framePointer ) : void

Resets stack pointer to point at base of old frame.

PopGoalStack ( ) : void

Mark that this is the start of a new clause

Removes the top goal from the goal stack

PrologContext ( KnowledgeBase kb, int stepLimit ) : System

Creates a PrologContext that can for at most the specified number of steps.

Reset ( ) : void
Reset ( object thisValue ) : void

Forcibly clears the execution context.

ResetStackAndProve ( Structure goal ) : IEnumerable

Resets the context (clears stack, etc.) and starts a proof of the specified goal.

ResetStackAndProve ( object goal ) : IEnumerable

Resets the context (clears stack, etc.) and starts a proof of the specified goal.

ResetStepLimit ( ) : void

Renews the step limit (e.g. for when the repl is asking for a new solution.

RestoreVariables ( int savedTrailPointer ) : void

Restores the values of all variables back to the specified position on the trace (i.e. the undo stack).

SaveVariable ( LogicVariable lvar ) : void

Saves the current value of a variable on the trail (i.e. the undo stack).

SetCallArg ( int argumentNumber, object value ) : void

Sets argument for an upcoming call.

SetCurrentRule ( Prolog.KnowledgeBaseEntry rule ) : void

Set the rule currently being tried by the goal at the top of the stack.

SetStack ( int frame, int offset, object value ) : void

Modifies a value from the stack.

StackTrace ( string sourcePath, int lineNumber, string toplevelCommand, bool fullTrace ) : string

Generate a stack trace that's close enough to a normal mono stack dump that the Unity logger will understand it.

TraceOutput ( string format, object arg ) : void

Prints trace information.

UnwindStack ( ushort depth ) : void

Resets the stack to the specified depth.

Private Methods

Method Description
AbortWokenGoals ( int newTracePointer ) : void
GetCallArgumentsAsArray ( int arity ) : object[]
GetStackTop ( bool throwOnEmptyStack ) : Structure
NewStep ( ) : void

Check whether the maximum number of steps has been exceeded. Called when a new step is initiated.

PrologContext ( ) : System
PrologContext ( KnowledgeBase kb ) : System

Creates a PrologContext with PrologContext.DefaultStepLimit

Prove ( Structure goal ) : IEnumerable

Proves the goal in the specified structure.

Prove ( object goal, string badGoalErrorMessage ) : IEnumerable

Proves the specified goal, throwing an exception with badGoalErrorMessage if the goal is ill-formed.

ProveAllWokenGoals ( ) : IEnumerable

Attempts to prove all woken goals, in the order they were woken.

ProveWokenGoalsInternal ( WokenGoal goals, int goalIndex ) : IEnumerable
PushArguments ( IList args ) : void

Copies args to a arguments position for the next stack frame.

PushArguments ( object args ) : void

Copies args to a arguments position for the next stack frame.

PushGoalStack ( Symbol functor, object args, ushort parentFrame ) : void
WakeUpGoal ( Structure goal ) : void

Method Details

Allocate() public static method

Gets a context that is currently free to use. Should be relased afterward using ReleaseContext().
public static Allocate ( KnowledgeBase kb, object thisValue ) : PrologContext
kb KnowledgeBase
thisValue object
return PrologContext

Dispose() public method

public Dispose ( ) : void
return void

GetStack() public method

Reads a value from the stack.
public GetStack ( int frame, int offset ) : object
frame int Base address of stack frame
offset int Offset into stack frame
return object

GoalStackGoal() public method

Returns the goal at the specified position on the stack
public GoalStackGoal ( ushort frame ) : Structure
frame ushort
return Structure

GoalStackParent() public method

Returns the stack position of the parent goal of the goal at the specified position on the stack
public GoalStackParent ( ushort frame ) : ushort
frame ushort
return ushort

IsTrue() public method

Test whether GOAL is provable
public IsTrue ( Structure goal ) : bool
goal Structure Goal to prove
return bool

IsTrue() public method

Test whether GOAL is provable
public IsTrue ( string predicateName ) : bool
predicateName string Name of the predicate to call
return bool

MakeFrame() public method

Reserve space for a new frame.
public MakeFrame ( int size ) : int
size int Number of words needed for frame
return int

MarkTrail() public method

Marks a place on the trail so subsequent bindings can be undone. Present implementation does not actually modify the stack in any way.
public MarkTrail ( ) : int
return int

PopFrame() public method

Resets stack pointer to point at base of old frame.
public PopFrame ( int framePointer ) : void
framePointer int Base of the frame we're popping off
return void

PopGoalStack() public method

Mark that this is the start of a new clause Removes the top goal from the goal stack
public PopGoalStack ( ) : void
return void

PrologContext() public method

Creates a PrologContext that can for at most the specified number of steps.
public PrologContext ( KnowledgeBase kb, int stepLimit ) : System
kb KnowledgeBase
stepLimit int
return System

Reset() public method

public Reset ( ) : void
return void

Reset() public method

Forcibly clears the execution context.
public Reset ( object thisValue ) : void
thisValue object
return void

ResetStackAndProve() public method

Resets the context (clears stack, etc.) and starts a proof of the specified goal.
public ResetStackAndProve ( Structure goal ) : IEnumerable
goal Structure Goal to attempt to prove
return IEnumerable

ResetStackAndProve() public method

Resets the context (clears stack, etc.) and starts a proof of the specified goal.
public ResetStackAndProve ( object goal ) : IEnumerable
goal object Goal to attempt to prove
return IEnumerable

ResetStepLimit() public method

Renews the step limit (e.g. for when the repl is asking for a new solution.
public ResetStepLimit ( ) : void
return void

RestoreVariables() public method

Restores the values of all variables back to the specified position on the trace (i.e. the undo stack).
public RestoreVariables ( int savedTrailPointer ) : void
savedTrailPointer int
return void

SaveVariable() public method

Saves the current value of a variable on the trail (i.e. the undo stack).
public SaveVariable ( LogicVariable lvar ) : void
lvar LogicVariable
return void

SetCallArg() public method

Sets argument for an upcoming call.
public SetCallArg ( int argumentNumber, object value ) : void
argumentNumber int Index of the argument (0=first, 1=second, etc.)
value object Value of the argument
return void

SetCurrentRule() public method

Set the rule currently being tried by the goal at the top of the stack.
public SetCurrentRule ( Prolog.KnowledgeBaseEntry rule ) : void
rule Prolog.KnowledgeBaseEntry the new rule.
return void

SetStack() public method

Modifies a value from the stack.
public SetStack ( int frame, int offset, object value ) : void
frame int Base address of stack frame
offset int Offset into stack frame
value object New value for stack variable
return void

StackTrace() public method

Generate a stack trace that's close enough to a normal mono stack dump that the Unity logger will understand it.
public StackTrace ( string sourcePath, int lineNumber, string toplevelCommand, bool fullTrace ) : string
sourcePath string Path for the source file being loaded.
lineNumber int Current line number in the source file.
toplevelCommand string Original prolog command to output, if stack is empty.
fullTrace bool If true, the complete stack is dumped, otherwise, just the starting frames.
return string

TraceOutput() public method

Prints trace information.
public TraceOutput ( string format, object arg ) : void
format string
arg object
return void

UnwindStack() public method

Resets the stack to the specified depth.
public UnwindStack ( ushort depth ) : void
depth ushort
return void

Property Details

IndexicalBindingStack public_oe property

public List> IndexicalBindingStack
return object>>.List

Output public_oe property

The defaultstream to write output to.
public TextWriter,System.IO Output
return System.IO.TextWriter

This public_oe property

The GameObject or Component responsible for initiating the current top-level goal.
public object This
return object