00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "xsb_config.h"
00027 #include "xsb_debug.h"
00028
00029 #include <stdio.h>
00030 #include <stdlib.h>
00031
00032 #include "auxlry.h"
00033 #include "cell_xsb.h"
00034 #include "inst_xsb.h"
00035 #include "register.h"
00036 #include "memory_xsb.h"
00037 #include "error_xsb.h"
00038 #include "psc_xsb.h"
00039 #include "deref.h"
00040 #include "binding.h"
00041 #include "cut_xsb.h"
00042 #include "sw_envs.h"
00043 #include "subp.h"
00044 #include "table_stats.h"
00045 #include "trie_internals.h"
00046 #include "macro_xsb.h"
00047 #include "tst_aux.h"
00048 #include "tst_utils.h"
00049 #include "debug_xsb.h"
00050 #include "flags_xsb.h"
00051 #include "thread_xsb.h"
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 #ifndef MULTI_THREAD
00067 static CPtr *trail_base;
00068
00069
00070
00071 static CPtr *orig_trreg;
00072 static CPtr orig_hreg;
00073 static CPtr orig_hbreg;
00074 static CPtr orig_ebreg;
00075 #endif
00076
00077
00078
00079
00080
00081 #define Save_and_Set_WAM_Registers \
00082 orig_hbreg = hbreg; \
00083 orig_hreg = hbreg = hreg; \
00084 orig_ebreg = ebreg; \
00085 ebreg = top_of_localstk; \
00086 orig_trreg = trreg; \
00087 trreg = top_of_trail
00088
00089 #define Restore_WAM_Registers \
00090 trreg = orig_trreg; \
00091 hreg = orig_hreg; \
00092 hbreg = orig_hbreg; \
00093 ebreg = orig_ebreg
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 #define Trie_bind_copy(Addr,Val) \
00118 Trie_Conditionally_Trail(Addr,Val); \
00119 *(Addr) = Val
00120
00121 #define Trie_Conditionally_Trail(Addr, Val) \
00122 if ( IsUnboundTrieVar(Addr) || conditional(Addr) ) \
00123 { pushtrail0(Addr, Val) }
00124
00125 #define Bind_and_Conditionally_Trail(Addr, Val) Trie_bind_copy(Addr,Val) \
00126
00127
00128
00129
00130 #define Bind_and_Trail(Addr, Val) pushtrail0(Addr, Val) \
00131 *(Addr) = Val
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 #define Sys_Trail_Unwind(UnwindBase) table_undo_bindings(UnwindBase)
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 #ifndef MULTI_THREAD
00155 static struct tstCPStack_t tstCPStack;
00156 #endif
00157
00158
00159 #define tstCPF_AlternateNode ((tstCPStack.top)->alt_node)
00160 #define tstCPF_TermStackTopIndex ((tstCPStack.top)->ts_top_index)
00161 #define tstCPF_TSLogTopIndex ((tstCPStack.top)->log_top_index)
00162 #define tstCPF_TrailTop ((tstCPStack.top)->trail_top)
00163 #define tstCPF_HBreg ((tstCPStack.top)->heap_bktrk)
00164
00165 #define CPStack_IsEmpty (tstCPStack.top == tstCPStack.base)
00166 #define CPStack_IsFull (tstCPStack.top == tstCPStack.ceiling)
00167
00168 void initCollectRelevantAnswers(CTXTdecl) {
00169
00170 tstCPStack.ceiling = tstCPStack.base + TST_CPSTACK_SIZE;
00171 }
00172
00173 #define CPStack_PushFrame(AlternateTSTN) \
00174 if ( IsNonNULL(AlternateTSTN) ) { \
00175 CPStack_OverflowCheck \
00176 tstCPF_AlternateNode = AlternateTSTN; \
00177 tstCPF_TermStackTopIndex = TermStack_Top - TermStack_Base + 1; \
00178 tstCPF_TSLogTopIndex = TermStackLog_Top - TermStackLog_Base; \
00179 tstCPF_TrailTop = trreg; \
00180 tstCPF_HBreg = hbreg; \
00181 hbreg = hreg; \
00182 tstCPStack.top++; \
00183 }
00184
00185 #define CPStack_Pop tstCPStack.top--
00186
00187
00188
00189
00190 #define TST_Backtrack \
00191 CPStack_Pop; \
00192 ResetParentAndCurrentNodes; \
00193 RestoreTermStack; \
00194 Sys_Trail_Unwind(tstCPF_TrailTop); \
00195 ResetHeap_fromCPF
00196
00197
00198
00199
00200
00201
00202 #define Descend_Into_TST_and_Continue_Search \
00203 parentTSTN = cur_chain; \
00204 cur_chain = TSTN_Child(cur_chain); \
00205 goto While_TSnotEmpty
00206
00207
00208
00209
00210
00211
00212 #define ResetParentAndCurrentNodes \
00213 cur_chain = tstCPF_AlternateNode; \
00214 parentTSTN = TSTN_Parent(cur_chain)
00215
00216
00217 #define RestoreTermStack \
00218 TermStackLog_Unwind(tstCPF_TSLogTopIndex); \
00219 TermStack_SetTOS(tstCPF_TermStackTopIndex)
00220
00221
00222 #define ResetHeap_fromCPF \
00223 hreg = hbreg; \
00224 hbreg = tstCPF_HBreg
00225
00226
00227 #define CPStack_OverflowCheck \
00228 if (CPStack_IsFull) \
00229 TST_Collection_Error("tstCPStack overflow.", RequiresCleanup)
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239 #define IsValidTS(SymbolTS,CutoffTS) (SymbolTS > CutoffTS)
00240
00241
00242
00243
00244
00245
00246 #define ALN_InsertAnswer(pAnsListHead,pAnswerNode) { \
00247 ALNptr newAnsListNode; \
00248 New_Private_ALN(newAnsListNode,(void *)pAnswerNode,pAnsListHead); \
00249 pAnsListHead = newAnsListNode; \
00250 }
00251
00252
00253
00254
00255 #define RequiresCleanup TRUE
00256 #define NoCleanupRequired FALSE
00257
00258 #define TST_Collection_Error(String, DoesRequireCleanup) { \
00259 tstCollectionError(CTXTc String, DoesRequireCleanup); \
00260 return NULL; \
00261 }
00262
00263 static void tstCollectionError(CTXTdeclc char *string, xsbBool cleanup_needed) {
00264 fprintf(stderr, "Error encountered in Time-Stamped Trie "
00265 "Collection algorithm!\n");
00266 if (cleanup_needed) {
00267 Sys_Trail_Unwind(trail_base);
00268 Restore_WAM_Registers;
00269 }
00270 xsb_abort(string);
00271 }
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282 #define backtrack break
00283
00284
00285
00286
00287
00288
00289 #define Chain_NextValidTSTN(Chain,TS,tsAccessMacro) \
00290 while ( IsNonNULL(Chain) && (! IsValidTS(tsAccessMacro(Chain),TS)) ) \
00291 Chain = TSTN_Sibling(Chain)
00292
00293
00294
00295
00296
00297 #define TSI_NextValidTSTN(ValidTSIN,TS) \
00298 ( ( IsNonNULL(TSIN_Next(ValidTSIN)) && \
00299 IsValidTS(TSIN_TimeStamp(TSIN_Next(ValidTSIN)),TS) ) \
00300 ? TSIN_TSTNode(TSIN_Next(ValidTSIN)) \
00301 : NULL )
00302
00303
00304
00305 #define SetMatchAndUnifyChains(Symbol,SymChain,VarChain) { \
00306 \
00307 TSTHTptr ht = (TSTHTptr)SymChain; \
00308 TSTNptr *buckets = TSTHT_BucketArray(ht); \
00309 \
00310 SymChain = buckets[TrieHash(Symbol,TSTHT_GetHashSeed(ht))]; \
00311 VarChain = buckets[TRIEVAR_BUCKET]; \
00312 }
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332 #define SearchChain_ExactMatch(SearchChain,TrieEncodedSubterm,TS, \
00333 ContChain,TermStack_PushOp) \
00334 while ( IsNonNULL(SearchChain) ) { \
00335 if ( TrieEncodedSubterm == TSTN_Symbol(SearchChain) ) { \
00336 if ( IsValidTS(TSTN_GetTSfromTSIN(SearchChain),TS) ) { \
00337 Chain_NextValidTSTN(ContChain,TS,TSTN_GetTSfromTSIN); \
00338 CPStack_PushFrame(ContChain); \
00339 TermStackLog_PushFrame; \
00340 TermStack_PushOp; \
00341 Descend_Into_TST_and_Continue_Search; \
00342 } \
00343 else \
00344 break; \
00345 } \
00346 SearchChain = TSTN_Sibling(SearchChain); \
00347 }
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380 #define SearchChain_UnifyWithConstant(Chain,Subterm,TS,Get_TS_Op) { \
00381 Chain_NextValidTSTN(Chain,TS,Get_TS_Op); \
00382 while ( IsNonNULL(Chain) ) { \
00383 alt_chain = TSTN_Sibling(Chain); \
00384 Chain_NextValidTSTN(alt_chain,TS,Get_TS_Op); \
00385 symbol = TSTN_Symbol(Chain); \
00386 TrieSymbol_Deref(symbol); \
00387 if ( isref(symbol) ) { \
00388
00389
00390 \
00391 CPStack_PushFrame(alt_chain); \
00392 Bind_and_Conditionally_Trail((CPtr)symbol, Subterm); \
00393 TermStackLog_PushFrame; \
00394 Descend_Into_TST_and_Continue_Search; \
00395 } \
00396 else if (symbol == Subterm) { \
00397 CPStack_PushFrame(alt_chain); \
00398 TermStackLog_PushFrame; \
00399 Descend_Into_TST_and_Continue_Search; \
00400 } \
00401 Chain = alt_chain; \
00402 } \
00403 }
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436 #define SearchChain_UnifyWithFunctor(Chain,Subterm,TS,Get_TS_Op) { \
00437 \
00438 Cell sym_tag; \
00439 \
00440 Chain_NextValidTSTN(Chain,TS,Get_TS_Op); \
00441 while ( IsNonNULL(Chain) ) { \
00442 alt_chain = TSTN_Sibling(Chain); \
00443 Chain_NextValidTSTN(alt_chain,TS,Get_TS_Op); \
00444 symbol = TSTN_Symbol(Chain); \
00445 sym_tag = TrieSymbolType(symbol); \
00446 TrieSymbol_Deref(symbol); \
00447 if ( isref(symbol) ) { \
00448
00449
00450
00451
00452
00453 \
00454 CPStack_PushFrame(alt_chain); \
00455 Bind_and_Conditionally_Trail((CPtr)symbol, Subterm); \
00456 TermStackLog_PushFrame; \
00457 Descend_Into_TST_and_Continue_Search; \
00458 } \
00459 else if ( IsTrieFunctor(symbol) ) { \
00460
00461
00462
00463
00464 \
00465 if ( sym_tag == XSB_STRUCT ) { \
00466 if ( get_str_psc(Subterm) == DecodeTrieFunctor(symbol) ) { \
00467
00468
00469 \
00470 CPStack_PushFrame(alt_chain); \
00471 TermStackLog_PushFrame; \
00472 TermStack_PushFunctorArgs(Subterm); \
00473 Descend_Into_TST_and_Continue_Search; \
00474 } \
00475 } \
00476 else { \
00477
00478
00479
00480
00481 \
00482 if (unify(CTXTc Subterm, symbol)) { \
00483 CPStack_PushFrame(alt_chain); \
00484 TermStackLog_PushFrame; \
00485 Descend_Into_TST_and_Continue_Search; \
00486 } \
00487 } \
00488 } \
00489 Chain = alt_chain; \
00490 } \
00491 }
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522 #define SearchChain_UnifyWithList(Chain,Subterm,TS,Get_TS_Op) { \
00523 \
00524 Cell sym_tag; \
00525 \
00526 Chain_NextValidTSTN(Chain,TS,Get_TS_Op); \
00527 while ( IsNonNULL(Chain) ) { \
00528 alt_chain = TSTN_Sibling(Chain); \
00529 Chain_NextValidTSTN(alt_chain,TS,Get_TS_Op); \
00530 symbol = TSTN_Symbol(Chain); \
00531 sym_tag = TrieSymbolType(symbol); \
00532 TrieSymbol_Deref(symbol); \
00533 if ( isref(symbol) ) { \
00534
00535
00536
00537
00538
00539 \
00540 CPStack_PushFrame(alt_chain); \
00541 Bind_and_Conditionally_Trail((CPtr)symbol,Subterm); \
00542 TermStackLog_PushFrame; \
00543 Descend_Into_TST_and_Continue_Search; \
00544 } \
00545 else if ( IsTrieList(symbol) ) { \
00546
00547
00548
00549
00550
00551 \
00552 if ( sym_tag == XSB_LIST ) { \
00553
00554
00555 \
00556 CPStack_PushFrame(alt_chain); \
00557 TermStackLog_PushFrame; \
00558 TermStack_PushListArgs(Subterm); \
00559 Descend_Into_TST_and_Continue_Search; \
00560 } \
00561 else { \
00562
00563
00564
00565 \
00566 if (unify(CTXTc Subterm, symbol)) { \
00567 CPStack_PushFrame(alt_chain); \
00568 TermStackLog_PushFrame; \
00569 Descend_Into_TST_and_Continue_Search; \
00570 } \
00571 } \
00572 } \
00573 Chain = alt_chain; \
00574 } \
00575 }
00576
00577
00578
00579
00580
00581
00582
00583 #define CurrentTSTN_UnifyWithVariable(Chain,Subterm,Continuation) \
00584 CPStack_PushFrame(Continuation); \
00585 TermStackLog_PushFrame; \
00586 symbol = TSTN_Symbol(Chain); \
00587 TrieSymbol_Deref(symbol); \
00588 switch(TrieSymbolType(symbol)) { \
00589 case XSB_INT: \
00590 case XSB_FLOAT: \
00591 case XSB_STRING: \
00592 \
00593 Trie_bind_copy((CPtr)Subterm,symbol); \
00594 \
00595 break; \
00596 \
00597 case XSB_STRUCT: \
00598
00599
00600
00601
00602 \
00603 if ( IsTrieFunctor(TSTN_Symbol(Chain)) ) { \
00604
00605
00606
00607
00608
00609 \
00610 CPtr heap_var_ptr; \
00611 int arity, i; \
00612 Psc symbolPsc; \
00613 \
00614 symbolPsc = (Psc)cs_val(symbol); \
00615 arity = get_arity(symbolPsc); \
00616 Trie_bind_copy((CPtr)Subterm,(Cell)hreg); \
00617 bld_cs(hreg, hreg + 1); \
00618 bld_functor(++hreg, symbolPsc); \
00619 for (heap_var_ptr = hreg + arity, i = 0; \
00620 i < arity; \
00621 heap_var_ptr--, i++) { \
00622 bld_free(heap_var_ptr); \
00623 TermStack_Push((Cell)heap_var_ptr); \
00624 } \
00625 hreg = hreg + arity + 1; \
00626 } \
00627 else { \
00628
00629
00630 \
00631 Trie_bind_copy((CPtr)Subterm,symbol); \
00632 } \
00633 break; \
00634 \
00635 case XSB_LIST: \
00636 if ( IsTrieList(TSTN_Symbol(Chain)) ) { \
00637
00638
00639
00640
00641
00642 \
00643 Trie_bind_copy((CPtr)Subterm,(Cell)hreg); \
00644 bld_list(hreg, hreg + 1); \
00645 hreg = hreg + 3; \
00646 bld_free(hreg - 1); \
00647 TermStack_Push((Cell)(hreg - 1)); \
00648 bld_free(hreg - 2); \
00649 TermStack_Push((Cell)(hreg - 2)); \
00650 } \
00651 else { \
00652
00653
00654 \
00655 Trie_bind_copy((CPtr)Subterm,symbol); \
00656 } \
00657 break; \
00658 \
00659 case XSB_REF: \
00660 case XSB_REF1: \
00661
00662
00663
00664
00665 \
00666 if (IsUnboundTrieVar(symbol)) { \
00667 Bind_and_Trail((CPtr)symbol,Subterm); \
00668 } \
00669 else \
00670 unify(CTXTc symbol,Subterm); \
00671 break; \
00672 \
00673 default: \
00674 fprintf(stderr, "subterm: unbound var (%ld), symbol: unknown " \
00675 "(%ld)\n", cell_tag(Subterm), TrieSymbolType(symbol)); \
00676 TST_Collection_Error("Trie symbol with bogus tag!", RequiresCleanup); \
00677 break; \
00678 } \
00679 Descend_Into_TST_and_Continue_Search
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713 ALNptr tst_collect_relevant_answers(CTXTdeclc TSTNptr tstRoot, TimeStamp ts,
00714 int numTerms, CPtr termsRev) {
00715
00716
00717
00718
00719 ALNptr tstAnswerList;
00720
00721 TSTNptr cur_chain;
00722
00723
00724
00725 TSTNptr alt_chain;
00726
00727
00728 TSTNptr parentTSTN;
00729
00730 Cell subterm;
00731 Cell symbol;
00732
00733
00734
00735
00736
00737 if (numTerms < 1)
00738 TST_Collection_Error("Called with < 1 terms",NoCleanupRequired);
00739
00740
00741
00742
00743 TermStack_ResetTOS;
00744 TermStack_PushHighToLowVector(termsRev,numTerms);
00745 TermStackLog_ResetTOS;
00746 tstCPStack.top = tstCPStack.base;
00747 trail_base = top_of_trail;
00748 Save_and_Set_WAM_Registers;
00749
00750 parentTSTN = tstRoot;
00751 cur_chain = TSTN_Child(tstRoot);
00752 tstAnswerList = NULL;
00753 symbol = 0;
00754
00755
00756
00757
00758
00759 While_TSnotEmpty:
00760 while ( ! TermStack_IsEmpty ) {
00761 TermStack_Pop(subterm);
00762 XSB_Deref(subterm);
00763 switch(cell_tag(subterm)) {
00764
00765
00766
00767 case XSB_INT:
00768 case XSB_FLOAT:
00769 case XSB_STRING:
00770
00771
00772
00773 if ( IsHashHeader(cur_chain) ) {
00774 symbol = EncodeTrieConstant(subterm);
00775 SetMatchAndUnifyChains(symbol,cur_chain,alt_chain);
00776 if ( cur_chain != alt_chain ) {
00777 SearchChain_ExactMatch(cur_chain,symbol,ts,alt_chain,
00778 TermStack_NOOP);
00779 cur_chain = alt_chain;
00780 }
00781 if ( IsNULL(cur_chain) )
00782 backtrack;
00783 }
00784 if ( IsHashedNode(cur_chain) )
00785 SearchChain_UnifyWithConstant(cur_chain,subterm,ts,
00786 TSTN_GetTSfromTSIN)
00787 else
00788 SearchChain_UnifyWithConstant(cur_chain,subterm,ts,TSTN_TimeStamp)
00789 break;
00790
00791
00792
00793 case XSB_STRUCT:
00794
00795
00796
00797
00798 if ( IsHashHeader(cur_chain) ) {
00799 symbol = EncodeTrieFunctor(subterm);
00800 SetMatchAndUnifyChains(symbol,cur_chain,alt_chain);
00801 if ( cur_chain != alt_chain ) {
00802 SearchChain_ExactMatch(cur_chain,symbol,ts,alt_chain,
00803 TermStack_PushFunctorArgs(subterm));
00804 cur_chain = alt_chain;
00805 }
00806 if ( IsNULL(cur_chain) )
00807 backtrack;
00808 }
00809 if ( IsHashedNode(cur_chain) )
00810 SearchChain_UnifyWithFunctor(cur_chain,subterm,ts,TSTN_GetTSfromTSIN)
00811 else
00812 SearchChain_UnifyWithFunctor(cur_chain,subterm,ts,TSTN_TimeStamp)
00813 break;
00814
00815
00816
00817 case XSB_LIST:
00818
00819
00820
00821
00822
00823
00824
00825 if ( IsHashHeader(cur_chain) ) {
00826 symbol = EncodeTrieList(subterm);
00827 SetMatchAndUnifyChains(symbol,cur_chain,alt_chain);
00828 if ( cur_chain != alt_chain ) {
00829 SearchChain_ExactMatch(cur_chain,symbol,ts,alt_chain,
00830 TermStack_PushListArgs(subterm));
00831 cur_chain = alt_chain;
00832 }
00833 if ( IsNULL(cur_chain) )
00834 backtrack;
00835 }
00836 if ( IsHashedNode(cur_chain) )
00837 SearchChain_UnifyWithList(cur_chain,subterm,ts,TSTN_GetTSfromTSIN)
00838 else
00839 SearchChain_UnifyWithList(cur_chain,subterm,ts,TSTN_TimeStamp)
00840 break;
00841
00842
00843
00844 case XSB_REF:
00845 case XSB_REF1:
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859 if ( IsHashedNode(cur_chain) )
00860
00861
00862
00863
00864
00865 alt_chain = TSI_NextValidTSTN(TSTN_GetTSIN(cur_chain),ts);
00866 else if ( IsHashHeader(cur_chain) ) {
00867
00868 TSINptr tsin = TSTHT_IndexHead((TSTHTptr)cur_chain);
00869
00870 if ( IsNULL(tsin) )
00871 TST_Collection_Error("TSI Structures don't exist", RequiresCleanup);
00872 if ( IsValidTS(TSIN_TimeStamp(tsin),ts) ) {
00873 cur_chain = TSIN_TSTNode(tsin);
00874 alt_chain = TSI_NextValidTSTN(tsin,ts);
00875 }
00876 else
00877 backtrack;
00878 }
00879 else {
00880
00881
00882
00883
00884 Chain_NextValidTSTN(cur_chain,ts,TSTN_TimeStamp);
00885 if ( IsNULL(cur_chain) )
00886 backtrack;
00887 alt_chain = TSTN_Sibling(cur_chain);
00888 Chain_NextValidTSTN(alt_chain,ts,TSTN_TimeStamp);
00889 }
00890 CurrentTSTN_UnifyWithVariable(cur_chain,subterm,alt_chain);
00891 break;
00892
00893 default:
00894 fprintf(stderr, "subterm: unknown (%ld), symbol: ? (%ld)\n",
00895 cell_tag(subterm), TrieSymbolType(symbol));
00896 TST_Collection_Error("Trie symbol with bogus tag!", RequiresCleanup);
00897 break;
00898 }
00899
00900
00901
00902
00903
00904
00905
00906
00907 if ( CPStack_IsEmpty ) {
00908 Sys_Trail_Unwind(trail_base);
00909 Restore_WAM_Registers;
00910 return tstAnswerList;
00911 }
00912 TST_Backtrack;
00913
00914 }
00915
00916
00917
00918
00919
00920
00921
00922
00923 if ( ! IsLeafNode(parentTSTN) ) {
00924 xsb_warn("During collection of relevant answers for subsumed subgoal\n"
00925 "TermStack is empty but a leaf node was not reached");
00926 xsb_dbgmsg((LOG_DEBUG, "Root "));
00927 dbg_printTrieNode(LOG_DEBUG, stddbg, (BTNptr)tstRoot);
00928 xsb_dbgmsg((LOG_DEBUG, "Last "));
00929 dbg_printTrieNode(LOG_DEBUG, stddbg, (BTNptr)parentTSTN);
00930 dbg_printAnswerTemplate(LOG_DEBUG, stddbg, termsRev,numTerms);
00931 xsb_dbgmsg((LOG_DEBUG,
00932 "(* Note: this template may be partially instantiated *)\n"));
00933 fprintf(stdwarn, "Attempting to continue...\n");
00934 }
00935 else {
00936
00937 ALN_InsertAnswer(tstAnswerList, parentTSTN);
00938 }
00939 if ( CPStack_IsEmpty ) {
00940 Sys_Trail_Unwind(trail_base);
00941 Restore_WAM_Registers;
00942 return tstAnswerList;
00943 }
00944 TST_Backtrack;
00945 goto While_TSnotEmpty;
00946 }