tables.h

00001 /* File:      tables.h
00002 ** Author(s): Johnson, Swift, Sagonas, Rao, Freire
00003 ** Contact:   xsb-contact@cs.sunysb.edu
00004 ** 
00005 ** Copyright (C) The Research Foundation of SUNY, 1986, 1993-1998
00006 ** 
00007 ** XSB is free software; you can redistribute it and/or modify it under the
00008 ** terms of the GNU Library General Public License as published by the Free
00009 ** Software Foundation; either version 2 of the License, or (at your option)
00010 ** any later version.
00011 ** 
00012 ** XSB is distributed in the hope that it will be useful, but WITHOUT ANY
00013 ** WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00014 ** FOR A PARTICULAR PURPOSE.  See the GNU Library General Public License for
00015 ** more details.
00016 ** 
00017 ** You should have received a copy of the GNU Library General Public License
00018 ** along with XSB; if not, write to the Free Software Foundation,
00019 ** Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00020 **
00021 ** $Id: tables.h,v 1.12 2006/01/12 21:33:52 tswift Exp $
00022 ** 
00023 */
00024 
00025 
00026 #ifndef __TABLES_H__
00027 
00028 #define __TABLES_H__
00029 
00030 
00031 /*===========================================================================*/
00032 
00033 /*
00034  *                    Tabling Function Prototypes
00035  *                    ===========================
00036  */
00037 
00038 void    table_call_search(CTXTdeclc TabledCallInfo *, CallLookupResults *);
00039 BTNptr  table_answer_search(CTXTdeclc VariantSF, int, int, CPtr, xsbBool *);
00040 void    table_consume_answer(CTXTdeclc BTNptr, int, int, CPtr, TIFptr);
00041 ALNptr  table_identify_relevant_answers(CTXTdeclc SubProdSF, SubConsSF, CPtr);
00042 void    table_complete_entry(CTXTdeclc VariantSF);
00043 
00044 void    release_all_tabling_resources(CTXTdecl);
00045 VariantSF NewProducerSF(CTXTdeclc BTNptr,TIFptr);
00046 
00047 /*
00048  * The next answer to consume is obtained from the old answer continuation.
00049  * The new answer continuation is the old continuation but with this answer
00050  * removed.
00051  */
00052 
00053 #define table_pending_answer( OldAnswerContinuation,                    \
00054                               NewAnswerContinuation,                    \
00055                               NextAnswer,                               \
00056                               Consumer,                                 \
00057                               Producer,                                 \
00058                               AnswerTemplate,                           \
00059                               PreIdentificationOp,                      \
00060                               PostIdentificationOp ) {                  \
00061                                                                         \
00062    NewAnswerContinuation = ALN_Next(OldAnswerContinuation);             \
00063                                                                         \
00064    if ( IsNULL(NewAnswerContinuation) && IsProperlySubsumed(Consumer) ) \
00065      if ( MoreAnswersAreAvailable(Consumer,Producer) ) {                \
00066        /* printf("make ans list for :"); sfPrintGoal(CTXTdeclc stddbg, Consumer, FALSE); */  \
00067        PreIdentificationOp;                                             \
00068        NewAnswerContinuation =                                          \
00069          table_identify_relevant_answers(CTXTc Producer, Consumer,      \
00070                                          AnswerTemplate);               \
00071        PostIdentificationOp;                                            \
00072      }                                                                  \
00073    if ( IsNonNULL(NewAnswerContinuation) )                              \
00074      NextAnswer = ALN_Answer(NewAnswerContinuation);                    \
00075    else                                                                 \
00076      NextAnswer = NULL;                                                 \
00077  }
00078 
00079 
00080 /*
00081  * Used as an argument to table_pending_answer() when no pre- or post-
00082  * identification operation is required.
00083  */
00084 
00085 #define TPA_NoOp
00086 
00087 
00088 /*
00089  * Determines whether a producer subgoal has added answers to its set
00090  * since the given consumer last collected relevant answers from that set.
00091  */
00092 
00093 #define MoreAnswersAreAvailable(ConsSF,ProdSF)                  \
00094    ( IsNonNULL(subg_ans_root_ptr(ProdSF)) &&                    \
00095      (TSTN_TimeStamp((TSTNptr)subg_ans_root_ptr(ProdSF)) >      \
00096       conssf_timestamp(ConsSF)) )
00097 
00098 
00099 /*===========================================================================*/
00100 
00101 
00102 #endif

Generated on Wed Jul 26 13:30:42 2006 for XSB by  doxygen 1.4.5