tr_delay.h

00001 /* File:      tr_delay.h
00002 ** Author(s): Kostis Sagonas, Baoqiu Cui
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: tr_delay.h,v 1.16 2005/01/14 18:31:35 ruim Exp $
00022 ** 
00023 */
00024 
00025 
00026 /* special debug includes */
00027 #include "debugs/debug_delay.h"
00028 
00029 /*----- Stuff for trie instructions ------------------------------------*/
00030 
00031 /*
00032  * In the execution of trie code, handle_conditional_answers is called
00033  * (in proceed_lpcreg) when NodePtr is an answer leaf.  If the answer is
00034  * a conditional one, then call delay_positively() to put it into the
00035  * delay list of the parent predicate.
00036  *
00037  * After the execution of trie code, the substitution factor of the
00038  * _answer_ is stored in array var_regs[], and the number of variables is
00039  * saved in num_vars_in_var_regs (-1 means there is no variable, 0 means
00040  * there is one variable, ...)
00041  *
00042  * Instead of saving the substitution factor of the call, we can save
00043  * the substitution factor of the answer in the delay element.
00044  */
00045 
00046 #ifndef IGNORE_DELAYVAR
00047 #define handle_conditional_answers {                                    \
00048     CPtr temp_hreg;                                                     \
00049     VariantSF subgoal;                                                  \
00050                                                                         \
00051     if (is_conditional_answer(NodePtr)) {                               \
00052       xsb_dbgmsg((LOG_DELAY,                                             \
00053                  "Trie-Code returning a conditional answer for "));     \
00054       subgoal = asi_subgoal(Delay(NodePtr));                            \
00055       dbg_print_subgoal(LOG_DELAY, stddbg, subgoal);                    \
00056       xsb_dbgmsg((LOG_DELAY, " (positively delaying)\n"));              \
00057       xsb_dbgmsg((LOG_DELAY,                                             \
00058                       ">>>> In handle_conditional_answers macro: \n"));  \
00059       xsb_dbgmsg((LOG_DELAY, ">>>>     num_vars_in_var_regs = %d\n",     \
00060                       num_vars_in_var_regs));                           \
00061       if (num_vars_in_var_regs == -1) {                                 \
00062         delay_positively(subgoal, NodePtr,                              \
00063                          makestring(get_ret_string()));                 \
00064       }                                                                 \
00065       else {                                                            \
00066         /* create the answer subsf ret/n */                             \
00067         temp_hreg = hreg;                                               \
00068         new_heap_functor(hreg, get_ret_psc(num_vars_in_var_regs + 1));  \
00069         {                                                               \
00070           int i;                                                        \
00071           for (i = 0; i < num_vars_in_var_regs + 1; i++) {              \
00072             cell(hreg++) = (Cell) var_regs[i]; /* new */                \
00073             xsb_dbgmsg((LOG_DELAY, ">>>>     var_regs[%d] = ", i));     \
00074             dbg_printterm(LOG_DELAY, stddbg, cell(var_regs[i]), 25);    \
00075             xsb_dbgmsg((LOG_DELAY, "\n"));                              \
00076           }                                                             \
00077         }                                                               \
00078         delay_positively(subgoal, NodePtr, makecs(temp_hreg));          \
00079       }                                                                 \
00080     }                                                                   \
00081   }
00082 #else  /* IGNORE_DELAYVAR */
00083 #define handle_conditional_answers {                    \
00084   if (is_conditional_answer(NodePtr)) {                 \
00085     VariantSF subgoal = asi_subgoal(Delay(NodePtr));    \
00086     delay_positively(subgoal, NodePtr,                  \
00087                      makestring(get_ret_string()));     \
00088   }                                                     \
00089 }
00090 #endif /* IGNORE_DELAYVAR */
00091 
00092 /*---------------------- end of file tr_delay.h ------------------------*/

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