#include "inst_xsb.h"#include "struct_manager.h"#include "tries.h"Data Structures | |
| struct | Basic_Trie_HashTable |
| struct | TimeStamp_Index_Node |
| struct | HashTable_for_TSTNs |
Defines | |
| #define | TrieHT_Instr(pTHT) TSC_Instr(pTHT) |
| #define | TrieHT_Status(pTHT) TSC_Status(pTHT) |
| #define | TrieHT_TrieType(pTHT) TSC_TrieType(pTHT) |
| #define | TrieHT_NodeType(pTHT) TSC_NodeType(pTHT) |
| #define | TrieHT_NumBuckets(pTHT) ( (pTHT)->numBuckets ) |
| #define | TrieHT_NumContents(pTHT) ( (pTHT)->numContents ) |
| #define | TrieHT_BucketArray(pTHT) ( (pTHT)->pBucketArray ) |
| #define | TrieHT_PrevHT(pTHT) ( (pTHT)->prev ) |
| #define | TrieHT_NextHT(pTHT) ( (pTHT)->next ) |
| #define | TrieHT_GetHashSeed(pTHT) ( TrieHT_NumBuckets(pTHT) - 1 ) |
| #define | TN_SetInstr(pTN, Symbol) |
| #define | TN_ResetInstrCPs(pHead, pSibling) |
| #define | TN_RotateInstrCPtoRETRYorTRUST(pTN) TN_Instr(pTN) += 0x1 |
| #define | TN_UpgradeInstrTypeToSUCCESS(pTN, SymbolTag) |
| #define | TN_ForceInstrCPtoNOCP(pTN) TN_Instr(pTN) = TN_Instr(pTN) & ~0x3 |
| #define | TN_ForceInstrCPtoTRY(pTN) TN_Instr(pTN) = (TN_Instr(pTN) & ~0x3) | 0x2 |
| #define | Contains_NOCP_Instr(pTN) ( (TN_Instr(pTN) & 0x3) == 0 ) |
| #define | Contains_TRUST_Instr(pTN) ( (TN_Instr(pTN) & 0x3) == 1 ) |
| #define | Contains_TRY_Instr(pTN) ( (TN_Instr(pTN) & 0x3) == 2 ) |
| #define | Contains_RETRY_Instr(pTN) ( (TN_Instr(pTN) & 0x3) == 3 ) |
| #define | TN_InstrCPType(pTN) ( TN_Instr(pTN) & 0x3 ) |
| #define | VALID_NODE_STATUS ( (byte) 0 ) |
| #define | IsValidNode(pTSC) ( TSC_Status(pTSC) == VALID_NODE_STATUS ) |
| #define | IsDeletedNode(pTSC) ( TSC_Status(pTSC) != VALID_NODE_STATUS ) |
| #define | MakeStatusValid(pTSC) TSC_Status(pTSC) = VALID_NODE_STATUS |
| #define | MakeStatusDeleted(pTSC) TSC_Status(pTSC) = TSC_Instr(pTSC) |
| #define | IsInCallTrie(pTSC) ( TSC_TrieType(pTSC) == CALL_TRIE_TT ) |
| #define | IsInAnswerTrie(pTSC) |
| #define | IsInDelayTrie(pTSC) ( TSC_TrieType(pTSC) == DELAY_TRIE_TT ) |
| #define | IsInAssertTrie(pTSC) ( TSC_TrieType(pTSC) == ASSERT_TRIE_TT ) |
| #define | IsInInternTrie(pTSC) ( TSC_TrieType(pTSC) == INTERN_TRIE_TT ) |
| #define | IsInTimeStampedTrie(pTSC) ( TSC_TrieType(pTSC) == TS_ANSWER_TRIE_TT ) |
| #define | IsInBasicTrie(pTSC) ( ! IsInTimeStampedTrie(pTSC) ) |
| #define | IsPrivateTrie(pTSC) ( TSC_TrieType(pTSC) & 0x08 = 0) |
| #define | IsSharedTrie(pTSC) ( TSC_TrieType(pTSC) & 0x08 = 1) |
| #define | HASHED_NODE_MASK 0x01 |
| #define | LEAF_NODE_MASK 0x02 |
| #define | IsTrieRoot(pTSC) (TSC_NodeType(pTSC) == TRIE_ROOT_NT) |
| #define | IsHashHeader(pTSC) (TSC_NodeType(pTSC) == HASH_HEADER_NT) |
| #define | IsHashedNode(pTSC) (TSC_NodeType(pTSC) & HASHED_NODE_MASK) |
| #define | IsLeafNode(pTSC) (TSC_NodeType(pTSC) & LEAF_NODE_MASK) |
| #define | IsEscapeNode(pTSC) (TSC_Instr(pTSC) == trie_proceed) |
| #define | MakeLeafNode(pTN) TN_NodeType(pTN) = TN_NodeType(pTN) | LEAF_NODE_MASK |
| #define | MakeHashedNode(pTN) TN_NodeType(pTN) = TN_NodeType(pTN) | HASHED_NODE_MASK |
| #define | TrieSymbolType(Symbol) cell_tag(Symbol) |
| #define | IsTrieVar(Symbol) ( TrieSymbolType(Symbol) == XSB_TrieVar ) |
| #define | IsTrieFunctor(Symbol) ( TrieSymbolType(Symbol) == XSB_STRUCT ) |
| #define | IsTrieList(Symbol) ( TrieSymbolType(Symbol) == XSB_LIST ) |
| #define | IsTrieString(Symbol) ( TrieSymbolType(Symbol) == XSB_STRING ) |
| #define | IsTrieInteger(Symbol) ( TrieSymbolType(Symbol) == XSB_INT ) |
| #define | IsTrieFloat(Symbol) ( TrieSymbolType(Symbol) == XSB_FLOAT ) |
| #define | EncodeTriePSC(pPSC) makecs(pPSC) |
| #define | EncodeTrieFunctor(Cell_STRUCT) makecs(follow(clref_val(Cell_STRUCT))) |
| #define | EncodeTrieList(Cell_LIST) ( (Cell)XSB_LIST ) |
| #define | EncodeTrieConstant(Cell_Const) ( (Cell)Cell_Const ) |
| #define | DecodeTrieFunctor(Symbol) (Psc)cs_val(Symbol) |
| #define | DecodeTrieList(Symbol) ( Symbol ) |
| #define | DecodeTrieString(Symbol) string_val(Symbol) |
| #define | DecodeTrieInteger(Symbol) int_val(Symbol) |
| #define | DecodeTrieFloat(Symbol) float_val(Symbol) |
| #define | ESCAPE_NODE_SYMBOL (Cell)0 |
| #define | NEW_TRIEVAR_TAG 0x10000 |
| #define | NEW_TRIEATTV_TAG 0x20000 |
| #define | TRIEVAR_INDEX_MASK 0xffff |
| #define | EncodeNewTrieVar(Index) maketrievar(Index | NEW_TRIEVAR_TAG) |
| #define | EncodeNewTrieAttv(Index) maketrievar(Index | NEW_TRIEATTV_TAG) |
| #define | EncodeTrieVar(Index) maketrievar(Index) |
| #define | DecodeTrieVar(Symbol) ( trievar_val(Symbol) & TRIEVAR_INDEX_MASK ) |
| #define | IsNewTrieVar(Symbol) ( trievar_val(Symbol) & NEW_TRIEVAR_TAG ) |
| #define | IsNewTrieAttv(Symbol) ( trievar_val(Symbol) & NEW_TRIEATTV_TAG) |
| #define | StandardizeVariable(dFreeVar, Index) bld_ref((CPtr)dFreeVar,VarEnumerator[Index]) |
| #define | IsStandardizedVariable(dFreeVar) |
| #define | ResetStandardizedVariable(VarAddr) bld_free( ((CPtr)VarAddr) ) |
| #define | IndexOfStdVar(pVarEnumCell) ( (CPtr)(pVarEnumCell) - VarEnumerator ) |
| #define | TrieSymbol_Deref(Symbol) |
| #define | IsUnboundTrieVar(dFreeVar) |
| #define | IsEmptyTrie(Root) IsNULL(TN_Child(Root)) |
| #define | TN_Init(TN, TrieType, NodeType, Symbol, Parent, Sibling) |
| #define | SearchChainForSymbol(Chain, Symbol, ChainLength) |
| #define | MAX_SIBLING_LEN 8 |
| #define | IsLongSiblingChain(ChainLength) ( ChainLength > MAX_SIBLING_LEN ) |
| #define | TRIEVAR_BUCKET 0 |
| #define | TrieHash(Symbol, HashSeed) |
| #define | CalculateBucketForSymbol(pHT, Symbol) ( TrieHT_BucketArray(pHT) + TrieHash(Symbol,TrieHT_GetHashSeed(pHT)) ) |
| #define | TrieHT_INIT_SIZE 64 |
| #define | TrieHT_NewSize(pHT) ( TrieHT_NumBuckets(pHT) << 1 ) |
| #define | BUCKET_CONTENT_THRESHOLD (MAX_SIBLING_LEN / 2) |
| #define | TrieHT_ExpansionCheck(pHT, NumBucketContents) |
| #define | TrieHT_InsertNode(pBucketArray, HashSeed, pTN) |
| #define | BTN_SetHashHdr(pBTN, pTHT) TN_SetHashHdr(pBTN,pTHT) |
| #define | BTN_GetHashHdr(pBTN) ( (BTHTptr)TN_GetHashHdr(pBTN) ) |
| #define | CallTrieLeaf_SetSF(pBTN, pSF) BTN_Child(pBTN) = (BTNptr)(pSF) |
| #define | CallTrieLeaf_GetSF(pBTN) ((VariantSF)BTN_Child(pBTN)) |
| #define | BTNs_PER_BLOCK 2*K |
| #define | New_BTN(BTN, TrieType, NodeType, Symbol, Parent, Sibling) BTN = new_btn(CTXTc TrieType,NodeType,Symbol,(BTNptr)Parent,(BTNptr)Sibling) |
| #define | CreateEscapeBTN(pBTN, TrieType, Parent) |
| #define | BTHT_Instr(pTHT) TrieHT_Instr(pTHT) |
| #define | BTHT_Status(pTHT) TrieHT_Status(pTHT) |
| #define | BTHT_TrieType(pTHT) TrieHT_TrieType(pTHT) |
| #define | BTHT_NodeType(pTHT) TrieHT_NodeType(pTHT) |
| #define | BTHT_NumBuckets(pTHT) TrieHT_NumBuckets(pTHT) |
| #define | BTHT_NumContents(pTHT) TrieHT_NumContents(pTHT) |
| #define | BTHT_BucketArray(pTHT) TrieHT_BucketArray(pTHT) |
| #define | BTHT_PrevBTHT(pTHT) TrieHT_PrevHT(pTHT) |
| #define | BTHT_NextBTHT(pTHT) TrieHT_NextHT(pTHT) |
| #define | BTHT_GetHashSeed(pTHT) TrieHT_GetHashSeed(pTHT) |
| #define | _New_TrieHT(SM, THT, TrieType) _New_TrieHT_Sub(SM,THT,TrieType) |
| #define | _New_TrieHT_Sub(SM, THT, TrieType) |
| #define | TrieHT_RemoveFromAllocList(SM, THT) SM_RemoveFromAllocList_DL(SM,THT,BTHT_PrevBTHT,BTHT_NextBTHT) |
| #define | TrieHT_FreeAllocatedBuckets(SM) |
| #define | BTHTs_PER_BLOCK 16 |
| #define | New_BTHT(BTHT, TrieType) _New_TrieHT(*smBTHT,BTHT,TrieType) |
| #define | TSTRoot_SetHTList(pTST, pTSTHT) TSTN_Sibling(pTST) = (TSTNptr)pTSTHT |
| #define | TSTRoot_GetHTList(pTST) ((TSTHTptr)TSTN_Sibling(pTST)) |
| #define | TSTN_SetHashHdr(pTSTN, pTSTHT) TN_SetHashHdr(pTSTN,pTSTHT) |
| #define | TSTN_GetHashHdr(pTSTN) ( (TSTHTptr)TN_GetHashHdr(pTSTN) ) |
| #define | TSTN_SetTSIN(pTSTN, TSIN) TSTN_TimeStamp(pTSTN) = (TimeStamp)(TSIN) |
| #define | TSTN_GetTSIN(pTSTN) ((TSINptr)TSTN_TimeStamp(pTSTN)) |
| #define | TSTN_GetTSfromTSIN(pTSTN) TSIN_TimeStamp(TSTN_GetTSIN(pTSTN)) |
| #define | TSTN_GetDelayList(pTSTN) TSTN_Child(pTSTN) |
| #define | TSTNs_PER_BLOCK K |
| #define | New_TSTN(TSTN, TrieType, NodeType, Symbol, Parent, Sibling) TSTN = new_tstn(CTXTc TrieType,NodeType,Symbol,Parent,Sibling) |
| #define | CreateEscapeTSTN(pTSTN, TrieType, Parent) |
| #define | EMPTY_TST_TIMESTAMP 0 |
| #define | TSTN_DEFAULT_TIMESTAMP 1 |
| #define | PRODUCER_SF_INITIAL_TS TSTN_DEFAULT_TIMESTAMP |
| #define | CONSUMER_SF_INITIAL_TS EMPTY_TST_TIMESTAMP |
| #define | TSIN_Prev(TSIN) ((TSIN)->prev) |
| #define | TSIN_Next(TSIN) ((TSIN)->next) |
| #define | TSIN_TimeStamp(TSIN) ((TSIN)->ts) |
| #define | TSIN_TSTNode(TSIN) ((TSIN)->tstn) |
| #define | IsTSindexHead(TSIN) IsNULL(TSIN_Prev(TSIN)) |
| #define | IsTSindexTail(TSIN) IsNULL(TSIN_Next(TSIN)) |
| #define | TSINs_PER_BLOCK 256 |
| #define | New_TSIN(TSIN, TSTN) |
| #define | TSTHT_Instr(pTSTHT) TrieHT_Instr(pTSTHT) |
| #define | TSTHT_Padding(pTSTHT) TrieHT_Status(pTSTHT) |
| #define | TSTHT_TrieType(pTSTHT) TrieHT_TrieType(pTSTHT) |
| #define | TSTHT_NodeType(pTSTHT) TrieHT_NodeType(pTSTHT) |
| #define | TSTHT_NumBuckets(pTSTHT) TrieHT_NumBuckets(pTSTHT) |
| #define | TSTHT_NumContents(pTSTHT) TrieHT_NumContents(pTSTHT) |
| #define | TSTHT_BucketArray(pTSTHT) TrieHT_BucketArray(pTSTHT) |
| #define | TSTHT_PrevTSTHT(pTSTHT) TrieHT_PrevHT(pTSTHT) |
| #define | TSTHT_NextTSTHT(pTSTHT) TrieHT_NextHT(pTSTHT) |
| #define | TSTHT_InternalLink(pTSTHT) ((pTSTHT)->internalLink) |
| #define | TSTHT_IndexHead(pTSTHT) ((pTSTHT)->index_head) |
| #define | TSTHT_IndexTail(pTSTHT) ((pTSTHT)->index_tail) |
| #define | TSTHT_GetHashSeed(pTSTHT) BTHT_GetHashSeed((BTHTptr)(pTSTHT)) |
| #define | TSTHTs_PER_BLOCK 16 |
| #define | New_TSTHT(TSTHT, TrieType, TST) |
| #define | ALNs_PER_BLOCK 512 |
| #define | New_ALN(subgoal, pALN, pTN, pNext) |
| #define | New_Private_ALN(pALN, pTN, pNext) |
| #define | free_answer_list(SubgoalFrame) |
| #define | trie_escape_lookup(Root) |
| #define | TST_InsertEscapeNode(Root, NewNode) |
| #define | BT_InsertEscapeNode(Root, NewNode) |
| #define | TrieError_UnknownSubtermTagMsg "Trie Subterm-to-Symbol Conversion\nUnknown subterm type (%d)" |
| #define | TrieError_UnknownSubtermTag(Subterm) xsb_abort(TrieError_UnknownSubtermTagMsg, cell_tag(Subterm)) |
| #define | TrieError_AbsentEscapeNode(Root) |
| #define | TrieError_TooManyTerms(Function) |
| #define | TrieError_TooFewTerms(Function) |
| #define | TrieError_InterfaceInvariant(Function) xsb_abort("Trie Interface\nImproper use of " Function) |
Typedefs | |
| typedef Basic_Trie_HashTable * | BTHTptr |
| typedef Basic_Trie_HashTable | BasicTrieHT |
| typedef TimeStamp_Index_Node * | TSINptr |
| typedef TimeStamp_Index_Node | TS_IndexNode |
| typedef HashTable_for_TSTNs * | TSTHTptr |
| typedef HashTable_for_TSTNs | TST_HashTable |
Enumerations | |
| enum | Types_of_Tries { CALL_TRIE_TT = 0x06, BASIC_ANSWER_TRIE_TT = 0x05, TS_ANSWER_TRIE_TT = 0x04, DELAY_TRIE_TT = 0x03, ASSERT_TRIE_TT = 0x02, INTERN_TRIE_TT = 0x01 } |
| enum | Types_of_Trie_Nodes { TRIE_ROOT_NT = 0x08, HASH_HEADER_NT = 0x04, LEAF_NT = 0x02, HASHED_LEAF_NT = 0x03, INTERIOR_NT = 0x00, HASHED_INTERIOR_NT = 0x01 } |
| enum | { NO_INSERT_SYMBOL = 0 } |
Functions | |
| void | hashify_children (CTXTdeclc BTNptr, int) |
| BTNptr | new_btn (CTXTdeclc int TrieType, int NodeType, Cell Symbol, BTNptr Parent, BTNptr Sibling) |
| void | expand_trie_ht (BTHTptr) |
| TSTNptr | new_tstn (CTXTdeclc int TrieType, int NodeType, Cell Symbol, TSTNptr Parent, TSTNptr Sibling) |
| void * | var_trie_lookup (CTXTdeclc void *, xsbBool *, Cell *) |
| void * | iter_sub_trie_lookup (CTXTdeclc void *trieNode, TriePathType *) |
| void * | stl_restore_variant_cont (CTXTdecl) |
| BTNptr | bt_escape_search (CTXTdeclc BTNptr root, xsbBool *isNew) |
| BTNptr | bt_insert (CTXTdeclc BTNptr root, BTNptr start, Cell firstSym) |
| TSTNptr | tst_insert (CTXTdeclc TSTNptr root, TSTNptr start, Cell firstSym, xsbBool maintainTSI) |
Variables | |
| Cell | VarEnumerator [] |
| Cell | TrieVarBindings [] |
| Structure_Manager | smTableBTN |
| Structure_Manager | smAssertBTN |
| Structure_Manager * | smBTN |
| Structure_Manager | smTSIN |
| Structure_Manager | smTSTHT |
| Structure_Manager | smTableBTHT |
| Structure_Manager | smAssertBTHT |
| Structure_Manager * | smBTHT |
| Structure_Manager | smTSTN |
| Structure_Manager | smALN |
|
|
|
|
|
Value: { \
\
void * btht; \
SM_AllocateStruct(SM,btht); \
BTHT_Instr(((BTHTptr)btht)) = hash_opcode; \
BTHT_Status(((BTHTptr)btht)) = VALID_NODE_STATUS; \
BTHT_TrieType(((BTHTptr)btht)) = TrieType; \
BTHT_NodeType(((BTHTptr)btht)) = HASH_HEADER_NT; \
BTHT_NumContents(((BTHTptr)btht)) = MAX_SIBLING_LEN + 1; \
BTHT_NumBuckets(((BTHTptr)btht)) = TrieHT_INIT_SIZE; \
BTHT_BucketArray(((BTHTptr)btht)) = \
(BTNptr *)mem_calloc(TrieHT_INIT_SIZE, sizeof(void *),TABLE_SPACE);\
SM_AddToAllocList_DL(SM,((BTHTptr)btht),BTHT_PrevBTHT,BTHT_NextBTHT) \
THT = btht; \
}
|
|
|
|
|
|
Value: { \
CreateEscapeBTN(NewNode,BTN_TrieType(Root),Root); \
BTN_Child(Root) = NewNode; \
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Value: { \
New_BTN(pBTN,TrieType,LEAF_NT,ESCAPE_NODE_SYMBOL,Parent,NULL); \
BTN_Instr(pBTN) = trie_proceed; \
}
|
|
|
Value: { \
New_TSTN(pTSTN,TrieType,LEAF_NT,ESCAPE_NODE_SYMBOL,Parent,NULL); \
TSTN_Instr(pTSTN) = trie_proceed; \
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Value: { \
if ( subg_answers(SubgoalFrame) > COND_ANSWERS ) \
SM_DeallocateStructList(smALN, \
subg_ans_list_ptr(SubgoalFrame), \
subg_ans_list_tail(SubgoalFrame)) \
else \
SM_DeallocateStruct(smALN,subg_ans_list_ptr(SubgoalFrame)); \
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Value: ( TSC_TrieType(pTSC) == BASIC_ANSWER_TRIE_TT || \ TSC_TrieType(pTSC) == TS_ANSWER_TRIE_TT ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Value: ( ((CPtr)(dFreeVar) >= VarEnumerator) && \ ((CPtr)(dFreeVar) <= (VarEnumerator + NUM_TRIEVARS - 1)) ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Value: ( ((CPtr)(dFreeVar) >= TrieVarBindings) && \ ((CPtr)(dFreeVar) <= (TrieVarBindings + NUM_TRIEVARS - 1)) ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Value: { \
void *p ; \
\
SM_AllocateStruct(smALN,p); \
pALN = (ALNptr)p; \
ALN_Answer(pALN) = (BTNptr)pTN; \
ALN_Next(pALN) = (ALNptr)pNext; \
}
|
|
|
|
|
|
|
|
|
Value: { \
void *p ; \
\
SM_AllocateStruct(smALN,p); \
pALN = (ALNptr)p; \
ALN_Answer(pALN) = (BTNptr)pTN; \
ALN_Next(pALN) = (ALNptr)pNext; \
}
|
|
|
|
|
|
|
|
|
Value: { \
void *t ; \
SM_AllocateStruct(smTSIN,t); \
TSIN = (TSINptr)t ; \
TSIN_TSTNode(TSIN) = TSTN; \
TSIN_TimeStamp(TSIN) = TSTN_TimeStamp(TSTN); \
}
|
|
|
Value: { \
_New_TrieHT_Sub(smTSTHT,TSTHT,TrieType); \
TSTHT_InternalLink(TSTHT) = (TSTHTptr)TSTRoot_GetHTList(TST);\
TSTRoot_SetHTList(TST,TSTHT); \
TSTHT_IndexHead(TSTHT) = TSTHT_IndexTail(TSTHT) = NULL; \
}
|
|
|
|
|
|
|
|
|
|
|
|
Value: { \
ChainLength = 0; \
while ( IsNonNULL(Chain) && (TN_Symbol(Chain) != Symbol) ) { \
ChainLength++; \
Chain = TN_Sibling(Chain); \
} \
}
|
|
|
|
|
|
|
|
|
|
|
|
Value: { \
\
if ( NodeType != TRIE_ROOT_NT ) { \
TN_SetInstr(TN,Symbol); \
TN_ResetInstrCPs(TN,Sibling); \
} \
else \
TN_Instr(TN) = trie_root; \
TN_Status(TN) = VALID_NODE_STATUS; \
TN_TrieType(TN) = TrieType; \
TN_NodeType(TN) = NodeType; \
TN_Symbol(TN) = Symbol; \
TN_Parent(TN) = Parent; \
TN_Child(TN) = NULL; \
TN_Sibling(TN) = Sibling; \
}
|
|
|
|
|
|
Value: { \
if ( IsNonNULL(pSibling) ) \
TN_RotateInstrCPtoRETRYorTRUST(pSibling); \
else \
TN_Instr(pHead) -= 0x2; /* TRY -> NO_CP */ \
}
|
|
|
|
|
|
Value: switch( TrieSymbolType(Symbol) ) { \ case XSB_STRUCT: \ TN_Instr(pTN) = (byte)trie_try_str; \ break; \ case XSB_INT: \ case XSB_STRING: \ case XSB_FLOAT: \ TN_Instr(pTN) = (byte)trie_try_numcon; \ break; \ case XSB_TrieVar: \ if (IsNewTrieVar(Symbol)) \ TN_Instr(pTN) = (byte)trie_try_var; \ else if (IsNewTrieAttv(Symbol)) { \ TN_Instr(pTN) = (byte)trie_try_attv; \ } \ else { \ TN_Instr(pTN) = (byte)trie_try_val; \ } \ break; \ case XSB_LIST: \ TN_Instr(pTN) = (byte)trie_try_list; \ break; \ default: \ xsb_abort("Trie Node creation: Bad tag in symbol %lx", \ Symbol); \ } |
|
|
Value: if ( SymbolTag == XSB_STRING || SymbolTag == XSB_INT \ || SymbolTag == XSB_FLOAT ) \ TN_Instr(pTN) += 0x4 |
|
|
Value: |
|
|
Value: { \
Cell symbol = TN_Symbol(Root); \
if ( IsTrieString(symbol) || \
(IsTrieFunctor(symbol) && \
(get_arity(DecodeTrieFunctor(symbol)) == 0)) ) \
xsb_abort("Trie Structure Anomaly\n" \
"Non-Escape-Node present in 0-ary trie"); \
else \
xsb_abort("Trie Structure Anomaly\n" \
"Escape Node expected but not found"); \
}
|
|
|
|
|
|
Value: xsb_abort("Trie Matching\nToo few terms for trie in " \ Function) |
|
|
Value: xsb_abort("Trie Matching\nToo many terms for trie in " \ Function) |
|
|
|
|
|
|
|
|
Value: ( IsTrieVar(Symbol) \ ? TRIEVAR_BUCKET \ : ( ((Symbol) >> XSB_CELL_TAG_NBITS) & (HashSeed) ) \ ) |
|
|
|
|
|
Value: { \
if ( (NumBucketContents > BUCKET_CONTENT_THRESHOLD) && \
(TrieHT_NumContents(pHT) > TrieHT_NumBuckets(pHT)) ) \
expand_trie_ht((BTHTptr)pHT); \
}
|
|
|
Value: { \
BTHTptr pBTHT; \
\
for ( pBTHT = (BTHTptr)SM_AllocList(SM); IsNonNULL(pBTHT); \
pBTHT = (BTHTptr)BTHT_NextBTHT(pBTHT) ) { \
/* printf("freeing table for thread %d: %x\n",xsb_thread_id,pBTHT); */ \
mem_dealloc(BTHT_BucketArray(pBTHT),BTHT_NumBuckets(pBTHT)*sizeof(void *),TABLE_SPACE); \
} \
}
|
|
|
|
|
|
|
|
|
Value: { \
\
void **pBucket; \
\
pBucket = (void **)(pBucketArray + TrieHash(TN_Symbol(pTN),HashSeed)); \
if ( IsNonNULL(*pBucket) ) { \
TN_ForceInstrCPtoTRY(pTN); \
TN_RotateInstrCPtoRETRYorTRUST((BTNptr)*pBucket); \
} \
else \
TN_ForceInstrCPtoNOCP(pTN); \
TN_Sibling(pTN) = *pBucket; \
*pBucket = pTN; \
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Value: if (IsTrieVar(Symbol)) { \ Symbol = TrieVarBindings[DecodeTrieVar(Symbol)]; \ XSB_Deref(Symbol); \ } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Value: { \
CreateEscapeTSTN(NewNode,TSTN_TrieType(Root),Root); \
TSTN_Child(Root) = NewNode; \
TSTN_TimeStamp(NewNode) = TSTN_TimeStamp(Root) = TSTN_DEFAULT_TIMESTAMP; \
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||||
|
|
|
||||||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||
|
|
|
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.4.5