ClassicExecutionContext
One frame of the :solve-classic execution-context stack: a substitution, the streams of remaining goals, candidate Rules and candidate primitive responses, plus a parent link. Frames chain into their parent rather than living in a separate stack container, so the parent chain (see pathToRoot) is the call stack -- ordinary heap-allocated data rather than native JVM/JS stack frames, which is what lets Prolog resolution of arbitrarily deep recursive programs run as an explicit, non-recursive it.unibo.tuprolog.solve.classic.fsm.State loop instead of unbounded host-language recursion.
Resolving a sub-goal (a primitive call or a rule body) pushes a new context whose parent is the current one (see it.unibo.tuprolog.solve.classic.fsm.createChild); finishing a context's goals pops back to its parent in it.unibo.tuprolog.solve.classic.fsm.StateGoalSelection. Every instance also threads through choicePoints, the sibling data structure (see ChoicePointContext) recording still-open backtracking alternatives.
Most fields mirror it.unibo.tuprolog.solve.ExecutionContext; the ones specific to the classic engine are:
query/goals: the original query, and the cursor over the goals still to be proven in this frame.
rules/primitives: the still-untried candidate clauses/primitive responses for the current goal, i.e. the frame's own view of the choicePoints entry recorded for it (if any).
choicePoints: the head of the choice-point queue as seen from this frame -- see ChoicePointContext.
parent/depth: the enclosing frame and this frame's distance from the root (
depth == 0, isRoot).step: a monotonically increasing counter of state-machine transitions, used to keep ClassicSolver's
currentContextin sync with resolution progress and to detect it.unibo.tuprolog.solve.exception.TimeOutExceptions.relevantVariables: the Vars still of interest to some ancestor frame, used to trim substitutions of variables local to a finished sub-goal when popping back to parent (see isVariableInteresting).
Throws
if depth and parent are inconsistent (depth == 0 iff parent == null), or if startTime or maxDuration are negative.
Constructors
Properties
The current goals entry with substitution already applied, or null if there is none left to prove.
Whether choicePoints (or any of its ancestors) still has an alternative to backtrack into.
Whether this frame corresponds to an actual procedure call, i.e. should appear in logicStackTrace.
This frame and all its ancestors, from here up to (and including) the root, in that order.
Functions
Solve.Response analogue of appendRulesAndChoicePoints, recording a it.unibo.tuprolog.solve.classic.ChoicePointContext.Primitives instead.
Attaches rules as this context's ClassicExecutionContext.rules cursor and records a matching it.unibo.tuprolog.solve.classic.ChoicePointContext.Rules onto ClassicExecutionContext.choicePoints, so the remaining candidates (if any) can be retried later on backtracking.
Pushes a new child frame onto the execution-context stack for the current goal, becoming its own ClassicExecutionContext.goals.
Combines createChild and appendPrimitivesAndChoicePoints: how StatePrimitiveSelection moves into a primitive call.
Combines createChild and appendRulesAndChoicePoints: the usual way StateRuleSelection moves into a non-tail rule call.
Whether variable is still relevant to this frame or any of its ancestors (i.e. is in relevantVariables, or occurs in this frame's currentGoal or query, or in an ancestor's). Used when popping a finished frame back to its parent (in it.unibo.tuprolog.solve.classic.fsm.StateGoalSelection) to filter the substitution handed up, discarding bindings for variables local to the finished sub-goal.
Last-call-optimization counterpart of createChild: reuses the current frame for the current goal (incrementing ClassicExecutionContext.depth without growing the ClassicExecutionContext.parent chain), used by StateRuleSelection for tail calls to avoid an unbounded execution-context stack.
Combines replaceWithChild and appendRulesAndChoicePoints: how StateRuleSelection moves into a last-call-optimized (tail) rule call.
Builds the Solve.Request passed to a Primitive's solve from this context, goal and signature, at startTime.