示例#1
0
文件: engine.c 项目: adinho/Testing
/*-------------------------------------------------------------------------*
 * PL_CALL_PROLOG                                                          *
 *                                                                         *
 * Call_Prolog runs the execution of one prolog goal.                      *
 * The current choice point is updated to set ALTB to Call_Prolog_Fail and *
 * CP is set to Call_Prolog_Success. At the end ALTB and CP are restored.  *
 * To ensure that a choice point always exists before invoking Call_Prolog,*
 * Start_Prolog reserve the space for a feint choice point, i.e ALTB can be*
 * safely modified.                                                        *
 *                                                                         *
 * Call_Prolog returns TRUE if the predicate has succeed, FALSE otherwise. *
 * The called predicate can be non-deterministic.                          *
 *-------------------------------------------------------------------------*/
Bool
Pl_Call_Prolog(CodePtr codep)
{
  WamWord *query_b = B;
  WamCont save_CP = CP;
  WamCont save_ALTB = ALTB(query_b);
  Bool ok;

  ALTB(query_b) = (CodePtr) Call_Prolog_Fail;	/* modify choice point */

  CP = Adjust_CP(Call_Prolog_Success);

#if defined(_WIN32) || defined(__CYGWIN__)
  SEH_PUSH(Win32_SEH_Handler);
#endif
  ok = Call_Next(codep);
#if defined(_WIN32) || defined(__CYGWIN__)
  SEH_POP;
#endif

  CP = save_CP;			/* restore continuation */
  ALTB(query_b) = save_ALTB;	/* restore choice point */

  return ok;
}
示例#2
0
文件: engine.c 项目: adinho/Testing
/*-------------------------------------------------------------------------*
 * PL_CALL_PROLOG_NEXT_SOL                                                 *
 *                                                                         *
 * Call_Prolog_Next_Sol bactracks over the next solution.                  *
 *-------------------------------------------------------------------------*/
Bool
Pl_Call_Prolog_Next_Sol(WamWord *query_b)
{
  WamCont save_CP = CP;
  WamCont save_ALTB = ALTB(query_b);
  Bool ok;

  ALTB(query_b) = (CodePtr) Call_Prolog_Fail;	/* modify choice point */

  CP = Adjust_CP(Call_Prolog_Success);	/* should be useless since */
  /* alternative will restore CP */

  ok = Call_Next(ALTB(B));

  CP = save_CP;			/* restore continuation */
  ALTB(query_b) = save_ALTB;	/* restore choice point */

  return ok;
}
示例#3
0
文件: engine.c 项目: maandree/gprolog
/*-------------------------------------------------------------------------*
 * PL_CALL_PROLOG                                                          *
 *                                                                         *
 * Call_Prolog runs the execution of one prolog goal.                      *
 * The current choice point is updated to set ALTB to Call_Prolog_Fail and *
 * CP is set to Call_Prolog_Success. At the end ALTB and CP are restored.  *
 * To ensure that a choice point always exists before invoking Call_Prolog,*
 * Start_Prolog reserve the space for a feint choice point, i.e ALTB can be*
 * safely modified.                                                        *
 *                                                                         *
 * Call_Prolog returns TRUE if the predicate has succeed, FALSE otherwise. *
 * The called predicate can be non-deterministic.                          *
 *-------------------------------------------------------------------------*/
Bool
Pl_Call_Prolog(CodePtr codep)
{
  WamWord *query_b = B;
  WamCont save_CP = CP;
  WamCont save_ALTB = ALTB(query_b);
  Bool ok;

  ALTB(query_b) = (CodePtr) Call_Prolog_Fail;   /* modify choice point */

  CP = Adjust_CP(Call_Prolog_Success);

  ok = Call_Next(codep);

  CP = save_CP;                 /* restore continuation */
  ALTB(query_b) = save_ALTB;    /* restore choice point */

  return ok;
}