#include "xsb_config.h"
#include "xsb_debug.h"
#include <stdio.h>
#include <stdlib.h>
#include "auxlry.h"
#include "cell_xsb.h"
#include "inst_xsb.h"
#include "register.h"
#include "memory_xsb.h"
#include "error_xsb.h"
#include "psc_xsb.h"
#include "deref.h"
#include "binding.h"
#include "cut_xsb.h"
#include "sw_envs.h"
#include "subp.h"
#include "table_stats.h"
#include "trie_internals.h"
#include "macro_xsb.h"
#include "tst_aux.h"
#include "tst_utils.h"
#include "debug_xsb.h"
#include "flags_xsb.h"
#include "thread_xsb.h"
Defines | |
#define | Save_and_Set_WAM_Registers |
#define | Restore_WAM_Registers |
#define | Trie_bind_copy(Addr, Val) |
#define | Trie_Conditionally_Trail(Addr, Val) |
#define | Bind_and_Conditionally_Trail(Addr, Val) Trie_bind_copy(Addr,Val) \ |
#define | Bind_and_Trail(Addr, Val) |
#define | Sys_Trail_Unwind(UnwindBase) table_undo_bindings(UnwindBase) |
#define | tstCPF_AlternateNode ((tstCPStack.top)->alt_node) |
#define | tstCPF_TermStackTopIndex ((tstCPStack.top)->ts_top_index) |
#define | tstCPF_TSLogTopIndex ((tstCPStack.top)->log_top_index) |
#define | tstCPF_TrailTop ((tstCPStack.top)->trail_top) |
#define | tstCPF_HBreg ((tstCPStack.top)->heap_bktrk) |
#define | CPStack_IsEmpty (tstCPStack.top == tstCPStack.base) |
#define | CPStack_IsFull (tstCPStack.top == tstCPStack.ceiling) |
#define | CPStack_PushFrame(AlternateTSTN) |
#define | CPStack_Pop tstCPStack.top-- |
#define | TST_Backtrack |
#define | Descend_Into_TST_and_Continue_Search |
#define | ResetParentAndCurrentNodes |
#define | RestoreTermStack |
#define | ResetHeap_fromCPF |
#define | CPStack_OverflowCheck |
#define | IsValidTS(SymbolTS, CutoffTS) (SymbolTS > CutoffTS) |
#define | ALN_InsertAnswer(pAnsListHead, pAnswerNode) |
#define | RequiresCleanup TRUE |
#define | NoCleanupRequired FALSE |
#define | TST_Collection_Error(String, DoesRequireCleanup) |
#define | backtrack break |
#define | Chain_NextValidTSTN(Chain, TS, tsAccessMacro) |
#define | TSI_NextValidTSTN(ValidTSIN, TS) |
#define | SetMatchAndUnifyChains(Symbol, SymChain, VarChain) |
#define | SearchChain_ExactMatch(SearchChain, TrieEncodedSubterm, TS, ContChain, TermStack_PushOp) |
#define | SearchChain_UnifyWithConstant(Chain, Subterm, TS, Get_TS_Op) |
#define | SearchChain_UnifyWithFunctor(Chain, Subterm, TS, Get_TS_Op) |
#define | SearchChain_UnifyWithList(Chain, Subterm, TS, Get_TS_Op) |
#define | CurrentTSTN_UnifyWithVariable(Chain, Subterm, Continuation) |
Functions | |
void | initCollectRelevantAnswers (CTXTdecl) |
static void | tstCollectionError (CTXTdeclc char *string, xsbBool cleanup_needed) |
ALNptr | tst_collect_relevant_answers (CTXTdeclc TSTNptr tstRoot, TimeStamp ts, int numTerms, CPtr termsRev) |
Variables | |
static CPtr * | trail_base |
static CPtr * | orig_trreg |
static CPtr | orig_hreg |
static CPtr | orig_hbreg |
static CPtr | orig_ebreg |
static struct tstCPStack_t | tstCPStack |
|
Value: { \ ALNptr newAnsListNode; \ New_Private_ALN(newAnsListNode,(void *)pAnswerNode,pAnsListHead); \ pAnsListHead = newAnsListNode; \ } |
|
|
|
|
|
Value: pushtrail0(Addr, Val) \ *(Addr) = Val |
|
Value: while ( IsNonNULL(Chain) && (! IsValidTS(tsAccessMacro(Chain),TS)) ) \ Chain = TSTN_Sibling(Chain) |
|
|
|
|
|
Value: if (CPStack_IsFull) \ TST_Collection_Error("tstCPStack overflow.", RequiresCleanup) |
|
|
|
Value: if ( IsNonNULL(AlternateTSTN) ) { \ CPStack_OverflowCheck \ tstCPF_AlternateNode = AlternateTSTN; \ tstCPF_TermStackTopIndex = TermStack_Top - TermStack_Base + 1; \ tstCPF_TSLogTopIndex = TermStackLog_Top - TermStackLog_Base; \ tstCPF_TrailTop = trreg; \ tstCPF_HBreg = hbreg; \ hbreg = hreg; \ tstCPStack.top++; \ } |
|
|
|
Value: parentTSTN = cur_chain; \ cur_chain = TSTN_Child(cur_chain); \ goto While_TSnotEmpty |
|
|
|
|
|
|
|
Value: hreg = hbreg; \ hbreg = tstCPF_HBreg |
|
Value: cur_chain = tstCPF_AlternateNode; \ parentTSTN = TSTN_Parent(cur_chain) |
|
Value: trreg = orig_trreg; \ hreg = orig_hreg; \ hbreg = orig_hbreg; \ ebreg = orig_ebreg |
|
Value: |
|
Value: orig_hbreg = hbreg; \ orig_hreg = hbreg = hreg; \ orig_ebreg = ebreg; \ ebreg = top_of_localstk; \ orig_trreg = trreg; \ trreg = top_of_trail |
|
Value: while ( IsNonNULL(SearchChain) ) { \ if ( TrieEncodedSubterm == TSTN_Symbol(SearchChain) ) { \ if ( IsValidTS(TSTN_GetTSfromTSIN(SearchChain),TS) ) { \ Chain_NextValidTSTN(ContChain,TS,TSTN_GetTSfromTSIN); \ CPStack_PushFrame(ContChain); \ TermStackLog_PushFrame; \ TermStack_PushOp; \ Descend_Into_TST_and_Continue_Search; \ } \ else \ break; /* matching symbol's TS is too old */ \ } \ SearchChain = TSTN_Sibling(SearchChain); \ } |
|
Value: { \ Chain_NextValidTSTN(Chain,TS,Get_TS_Op); \ while ( IsNonNULL(Chain) ) { \ alt_chain = TSTN_Sibling(Chain); \ Chain_NextValidTSTN(alt_chain,TS,Get_TS_Op); \ symbol = TSTN_Symbol(Chain); \ TrieSymbol_Deref(symbol); \ if ( isref(symbol) ) { \ /* \ * Either an unbound TrieVar or some unbound prolog var. \ */ \ CPStack_PushFrame(alt_chain); \ Bind_and_Conditionally_Trail((CPtr)symbol, Subterm); \ TermStackLog_PushFrame; \ Descend_Into_TST_and_Continue_Search; \ } \ else if (symbol == Subterm) { \ CPStack_PushFrame(alt_chain); \ TermStackLog_PushFrame; \ Descend_Into_TST_and_Continue_Search; \ } \ Chain = alt_chain; \ } \ } |
|
|
|
|
|
Value: { \ \ TSTHTptr ht = (TSTHTptr)SymChain; \ TSTNptr *buckets = TSTHT_BucketArray(ht); \ \ SymChain = buckets[TrieHash(Symbol,TSTHT_GetHashSeed(ht))]; \ VarChain = buckets[TRIEVAR_BUCKET]; \ } |
|
|
|
Value: Trie_Conditionally_Trail(Addr,Val); \ *(Addr) = Val |
|
Value: if ( IsUnboundTrieVar(Addr) || conditional(Addr) ) \ { pushtrail0(Addr, Val) } |
|
Value: ( ( IsNonNULL(TSIN_Next(ValidTSIN)) && \ IsValidTS(TSIN_TimeStamp(TSIN_Next(ValidTSIN)),TS) ) \ ? TSIN_TSTNode(TSIN_Next(ValidTSIN)) \ : NULL ) |
|
Value: |
|
Value: { \ tstCollectionError(CTXTc String, DoesRequireCleanup); \ return NULL; \ } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|