bug fices
This commit is contained in:
		
							
								
								
									
										23
									
								
								C/modules.c
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								C/modules.c
									
									
									
									
									
								
							@@ -70,6 +70,7 @@ inline static ModEntry *GetModuleEntry(Atom at)
 | 
			
		||||
    new->NextME = CurrentModules;
 | 
			
		||||
    CurrentModules = new;
 | 
			
		||||
    new->AtomOfME = ae;
 | 
			
		||||
    new->OwnerFile = Yap_ConsultingFile( PASS_REGS1);
 | 
			
		||||
    AddPropToAtom(ae, (PropEntry *)new);
 | 
			
		||||
    if (CurrentModule == 0L || (oat = GetModuleEntry(AtomOfTerm(CurrentModule))) == new) {
 | 
			
		||||
      Yap_setModuleFlags(new, NULL);
 | 
			
		||||
@@ -85,6 +86,8 @@ Term Yap_getUnknownModule(ModEntry *m) {
 | 
			
		||||
    return TermError;
 | 
			
		||||
  } else if (m && m->flags & UNKNOWN_WARNING) {
 | 
			
		||||
    return TermWarning;
 | 
			
		||||
  } else if (m && m->flags & UNKNOWN_FAST_FAIL) {
 | 
			
		||||
    return TermFastFail;
 | 
			
		||||
  } else {
 | 
			
		||||
    return TermFail;
 | 
			
		||||
  }
 | 
			
		||||
@@ -92,13 +95,7 @@ Term Yap_getUnknownModule(ModEntry *m) {
 | 
			
		||||
 | 
			
		||||
bool Yap_getUnknown ( Term mod) {
 | 
			
		||||
  ModEntry *m = LookupModule( mod );
 | 
			
		||||
  if (m && m->flags & UNKNOWN_ERROR) {
 | 
			
		||||
    return TermError;
 | 
			
		||||
  } else if (m && m->flags & UNKNOWN_WARNING) {
 | 
			
		||||
    return TermWarning;
 | 
			
		||||
  } else {
 | 
			
		||||
    return TermFail;
 | 
			
		||||
  }
 | 
			
		||||
  return Yap_getUnknownModule( m );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -131,9 +128,11 @@ Term Yap_Module_Name(PredEntry *ap) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static ModEntry *LookupSystemModule(Term a) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  Atom at;
 | 
			
		||||
  ModEntry *me;
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  /* prolog module */
 | 
			
		||||
  if (a == 0) {
 | 
			
		||||
    return GetModuleEntry(AtomProlog);
 | 
			
		||||
@@ -141,6 +140,7 @@ static ModEntry *LookupSystemModule(Term a) {
 | 
			
		||||
  at = AtomOfTerm(a);
 | 
			
		||||
  me = GetModuleEntry(at);
 | 
			
		||||
  me->flags |= M_SYSTEM;
 | 
			
		||||
  me->OwnerFile = Yap_ConsultingFile( PASS_REGS1 );
 | 
			
		||||
  return me;}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -316,7 +316,7 @@ static Int init_ground_module(USES_REGS1) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** 
 | 
			
		||||
 * @pred is_system_module( + _Mod_)
 | 
			
		||||
 * @pred system_module( + _Mod_)
 | 
			
		||||
 * 
 | 
			
		||||
 * @param module 
 | 
			
		||||
 * 
 | 
			
		||||
@@ -335,7 +335,7 @@ static Int is_system_module( USES_REGS1 )
 | 
			
		||||
  return Yap_isSystemModule( t );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Int system_module( USES_REGS1 )
 | 
			
		||||
static Int new_system_module( USES_REGS1 )
 | 
			
		||||
{
 | 
			
		||||
  ModEntry *me;
 | 
			
		||||
  Term t;
 | 
			
		||||
@@ -348,6 +348,7 @@ static Int system_module( USES_REGS1 )
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
  me = LookupSystemModule( t );
 | 
			
		||||
  me->OwnerFile = Yap_ConsultingFile( PASS_REGS1);
 | 
			
		||||
  return me != NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -495,8 +496,8 @@ void Yap_InitModulesC(void) {
 | 
			
		||||
  Yap_InitCPred("$yap_strip_module", 3, yap_strip_module,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("context_module", 1, context_module, 0);
 | 
			
		||||
  Yap_InitCPred("system_module", 1, system_module, SafePredFlag);
 | 
			
		||||
  Yap_InitCPred("is_system_module", 1, is_system_module, SafePredFlag);
 | 
			
		||||
  Yap_InitCPred("$is_system_module", 1, is_system_module, SafePredFlag);
 | 
			
		||||
  Yap_InitCPred("new_system_module", 1, new_system_module, SafePredFlag);
 | 
			
		||||
  Yap_InitCPredBack("$all_current_modules", 1, 1, init_current_module,
 | 
			
		||||
                    cont_current_module, SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPredBack("$ground_module", 3, 1, init_ground_module,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										16
									
								
								C/parser.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								C/parser.c
									
									
									
									
									
								
							@@ -745,34 +745,46 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS) {
 | 
			
		||||
  case String_tok: /* build list on the heap */
 | 
			
		||||
  {
 | 
			
		||||
    Volatile char *p = (char *)LOCAL_tokptr->TokInfo;
 | 
			
		||||
    // we may be operating under a syntax error
 | 
			
		||||
    yap_error_number oerr = LOCAL_Error_TYPE;
 | 
			
		||||
    LOCAL_Error_TYPE = YAP_NO_ERROR;
 | 
			
		||||
    t = Yap_CharsToTDQ(p, CurrentModule, LOCAL_encoding PASS_REGS);
 | 
			
		||||
    if (!t) {
 | 
			
		||||
      syntax_msg("could not convert \"%s\"", (char *)LOCAL_tokptr->TokInfo);
 | 
			
		||||
      FAIL;
 | 
			
		||||
    }
 | 
			
		||||
    LOCAL_Error_TYPE = oerr;
 | 
			
		||||
    NextToken;
 | 
			
		||||
  } break;
 | 
			
		||||
 | 
			
		||||
  case WString_tok: /* build list on the heap */
 | 
			
		||||
  {
 | 
			
		||||
    Volatile wchar_t *p = (wchar_t *)LOCAL_tokptr->TokInfo;
 | 
			
		||||
    // we may be operating under a syntax error
 | 
			
		||||
    yap_error_number oerr = LOCAL_Error_TYPE;
 | 
			
		||||
    LOCAL_Error_TYPE = YAP_NO_ERROR;
 | 
			
		||||
    t = Yap_WCharsToTDQ(p, CurrentModule PASS_REGS);
 | 
			
		||||
    if (!t) {
 | 
			
		||||
      syntax_msg("could not convert \'%S\'", (wchar_t *)LOCAL_tokptr->TokInfo);
 | 
			
		||||
      FAIL;
 | 
			
		||||
    }
 | 
			
		||||
     LOCAL_Error_TYPE = oerr;
 | 
			
		||||
   NextToken;
 | 
			
		||||
  } break;
 | 
			
		||||
 | 
			
		||||
  case BQString_tok: /* build list on the heap */
 | 
			
		||||
  {
 | 
			
		||||
    Volatile char *p = (char *)LOCAL_tokptr->TokInfo;
 | 
			
		||||
    // we may be operating under a syntax error
 | 
			
		||||
    yap_error_number oerr = LOCAL_Error_TYPE;
 | 
			
		||||
    LOCAL_Error_TYPE = YAP_NO_ERROR;
 | 
			
		||||
 | 
			
		||||
    t = Yap_CharsToTBQ(p, CurrentModule,  LOCAL_encoding PASS_REGS);
 | 
			
		||||
    if (!t) {
 | 
			
		||||
      syntax_msg("could not convert \'%s\"", (char *)LOCAL_tokptr->TokInfo);
 | 
			
		||||
      FAIL;
 | 
			
		||||
    }
 | 
			
		||||
    LOCAL_Error_TYPE = oerr;
 | 
			
		||||
    NextToken;
 | 
			
		||||
  } break;
 | 
			
		||||
 | 
			
		||||
@@ -780,10 +792,14 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS) {
 | 
			
		||||
  {
 | 
			
		||||
    Volatile wchar_t *p = (wchar_t *)LOCAL_tokptr->TokInfo;
 | 
			
		||||
    t = Yap_WCharsToTBQ(p, CurrentModule PASS_REGS);
 | 
			
		||||
    // we may be operating under a syntax error
 | 
			
		||||
    yap_error_number oerr = LOCAL_Error_TYPE;
 | 
			
		||||
    LOCAL_Error_TYPE = YAP_NO_ERROR;
 | 
			
		||||
    if (!t) {
 | 
			
		||||
      syntax_msg("could not convert \"%S\"", (wchar_t *)LOCAL_tokptr->TokInfo);
 | 
			
		||||
      FAIL;
 | 
			
		||||
    }
 | 
			
		||||
    LOCAL_Error_TYPE = oerr;
 | 
			
		||||
    NextToken;
 | 
			
		||||
  } break;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										41
									
								
								C/qlyr.c
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								C/qlyr.c
									
									
									
									
									
								
							@@ -698,7 +698,7 @@ read_tag(FILE *stream)
 | 
			
		||||
  return ch;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static UInt
 | 
			
		||||
static pred_flags_t
 | 
			
		||||
read_predFlags(FILE *stream)
 | 
			
		||||
{
 | 
			
		||||
  pred_flags_t v;
 | 
			
		||||
@@ -1018,23 +1018,30 @@ read_pred(FILE *stream, Term mod) {
 | 
			
		||||
 | 
			
		||||
  ap = LookupPredEntry((PredEntry *)read_UInt(stream));
 | 
			
		||||
  flags = read_predFlags(stream);
 | 
			
		||||
#if 0
 | 
			
		||||
  if (ap->ArityOfPE && ap->ModuleOfPred != IDB_MODULE)
 | 
			
		||||
    // __android_log_print(ANDROID_LOG_INFO, "YAP ", "   %s/%ld %llx %llx\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE, ap->ArityOfPE, ap->PredFlags, flags);
 | 
			
		||||
     printf("   %s/%ld %llx %llx\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE, ap->ArityOfPE, ap->PredFlags, flags); 
 | 
			
		||||
  else if (ap->ModuleOfPred != IDB_MODULE)
 | 
			
		||||
    //__android_log_print(ANDROID_LOG_INFO, "YAP ","   %s/%ld %llx %llx\n", ((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE, flags);
 | 
			
		||||
     printf("   %s/%ld %llx %llx\n", ((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE, ap->PredFlags, flags); 
 | 
			
		||||
    //else
 | 
			
		||||
    //  __android_log_print(ANDROID_LOG_INFO, "YAP ","   number\n");
 | 
			
		||||
#endif
 | 
			
		||||
  if (flags & ForeignPredFlags) {
 | 
			
		||||
    if (!(ap->PredFlags & ForeignPredFlags))
 | 
			
		||||
      QLYR_ERROR(INCONSISTENT_CPRED);
 | 
			
		||||
    if (flags & MetaPredFlag)
 | 
			
		||||
      ap->PredFlags |= MetaPredFlag;
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  nclauses = read_UInt(stream);
 | 
			
		||||
  if (ap->PredFlags & IndexedPredFlag) {
 | 
			
		||||
    Yap_RemoveIndexation(ap);
 | 
			
		||||
  }
 | 
			
		||||
#if 0
 | 
			
		||||
  if (ap->ArityOfPE && ap->ModuleOfPred != IDB_MODULE)
 | 
			
		||||
      __android_log_print(ANDROID_LOG_INFO, "YAP ", "   %s/%ld %lx\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE, ap->ArityOfPE, flags);
 | 
			
		||||
  /*   printf("   %s/%ld %lx\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE, ap->ArityOfPE, flags); */
 | 
			
		||||
  else if (ap->ModuleOfPred != IDB_MODULE)
 | 
			
		||||
  __android_log_print(ANDROID_LOG_INFO, "YAP ","   %s/%ld %lx\n", ((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE, flags);
 | 
			
		||||
  /*   printf("   %s/%ld %lx\n", ((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE, flags); */
 | 
			
		||||
  else
 | 
			
		||||
      __android_log_print(ANDROID_LOG_INFO, "YAP ","   number\n");
 | 
			
		||||
#endif
 | 
			
		||||
  fl1 = flags & ((pred_flags_t)STATIC_PRED_FLAGS|(UInt)EXTRA_PRED_FLAGS);
 | 
			
		||||
  ap->PredFlags &= ~((UInt)STATIC_PRED_FLAGS|(UInt)EXTRA_PRED_FLAGS);
 | 
			
		||||
  ap->PredFlags |= fl1;
 | 
			
		||||
  //fl1 = flags & ((pred_flags_t)STATIC_PRED_FLAGS|(UInt)EXTRA_PRED_FLAGS);
 | 
			
		||||
  //ap->PredFlags &= ~((UInt)STATIC_PRED_FLAGS|(UInt)EXTRA_PRED_FLAGS);
 | 
			
		||||
  ap->PredFlags = flags & ~StatePredFlags;
 | 
			
		||||
  if (flags & NumberDBPredFlag) {
 | 
			
		||||
    ap->src.IndxId = read_UInt(stream);
 | 
			
		||||
  } else {
 | 
			
		||||
@@ -1046,9 +1053,9 @@ read_pred(FILE *stream, Term mod) {
 | 
			
		||||
  }
 | 
			
		||||
  ap->TimeStampOfPred = read_UInt(stream);
 | 
			
		||||
  /* multifile predicates cannot reside in module 0 */
 | 
			
		||||
  if (flags & MultiFileFlag && ap->ModuleOfPred == PROLOG_MODULE) {
 | 
			
		||||
    ap->ModuleOfPred = TermProlog;
 | 
			
		||||
  }
 | 
			
		||||
  //  if (flags & MultiFileFlag && ap->ModuleOfPred == PROLOG_MODULE) {
 | 
			
		||||
  //  ap->ModuleOfPred = TermProlog;
 | 
			
		||||
  // }
 | 
			
		||||
  if (nclauses)
 | 
			
		||||
    read_clauses(stream, ap, nclauses, flags);
 | 
			
		||||
#if DEBUG
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										9
									
								
								C/qlyw.c
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								C/qlyw.c
									
									
									
									
									
								
							@@ -698,6 +698,8 @@ static size_t
 | 
			
		||||
save_pred(FILE *stream, PredEntry *ap) {
 | 
			
		||||
  CHECK(save_UInt(stream, (UInt)ap));
 | 
			
		||||
  CHECK(save_predFlags(stream, ap->PredFlags));
 | 
			
		||||
  if (ap->PredFlags & ForeignPredFlags)
 | 
			
		||||
    return 1;
 | 
			
		||||
  CHECK(save_UInt(stream, ap->cs.p_code.NOfClauses));
 | 
			
		||||
  CHECK(save_UInt(stream, ap->src.IndxId));
 | 
			
		||||
  CHECK(save_UInt(stream, ap->TimeStampOfPred));
 | 
			
		||||
@@ -706,11 +708,8 @@ save_pred(FILE *stream, PredEntry *ap) {
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
clean_pred(PredEntry *pp USES_REGS) {
 | 
			
		||||
  if (pp->PredFlags & (AsmPredFlag|CPredFlag)) {
 | 
			
		||||
    /* assembly */
 | 
			
		||||
    if (pp->CodeOfPred) {
 | 
			
		||||
      CleanClauses(pp->CodeOfPred, pp->CodeOfPred, pp PASS_REGS);
 | 
			
		||||
    }
 | 
			
		||||
  if (pp->PredFlags & ForeignPredFlags) {
 | 
			
		||||
    return true;
 | 
			
		||||
  } else {
 | 
			
		||||
    CleanClauses(pp->cs.p_code.FirstClause, pp->cs.p_code.LastClause, pp PASS_REGS);
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								C/save.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								C/save.c
									
									
									
									
									
								
							@@ -455,7 +455,7 @@ save_regs(int mode USES_REGS)
 | 
			
		||||
  if (putcellptr(CellPtr(HeapTop)) < 0)
 | 
			
		||||
    return -1;
 | 
			
		||||
  /* and the space it ocuppies */
 | 
			
		||||
  if (putout(Unsigned(Yap_heap_regs->heap_used)) < 0)
 | 
			
		||||
  if (putout(Unsigned(HeapUsed)) < 0)
 | 
			
		||||
    return -1;
 | 
			
		||||
  /* Then the start of the free code */
 | 
			
		||||
  if (putcellptr(CellPtr(FreeBlocks)) < 0)
 | 
			
		||||
@@ -1035,6 +1035,8 @@ get_coded(int flag, OPCODE old_ops[] USES_REGS)
 | 
			
		||||
  return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* restore some heap registers */
 | 
			
		||||
static void
 | 
			
		||||
restore_heap_regs( USES_REGS1 )
 | 
			
		||||
@@ -1043,7 +1045,7 @@ restore_heap_regs( USES_REGS1 )
 | 
			
		||||
    HeapTop = AddrAdjust(HeapTop);
 | 
			
		||||
    *((YAP_SEG_SIZE *) HeapTop) = InUseFlag;
 | 
			
		||||
  }
 | 
			
		||||
  HeapMax = Yap_heap_regs->heap_used = OldHeapUsed;
 | 
			
		||||
  HeapMax = HeapUsed = OldHeapUsed;
 | 
			
		||||
  HeapLim = LOCAL_GlobalBase;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										120
									
								
								C/signals.c
									
									
									
									
									
								
							
							
						
						
									
										120
									
								
								C/signals.c
									
									
									
									
									
								
							@@ -51,13 +51,12 @@ static char     SccsId[] = "%W% %G%";
 | 
			
		||||
#include <tracer.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * The InteractSIGINT function is called after a normal interrupt had been caught.
 | 
			
		||||
 * The InteractSIGINT function is called after a normal interrupt had been
 | 
			
		||||
 * caught.
 | 
			
		||||
 * It allows 6 possibilities: abort, continue, trace, debug, help, exit.
 | 
			
		||||
 */
 | 
			
		||||
static yap_signals
 | 
			
		||||
InteractSIGINT(int ch) {
 | 
			
		||||
static yap_signals InteractSIGINT(int ch) {
 | 
			
		||||
#ifdef HAVE_SETBUF
 | 
			
		||||
  /* make sure we are not waiting for the end of line */
 | 
			
		||||
  setbuf(stdin, NULL);
 | 
			
		||||
@@ -101,7 +100,8 @@ InteractSIGINT(int ch) {
 | 
			
		||||
    /* show an helpful message */
 | 
			
		||||
    fprintf(stderr, "Please press one of:\n");
 | 
			
		||||
    fprintf(stderr, "  a for abort\n  c for continue\n  d for debug\n");
 | 
			
		||||
      fprintf(stderr, "  e for exit\n  g for stack dump\n  s for statistics\n  t for trace\n");
 | 
			
		||||
    fprintf(stderr, "  e for exit\n  g for stack dump\n  s for statistics\n  t "
 | 
			
		||||
                    "for trace\n");
 | 
			
		||||
    fprintf(stderr, "  b for break\n");
 | 
			
		||||
    return YAP_NO_SIGNAL;
 | 
			
		||||
  }
 | 
			
		||||
@@ -111,9 +111,7 @@ InteractSIGINT(int ch) {
 | 
			
		||||
  This function talks to the user about a signal. We assume we are in
 | 
			
		||||
  the context of the main Prolog thread (trivial in Unix, but hard in WIN32)
 | 
			
		||||
 */
 | 
			
		||||
static yap_signals
 | 
			
		||||
ProcessSIGINT(void)
 | 
			
		||||
{
 | 
			
		||||
static yap_signals ProcessSIGINT(void) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  int ch, out;
 | 
			
		||||
#if _WIN32
 | 
			
		||||
@@ -133,9 +131,7 @@ ProcessSIGINT(void)
 | 
			
		||||
  return (out);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline static void
 | 
			
		||||
do_signal(int wid, yap_signals sig USES_REGS)
 | 
			
		||||
{
 | 
			
		||||
inline static void do_signal(int wid, yap_signals sig USES_REGS) {
 | 
			
		||||
#if THREADS
 | 
			
		||||
  __sync_fetch_and_or(&REMOTE(wid)->Signals_, SIGNAL_TO_BIT(sig));
 | 
			
		||||
  if (!REMOTE_InterruptsDisabled(wid)) {
 | 
			
		||||
@@ -145,17 +141,12 @@ do_signal(int wid, yap_signals sig USES_REGS)
 | 
			
		||||
#else
 | 
			
		||||
  LOCAL_Signals |= SIGNAL_TO_BIT(sig);
 | 
			
		||||
  if (!LOCAL_InterruptsDisabled) {
 | 
			
		||||
      CreepFlag =
 | 
			
		||||
	  Unsigned(LCL0);
 | 
			
		||||
    CreepFlag = Unsigned(LCL0);
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
inline static int
 | 
			
		||||
get_signal(yap_signals sig USES_REGS)
 | 
			
		||||
{
 | 
			
		||||
inline static bool get_signal(yap_signals sig USES_REGS) {
 | 
			
		||||
#if THREADS
 | 
			
		||||
  uint64_t old;
 | 
			
		||||
 | 
			
		||||
@@ -195,9 +186,7 @@ get_signal(yap_signals sig USES_REGS)
 | 
			
		||||
/**
 | 
			
		||||
  Function called to handle delayed interrupts.
 | 
			
		||||
 */
 | 
			
		||||
int
 | 
			
		||||
Yap_HandleInterrupts( void )
 | 
			
		||||
{
 | 
			
		||||
int Yap_HandleInterrupts(void) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  yap_signals sig;
 | 
			
		||||
 | 
			
		||||
@@ -210,9 +199,7 @@ Yap_HandleInterrupts( void )
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Int 
 | 
			
		||||
p_creep( USES_REGS1 )
 | 
			
		||||
{
 | 
			
		||||
static Int p_creep(USES_REGS1) {
 | 
			
		||||
  Atom at;
 | 
			
		||||
  PredEntry *pred;
 | 
			
		||||
 | 
			
		||||
@@ -223,9 +210,7 @@ p_creep( USES_REGS1 )
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Int 
 | 
			
		||||
p_creep_fail( USES_REGS1 )
 | 
			
		||||
{
 | 
			
		||||
static Int p_creep_fail(USES_REGS1) {
 | 
			
		||||
  Atom at;
 | 
			
		||||
  PredEntry *pred;
 | 
			
		||||
 | 
			
		||||
@@ -236,15 +221,19 @@ p_creep_fail( USES_REGS1 )
 | 
			
		||||
  return FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Int stop_creeping( USES_REGS1 )
 | 
			
		||||
{
 | 
			
		||||
static Int stop_creeping(USES_REGS1) {
 | 
			
		||||
  if (get_signal(YAP_CREEP_SIGNAL PASS_REGS)) {
 | 
			
		||||
    return Yap_unify(ARG1, TermTrue);
 | 
			
		||||
  }
 | 
			
		||||
  return Yap_unify(ARG1, TermFalse);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Int disable_debugging(USES_REGS1) {
 | 
			
		||||
  get_signal(YAP_CREEP_SIGNAL PASS_REGS);
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Int
 | 
			
		||||
creep_allowed( USES_REGS1 )
 | 
			
		||||
{
 | 
			
		||||
static Int creep_allowed(USES_REGS1) {
 | 
			
		||||
  if (PP != NULL) {
 | 
			
		||||
    get_signal(YAP_CREEP_SIGNAL PASS_REGS);
 | 
			
		||||
    return true;
 | 
			
		||||
@@ -252,21 +241,16 @@ creep_allowed( USES_REGS1 )
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void 
 | 
			
		||||
Yap_signal(yap_signals sig)
 | 
			
		||||
{
 | 
			
		||||
void Yap_signal(yap_signals sig) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  do_signal(worker_id, sig PASS_REGS);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
static Int
 | 
			
		||||
p_debug( USES_REGS1 );
 | 
			
		||||
static Int p_debug(USES_REGS1);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void 
 | 
			
		||||
Yap_external_signal(int wid, yap_signals sig)
 | 
			
		||||
{
 | 
			
		||||
void Yap_external_signal(int wid, yap_signals sig) {
 | 
			
		||||
#if THREADS
 | 
			
		||||
  REGSTORE *regcache = REMOTE_ThreadHandle(wid).current_yaam_regs;
 | 
			
		||||
#endif
 | 
			
		||||
@@ -274,23 +258,16 @@ Yap_external_signal(int wid, yap_signals sig)
 | 
			
		||||
  LOCAL_PrologMode &= ~InterruptMode;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
Yap_get_signal__(yap_signals sig USES_REGS)
 | 
			
		||||
{
 | 
			
		||||
int Yap_get_signal__(yap_signals sig USES_REGS) {
 | 
			
		||||
  return get_signal(sig PASS_REGS);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// the caller holds the lock.
 | 
			
		||||
int 
 | 
			
		||||
Yap_has_signals__(yap_signals sig1, yap_signals sig2 USES_REGS)
 | 
			
		||||
{
 | 
			
		||||
int Yap_has_signals__(yap_signals sig1, yap_signals sig2 USES_REGS) {
 | 
			
		||||
  return LOCAL_Signals & (SIGNAL_TO_BIT(sig1) | SIGNAL_TO_BIT(sig2));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int 
 | 
			
		||||
Yap_only_has_signals__(yap_signals sig1, yap_signals sig2 USES_REGS)
 | 
			
		||||
{
 | 
			
		||||
int Yap_only_has_signals__(yap_signals sig1, yap_signals sig2 USES_REGS) {
 | 
			
		||||
  uint64_t sigs = LOCAL_Signals;
 | 
			
		||||
  return sigs & (SIGNAL_TO_BIT(sig1) | SIGNAL_TO_BIT(sig2)) &&
 | 
			
		||||
         !(sigs & ~(SIGNAL_TO_BIT(sig1) | SIGNAL_TO_BIT(sig2)));
 | 
			
		||||
@@ -300,33 +277,26 @@ Yap_only_has_signals__(yap_signals sig1, yap_signals sig2 USES_REGS)
 | 
			
		||||
 | 
			
		||||
volatile int volat = 0;
 | 
			
		||||
 | 
			
		||||
static Int 
 | 
			
		||||
p_debug( USES_REGS1 )
 | 
			
		||||
{				/* $debug(+Flag) */
 | 
			
		||||
static Int p_debug(USES_REGS1) { /* $debug(+Flag) */
 | 
			
		||||
  int i = IntOfTerm(Deref(ARG1));
 | 
			
		||||
  while (volat == 0) {
 | 
			
		||||
  }
 | 
			
		||||
  if (i >= 'a' && i <= 'z')
 | 
			
		||||
    GLOBAL_Option[i - 96] = !GLOBAL_Option[i - 96];
 | 
			
		||||
  return (1);
 | 
			
		||||
  return 1;
 | 
			
		||||
}
 | 
			
		||||
void Yap_loop(void);
 | 
			
		||||
void Yap_debug_end_loop(void);
 | 
			
		||||
 | 
			
		||||
void Yap_loop(void)
 | 
			
		||||
{
 | 
			
		||||
  while (volat == 0);
 | 
			
		||||
void Yap_loop(void) {
 | 
			
		||||
  while (volat == 0)
 | 
			
		||||
    ;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Yap_debug_end_loop(void)
 | 
			
		||||
{
 | 
			
		||||
  volat = 1;
 | 
			
		||||
}
 | 
			
		||||
void Yap_debug_end_loop(void) { volat = 1; }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static Int
 | 
			
		||||
first_signal( USES_REGS1 )
 | 
			
		||||
{
 | 
			
		||||
static Int first_signal(USES_REGS1) {
 | 
			
		||||
  Atom at;
 | 
			
		||||
  yap_signals sig;
 | 
			
		||||
 | 
			
		||||
@@ -439,30 +409,26 @@ first_signal( USES_REGS1 )
 | 
			
		||||
  return Yap_unify(ARG1, MkAtomTerm(at));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Int
 | 
			
		||||
continue_signals( USES_REGS1 )
 | 
			
		||||
{
 | 
			
		||||
  return first_signal( PASS_REGS1 );
 | 
			
		||||
}
 | 
			
		||||
static Int continue_signals(USES_REGS1) { return first_signal(PASS_REGS1); }
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
Yap_InitSignalCPreds(void)
 | 
			
		||||
{
 | 
			
		||||
void Yap_InitSignalCPreds(void) {
 | 
			
		||||
  /* Basic predicates for the debugger */
 | 
			
		||||
  Yap_InitCPred("$creep", 0, p_creep, SafePredFlag);
 | 
			
		||||
  Yap_InitCPred("$creep_fail", 0, p_creep_fail, SafePredFlag);
 | 
			
		||||
  Yap_InitCPred("$stop_creeping", 0, stop_creeping, NoTracePredFlag|HiddenPredFlag|SafePredFlag);
 | 
			
		||||
  Yap_InitCPred("$disable_debugging", 0, stop_creeping, NoTracePredFlag|HiddenPredFlag|SafePredFlag);
 | 
			
		||||
  Yap_InitCPred("$stop_creeping", 1, stop_creeping,
 | 
			
		||||
                NoTracePredFlag | HiddenPredFlag | SafePredFlag);
 | 
			
		||||
  Yap_InitCPred("$disable_debugging", 0, disable_debugging,
 | 
			
		||||
                NoTracePredFlag | HiddenPredFlag | SafePredFlag);
 | 
			
		||||
  Yap_InitCPred("$first_signal", 1, first_signal, SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred ("$continue_signals", 0, continue_signals, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$continue_signals", 0, continue_signals,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("creep_allowed", 0, creep_allowed, 0);
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
  Yap_InitCPred("sys_debug", 1, p_debug, SafePredFlag | SyncPredFlag);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *Yap_InitSignals(int wid)
 | 
			
		||||
{
 | 
			
		||||
void *Yap_InitSignals(int wid) {
 | 
			
		||||
  void *ptr = (void *)malloc(sizeof(UInt) * REMOTE_MaxActiveSignals(wid));
 | 
			
		||||
  return ptr;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										46
									
								
								C/stdpreds.c
									
									
									
									
									
								
							
							
						
						
									
										46
									
								
								C/stdpreds.c
									
									
									
									
									
								
							@@ -1,3 +1,4 @@
 | 
			
		||||
 | 
			
		||||
/*************************************************************************
 | 
			
		||||
*									 *
 | 
			
		||||
*	 YAP Prolog 							 *
 | 
			
		||||
@@ -981,15 +982,7 @@ static PredEntry *firstModulePred(PredEntry *npp, Term task) {
 | 
			
		||||
  return npp;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static PredEntry *firstModulesPred(PredEntry *npp, Term task) {
 | 
			
		||||
  ModEntry *m;
 | 
			
		||||
  if (npp) {
 | 
			
		||||
    m = Yap_GetModuleEntry(npp->ModuleOfPred);
 | 
			
		||||
    npp = npp->NextPredOfModule;
 | 
			
		||||
  } else {
 | 
			
		||||
    m = CurrentModules;
 | 
			
		||||
    npp = m->PredForME;
 | 
			
		||||
  }
 | 
			
		||||
static PredEntry *firstModulesPred(PredEntry *npp, ModEntry *m, Term task) {
 | 
			
		||||
  do {
 | 
			
		||||
    while (npp && !valid_prop(AbsPredProp(npp), task))
 | 
			
		||||
      npp = npp->NextPredOfModule;
 | 
			
		||||
@@ -998,7 +991,8 @@ static PredEntry *firstModulesPred(PredEntry *npp, Term task) {
 | 
			
		||||
    m = m->NextME;
 | 
			
		||||
    if (m) {
 | 
			
		||||
      npp = m->PredForME;
 | 
			
		||||
    }
 | 
			
		||||
    } else
 | 
			
		||||
      return NULL;
 | 
			
		||||
  } while (npp || m);
 | 
			
		||||
  return npp;
 | 
			
		||||
}
 | 
			
		||||
@@ -1022,16 +1016,14 @@ static Int cont_current_predicate(USES_REGS1) {
 | 
			
		||||
      // module and functor known, should be easy
 | 
			
		||||
      if (IsAtomTerm(t2)) {
 | 
			
		||||
        if ((p = Yap_GetPredPropByAtom(AtomOfTerm(t3), t2)) &&
 | 
			
		||||
            valid_prop(p, task)
 | 
			
		||||
            ) {
 | 
			
		||||
            valid_prop(p, task)) {
 | 
			
		||||
          cut_succeed();
 | 
			
		||||
        } else {
 | 
			
		||||
          cut_fail();
 | 
			
		||||
        }
 | 
			
		||||
      } else {
 | 
			
		||||
        if ((p = Yap_GetPredPropByFunc(FunctorOfTerm(t3), t2)) &&
 | 
			
		||||
            valid_prop(p, task)
 | 
			
		||||
            ) {
 | 
			
		||||
            valid_prop(p, task)) {
 | 
			
		||||
          cut_succeed();
 | 
			
		||||
        } else {
 | 
			
		||||
          cut_fail();
 | 
			
		||||
@@ -1057,8 +1049,10 @@ static Int cont_current_predicate(USES_REGS1) {
 | 
			
		||||
      mod = TermProlog;
 | 
			
		||||
    bool b = Yap_unify(t2, mod);
 | 
			
		||||
    if (!np) {
 | 
			
		||||
      if (b) cut_succeed();
 | 
			
		||||
      else cut_fail();
 | 
			
		||||
      if (b)
 | 
			
		||||
        cut_succeed();
 | 
			
		||||
      else
 | 
			
		||||
        cut_fail();
 | 
			
		||||
    } else {
 | 
			
		||||
      EXTRA_CBACK_ARG(4, 1) = MkAddressTerm(RepPredProp(np));
 | 
			
		||||
      B->cp_h = HR;
 | 
			
		||||
@@ -1080,6 +1074,7 @@ static Int cont_current_predicate(USES_REGS1) {
 | 
			
		||||
        p = getPredProp(RepAtom(at)->PropsOfAE, task);
 | 
			
		||||
      } else {
 | 
			
		||||
        Yap_Error(TYPE_ERROR_CALLABLE, t1, "current_predicate/2");
 | 
			
		||||
        return false;
 | 
			
		||||
      }
 | 
			
		||||
      if (!p)
 | 
			
		||||
        cut_fail();
 | 
			
		||||
@@ -1117,18 +1112,21 @@ static Int cont_current_predicate(USES_REGS1) {
 | 
			
		||||
    }
 | 
			
		||||
  } else {
 | 
			
		||||
    // operating across all modules.
 | 
			
		||||
    PredEntry *npp;
 | 
			
		||||
 | 
			
		||||
    PredEntry *npp = pp;
 | 
			
		||||
    ModEntry *me;
 | 
			
		||||
    if (!pp) {
 | 
			
		||||
      pp = firstModulesPred(CurrentModules->PredForME, task);
 | 
			
		||||
      pp = firstModulesPred(CurrentModules->PredForME, CurrentModules, task);
 | 
			
		||||
    }
 | 
			
		||||
    if (!pp)
 | 
			
		||||
      cut_fail();
 | 
			
		||||
    }
 | 
			
		||||
    npp = firstModulesPred(pp, task);
 | 
			
		||||
 | 
			
		||||
    if (pp->ModuleOfPred == PROLOG_MODULE)
 | 
			
		||||
      me = Yap_GetModuleEntry(TermProlog);
 | 
			
		||||
    else
 | 
			
		||||
      me = Yap_GetModuleEntry(pp->ModuleOfPred);
 | 
			
		||||
    npp = firstModulesPred(pp->NextPredOfModule, me, task);
 | 
			
		||||
    if (!npp)
 | 
			
		||||
      will_cut = true;
 | 
			
		||||
    // just try next one
 | 
			
		||||
    // just try next module.
 | 
			
		||||
    else {
 | 
			
		||||
      EXTRA_CBACK_ARG(4, 1) = MkAddressTerm(npp);
 | 
			
		||||
      B->cp_h = HR;
 | 
			
		||||
@@ -1800,9 +1798,7 @@ void Yap_InitCPreds(void) {
 | 
			
		||||
#ifdef ANALYST
 | 
			
		||||
  Yap_InitAnalystPreds();
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef LOW_LEVEL_TRACER
 | 
			
		||||
  Yap_InitLowLevelTrace();
 | 
			
		||||
#endif
 | 
			
		||||
  Yap_InitEval();
 | 
			
		||||
  Yap_InitGrowPreds();
 | 
			
		||||
  Yap_InitLowProf();
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,7 @@ static char     SccsId[] = "%W% %G%";
 | 
			
		||||
#include "yapio.h"
 | 
			
		||||
#include "blobs.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#if HAVE_STRING_H
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#endif
 | 
			
		||||
@@ -1565,7 +1566,9 @@ p_thread_unlock( USES_REGS1 )
 | 
			
		||||
intptr_t
 | 
			
		||||
system_thread_id(void)
 | 
			
		||||
{
 | 
			
		||||
#if HAVE_SYS_GETTID
 | 
			
		||||
#if defined(__APPLE__)
 | 
			
		||||
  return      syscall(SYS_thread_selfid);
 | 
			
		||||
#elif HAVE_SYS_GETTID || defined(__APPLE__)
 | 
			
		||||
  return syscall( SYS_GETTID );
 | 
			
		||||
#elif HAVE_GETTID_SYSCALL
 | 
			
		||||
    return syscall(__NR_gettid);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										16
									
								
								C/tracer.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								C/tracer.c
									
									
									
									
									
								
							@@ -50,7 +50,8 @@ static void send_tracer_message(char *start, char *name, Int arity, char *mname,
 | 
			
		||||
      for (i = 0; i < arity; i++) {
 | 
			
		||||
        if (i > 0)
 | 
			
		||||
          fprintf(stderr, ",");
 | 
			
		||||
        Yap_plwrite(args[i], NULL, 15, Handle_vars_f | AttVar_Portray_f, GLOBAL_MaxPriority);
 | 
			
		||||
        Yap_plwrite(args[i], NULL, 15, Handle_vars_f | AttVar_Portray_f,
 | 
			
		||||
                    GLOBAL_MaxPriority);
 | 
			
		||||
      }
 | 
			
		||||
      if (arity) {
 | 
			
		||||
        fprintf(stderr, ")");
 | 
			
		||||
@@ -475,6 +476,8 @@ static Int vsc_go(USES_REGS1) {
 | 
			
		||||
void Yap_InitLowLevelTrace(void) {
 | 
			
		||||
  Yap_InitCPred("start_low_level_trace", 0, start_low_level_trace,
 | 
			
		||||
                SafePredFlag);
 | 
			
		||||
  Yap_InitCPred("$start_low_level_trace", 0, start_low_level_trace,
 | 
			
		||||
                SafePredFlag);
 | 
			
		||||
/** @pred start_low_level_trace
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -488,6 +491,7 @@ Begin display of messages at procedure entry and retry.
 | 
			
		||||
#endif
 | 
			
		||||
  Yap_InitCPred("stop_low_level_trace", 0, stop_low_level_trace, SafePredFlag);
 | 
			
		||||
  Yap_InitCPred("show_low_level_trace", 0, show_low_level_trace, SafePredFlag);
 | 
			
		||||
  Yap_InitCPred("$stop_low_level_trace", 0, stop_low_level_trace, SafePredFlag);
 | 
			
		||||
  Yap_InitCPred("total_choicepoints", 1, total_choicepoints, SafePredFlag);
 | 
			
		||||
  Yap_InitCPred("reset_total_choicepoints", 0, reset_total_choicepoints,
 | 
			
		||||
                SafePredFlag);
 | 
			
		||||
@@ -495,4 +499,14 @@ Begin display of messages at procedure entry and retry.
 | 
			
		||||
  Yap_InitCPred("vsc_go", 0, vsc_go, SafePredFlag);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
static null(USES_REGS1) { return true; }
 | 
			
		||||
 | 
			
		||||
void Yap_InitLowLevelTrace(void) {
 | 
			
		||||
  Yap_InitCPred("$start_low_level_trace", 0, null,
 | 
			
		||||
                SafePredFlag | HiddenPredFlag);
 | 
			
		||||
  Yap_InitCPred("$stop_low_level_trace", 0, null,
 | 
			
		||||
                SafePredFlag | HiddenPredFlag);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										20
									
								
								C/write.c
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								C/write.c
									
									
									
									
									
								
							@@ -444,26 +444,28 @@ static int legalAtom(unsigned char *s) /* Is this a legal atom ? */
 | 
			
		||||
      return (s[1] == '}' && !s[2]);
 | 
			
		||||
    } else if (Yap_chtype[ch] == SL) {
 | 
			
		||||
      return (!s[1]);
 | 
			
		||||
    } else if (ch == '`') {
 | 
			
		||||
      return false;
 | 
			
		||||
    } else if ((ch == ',' || ch == '.') && !s[1]) {
 | 
			
		||||
      return false;
 | 
			
		||||
    } else {
 | 
			
		||||
      if (ch == '/') {
 | 
			
		||||
        if (s[1] == '*')
 | 
			
		||||
          return FALSE;
 | 
			
		||||
          return false;
 | 
			
		||||
      }
 | 
			
		||||
      while (ch) {
 | 
			
		||||
        if (Yap_chtype[ch] != SY) {
 | 
			
		||||
          return FALSE;
 | 
			
		||||
          return false;
 | 
			
		||||
        }
 | 
			
		||||
        ch = *++s;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return TRUE;
 | 
			
		||||
    return true;
 | 
			
		||||
  } else
 | 
			
		||||
    while ((ch = *++s) != 0)
 | 
			
		||||
      if (Yap_chtype[ch] > NU)
 | 
			
		||||
        return FALSE;
 | 
			
		||||
  return (TRUE);
 | 
			
		||||
        return false;
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static wtype
 | 
			
		||||
@@ -709,7 +711,7 @@ static Term from_pointer(CELL *ptr0, struct rewind_term *rwt,
 | 
			
		||||
 | 
			
		||||
    if (!IsAtomicTerm(t) && !IsVarTerm(t)) {
 | 
			
		||||
      while (x) {
 | 
			
		||||
        if (Yap_GetDerefedFromSlot(x->u_sd.s.old PASS_REGS) == t)
 | 
			
		||||
        if (Yap_GetDerefedFromSlot(x->u_sd.s.old) == t)
 | 
			
		||||
          return TermFoundVar;
 | 
			
		||||
        x = x->parent;
 | 
			
		||||
      }
 | 
			
		||||
@@ -736,8 +738,8 @@ static CELL *restore_from_write(struct rewind_term *rwt,
 | 
			
		||||
  CELL *ptr;
 | 
			
		||||
 | 
			
		||||
  if (wglb->Keep_terms) {
 | 
			
		||||
    ptr = (CELL *)Yap_GetPtrFromSlot(rwt->u_sd.s.ptr PASS_REGS);
 | 
			
		||||
    Yap_RecoverSlots(2, rwt->u_sd.s.old PASS_REGS);
 | 
			
		||||
    ptr = Yap_GetPtrFromSlot(rwt->u_sd.s.ptr );
 | 
			
		||||
    Yap_RecoverSlots(2, rwt->u_sd.s.old );
 | 
			
		||||
    //      printf("leak=%d %d\n", LOCALCurSlot,rwt->u_sd.s.old) ;
 | 
			
		||||
  } else {
 | 
			
		||||
    ptr = rwt->u_sd.d.ptr;
 | 
			
		||||
@@ -1232,7 +1234,7 @@ void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags,
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  struct write_globs wglb;
 | 
			
		||||
  struct rewind_term rwt;
 | 
			
		||||
  yhandle_t sls = Yap_CurrentSlot(PASS_REGS1);
 | 
			
		||||
  yhandle_t sls = Yap_CurrentSlot();
 | 
			
		||||
 | 
			
		||||
  if (!mywrite) {
 | 
			
		||||
    CACHE_REGS
 | 
			
		||||
 
 | 
			
		||||
@@ -28,14 +28,18 @@ set(YAP_MAJOR_VERSION 6)
 | 
			
		||||
set(YAP_MINOR_VERSION 3)
 | 
			
		||||
set(YAP_PATCH_VERSION 4)
 | 
			
		||||
 | 
			
		||||
set(YAP_SYSTEM_OPTIONS "attributed_variables" )
 | 
			
		||||
 | 
			
		||||
if (WIN32)
 | 
			
		||||
  set (YAP_ARCH $ENV{PROCESSOR_ARCHITECTURE})
 | 
			
		||||
  set(YAP_SYSTEM_OPTIONS "windows " ${YAP_SYSTEM_OPTIONS})
 | 
			
		||||
endif()
 | 
			
		||||
if (UNIX)
 | 
			
		||||
  find_program (UNAME uname)
 | 
			
		||||
  execute_process (
 | 
			
		||||
    COMMAND ${UNAME} -m
 | 
			
		||||
    OUTPUT_VARIABLE YAP_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE )
 | 
			
		||||
    set(YAP_SYSTEM_OPTIONS "unix " ${YAP_SYSTEM_OPTIONS})
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
set(YAP_FULL_VERSION
 | 
			
		||||
@@ -92,13 +96,14 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 | 
			
		||||
  #cmake_policy( NO_POLICY_SCOPE )
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
set (BUILD_SHARED_LIBS ON)
 | 
			
		||||
 | 
			
		||||
## define system
 | 
			
		||||
 | 
			
		||||
include (Sources)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
add_library(libYap SHARED
 | 
			
		||||
add_library(libYap
 | 
			
		||||
  ${ENGINE_SOURCES}
 | 
			
		||||
  ${C_INTERFACE_SOURCES}
 | 
			
		||||
  ${STATIC_SOURCES}
 | 
			
		||||
@@ -106,7 +111,7 @@ add_library(libYap SHARED
 | 
			
		||||
  ${HEADERS}
 | 
			
		||||
    $<TARGET_OBJECTS:libYAPOs>
 | 
			
		||||
  $<TARGET_OBJECTS:libOPTYap>
 | 
			
		||||
#  $<TARGET_OBJECTS:myddas>
 | 
			
		||||
  $<TARGET_OBJECTS:myddas>
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
set_property(DIRECTORY PROPERTY CXX_STANDARD 11)
 | 
			
		||||
@@ -249,14 +254,13 @@ if (HAVE_GCC)
 | 
			
		||||
endif (HAVE_GCC)
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
set (BUILD_SHARED_LIBS ON)
 | 
			
		||||
 | 
			
		||||
#option (YAP_SWI_IO ON)
 | 
			
		||||
 | 
			
		||||
OPTION (WITH_CALL_TRACER
 | 
			
		||||
"support for procedure-call tracing" ON)
 | 
			
		||||
#TODO:
 | 
			
		||||
if (WITH_CALL_TRACER)
 | 
			
		||||
    set(YAP_SYSTEM_OPTIONS "call_tracer " ${YAP_SYSTEM_OPTIONS})
 | 
			
		||||
set_property( DIRECTORY  APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:LOW_LEVEL_TRACER=1> )
 | 
			
		||||
endif (WITH_CALL_TRACER)
 | 
			
		||||
 | 
			
		||||
@@ -275,6 +279,7 @@ macro_log_feature (GMP_FOUND
 | 
			
		||||
  "libgmp"
 | 
			
		||||
  "GNU big integers and rationals"
 | 
			
		||||
  "http://gmplib.org")
 | 
			
		||||
  set(YAP_SYSTEM_OPTIONS "big_numbers " ${YAP_SYSTEM_OPTIONS})
 | 
			
		||||
if (GMP_FOUND)
 | 
			
		||||
  include_directories (${GMP_INCLUDE_DIR})
 | 
			
		||||
    #add_executable(test ${SOURCES})
 | 
			
		||||
@@ -323,6 +328,7 @@ if (WITH_Threads)
 | 
			
		||||
    check_function_exists( pthread_mutexattr_settype HAVE_PTHREAD_MUTEXATTR_SETTYPE )
 | 
			
		||||
    check_function_exists( pthread_setconcurrency HAVE_PTHREAD_SETCONCURRENCY )
 | 
			
		||||
  endif (CMAKE_USE_PTHREADS_INIT)
 | 
			
		||||
  set(YAP_SYSTEM_OPTIONS "threads " ${YAP_SYSTEM_OPTIONS})
 | 
			
		||||
 set_property( DIRECTORY  APPEND PROPERTY COMPILE_DEFINITIONS  THREADS=1)
 | 
			
		||||
  #
 | 
			
		||||
  # Please note that the compiler flag can only be used with the imported
 | 
			
		||||
@@ -344,7 +350,6 @@ IF(WITH_Pthread_Lockin)
 | 
			
		||||
  set_DIRECTORY_properties(PROPERTIES APPEND COMPILE_DEFINITIONS USE_PTHREAD_LOCKING=1)
 | 
			
		||||
ENDIF()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# include OS and I/o stuff
 | 
			
		||||
#
 | 
			
		||||
@@ -353,7 +358,7 @@ ENDIF()
 | 
			
		||||
#
 | 
			
		||||
add_subDIRECTORY (OPTYap)
 | 
			
		||||
 | 
			
		||||
#add_subDIRECTORY (packages/myddas)
 | 
			
		||||
add_subDIRECTORY (packages/myddas)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
add_subDIRECTORY (os)
 | 
			
		||||
@@ -369,6 +374,7 @@ ADD_SUBDIRECTORY(swi/library)
 | 
			
		||||
# ADD_SUBDIRECTORY(os)
 | 
			
		||||
# ADD_SUBDIRECTORY(packages)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
option (WITH_JIT
 | 
			
		||||
"just in Time Clause Compilation" OFF)
 | 
			
		||||
if (WITH_JIT)
 | 
			
		||||
@@ -397,7 +403,7 @@ add_subDIRECTORY (packages/cplint)
 | 
			
		||||
 | 
			
		||||
add_subDIRECTORY (packages/raptor)
 | 
			
		||||
 | 
			
		||||
add_subDIRECTORY (docs)
 | 
			
		||||
# add_subDIRECTORY (docs)
 | 
			
		||||
 | 
			
		||||
# add_subDIRECTORY (packages/cuda)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -428,7 +428,7 @@ YAPQuery::initQuery( YAPTerm ts[], arity_t arity )
 | 
			
		||||
  if (arity) {
 | 
			
		||||
    q_g = Yap_NewSlots( arity );
 | 
			
		||||
    for (arity_t i=0; i < arity; i++) {
 | 
			
		||||
      Yap_PutInSlot(q_g+i, ts[i].term() PASS_REGS);
 | 
			
		||||
      Yap_PutInSlot(q_g+i, ts[i].term());
 | 
			
		||||
    }
 | 
			
		||||
    Term t = Yap_MkApplTerm(ap->FunctorOfPred, ap->ArityOfPE, Yap_AddressFromSlot(q_g));
 | 
			
		||||
    goal = YAPTerm( t );
 | 
			
		||||
 
 | 
			
		||||
@@ -1,2 +1,2 @@
 | 
			
		||||
#define GIT_SHA1 "036876299f12a4761f8d1de2dfba9709d5c91739"
 | 
			
		||||
#define GIT_SHA1 "60a8efb467c383c47e440c3552cca7d179f66c2e"
 | 
			
		||||
const char g_GIT_SHA1[] = GIT_SHA1;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										28
									
								
								H/Yap.h
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								H/Yap.h
									
									
									
									
									
								
							@@ -376,6 +376,17 @@ typedef volatile int lockvar;
 | 
			
		||||
 | 
			
		||||
#include "Regs.h"
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************
 | 
			
		||||
                                       OPTYAP includes
 | 
			
		||||
*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#if defined(YAPOR) || defined(TABLING)
 | 
			
		||||
#include "opt.structs.h"
 | 
			
		||||
#include "opt.proto.h"
 | 
			
		||||
#include "opt.macros.h"
 | 
			
		||||
#endif /* YAPOR || TABLING */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************
 | 
			
		||||
                              variables concerned with Error Handling
 | 
			
		||||
*************************************************************************************************/
 | 
			
		||||
@@ -733,17 +744,6 @@ typedef struct scratch_block_struct {
 | 
			
		||||
/* scanner types */
 | 
			
		||||
#include "ScannerTypes.h"
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************
 | 
			
		||||
                                       OPTYAP includes
 | 
			
		||||
*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#if defined(YAPOR) || defined(TABLING)
 | 
			
		||||
#include "opt.structs.h"
 | 
			
		||||
#include "opt.proto.h"
 | 
			
		||||
#include "opt.macros.h"
 | 
			
		||||
#endif /* YAPOR || TABLING */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************
 | 
			
		||||
                                  GLOBAL and LOCAL variables
 | 
			
		||||
*************************************************************************************************/
 | 
			
		||||
@@ -771,10 +771,8 @@ extern struct worker_local Yap_local;
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#define YP_FILE		FILE
 | 
			
		||||
#include "hglobals.h"
 | 
			
		||||
#include "dglobals.h"
 | 
			
		||||
#include "hlocals.h"
 | 
			
		||||
#include "dlocals.h"
 | 
			
		||||
 | 
			
		||||
#include <YapHeap.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										61
									
								
								H/YapFlags.h
									
									
									
									
									
								
							
							
						
						
									
										61
									
								
								H/YapFlags.h
									
									
									
									
									
								
							@@ -25,37 +25,66 @@
 | 
			
		||||
 | 
			
		||||
// INLINE_ONLY inline EXTERN  bool nat( Term inp );
 | 
			
		||||
 | 
			
		||||
#define SYSTEM_OPTION_0 "attributed_variables,rational_trees]"
 | 
			
		||||
#if THREADS
 | 
			
		||||
#define SYSTEM_OPTION_1 "threads,"
 | 
			
		||||
#endif
 | 
			
		||||
#if USE_GMP
 | 
			
		||||
#define SYSTEM_OPTION_3 "big_numbers,"
 | 
			
		||||
#endif
 | 
			
		||||
#if DEPTH_LIMIT
 | 
			
		||||
#define SYSTEM_OPTION_4 "depth_limit,"
 | 
			
		||||
#endif
 | 
			
		||||
#if LOW_LEVEL_TRACE
 | 
			
		||||
#define SYSTEM_OPTION_5 "low_level_tracer,"
 | 
			
		||||
#endif
 | 
			
		||||
#if YAPOR
 | 
			
		||||
#define SYSTEM_OPTION_6 "or_parallelism,"
 | 
			
		||||
#endif
 | 
			
		||||
#if USE_READLINE
 | 
			
		||||
#define SYSTEM_OPTION_7 "readline,"
 | 
			
		||||
#endif
 | 
			
		||||
#if TABLING
 | 
			
		||||
#define SYSTEM_OPTION_8 "tabling,"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static inline bool nat(Term inp) {
 | 
			
		||||
  if (IsVarTerm(inp)) {
 | 
			
		||||
    Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s", "bound");
 | 
			
		||||
    Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s",
 | 
			
		||||
              "bound");
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
  if (IsIntTerm(inp)) {
 | 
			
		||||
    Int i = IntOfTerm(inp);
 | 
			
		||||
    if (i >= 0)
 | 
			
		||||
      return true;
 | 
			
		||||
    Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, inp, "set_prolog_flag: value must be %s", ">= 0");
 | 
			
		||||
    Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, inp,
 | 
			
		||||
              "set_prolog_flag: value must be %s", ">= 0");
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
  Yap_Error(TYPE_ERROR_INTEGER, inp, "set_prolog_flag: value must be %s", "integer");
 | 
			
		||||
  Yap_Error(TYPE_ERROR_INTEGER, inp, "set_prolog_flag: value must be %s",
 | 
			
		||||
            "integer");
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline bool at2n(Term inp) {
 | 
			
		||||
  Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s", "flag is read-only");
 | 
			
		||||
  Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s",
 | 
			
		||||
            "flag is read-only");
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline bool isfloat(Term inp) {
 | 
			
		||||
  if (IsVarTerm(inp)) {
 | 
			
		||||
    Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s", "integer");
 | 
			
		||||
    Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s",
 | 
			
		||||
              "integer");
 | 
			
		||||
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
  if (IsFloatTerm(inp)) {
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
  Yap_Error(TYPE_ERROR_FLOAT, inp, "set_prolog_flag: value must be %s", "floating-point");
 | 
			
		||||
  Yap_Error(TYPE_ERROR_FLOAT, inp, "set_prolog_flag: value must be %s",
 | 
			
		||||
            "floating-point");
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -63,20 +92,24 @@ INLINE_ONLY inline EXTERN bool ro(Term inp);
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY inline EXTERN bool ro(Term inp) {
 | 
			
		||||
  if (IsVarTerm(inp)) {
 | 
			
		||||
    Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s", "bound");
 | 
			
		||||
    Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s",
 | 
			
		||||
              "bound");
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
  Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s", "flag is read-only");
 | 
			
		||||
  Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s",
 | 
			
		||||
            "flag is read-only");
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY inline EXTERN bool aro(Term inp) {
 | 
			
		||||
  if (IsVarTerm(inp)) {
 | 
			
		||||
    Yap_Error(INSTANTIATION_ERROR, inp,  "set_prolog_flag %s", "value must be bound");
 | 
			
		||||
    Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s",
 | 
			
		||||
              "value must be bound");
 | 
			
		||||
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
  Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s", "flag is read-only");
 | 
			
		||||
  Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s",
 | 
			
		||||
            "flag is read-only");
 | 
			
		||||
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
@@ -87,7 +120,8 @@ static inline bool boolean(Term inp) {
 | 
			
		||||
  if (inp == TermTrue || inp == TermFalse || inp == TermOn || inp == TermOff)
 | 
			
		||||
    return true;
 | 
			
		||||
  if (IsVarTerm(inp)) {
 | 
			
		||||
    Yap_Error(INSTANTIATION_ERROR, inp,  "set_prolog_flag %s", "value must be bound");
 | 
			
		||||
    Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s",
 | 
			
		||||
              "value must be bound");
 | 
			
		||||
    ;
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
@@ -134,7 +168,8 @@ static bool bqs(Term inp) {
 | 
			
		||||
 | 
			
		||||
static inline bool isatom(Term inp) {
 | 
			
		||||
  if (IsVarTerm(inp)) {
 | 
			
		||||
    Yap_Error(INSTANTIATION_ERROR, inp,  "set_prolog_flag %s", "value must be bound");
 | 
			
		||||
    Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s",
 | 
			
		||||
              "value must be bound");
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
  if (IsAtomTerm(inp))
 | 
			
		||||
@@ -143,6 +178,8 @@ static inline bool isatom(Term inp) {
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline bool options(Term inp) { return Yap_IsGroundTerm(inp); }
 | 
			
		||||
 | 
			
		||||
// INLINE_ONLY inline EXTERN  bool ok( Term inp );
 | 
			
		||||
 | 
			
		||||
static inline bool ok(Term inp) { return true; }
 | 
			
		||||
 
 | 
			
		||||
@@ -63,7 +63,7 @@ Prolog exceptions. If enabled:
 | 
			
		||||
~~~~
 | 
			
		||||
?- X is 2/0.
 | 
			
		||||
ERROR!!
 | 
			
		||||
ZERO DIVISOR ERROR- X is Exp
 | 
			
		||||
ZERO DIVISO]]R ERROR- X is Exp
 | 
			
		||||
~~~~
 | 
			
		||||
 | 
			
		||||
If disabled:
 | 
			
		||||
@@ -364,7 +364,7 @@ bound to `off` disable strict mode, and keep the current language
 | 
			
		||||
mode. The default for YAP is `off`.
 | 
			
		||||
Under strict ISO Prolog mode all calls to non-ISO built-ins generate an
 | 
			
		||||
error. Compilation of clauses that would call non-ISO built-ins will
 | 
			
		||||
§§also generate errors. Pre-processing for grammar rules is also
 | 
			
		||||
also generate errors. Pre-processing for grammar rules is also
 | 
			
		||||
disabled. Module expansion is still performed.
 | 
			
		||||
Arguably, ISO Prolog does not provide all the functionality required
 | 
			
		||||
from a modern Prolog system. Moreover, because most Prolog
 | 
			
		||||
@@ -377,9 +377,8 @@ believe this mode is mostly useful when investigating how a program
 | 
			
		||||
depends on a Prolog's platform specific features.
 | 
			
		||||
 | 
			
		||||
                    */
 | 
			
		||||
    YAP_FLAG(SYSTEM_OPTIONS_FLAG, "system_options", false, ro,
 | 
			
		||||
             "[big_numbers,coroutining,depth_limit,low_level_tracer,rational_"
 | 
			
		||||
             "trees,threads,tabling]",
 | 
			
		||||
    YAP_FLAG(SYSTEM_OPTIONS_FLAG, "system_options", false, options,
 | 
			
		||||
             SYSTEM_OPTIONS,
 | 
			
		||||
             NULL), /**<  `system_options `
 | 
			
		||||
 | 
			
		||||
This read only flag tells which options were used to compile
 | 
			
		||||
@@ -411,8 +410,8 @@ presented. Only the first solution is considered and the goal is not
 | 
			
		||||
backtracked into.
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
    YAP_FLAG(TOPLEVEL_PROMPT_FLAG, "toplevel_prompt", true, isatom,
 | 
			
		||||
             "?- ", mkprompt),
 | 
			
		||||
    YAP_FLAG(TOPLEVEL_PROMPT_FLAG, "toplevel_prompt", true, isatom, "?- ",
 | 
			
		||||
             mkprompt),
 | 
			
		||||
    YAP_FLAG(TTY_CONTROL_FLAG, "tty_control", true, boolean, "true", NULL),
 | 
			
		||||
    YAP_FLAG(UNIX_FLAG, "unix", false, ro, "true", NULL), /**< `unix`
 | 
			
		||||
 | 
			
		||||
@@ -445,7 +444,8 @@ follows immediate semantics.
 | 
			
		||||
             Yap_unknown), /**< `unknown is iso`
 | 
			
		||||
 | 
			
		||||
Corresponds to calling the unknown/2 built-in. Possible ISO values
 | 
			
		||||
are `error`, `fail`, and `warning`. Yap includes the following extensions: `fast_fail` does not invoke any handler.
 | 
			
		||||
are `error`, `fail`, and `warning`. Yap includes the following extensions:
 | 
			
		||||
`fast_fail` does not invoke any handler.
 | 
			
		||||
*/
 | 
			
		||||
    YAP_FLAG(VARIABLE_NAMES_MAY_END_WITH_QUOTES_FLAG,
 | 
			
		||||
             "variable_names_may_end_with_quotes", true, boolean, "false",
 | 
			
		||||
 
 | 
			
		||||
@@ -67,61 +67,80 @@ static inline void Yap_RebootSlots__(int wid USES_REGS) {
 | 
			
		||||
 | 
			
		||||
/// @brief declares a new set of slots.
 | 
			
		||||
/// Used to tell how many slots we had when we entered a segment of code.
 | 
			
		||||
//#define Yap_StartSlots() ( printf("[<<<%s,%s,%d-%ld\n",__FILE__,__FUNCTION__,__LINE__,LOCAL_CurSlot)?Yap_StartSlots__(PASS_REGS1): -1)
 | 
			
		||||
//#define Yap_StartSlots() (
 | 
			
		||||
// printf("[<<<%s,%s,%d-%ld\n",__FILE__,__FUNCTION__,__LINE__,LOCAL_CurSlot)?Yap_StartSlots__(PASS_REGS1):
 | 
			
		||||
//-1)
 | 
			
		||||
#define Yap_StartSlots() Yap_StartSlots__(PASS_REGS1)
 | 
			
		||||
 | 
			
		||||
static inline yhandle_t Yap_StartSlots__(USES_REGS1) {
 | 
			
		||||
INLINE_ONLY inline EXTERN yhandle_t Yap_StartSlots__(USES_REGS1);
 | 
			
		||||
INLINE_ONLY inline EXTERN yhandle_t Yap_StartSlots__(USES_REGS1) {
 | 
			
		||||
  //  // fprintf(stderr,  " StartSlots = %ld", LOCAL_CurSlot);
 | 
			
		||||
  // fprintf(stderr,"SS %s:%d\n", __FUNCTION__, __LINE__);;
 | 
			
		||||
  // fprintf(stderr,"SS %s:%d\n", __FILE__, __LINE__);;
 | 
			
		||||
  if (LOCAL_CurSlot < 0) {
 | 
			
		||||
    Yap_Error(SYSTEM_ERROR_INTERNAL, 0L, " StartSlots = %ld", LOCAL_CurSlot);
 | 
			
		||||
  }
 | 
			
		||||
  return LOCAL_CurSlot;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/// @brief reset slots to a well-known position in the stack
 | 
			
		||||
//#define Yap_CloseSlots(slot) ( printf("- %s,%s,%d %ld>>>]\n",__FILE__,__FUNCTION__,__LINE__, slot)?Yap_CloseSlots__(slot PASS_REGS):-1)
 | 
			
		||||
//#define Yap_CloseSlots(slot) ( printf("- %s,%s,%d
 | 
			
		||||
//%ld>>>]\n",__FILE__,__FUNCTION__,__LINE__, slot)?Yap_CloseSlots__(slot
 | 
			
		||||
// PASS_REGS):-1)
 | 
			
		||||
#define Yap_CloseSlots(slot) Yap_CloseSlots__(slot PASS_REGS)
 | 
			
		||||
 | 
			
		||||
static inline void Yap_CloseSlots__(yhandle_t slot USES_REGS) {
 | 
			
		||||
  // fprintf(stderr,"CS %s:%d\n", __FUNCTION__, __LINE__);;
 | 
			
		||||
INLINE_ONLY inline EXTERN void Yap_CloseSlots__(yhandle_t slot USES_REGS);
 | 
			
		||||
INLINE_ONLY inline EXTERN void Yap_CloseSlots__(yhandle_t slot USES_REGS) {
 | 
			
		||||
  // fprintf(stderr,"CS %s:%d\n", __FILE__, __LINE__);;
 | 
			
		||||
  LOCAL_CurSlot = slot;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define Yap_CurrentSlot() Yap_CurrentSlot__(PASS_REGS1)
 | 
			
		||||
/// @brief report the current position of the slots, assuming that they occupy
 | 
			
		||||
/// the top of the stack.
 | 
			
		||||
static inline yhandle_t Yap_CurrentSlot(USES_REGS1) { return LOCAL_CurSlot; }
 | 
			
		||||
INLINE_ONLY inline EXTERN yhandle_t Yap_CurrentSlot__(USES_REGS1);
 | 
			
		||||
INLINE_ONLY inline EXTERN yhandle_t Yap_CurrentSlot__(USES_REGS1) {
 | 
			
		||||
  return LOCAL_CurSlot;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define Yap_GetFromSlot(slot) Yap_GetFromSlot__(slot PASS_REGS)
 | 
			
		||||
/// @brief read from a slot.
 | 
			
		||||
static inline Term Yap_GetFromSlot__(yhandle_t slot USES_REGS) {
 | 
			
		||||
  // fprintf(stderr,"GS %s:%d\n", __FUNCTION__, __LINE__);;
 | 
			
		||||
  return (Deref(LOCAL_SlotBase[slot]));
 | 
			
		||||
INLINE_ONLY inline EXTERN Term Yap_GetFromSlot__(yhandle_t slot USES_REGS);
 | 
			
		||||
INLINE_ONLY inline EXTERN Term Yap_GetFromSlot__(yhandle_t slot USES_REGS) {
 | 
			
		||||
  //  fprintf(stderr, "GS %s:%d\n", __FILE__, __LINE__);
 | 
			
		||||
  return Deref(LOCAL_SlotBase[slot]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define Yap_GetDerefedFromSlot( slot ) Yap_GetDerefedFromSlot__(slot PASS_REGS)
 | 
			
		||||
/// @brief read from a slot. but does not try to dereference the slot.
 | 
			
		||||
static inline Term Yap_GetDerefedFromSlot(yhandle_t slot USES_REGS) {
 | 
			
		||||
  // fprintf(stderr,"GDS %s:%d\n", __FUNCTION__, __LINE__);
 | 
			
		||||
INLINE_ONLY inline EXTERN Term Yap_GetDerefedFromSlot__(yhandle_t slot USES_REGS);
 | 
			
		||||
INLINE_ONLY inline EXTERN Term Yap_GetDerefedFromSlot__(yhandle_t slot USES_REGS) {
 | 
			
		||||
  // fprintf(stderr,"GDS %s:%d\n", __FILE__, __LINE__);
 | 
			
		||||
  return LOCAL_SlotBase[slot];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define Yap_GetPtrFromSlot( slot ) Yap_GetPtrFromSlot__(slot PASS_REGS)
 | 
			
		||||
 | 
			
		||||
/// @brief read the object in a slot. but do not try to dereference the slot.
 | 
			
		||||
static inline Term Yap_GetPtrFromSlot(yhandle_t slot USES_REGS) {
 | 
			
		||||
  // fprintf(stderr,"GPS %s:%d\n", __FUNCTION__, __LINE__);
 | 
			
		||||
  return LOCAL_SlotBase[slot];
 | 
			
		||||
INLINE_ONLY inline EXTERN Term *Yap_GetPtrFromSlot__(yhandle_t slot USES_REGS);
 | 
			
		||||
INLINE_ONLY inline EXTERN Term *Yap_GetPtrFromSlot__(yhandle_t slot USES_REGS) {
 | 
			
		||||
  // fprintf(stderr,"GPS %s:%d\n", __FILE__, __LINE__);
 | 
			
		||||
  return (Term *)LOCAL_SlotBase[slot];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define Yap_AddressFromSlot(slot) Yap_AddressFromSlot__(slot PASS_REGS)
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY inline EXTERN CELL *Yap_AddressFromSlot__(yhandle_t slot USES_REGS);
 | 
			
		||||
INLINE_ONLY inline EXTERN CELL *Yap_AddressFromSlot__(yhandle_t slot USES_REGS) {
 | 
			
		||||
  /// @brief get the memory address of a slot
 | 
			
		||||
static inline Term *Yap_AddressFromSlot__(yhandle_t slot USES_REGS) {
 | 
			
		||||
 | 
			
		||||
  return LOCAL_SlotBase + slot;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define Yap_PutInSlot(slot, t) Yap_PutInSlot__(slot, t PASS_REGS)
 | 
			
		||||
/// @brief store  term in a slot
 | 
			
		||||
static inline void Yap_PutInSlot(yhandle_t slot, Term t USES_REGS) {
 | 
			
		||||
  // fprintf(stderr,"PS %s:%d\n", __FUNCTION__, __LINE__);
 | 
			
		||||
INLINE_ONLY inline EXTERN void Yap_PutInSlot__(yhandle_t slot, Term t USES_REGS);
 | 
			
		||||
INLINE_ONLY inline EXTERN void Yap_PutInSlot__(yhandle_t slot, Term t USES_REGS) {
 | 
			
		||||
  // fprintf(stderr,"PS %s:%d\n", __FILE__, __LINE__);
 | 
			
		||||
  LOCAL_SlotBase[slot] = t;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -129,7 +148,7 @@ static inline void Yap_PutInSlot(yhandle_t slot, Term t USES_REGS) {
 | 
			
		||||
#define max(X, Y) (X > Y ? X : Y)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static inline void ensure_slots(int N USES_REGS) {
 | 
			
		||||
INLINE_ONLY inline EXTERN void ensure_slots(int N USES_REGS) {
 | 
			
		||||
  if (LOCAL_CurSlot + N >= LOCAL_NSlots) {
 | 
			
		||||
    size_t inc = max(16 * 1024, LOCAL_NSlots / 2); // measured in cells
 | 
			
		||||
    inc = max(inc, N + 16);                        // measured in cells
 | 
			
		||||
@@ -147,12 +166,15 @@ static inline void ensure_slots(int N USES_REGS) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// @brief create a new slot with term t
 | 
			
		||||
//#define Yap_InitSlot(t) ( printf("+%d %s,%s,%d>>>]\n",1,__FILE__,__FUNCTION__,__LINE__)?Yap_InitSlot__(t PASS_REGS):-1)
 | 
			
		||||
   // #define Yap_InitSlot(t)                                               \
 | 
			
		||||
  //  (printf("+%d %ld %s,%s,%d>>>]\n", 1, LOCAL_CurSlot,__FILE__, __FUNCTION__, __LINE__) \
 | 
			
		||||
  //    ? Yap_InitSlot__(t PASS_REGS)                                   \
 | 
			
		||||
  //    : -1)
 | 
			
		||||
#define Yap_InitSlot(t) Yap_InitSlot__(t PASS_REGS)
 | 
			
		||||
 | 
			
		||||
static inline yhandle_t Yap_InitSlot__(Term t USES_REGS) {
 | 
			
		||||
INLINE_ONLY inline EXTERN yhandle_t Yap_InitSlot__(Term t USES_REGS);
 | 
			
		||||
INLINE_ONLY inline EXTERN yhandle_t Yap_InitSlot__(Term t USES_REGS) {
 | 
			
		||||
  yhandle_t old_slots = LOCAL_CurSlot;
 | 
			
		||||
  // fprintf(stderr,"IS %s:%d\n", __FUNCTION__, __LINE__);
 | 
			
		||||
 | 
			
		||||
  ensure_slots(1 PASS_REGS);
 | 
			
		||||
  LOCAL_SlotBase[old_slots] = t;
 | 
			
		||||
@@ -160,14 +182,14 @@ static inline yhandle_t Yap_InitSlot__(Term t USES_REGS) {
 | 
			
		||||
  return old_slots;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//#define Yap_NewSlots(n) ( printf("+%d %s,%s,%d>>>]\n",n,__FILE__,__FUNCTION__,__LINE__)?Yap_NewSlots__(n PASS_REGS):-1)
 | 
			
		||||
//#define Yap_NewSlots(n) ( printf("+%d %ld %s,%s,%d>>>]\n",n,LOCAL_CurSlot,__FILE__,__FUNCTION__,__LINE__) ?Yap_NewSlots__(n PASS_REGS):-1)
 | 
			
		||||
#define Yap_NewSlots(n)  Yap_NewSlots__(n PASS_REGS)
 | 
			
		||||
 | 
			
		||||
/// @brief allocate n empty new slots
 | 
			
		||||
static inline yhandle_t Yap_NewSlots__(int n USES_REGS) {
 | 
			
		||||
INLINE_ONLY inline EXTERN yhandle_t Yap_NewSlots__(int n USES_REGS);
 | 
			
		||||
INLINE_ONLY inline EXTERN yhandle_t Yap_NewSlots__(int n USES_REGS) {
 | 
			
		||||
  yhandle_t old_slots = LOCAL_CurSlot;
 | 
			
		||||
  int i;
 | 
			
		||||
  // fprintf(stderr,"NS %s:%d\n", __FUNCTION__, __LINE__);
 | 
			
		||||
  //fprintf(stderr, "NS %s:%d\n", __FILE__, __LINE__);
 | 
			
		||||
 | 
			
		||||
  ensure_slots(n PASS_REGS);
 | 
			
		||||
  for (i = 0; i < n; i++) {
 | 
			
		||||
@@ -177,15 +199,17 @@ static inline yhandle_t Yap_NewSlots__(int n USES_REGS) {
 | 
			
		||||
  return old_slots;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//#define Yap_InitSlots(n, ts) ( printf("+%d %s,%s,%d>>>]\n",n,__FILE__,__FUNCTION__,__LINE__)?Yap_InitSlots__(n, ts PASS_REGS):-1)
 | 
			
		||||
//#define Yap_InitSlots(n, ts)                                          \
 | 
			
		||||
  //  (printf("+%d %d %s,%s,%d>>>]\n", n, LOCAL_CurSlot, __FILE__, __FUNCTION__, __LINE__) \
 | 
			
		||||
  //   ? Yap_InitSlots__(n, ts PASS_REGS)                               \
 | 
			
		||||
  //   : -1)
 | 
			
		||||
#define Yap_InitSlots(n, ts) Yap_InitSlots__(n, ts PASS_REGS)
 | 
			
		||||
 | 
			
		||||
/// @brief create n new slots with terms ts[]
 | 
			
		||||
static inline yhandle_t Yap_InitSlots__(int n, Term *ts USES_REGS) {
 | 
			
		||||
INLINE_ONLY inline EXTERN yhandle_t Yap_InitSlots__(int n, Term *ts USES_REGS);
 | 
			
		||||
INLINE_ONLY inline EXTERN yhandle_t Yap_InitSlots__(int n, Term *ts USES_REGS) {
 | 
			
		||||
  yhandle_t old_slots = LOCAL_CurSlot;
 | 
			
		||||
  int i;
 | 
			
		||||
  // fprintf(stderr,"1S %s:%d\n", __FUNCTION__, __LINE__);
 | 
			
		||||
 | 
			
		||||
  ensure_slots(n PASS_REGS);
 | 
			
		||||
  for (i = 0; i < n; i++)
 | 
			
		||||
    LOCAL_SlotBase[old_slots + i] = ts[i];
 | 
			
		||||
@@ -193,19 +217,23 @@ static inline yhandle_t Yap_InitSlots__(int n, Term *ts USES_REGS) {
 | 
			
		||||
  return old_slots;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define Yap_RecoverSlots(n, ts) Yap_RecoverSlots__(n, ts PASS_REGS)
 | 
			
		||||
 | 
			
		||||
/// @brief Succeeds if it is to recover the space allocated for $n$ contiguos
 | 
			
		||||
/// slots starting at topSlot.
 | 
			
		||||
static inline bool Yap_RecoverSlots(int n, yhandle_t topSlot USES_REGS) {
 | 
			
		||||
static inline bool Yap_RecoverSlots__(int n, yhandle_t topSlot USES_REGS);
 | 
			
		||||
static inline bool Yap_RecoverSlots__(int n, yhandle_t topSlot USES_REGS) {
 | 
			
		||||
  if (topSlot + n < LOCAL_CurSlot)
 | 
			
		||||
    return false;
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
  if (n > LOCAL_CurSlot) {
 | 
			
		||||
    Yap_Error(SYSTEM_ERROR_INTERNAL, 0 ,  "Inconsistent slot state in Yap_RecoverSlots.", 0);
 | 
			
		||||
    Yap_Error(SYSTEM_ERROR_INTERNAL, 0,
 | 
			
		||||
              "Inconsistent slot state in Yap_RecoverSlots.", 0);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
  LOCAL_CurSlot -= n;
 | 
			
		||||
// fprintf(stderr,"RS %s:%d\n", __FUNCTION__, __LINE__);
 | 
			
		||||
  //fprintf(stderr,"RS %ld %s:%d\n", LOCAL_CurSlot, __FILE__, __LINE__);
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										68
									
								
								H/YapHeap.h
									
									
									
									
									
								
							
							
						
						
									
										68
									
								
								H/YapHeap.h
									
									
									
									
									
								
							@@ -156,16 +156,46 @@ typedef struct thandle {
 | 
			
		||||
/*******************
 | 
			
		||||
  this is the data base: everything here should be possible to restore
 | 
			
		||||
********************/
 | 
			
		||||
#if YAPOR
 | 
			
		||||
typedef struct various_codes {
 | 
			
		||||
  /* memory allocation and management */
 | 
			
		||||
  special_functors funcs;
 | 
			
		||||
 | 
			
		||||
#include "hstruct.h"
 | 
			
		||||
#include "heap/hstruct.h"
 | 
			
		||||
 | 
			
		||||
} all_heap_codes;
 | 
			
		||||
 | 
			
		||||
//#include "hglobals.h"
 | 
			
		||||
//#include "hlocals.h"
 | 
			
		||||
#include "heap/hglobals.h"
 | 
			
		||||
 | 
			
		||||
#include "heap/dhstruct.h"
 | 
			
		||||
#include "heap/dglobals.h"
 | 
			
		||||
#else
 | 
			
		||||
typedef struct various_codes {
 | 
			
		||||
  /* memory allocation and management */
 | 
			
		||||
  special_functors funcs;
 | 
			
		||||
 | 
			
		||||
  #include "tatoms.h"
 | 
			
		||||
 | 
			
		||||
} all_heap_codes;
 | 
			
		||||
 | 
			
		||||
#if __INIT_C__
 | 
			
		||||
#define EXTERNAL
 | 
			
		||||
#else
 | 
			
		||||
#define EXTERNAL extern
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "heap/h0struct.h"
 | 
			
		||||
 | 
			
		||||
#include "heap/h0globals.h"
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "heap/hlocals.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "heap/dlocals.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* ricardo
 | 
			
		||||
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
 | 
			
		||||
@@ -194,22 +224,14 @@ extern struct various_codes *Yap_heap_regs;
 | 
			
		||||
#define Yap_heap_regs ((all_heap_codes *)HEAP_INIT_BASE)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "dhstruct.h"
 | 
			
		||||
//#include "dglobals.h"
 | 
			
		||||
//#include "dlocals.h"
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * gc-P: how to start-up the grbage collector in C-code
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
static inline
 | 
			
		||||
yamop *
 | 
			
		||||
gc_P(yamop *p, yamop *cp)
 | 
			
		||||
{
 | 
			
		||||
  return (p->opc == EXECUTE_CPRED_OPCODE ? cp : p);
 | 
			
		||||
static inline yamop *gc_P(yamop *p, yamop *cp) {
 | 
			
		||||
  return (p && p->opc == EXECUTE_CPRED_OPCODE ? cp : p);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Yap_CurrentModule: access the current module for looking
 | 
			
		||||
  up predicates
 | 
			
		||||
@@ -219,15 +241,12 @@ gc_P(yamop *p, yamop *cp)
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY inline EXTERN Term Yap_CurrentModule__(USES_REGS1);
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY inline EXTERN Term
 | 
			
		||||
Yap_CurrentModule__ (USES_REGS1)
 | 
			
		||||
{
 | 
			
		||||
  if (CurrentModule) return CurrentModule;
 | 
			
		||||
INLINE_ONLY inline EXTERN Term Yap_CurrentModule__(USES_REGS1) {
 | 
			
		||||
  if (CurrentModule)
 | 
			
		||||
    return CurrentModule;
 | 
			
		||||
  return TermProlog;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*******************
 | 
			
		||||
  these are the global variables: they need not be restored...
 | 
			
		||||
********************/
 | 
			
		||||
@@ -236,14 +255,10 @@ Yap_CurrentModule__ (USES_REGS1)
 | 
			
		||||
#define UPDATE_MODE_LOGICAL 1
 | 
			
		||||
#define UPDATE_MODE_LOGICAL_ASSERT 2
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* initially allow for files with up to 1024 predicates. This number
 | 
			
		||||
   is extended whenever needed */
 | 
			
		||||
#define InitialConsultCapacity 1024
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if (defined(USE_SYSTEM_MALLOC) && HAVE_MALLINFO) || USE_DL_MALLOC
 | 
			
		||||
UInt Yap_givemallinfo(void);
 | 
			
		||||
#endif
 | 
			
		||||
@@ -253,12 +268,9 @@ ADDR    Yap_ExpandPreAllocCodeSpace(UInt, void *, int);
 | 
			
		||||
ADDR Yap_InitPreAllocCodeSpace(int);
 | 
			
		||||
 | 
			
		||||
#include "inline-only.h"
 | 
			
		||||
INLINE_ONLY EXTERN inline ADDR
 | 
			
		||||
Yap_PreAllocCodeSpace(void);
 | 
			
		||||
INLINE_ONLY EXTERN inline ADDR Yap_PreAllocCodeSpace(void);
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY EXTERN inline ADDR
 | 
			
		||||
Yap_PreAllocCodeSpace(void)
 | 
			
		||||
{
 | 
			
		||||
INLINE_ONLY EXTERN inline ADDR Yap_PreAllocCodeSpace(void) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  return AuxBase;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,7 @@
 | 
			
		||||
 | 
			
		||||
YAP_FLAG(  AUTOLOAD_FLAG, "autoload", true, boolean, "false" , NULL ),
 | 
			
		||||
YAP_FLAG(  BREAK_LEVEL_FLAG, "break_level", true, nat, "0" , NULL ),
 | 
			
		||||
YAP_FLAG(  ENCODING_FLAG, "encoding", true, isatom, "text" , getenc ),
 | 
			
		||||
YAP_FLAG(  ENCODING_FLAG, "encoding", true, isatom, "utf-8" , getenc ),
 | 
			
		||||
YAP_FLAG(  FILEERRORS_FLAG, "fileerrors", true, boolean, "true" , NULL ), /**< `fileerrors`
 | 
			
		||||
                                                                           
 | 
			
		||||
                                                                           If `on` `fileerrors` is `on`, if `off` (default)
 | 
			
		||||
 
 | 
			
		||||
@@ -483,8 +483,7 @@ static inline Term Yap_AtomToNumber(Term t0 USES_REGS) {
 | 
			
		||||
  inp.val.t = t0;
 | 
			
		||||
  inp.type = YAP_STRING_ATOM;
 | 
			
		||||
  out.val.uc = NULL;
 | 
			
		||||
  out.type =
 | 
			
		||||
      YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG;
 | 
			
		||||
  out.type = YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG;
 | 
			
		||||
  if (!Yap_CVT_Text(&inp, &out PASS_REGS))
 | 
			
		||||
    return 0L;
 | 
			
		||||
  return out.val.t;
 | 
			
		||||
@@ -1216,8 +1215,6 @@ static inline Term Yap_UTF8ToString(const char *s USES_REGS) {
 | 
			
		||||
  return MkStringTerm(s);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static inline Term Yap_WCharsToListOfCodes(const wchar_t *s USES_REGS) {
 | 
			
		||||
  seq_tv_t inp, out;
 | 
			
		||||
  inp.val.w0 = s;
 | 
			
		||||
 
 | 
			
		||||
@@ -124,7 +124,7 @@ Atom Yap_ConsultingFile(USES_REGS1);
 | 
			
		||||
struct pred_entry *Yap_PredForChoicePt(choiceptr bptr, op_numbers *op);
 | 
			
		||||
void Yap_InitCdMgr(void);
 | 
			
		||||
struct pred_entry *Yap_PredFromClause(Term t USES_REGS);
 | 
			
		||||
bool Yap_discontiguous(struct pred_entry *ap USES_REGS);
 | 
			
		||||
bool Yap_discontiguous(struct pred_entry *ap, Term mode USES_REGS);
 | 
			
		||||
bool Yap_multiple(struct pred_entry *ap, int mode USES_REGS);
 | 
			
		||||
void Yap_init_consult(int, const char *);
 | 
			
		||||
void Yap_end_consult(void);
 | 
			
		||||
@@ -136,6 +136,7 @@ void Yap_AssertzClause(struct pred_entry *, yamop *);
 | 
			
		||||
void Yap_HidePred(struct pred_entry *pe);
 | 
			
		||||
int Yap_SetNoTrace(char *name, UInt arity, Term tmod);
 | 
			
		||||
bool Yap_unknown(Term tflagvalue);
 | 
			
		||||
struct pred_entry *Yap_MkLogPred(struct pred_entry *pe);
 | 
			
		||||
 | 
			
		||||
/* cmppreds.c */
 | 
			
		||||
Int Yap_compare_terms(Term, Term);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										125
									
								
								H/clause.h
									
									
									
									
									
								
							
							
						
						
									
										125
									
								
								H/clause.h
									
									
									
									
									
								
							@@ -92,9 +92,8 @@ typedef struct logic_upd_clause {
 | 
			
		||||
#include "inline-only.h"
 | 
			
		||||
INLINE_ONLY inline EXTERN int VALID_TIMESTAMP(UInt, struct logic_upd_clause *);
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY inline EXTERN int
 | 
			
		||||
VALID_TIMESTAMP(UInt timestamp, struct logic_upd_clause *cl)
 | 
			
		||||
{
 | 
			
		||||
INLINE_ONLY inline EXTERN int VALID_TIMESTAMP(UInt timestamp,
 | 
			
		||||
                                              struct logic_upd_clause *cl) {
 | 
			
		||||
  return IN_BETWEEN(cl->ClTimeStart, timestamp, cl->ClTimeEnd);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -191,37 +190,37 @@ typedef struct index_t {
 | 
			
		||||
  UInt udi_arg;
 | 
			
		||||
} Index_t;
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY EXTERN inline BITS32 EXO_ADDRESS_TO_OFFSET(struct index_t *it, CELL *ptr);
 | 
			
		||||
INLINE_ONLY EXTERN inline BITS32 EXO_ADDRESS_TO_OFFSET(struct index_t *it,
 | 
			
		||||
                                                       CELL *ptr);
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY EXTERN inline   BITS32
 | 
			
		||||
EXO_ADDRESS_TO_OFFSET(struct index_t *it, CELL* ptr)
 | 
			
		||||
{
 | 
			
		||||
INLINE_ONLY EXTERN inline BITS32 EXO_ADDRESS_TO_OFFSET(struct index_t *it,
 | 
			
		||||
                                                       CELL *ptr) {
 | 
			
		||||
  return (ptr - it->cls) / it->arity + 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY EXTERN inline  CELL *EXO_OFFSET_TO_ADDRESS(struct index_t *it, BITS32  off);
 | 
			
		||||
INLINE_ONLY EXTERN inline CELL *EXO_OFFSET_TO_ADDRESS(struct index_t *it,
 | 
			
		||||
                                                      BITS32 off);
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY EXTERN inline   CELL *
 | 
			
		||||
EXO_OFFSET_TO_ADDRESS(struct index_t *it, BITS32  off)
 | 
			
		||||
{
 | 
			
		||||
INLINE_ONLY EXTERN inline CELL *EXO_OFFSET_TO_ADDRESS(struct index_t *it,
 | 
			
		||||
                                                      BITS32 off) {
 | 
			
		||||
  if (off == 0L)
 | 
			
		||||
    return (CELL *)NULL;
 | 
			
		||||
  return (it->cls) + (off - 1) * it->arity;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY EXTERN inline  BITS32 ADDRESS_TO_LINK(struct index_t *it, BITS32 *ptr);
 | 
			
		||||
INLINE_ONLY EXTERN inline BITS32 ADDRESS_TO_LINK(struct index_t *it,
 | 
			
		||||
                                                 BITS32 *ptr);
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY EXTERN inline  BITS32
 | 
			
		||||
ADDRESS_TO_LINK(struct index_t *it, BITS32* ptr)
 | 
			
		||||
{
 | 
			
		||||
INLINE_ONLY EXTERN inline BITS32 ADDRESS_TO_LINK(struct index_t *it,
 | 
			
		||||
                                                 BITS32 *ptr) {
 | 
			
		||||
  return ptr - it->links;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY EXTERN inline BITS32 *LINK_TO_ADDRESS(struct index_t *it, BITS32  off);
 | 
			
		||||
INLINE_ONLY EXTERN inline BITS32 *LINK_TO_ADDRESS(struct index_t *it,
 | 
			
		||||
                                                  BITS32 off);
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY EXTERN inline   BITS32 *
 | 
			
		||||
LINK_TO_ADDRESS(struct index_t *it, BITS32  off)
 | 
			
		||||
{
 | 
			
		||||
INLINE_ONLY EXTERN inline BITS32 *LINK_TO_ADDRESS(struct index_t *it,
 | 
			
		||||
                                                  BITS32 off) {
 | 
			
		||||
  return it->links + off;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -237,16 +236,24 @@ typedef struct dbterm_list {
 | 
			
		||||
  struct dbterm_list *next_dbl;
 | 
			
		||||
} DBTermList;
 | 
			
		||||
 | 
			
		||||
#define ClauseCodeToDynamicClause(p)    ((DynamicClause *)((CODEADDR)(p)-(CELL)(((DynamicClause *)NULL)->ClCode)))
 | 
			
		||||
#define ClauseCodeToStaticClause(p)    ((StaticClause *)((CODEADDR)(p)-(CELL)(((StaticClause *)NULL)->ClCode)))
 | 
			
		||||
#define ClauseCodeToLogUpdClause(p)    ((LogUpdClause *)((CODEADDR)(p)-(CELL)(((LogUpdClause *)NULL)->ClCode)))
 | 
			
		||||
#define ClauseCodeToMegaClause(p)    ((MegaClause *)((CODEADDR)(p)-(CELL)(((MegaClause *)NULL)->ClCode)))
 | 
			
		||||
#define ClauseCodeToLogUpdIndex(p)    ((LogUpdIndex *)((CODEADDR)(p)-(CELL)(((LogUpdIndex *)NULL)->ClCode)))
 | 
			
		||||
#define ClauseCodeToStaticIndex(p)    ((StaticIndex *)((CODEADDR)(p)-(CELL)(((StaticIndex *)NULL)->ClCode)))
 | 
			
		||||
#define ClauseCodeToDynamicClause(p)                                           \
 | 
			
		||||
  ((DynamicClause *)((CODEADDR)(p) - (CELL)(((DynamicClause *)NULL)->ClCode)))
 | 
			
		||||
#define ClauseCodeToStaticClause(p)                                            \
 | 
			
		||||
  ((StaticClause *)((CODEADDR)(p) - (CELL)(((StaticClause *)NULL)->ClCode)))
 | 
			
		||||
#define ClauseCodeToLogUpdClause(p)                                            \
 | 
			
		||||
  ((LogUpdClause *)((CODEADDR)(p) - (CELL)(((LogUpdClause *)NULL)->ClCode)))
 | 
			
		||||
#define ClauseCodeToMegaClause(p)                                              \
 | 
			
		||||
  ((MegaClause *)((CODEADDR)(p) - (CELL)(((MegaClause *)NULL)->ClCode)))
 | 
			
		||||
#define ClauseCodeToLogUpdIndex(p)                                             \
 | 
			
		||||
  ((LogUpdIndex *)((CODEADDR)(p) - (CELL)(((LogUpdIndex *)NULL)->ClCode)))
 | 
			
		||||
#define ClauseCodeToStaticIndex(p)                                             \
 | 
			
		||||
  ((StaticIndex *)((CODEADDR)(p) - (CELL)(((StaticIndex *)NULL)->ClCode)))
 | 
			
		||||
 | 
			
		||||
#define ClauseFlagsToDynamicClause(p) ((DynamicClause *)(p))
 | 
			
		||||
#define ClauseFlagsToLogUpdClause(p)     ((LogUpdClause *)((CODEADDR)(p)-(CELL)(&(((LogUpdClause *)NULL)->ClFlags))))
 | 
			
		||||
#define ClauseFlagsToLogUpdIndex(p)      ((LogUpdIndex *)((CODEADDR)(p)-(CELL)(&(((LogUpdIndex *)NULL)->ClFlags))))
 | 
			
		||||
#define ClauseFlagsToLogUpdClause(p)                                           \
 | 
			
		||||
  ((LogUpdClause *)((CODEADDR)(p) - (CELL)(&(((LogUpdClause *)NULL)->ClFlags))))
 | 
			
		||||
#define ClauseFlagsToLogUpdIndex(p)                                            \
 | 
			
		||||
  ((LogUpdIndex *)((CODEADDR)(p) - (CELL)(&(((LogUpdIndex *)NULL)->ClFlags))))
 | 
			
		||||
#define ClauseFlagsToStaticClause(p) ((StaticClause *)(p))
 | 
			
		||||
 | 
			
		||||
#define DynamicFlags(X) (ClauseCodeToDynamicClause(X)->ClFlags)
 | 
			
		||||
@@ -273,7 +280,7 @@ void    Yap_InitComma(void);
 | 
			
		||||
 | 
			
		||||
/* cdmgr.c */
 | 
			
		||||
void Yap_IPred(PredEntry *, UInt, yamop *);
 | 
			
		||||
int	Yap_addclause(Term,yamop *,int,Term,Term*);
 | 
			
		||||
bool Yap_addclause(Term, yamop *, int, Term, Term *);
 | 
			
		||||
void Yap_add_logupd_clause(PredEntry *, LogUpdClause *, int);
 | 
			
		||||
void Yap_kill_iblock(ClauseUnion *, ClauseUnion *, PredEntry *);
 | 
			
		||||
void Yap_EraseStaticClause(StaticClause *, PredEntry *, Term);
 | 
			
		||||
@@ -298,7 +305,8 @@ void     Yap_CleanKids(struct logic_upd_index *);
 | 
			
		||||
void Yap_AddClauseToIndex(PredEntry *, yamop *, int);
 | 
			
		||||
void Yap_RemoveClauseFromIndex(PredEntry *, yamop *);
 | 
			
		||||
LogUpdClause *Yap_NthClause(PredEntry *, Int);
 | 
			
		||||
LogUpdClause  *Yap_FollowIndexingCode(PredEntry *,yamop *, Term *, yamop *,yamop *);
 | 
			
		||||
LogUpdClause *Yap_FollowIndexingCode(PredEntry *, yamop *, Term *, yamop *,
 | 
			
		||||
                                     yamop *);
 | 
			
		||||
 | 
			
		||||
/* exo.c */
 | 
			
		||||
yamop *Yap_ExoLookup(PredEntry *ap USES_REGS);
 | 
			
		||||
@@ -311,8 +319,7 @@ CELL    Yap_NextExo(choiceptr cpt, struct index_t *it);
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY inline EXTERN int rtable_hash_op(OPCODE opc, int hash_mask);
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY inline EXTERN int
 | 
			
		||||
rtable_hash_op(OPCODE opc, int hash_mask) {
 | 
			
		||||
INLINE_ONLY inline EXTERN int rtable_hash_op(OPCODE opc, int hash_mask) {
 | 
			
		||||
  return ((((CELL)opc) >> 3) & hash_mask);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -320,9 +327,7 @@ INLINE_ONLY inline EXTERN op_numbers Yap_op_from_opcode(OPCODE opc);
 | 
			
		||||
 | 
			
		||||
/* given an opcode find the corresponding opnumber. This should make
 | 
			
		||||
   switches on ops a much easier operation */
 | 
			
		||||
INLINE_ONLY inline EXTERN op_numbers
 | 
			
		||||
Yap_op_from_opcode(OPCODE opc)
 | 
			
		||||
{
 | 
			
		||||
INLINE_ONLY inline EXTERN op_numbers Yap_op_from_opcode(OPCODE opc) {
 | 
			
		||||
  int j = rtable_hash_op(opc, OP_HASH_SIZE - 1);
 | 
			
		||||
 | 
			
		||||
  while (OP_RTABLE[j].opc != opc) {
 | 
			
		||||
@@ -337,9 +342,7 @@ Yap_op_from_opcode(OPCODE opc)
 | 
			
		||||
  return OP_RTABLE[j].opnum;
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
static inline op_numbers
 | 
			
		||||
Yap_op_from_opcode(OPCODE opc)
 | 
			
		||||
{
 | 
			
		||||
static inline op_numbers Yap_op_from_opcode(OPCODE opc) {
 | 
			
		||||
  return ((op_numbers)opc);
 | 
			
		||||
}
 | 
			
		||||
#endif /* USE_THREADED_CODE */
 | 
			
		||||
@@ -347,16 +350,15 @@ Yap_op_from_opcode(OPCODE opc)
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
static inline int same_lu_block(yamop **, yamop *);
 | 
			
		||||
 | 
			
		||||
static inline int
 | 
			
		||||
same_lu_block(yamop **paddr, yamop *p)
 | 
			
		||||
{
 | 
			
		||||
static inline int same_lu_block(yamop **paddr, yamop *p) {
 | 
			
		||||
  yamop *np = *paddr;
 | 
			
		||||
  if (np != p) {
 | 
			
		||||
    OPCODE jmp_op = Yap_opcode(_jump_if_nonvar);
 | 
			
		||||
 | 
			
		||||
    while (np->opc == jmp_op) {
 | 
			
		||||
      np = NEXTOP(np, xll);
 | 
			
		||||
      if (np == p) return TRUE;
 | 
			
		||||
      if (np == p)
 | 
			
		||||
        return TRUE;
 | 
			
		||||
    }
 | 
			
		||||
    return FALSE;
 | 
			
		||||
  } else {
 | 
			
		||||
@@ -367,64 +369,49 @@ same_lu_block(yamop **paddr, yamop *p)
 | 
			
		||||
 | 
			
		||||
#define Yap_MkStaticRefTerm(cp, ap) __Yap_MkStaticRefTerm((cp), (ap)PASS_REGS)
 | 
			
		||||
 | 
			
		||||
static inline Term
 | 
			
		||||
__Yap_MkStaticRefTerm(StaticClause *cp, PredEntry *ap USES_REGS)
 | 
			
		||||
{
 | 
			
		||||
static inline Term __Yap_MkStaticRefTerm(StaticClause *cp,
 | 
			
		||||
                                         PredEntry *ap USES_REGS) {
 | 
			
		||||
  Term t[2];
 | 
			
		||||
  t[0] = MkIntegerTerm((Int)cp);
 | 
			
		||||
  t[1] = MkIntegerTerm((Int)ap);
 | 
			
		||||
  return Yap_MkApplTerm(FunctorStaticClause, 2, t);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline StaticClause *
 | 
			
		||||
Yap_ClauseFromTerm(Term t)
 | 
			
		||||
{
 | 
			
		||||
static inline StaticClause *Yap_ClauseFromTerm(Term t) {
 | 
			
		||||
  return (StaticClause *)IntegerOfTerm(ArgOfTerm(1, t));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define Yap_MkMegaRefTerm(ap, ipc) __Yap_MkMegaRefTerm((ap), (ipc)PASS_REGS)
 | 
			
		||||
 | 
			
		||||
static inline Term
 | 
			
		||||
__Yap_MkMegaRefTerm(PredEntry *ap,yamop *ipc USES_REGS)
 | 
			
		||||
{
 | 
			
		||||
static inline Term __Yap_MkMegaRefTerm(PredEntry *ap, yamop *ipc USES_REGS) {
 | 
			
		||||
  Term t[2];
 | 
			
		||||
  t[0] = MkIntegerTerm((Int)ap);
 | 
			
		||||
  t[1] = MkIntegerTerm((Int)ipc);
 | 
			
		||||
  return Yap_MkApplTerm(FunctorMegaClause, 2, t);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline yamop *
 | 
			
		||||
Yap_MegaClauseFromTerm(Term t)
 | 
			
		||||
{
 | 
			
		||||
static inline yamop *Yap_MegaClauseFromTerm(Term t) {
 | 
			
		||||
  return (yamop *)IntegerOfTerm(ArgOfTerm(2, t));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline PredEntry *
 | 
			
		||||
Yap_MegaClausePredicateFromTerm(Term t)
 | 
			
		||||
{
 | 
			
		||||
static inline PredEntry *Yap_MegaClausePredicateFromTerm(Term t) {
 | 
			
		||||
  return (PredEntry *)IntegerOfTerm(ArgOfTerm(1, t));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define Yap_MkExoRefTerm(ap, i) __Yap_MkExoRefTerm((ap), (i)PASS_REGS)
 | 
			
		||||
 | 
			
		||||
static inline Term
 | 
			
		||||
__Yap_MkExoRefTerm(PredEntry *ap,Int i USES_REGS)
 | 
			
		||||
{
 | 
			
		||||
static inline Term __Yap_MkExoRefTerm(PredEntry *ap, Int i USES_REGS) {
 | 
			
		||||
  Term t[2];
 | 
			
		||||
  t[0] = MkIntegerTerm((Int)ap);
 | 
			
		||||
  t[1] = MkIntegerTerm((Int)i);
 | 
			
		||||
  return Yap_MkApplTerm(FunctorExoClause, 2, t);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline Int
 | 
			
		||||
Yap_ExoClauseFromTerm(Term t)
 | 
			
		||||
{
 | 
			
		||||
static inline Int Yap_ExoClauseFromTerm(Term t) {
 | 
			
		||||
  return IntegerOfTerm(ArgOfTerm(2, t));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline PredEntry *
 | 
			
		||||
Yap_ExoClausePredicateFromTerm(Term t)
 | 
			
		||||
{
 | 
			
		||||
static inline PredEntry *Yap_ExoClausePredicateFromTerm(Term t) {
 | 
			
		||||
  return (PredEntry *)IntegerOfTerm(ArgOfTerm(1, t));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -434,12 +421,10 @@ Yap_ExoClausePredicateFromTerm(Term t)
 | 
			
		||||
 | 
			
		||||
******************************************************************/
 | 
			
		||||
 | 
			
		||||
bool
 | 
			
		||||
Yap_search_for_static_predicate_in_use(PredEntry *p, bool check_everything);
 | 
			
		||||
bool Yap_search_for_static_predicate_in_use(PredEntry *p,
 | 
			
		||||
                                            bool check_everything);
 | 
			
		||||
 | 
			
		||||
static inline bool
 | 
			
		||||
Yap_static_in_use(PredEntry *p, bool check_everything)
 | 
			
		||||
{
 | 
			
		||||
static inline bool Yap_static_in_use(PredEntry *p, bool check_everything) {
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
  return TRUE;
 | 
			
		||||
#else
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										146
									
								
								H/dglobals.h
									
									
									
									
									
								
							
							
						
						
									
										146
									
								
								H/dglobals.h
									
									
									
									
									
								
							@@ -1,146 +0,0 @@
 | 
			
		||||
 | 
			
		||||
  /* This file, dglobals.h, was generated automatically by "yap -L misc/buildlocalglobal"
 | 
			
		||||
     please do not update, update misc/GLOBALS instead */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_Initialised Yap_global->Initialised_
 | 
			
		||||
#define GLOBAL_InitialisedFromPL Yap_global->InitialisedFromPL_
 | 
			
		||||
#define GLOBAL_PL_Argc Yap_global->PL_Argc_
 | 
			
		||||
#define GLOBAL_PL_Argv Yap_global->PL_Argv_
 | 
			
		||||
#define GLOBAL_FAST_BOOT_FLAG Yap_global->FAST_BOOT_FLAG_
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_HaltHooks Yap_global->HaltHooks_
 | 
			
		||||
#define GLOBAL_JIT_finalizer Yap_global->JIT_finalizer_
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_AllowLocalExpansion Yap_global->AllowLocalExpansion_
 | 
			
		||||
#define GLOBAL_AllowGlobalExpansion Yap_global->AllowGlobalExpansion_
 | 
			
		||||
#define GLOBAL_AllowTrailExpansion Yap_global->AllowTrailExpansion_
 | 
			
		||||
#define GLOBAL_SizeOfOverflow Yap_global->SizeOfOverflow_
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_AGcThreshold Yap_global->AGcThreshold_
 | 
			
		||||
#define GLOBAL_AGCHook Yap_global->AGCHook_
 | 
			
		||||
#if __ANDROID__
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_assetManager Yap_global->assetManager_
 | 
			
		||||
#define GLOBAL_AssetsWD Yap_global->AssetsWD_
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if THREADS
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_NOfThreads Yap_global->NOfThreads_
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_NOfThreadsCreated Yap_global->NOfThreadsCreated_
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_ThreadsTotalTime Yap_global->ThreadsTotalTime_
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_ThreadHandlesLock Yap_global->ThreadHandlesLock_
 | 
			
		||||
#endif	
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_BGL Yap_global->BGL_
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(YAPOR) || defined(TABLING)
 | 
			
		||||
#define GLOBAL_optyap_data Yap_global->optyap_data_
 | 
			
		||||
#endif /* YAPOR || TABLING */
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_PrologShouldHandleInterrupts Yap_global->PrologShouldHandleInterrupts_
 | 
			
		||||
 | 
			
		||||
#if defined(THREADS)
 | 
			
		||||
#define GLOBAL_master_thread Yap_global->master_thread_
 | 
			
		||||
#define GLOBAL_named_mboxes Yap_global->named_mboxes_
 | 
			
		||||
#define GLOBAL_mboxq_lock Yap_global->mboxq_lock_
 | 
			
		||||
#define GLOBAL_mbox_count Yap_global->mbox_count_
 | 
			
		||||
#define GLOBAL_WithMutex Yap_global->WithMutex_
 | 
			
		||||
#endif /* THREADS */
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_Stream Yap_global->Stream_
 | 
			
		||||
#if defined(THREADS)||defined(YAPOR)
 | 
			
		||||
#define GLOBAL_StreamDescLock Yap_global->StreamDescLock_
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_argv Yap_global->argv_
 | 
			
		||||
#define GLOBAL_argc Yap_global->argc_
 | 
			
		||||
 | 
			
		||||
#ifdef COROUTINING
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_attas Yap_global->attas_
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_agc_calls Yap_global->agc_calls_
 | 
			
		||||
#define GLOBAL_agc_collected Yap_global->agc_collected_
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_tot_agc_time Yap_global->tot_agc_time_
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_tot_agc_recovered Yap_global->tot_agc_recovered_
 | 
			
		||||
 | 
			
		||||
#if HAVE_MMAP
 | 
			
		||||
#define GLOBAL_mmap_arrays Yap_global->mmap_arrays_
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_Option Yap_global->Option_
 | 
			
		||||
#define GLOBAL_logfile Yap_global->logfile_
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(COFF)  || defined(A_OUT)
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_Executable Yap_global->Executable_
 | 
			
		||||
#endif
 | 
			
		||||
#define GLOBAL_OpaqueHandlersCount Yap_global->OpaqueHandlersCount_
 | 
			
		||||
#define GLOBAL_OpaqueHandlers Yap_global->OpaqueHandlers_
 | 
			
		||||
#if  __simplescalar__
 | 
			
		||||
#define GLOBAL_pwd Yap_global->pwd_
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_RestoreFile Yap_global->RestoreFile_
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_ProfCalls Yap_global->ProfCalls_
 | 
			
		||||
#define GLOBAL_ProfGCs Yap_global->ProfGCs_
 | 
			
		||||
#define GLOBAL_ProfHGrows Yap_global->ProfHGrows_
 | 
			
		||||
#define GLOBAL_ProfSGrows Yap_global->ProfSGrows_
 | 
			
		||||
#define GLOBAL_ProfMallocs Yap_global->ProfMallocs_
 | 
			
		||||
#define GLOBAL_ProfIndexing Yap_global->ProfIndexing_
 | 
			
		||||
#define GLOBAL_ProfOn Yap_global->ProfOn_
 | 
			
		||||
#define GLOBAL_ProfOns Yap_global->ProfOns_
 | 
			
		||||
#define GLOBAL_ProfilerRoot Yap_global->ProfilerRoot_
 | 
			
		||||
#define GLOBAL_ProfilerNil Yap_global->ProfilerNil_
 | 
			
		||||
#define GLOBAL_DIRNAME Yap_global->DIRNAME_
 | 
			
		||||
#if LOW_PROF
 | 
			
		||||
#define GLOBAL_ProfilerOn Yap_global->ProfilerOn_
 | 
			
		||||
#define GLOBAL_FProf Yap_global->FProf_
 | 
			
		||||
#define GLOBAL_FPreds Yap_global->FPreds_
 | 
			
		||||
#endif /* LOW_PROF */
 | 
			
		||||
 | 
			
		||||
#if THREADS
 | 
			
		||||
#define GLOBAL_FreeMutexes Yap_global->FreeMutexes_
 | 
			
		||||
#define GLOBAL_mutex_backbone Yap_global->mutex_backbone_
 | 
			
		||||
#define GLOBAL_MUT_ACCESS Yap_global->MUT_ACCESS_
 | 
			
		||||
#endif
 | 
			
		||||
#define GLOBAL_Home Yap_global->Home_
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_CharConversionTable Yap_global->CharConversionTable_
 | 
			
		||||
#define GLOBAL_CharConversionTable2 Yap_global->CharConversionTable2_
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_LastWTimePtr Yap_global->LastWTimePtr_
 | 
			
		||||
 | 
			
		||||
#define GLOBAL_MaxPriority Yap_global->MaxPriority_
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										493
									
								
								H/dlocals.h
									
									
									
									
									
								
							
							
						
						
									
										493
									
								
								H/dlocals.h
									
									
									
									
									
								
							@@ -1,493 +0,0 @@
 | 
			
		||||
 | 
			
		||||
  /* This file, dlocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
 | 
			
		||||
     please do not update, update misc/LOCALS instead */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define LOCAL_FileAliases LOCAL->FileAliases_
 | 
			
		||||
#define REMOTE_FileAliases(wid) REMOTE(wid)->FileAliases_
 | 
			
		||||
#define LOCAL_NOfFileAliases LOCAL->NOfFileAliases_
 | 
			
		||||
#define REMOTE_NOfFileAliases(wid) REMOTE(wid)->NOfFileAliases_
 | 
			
		||||
#define LOCAL_SzOfFileAliases LOCAL->SzOfFileAliases_
 | 
			
		||||
#define REMOTE_SzOfFileAliases(wid) REMOTE(wid)->SzOfFileAliases_
 | 
			
		||||
#define LOCAL_c_input_stream LOCAL->c_input_stream_
 | 
			
		||||
#define REMOTE_c_input_stream(wid) REMOTE(wid)->c_input_stream_
 | 
			
		||||
#define LOCAL_c_output_stream LOCAL->c_output_stream_
 | 
			
		||||
#define REMOTE_c_output_stream(wid) REMOTE(wid)->c_output_stream_
 | 
			
		||||
#define LOCAL_c_error_stream LOCAL->c_error_stream_
 | 
			
		||||
#define REMOTE_c_error_stream(wid) REMOTE(wid)->c_error_stream_
 | 
			
		||||
#define LOCAL_sockets_io LOCAL->sockets_io_
 | 
			
		||||
#define REMOTE_sockets_io(wid) REMOTE(wid)->sockets_io_
 | 
			
		||||
#define LOCAL_within_print_message LOCAL->within_print_message_
 | 
			
		||||
#define REMOTE_within_print_message(wid) REMOTE(wid)->within_print_message_
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define LOCAL_newline LOCAL->newline_
 | 
			
		||||
#define REMOTE_newline(wid) REMOTE(wid)->newline_
 | 
			
		||||
#define LOCAL_AtPrompt LOCAL->AtPrompt_
 | 
			
		||||
#define REMOTE_AtPrompt(wid) REMOTE(wid)->AtPrompt_
 | 
			
		||||
#define LOCAL_Prompt LOCAL->Prompt_
 | 
			
		||||
#define REMOTE_Prompt(wid) REMOTE(wid)->Prompt_
 | 
			
		||||
#define LOCAL_encoding LOCAL->encoding_
 | 
			
		||||
#define REMOTE_encoding(wid) REMOTE(wid)->encoding_
 | 
			
		||||
#define LOCAL_quasi_quotations LOCAL->quasi_quotations_
 | 
			
		||||
#define REMOTE_quasi_quotations(wid) REMOTE(wid)->quasi_quotations_
 | 
			
		||||
#define LOCAL_default_priority LOCAL->default_priority_
 | 
			
		||||
#define REMOTE_default_priority(wid) REMOTE(wid)->default_priority_
 | 
			
		||||
#define LOCAL_eot_before_eof LOCAL->eot_before_eof_
 | 
			
		||||
#define REMOTE_eot_before_eof(wid) REMOTE(wid)->eot_before_eof_
 | 
			
		||||
#define LOCAL_max_depth LOCAL->max_depth_
 | 
			
		||||
#define REMOTE_max_depth(wid) REMOTE(wid)->max_depth_
 | 
			
		||||
#define LOCAL_max_list LOCAL->max_list_
 | 
			
		||||
#define REMOTE_max_list(wid) REMOTE(wid)->max_list_
 | 
			
		||||
#define LOCAL_max_write_args LOCAL->max_write_args_
 | 
			
		||||
#define REMOTE_max_write_args(wid) REMOTE(wid)->max_write_args_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_OldASP LOCAL->OldASP_
 | 
			
		||||
#define REMOTE_OldASP(wid) REMOTE(wid)->OldASP_
 | 
			
		||||
#define LOCAL_OldLCL0 LOCAL->OldLCL0_
 | 
			
		||||
#define REMOTE_OldLCL0(wid) REMOTE(wid)->OldLCL0_
 | 
			
		||||
#define LOCAL_OldTR LOCAL->OldTR_
 | 
			
		||||
#define REMOTE_OldTR(wid) REMOTE(wid)->OldTR_
 | 
			
		||||
#define LOCAL_OldGlobalBase LOCAL->OldGlobalBase_
 | 
			
		||||
#define REMOTE_OldGlobalBase(wid) REMOTE(wid)->OldGlobalBase_
 | 
			
		||||
#define LOCAL_OldH LOCAL->OldH_
 | 
			
		||||
#define REMOTE_OldH(wid) REMOTE(wid)->OldH_
 | 
			
		||||
#define LOCAL_OldH0 LOCAL->OldH0_
 | 
			
		||||
#define REMOTE_OldH0(wid) REMOTE(wid)->OldH0_
 | 
			
		||||
#define LOCAL_OldTrailBase LOCAL->OldTrailBase_
 | 
			
		||||
#define REMOTE_OldTrailBase(wid) REMOTE(wid)->OldTrailBase_
 | 
			
		||||
#define LOCAL_OldTrailTop LOCAL->OldTrailTop_
 | 
			
		||||
#define REMOTE_OldTrailTop(wid) REMOTE(wid)->OldTrailTop_
 | 
			
		||||
#define LOCAL_OldHeapBase LOCAL->OldHeapBase_
 | 
			
		||||
#define REMOTE_OldHeapBase(wid) REMOTE(wid)->OldHeapBase_
 | 
			
		||||
#define LOCAL_OldHeapTop LOCAL->OldHeapTop_
 | 
			
		||||
#define REMOTE_OldHeapTop(wid) REMOTE(wid)->OldHeapTop_
 | 
			
		||||
#define LOCAL_ClDiff LOCAL->ClDiff_
 | 
			
		||||
#define REMOTE_ClDiff(wid) REMOTE(wid)->ClDiff_
 | 
			
		||||
#define LOCAL_GDiff LOCAL->GDiff_
 | 
			
		||||
#define REMOTE_GDiff(wid) REMOTE(wid)->GDiff_
 | 
			
		||||
#define LOCAL_HDiff LOCAL->HDiff_
 | 
			
		||||
#define REMOTE_HDiff(wid) REMOTE(wid)->HDiff_
 | 
			
		||||
#define LOCAL_GDiff0 LOCAL->GDiff0_
 | 
			
		||||
#define REMOTE_GDiff0(wid) REMOTE(wid)->GDiff0_
 | 
			
		||||
#define LOCAL_GSplit LOCAL->GSplit_
 | 
			
		||||
#define REMOTE_GSplit(wid) REMOTE(wid)->GSplit_
 | 
			
		||||
#define LOCAL_LDiff LOCAL->LDiff_
 | 
			
		||||
#define REMOTE_LDiff(wid) REMOTE(wid)->LDiff_
 | 
			
		||||
#define LOCAL_TrDiff LOCAL->TrDiff_
 | 
			
		||||
#define REMOTE_TrDiff(wid) REMOTE(wid)->TrDiff_
 | 
			
		||||
#define LOCAL_XDiff LOCAL->XDiff_
 | 
			
		||||
#define REMOTE_XDiff(wid) REMOTE(wid)->XDiff_
 | 
			
		||||
#define LOCAL_DelayDiff LOCAL->DelayDiff_
 | 
			
		||||
#define REMOTE_DelayDiff(wid) REMOTE(wid)->DelayDiff_
 | 
			
		||||
#define LOCAL_BaseDiff LOCAL->BaseDiff_
 | 
			
		||||
#define REMOTE_BaseDiff(wid) REMOTE(wid)->BaseDiff_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_ReductionsCounter LOCAL->ReductionsCounter_
 | 
			
		||||
#define REMOTE_ReductionsCounter(wid) REMOTE(wid)->ReductionsCounter_
 | 
			
		||||
#define LOCAL_PredEntriesCounter LOCAL->PredEntriesCounter_
 | 
			
		||||
#define REMOTE_PredEntriesCounter(wid) REMOTE(wid)->PredEntriesCounter_
 | 
			
		||||
#define LOCAL_RetriesCounter LOCAL->RetriesCounter_
 | 
			
		||||
#define REMOTE_RetriesCounter(wid) REMOTE(wid)->RetriesCounter_
 | 
			
		||||
#define LOCAL_ReductionsCounterOn LOCAL->ReductionsCounterOn_
 | 
			
		||||
#define REMOTE_ReductionsCounterOn(wid) REMOTE(wid)->ReductionsCounterOn_
 | 
			
		||||
#define LOCAL_PredEntriesCounterOn LOCAL->PredEntriesCounterOn_
 | 
			
		||||
#define REMOTE_PredEntriesCounterOn(wid) REMOTE(wid)->PredEntriesCounterOn_
 | 
			
		||||
#define LOCAL_RetriesCounterOn LOCAL->RetriesCounterOn_
 | 
			
		||||
#define REMOTE_RetriesCounterOn(wid) REMOTE(wid)->RetriesCounterOn_
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define LOCAL_ConsultSp LOCAL->ConsultSp_
 | 
			
		||||
#define REMOTE_ConsultSp(wid) REMOTE(wid)->ConsultSp_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_ConsultCapacity LOCAL->ConsultCapacity_
 | 
			
		||||
#define REMOTE_ConsultCapacity(wid) REMOTE(wid)->ConsultCapacity_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_ConsultBase LOCAL->ConsultBase_
 | 
			
		||||
#define REMOTE_ConsultBase(wid) REMOTE(wid)->ConsultBase_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_ConsultLow LOCAL->ConsultLow_
 | 
			
		||||
#define REMOTE_ConsultLow(wid) REMOTE(wid)->ConsultLow_
 | 
			
		||||
#define LOCAL_VarNames LOCAL->VarNames_
 | 
			
		||||
#define REMOTE_VarNames(wid) REMOTE(wid)->VarNames_
 | 
			
		||||
#define LOCAL_SourceFileName LOCAL->SourceFileName_
 | 
			
		||||
#define REMOTE_SourceFileName(wid) REMOTE(wid)->SourceFileName_
 | 
			
		||||
#define LOCAL_SourceFileLineno LOCAL->SourceFileLineno_
 | 
			
		||||
#define REMOTE_SourceFileLineno(wid) REMOTE(wid)->SourceFileLineno_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_GlobalArena LOCAL->GlobalArena_
 | 
			
		||||
#define REMOTE_GlobalArena(wid) REMOTE(wid)->GlobalArena_
 | 
			
		||||
#define LOCAL_GlobalArenaOverflows LOCAL->GlobalArenaOverflows_
 | 
			
		||||
#define REMOTE_GlobalArenaOverflows(wid) REMOTE(wid)->GlobalArenaOverflows_
 | 
			
		||||
#define LOCAL_ArenaOverflows LOCAL->ArenaOverflows_
 | 
			
		||||
#define REMOTE_ArenaOverflows(wid) REMOTE(wid)->ArenaOverflows_
 | 
			
		||||
#define LOCAL_DepthArenas LOCAL->DepthArenas_
 | 
			
		||||
#define REMOTE_DepthArenas(wid) REMOTE(wid)->DepthArenas_
 | 
			
		||||
#define LOCAL_ArithError LOCAL->ArithError_
 | 
			
		||||
#define REMOTE_ArithError(wid) REMOTE(wid)->ArithError_
 | 
			
		||||
#define LOCAL_LastAssertedPred LOCAL->LastAssertedPred_
 | 
			
		||||
#define REMOTE_LastAssertedPred(wid) REMOTE(wid)->LastAssertedPred_
 | 
			
		||||
#define LOCAL_TmpPred LOCAL->TmpPred_
 | 
			
		||||
#define REMOTE_TmpPred(wid) REMOTE(wid)->TmpPred_
 | 
			
		||||
#define LOCAL_ScannerStack LOCAL->ScannerStack_
 | 
			
		||||
#define REMOTE_ScannerStack(wid) REMOTE(wid)->ScannerStack_
 | 
			
		||||
#define LOCAL_ScannerExtraBlocks LOCAL->ScannerExtraBlocks_
 | 
			
		||||
#define REMOTE_ScannerExtraBlocks(wid) REMOTE(wid)->ScannerExtraBlocks_
 | 
			
		||||
#define LOCAL_BallTerm LOCAL->BallTerm_
 | 
			
		||||
#define REMOTE_BallTerm(wid) REMOTE(wid)->BallTerm_
 | 
			
		||||
#define LOCAL_MaxActiveSignals LOCAL->MaxActiveSignals_
 | 
			
		||||
#define REMOTE_MaxActiveSignals(wid) REMOTE(wid)->MaxActiveSignals_
 | 
			
		||||
#define LOCAL_Signals LOCAL->Signals_
 | 
			
		||||
#define REMOTE_Signals(wid) REMOTE(wid)->Signals_
 | 
			
		||||
#define LOCAL_IPredArity LOCAL->IPredArity_
 | 
			
		||||
#define REMOTE_IPredArity(wid) REMOTE(wid)->IPredArity_
 | 
			
		||||
#define LOCAL_ProfEnd LOCAL->ProfEnd_
 | 
			
		||||
#define REMOTE_ProfEnd(wid) REMOTE(wid)->ProfEnd_
 | 
			
		||||
#define LOCAL_UncaughtThrow LOCAL->UncaughtThrow_
 | 
			
		||||
#define REMOTE_UncaughtThrow(wid) REMOTE(wid)->UncaughtThrow_
 | 
			
		||||
#define LOCAL_DoingUndefp LOCAL->DoingUndefp_
 | 
			
		||||
#define REMOTE_DoingUndefp(wid) REMOTE(wid)->DoingUndefp_
 | 
			
		||||
#define LOCAL_StartCharCount LOCAL->StartCharCount_
 | 
			
		||||
#define REMOTE_StartCharCount(wid) REMOTE(wid)->StartCharCount_
 | 
			
		||||
#define LOCAL_StartLineCount LOCAL->StartLineCount_
 | 
			
		||||
#define REMOTE_StartLineCount(wid) REMOTE(wid)->StartLineCount_
 | 
			
		||||
#define LOCAL_StartLinePos LOCAL->StartLinePos_
 | 
			
		||||
#define REMOTE_StartLinePos(wid) REMOTE(wid)->StartLinePos_
 | 
			
		||||
#define LOCAL_ScratchPad LOCAL->ScratchPad_
 | 
			
		||||
#define REMOTE_ScratchPad(wid) REMOTE(wid)->ScratchPad_
 | 
			
		||||
#ifdef  COROUTINING
 | 
			
		||||
#define LOCAL_WokenGoals LOCAL->WokenGoals_
 | 
			
		||||
#define REMOTE_WokenGoals(wid) REMOTE(wid)->WokenGoals_
 | 
			
		||||
#define LOCAL_AttsMutableList LOCAL->AttsMutableList_
 | 
			
		||||
#define REMOTE_AttsMutableList(wid) REMOTE(wid)->AttsMutableList_
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define LOCAL_GcGeneration LOCAL->GcGeneration_
 | 
			
		||||
#define REMOTE_GcGeneration(wid) REMOTE(wid)->GcGeneration_
 | 
			
		||||
#define LOCAL_GcPhase LOCAL->GcPhase_
 | 
			
		||||
#define REMOTE_GcPhase(wid) REMOTE(wid)->GcPhase_
 | 
			
		||||
#define LOCAL_GcCurrentPhase LOCAL->GcCurrentPhase_
 | 
			
		||||
#define REMOTE_GcCurrentPhase(wid) REMOTE(wid)->GcCurrentPhase_
 | 
			
		||||
#define LOCAL_GcCalls LOCAL->GcCalls_
 | 
			
		||||
#define REMOTE_GcCalls(wid) REMOTE(wid)->GcCalls_
 | 
			
		||||
#define LOCAL_TotGcTime LOCAL->TotGcTime_
 | 
			
		||||
#define REMOTE_TotGcTime(wid) REMOTE(wid)->TotGcTime_
 | 
			
		||||
#define LOCAL_TotGcRecovered LOCAL->TotGcRecovered_
 | 
			
		||||
#define REMOTE_TotGcRecovered(wid) REMOTE(wid)->TotGcRecovered_
 | 
			
		||||
#define LOCAL_LastGcTime LOCAL->LastGcTime_
 | 
			
		||||
#define REMOTE_LastGcTime(wid) REMOTE(wid)->LastGcTime_
 | 
			
		||||
#define LOCAL_LastSSTime LOCAL->LastSSTime_
 | 
			
		||||
#define REMOTE_LastSSTime(wid) REMOTE(wid)->LastSSTime_
 | 
			
		||||
#define LOCAL_OpenArray LOCAL->OpenArray_
 | 
			
		||||
#define REMOTE_OpenArray(wid) REMOTE(wid)->OpenArray_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_total_marked LOCAL->total_marked_
 | 
			
		||||
#define REMOTE_total_marked(wid) REMOTE(wid)->total_marked_
 | 
			
		||||
#define LOCAL_total_oldies LOCAL->total_oldies_
 | 
			
		||||
#define REMOTE_total_oldies(wid) REMOTE(wid)->total_oldies_
 | 
			
		||||
#define LOCAL_current_B LOCAL->current_B_
 | 
			
		||||
#define REMOTE_current_B(wid) REMOTE(wid)->current_B_
 | 
			
		||||
#define LOCAL_prev_HB LOCAL->prev_HB_
 | 
			
		||||
#define REMOTE_prev_HB(wid) REMOTE(wid)->prev_HB_
 | 
			
		||||
#define LOCAL_HGEN LOCAL->HGEN_
 | 
			
		||||
#define REMOTE_HGEN(wid) REMOTE(wid)->HGEN_
 | 
			
		||||
#define LOCAL_iptop LOCAL->iptop_
 | 
			
		||||
#define REMOTE_iptop(wid) REMOTE(wid)->iptop_
 | 
			
		||||
#if defined(GC_NO_TAGS)
 | 
			
		||||
#define LOCAL_bp LOCAL->bp_
 | 
			
		||||
#define REMOTE_bp(wid) REMOTE(wid)->bp_
 | 
			
		||||
#endif
 | 
			
		||||
#define LOCAL_sTR LOCAL->sTR_
 | 
			
		||||
#define REMOTE_sTR(wid) REMOTE(wid)->sTR_
 | 
			
		||||
#define LOCAL_sTR0 LOCAL->sTR0_
 | 
			
		||||
#define REMOTE_sTR0(wid) REMOTE(wid)->sTR0_
 | 
			
		||||
#define LOCAL_new_TR LOCAL->new_TR_
 | 
			
		||||
#define REMOTE_new_TR(wid) REMOTE(wid)->new_TR_
 | 
			
		||||
#define LOCAL_cont_top0 LOCAL->cont_top0_
 | 
			
		||||
#define REMOTE_cont_top0(wid) REMOTE(wid)->cont_top0_
 | 
			
		||||
#define LOCAL_cont_top LOCAL->cont_top_
 | 
			
		||||
#define REMOTE_cont_top(wid) REMOTE(wid)->cont_top_
 | 
			
		||||
#define LOCAL_discard_trail_entries LOCAL->discard_trail_entries_
 | 
			
		||||
#define REMOTE_discard_trail_entries(wid) REMOTE(wid)->discard_trail_entries_
 | 
			
		||||
#define LOCAL_gc_ma_hash_table LOCAL->gc_ma_hash_table_
 | 
			
		||||
#define REMOTE_gc_ma_hash_table(wid) REMOTE(wid)->gc_ma_hash_table_
 | 
			
		||||
#define LOCAL_gc_ma_h_top LOCAL->gc_ma_h_top_
 | 
			
		||||
#define REMOTE_gc_ma_h_top(wid) REMOTE(wid)->gc_ma_h_top_
 | 
			
		||||
#define LOCAL_gc_ma_h_list LOCAL->gc_ma_h_list_
 | 
			
		||||
#define REMOTE_gc_ma_h_list(wid) REMOTE(wid)->gc_ma_h_list_
 | 
			
		||||
#define LOCAL_gc_timestamp LOCAL->gc_timestamp_
 | 
			
		||||
#define REMOTE_gc_timestamp(wid) REMOTE(wid)->gc_timestamp_
 | 
			
		||||
#define LOCAL_db_vec LOCAL->db_vec_
 | 
			
		||||
#define REMOTE_db_vec(wid) REMOTE(wid)->db_vec_
 | 
			
		||||
#define LOCAL_db_vec0 LOCAL->db_vec0_
 | 
			
		||||
#define REMOTE_db_vec0(wid) REMOTE(wid)->db_vec0_
 | 
			
		||||
#define LOCAL_db_root LOCAL->db_root_
 | 
			
		||||
#define REMOTE_db_root(wid) REMOTE(wid)->db_root_
 | 
			
		||||
#define LOCAL_db_nil LOCAL->db_nil_
 | 
			
		||||
#define REMOTE_db_nil(wid) REMOTE(wid)->db_nil_
 | 
			
		||||
#define LOCAL_gc_restore LOCAL->gc_restore_
 | 
			
		||||
#define REMOTE_gc_restore(wid) REMOTE(wid)->gc_restore_
 | 
			
		||||
#define LOCAL_extra_gc_cells LOCAL->extra_gc_cells_
 | 
			
		||||
#define REMOTE_extra_gc_cells(wid) REMOTE(wid)->extra_gc_cells_
 | 
			
		||||
#define LOCAL_extra_gc_cells_base LOCAL->extra_gc_cells_base_
 | 
			
		||||
#define REMOTE_extra_gc_cells_base(wid) REMOTE(wid)->extra_gc_cells_base_
 | 
			
		||||
#define LOCAL_extra_gc_cells_top LOCAL->extra_gc_cells_top_
 | 
			
		||||
#define REMOTE_extra_gc_cells_top(wid) REMOTE(wid)->extra_gc_cells_top_
 | 
			
		||||
#define LOCAL_extra_gc_cells_size LOCAL->extra_gc_cells_size_
 | 
			
		||||
#define REMOTE_extra_gc_cells_size(wid) REMOTE(wid)->extra_gc_cells_size_
 | 
			
		||||
#define LOCAL_DynamicArrays LOCAL->DynamicArrays_
 | 
			
		||||
#define REMOTE_DynamicArrays(wid) REMOTE(wid)->DynamicArrays_
 | 
			
		||||
#define LOCAL_StaticArrays LOCAL->StaticArrays_
 | 
			
		||||
#define REMOTE_StaticArrays(wid) REMOTE(wid)->StaticArrays_
 | 
			
		||||
#define LOCAL_GlobalVariables LOCAL->GlobalVariables_
 | 
			
		||||
#define REMOTE_GlobalVariables(wid) REMOTE(wid)->GlobalVariables_
 | 
			
		||||
#define LOCAL_AllowRestart LOCAL->AllowRestart_
 | 
			
		||||
#define REMOTE_AllowRestart(wid) REMOTE(wid)->AllowRestart_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_CMemFirstBlock LOCAL->CMemFirstBlock_
 | 
			
		||||
#define REMOTE_CMemFirstBlock(wid) REMOTE(wid)->CMemFirstBlock_
 | 
			
		||||
#define LOCAL_CMemFirstBlockSz LOCAL->CMemFirstBlockSz_
 | 
			
		||||
#define REMOTE_CMemFirstBlockSz(wid) REMOTE(wid)->CMemFirstBlockSz_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_nperm LOCAL->nperm_
 | 
			
		||||
#define REMOTE_nperm(wid) REMOTE(wid)->nperm_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_LabelFirstArray LOCAL->LabelFirstArray_
 | 
			
		||||
#define REMOTE_LabelFirstArray(wid) REMOTE(wid)->LabelFirstArray_
 | 
			
		||||
#define LOCAL_LabelFirstArraySz LOCAL->LabelFirstArraySz_
 | 
			
		||||
#define REMOTE_LabelFirstArraySz(wid) REMOTE(wid)->LabelFirstArraySz_
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef THREADS
 | 
			
		||||
#define LOCAL_ThreadHandle LOCAL->ThreadHandle_
 | 
			
		||||
#define REMOTE_ThreadHandle(wid) REMOTE(wid)->ThreadHandle_
 | 
			
		||||
#endif /* THREADS */
 | 
			
		||||
#if defined(YAPOR) || defined(TABLING)
 | 
			
		||||
#define LOCAL_optyap_data LOCAL->optyap_data_
 | 
			
		||||
#define REMOTE_optyap_data(wid) REMOTE(wid)->optyap_data_
 | 
			
		||||
#define LOCAL_TabMode LOCAL->TabMode_
 | 
			
		||||
#define REMOTE_TabMode(wid) REMOTE(wid)->TabMode_
 | 
			
		||||
#endif /* YAPOR || TABLING */
 | 
			
		||||
#define LOCAL_InterruptsDisabled LOCAL->InterruptsDisabled_
 | 
			
		||||
#define REMOTE_InterruptsDisabled(wid) REMOTE(wid)->InterruptsDisabled_
 | 
			
		||||
#define LOCAL_execution LOCAL->execution_
 | 
			
		||||
#define REMOTE_execution(wid) REMOTE(wid)->execution_
 | 
			
		||||
#if LOW_LEVEL_TRACER
 | 
			
		||||
#define LOCAL_total_choicepoints LOCAL->total_choicepoints_
 | 
			
		||||
#define REMOTE_total_choicepoints(wid) REMOTE(wid)->total_choicepoints_
 | 
			
		||||
#endif
 | 
			
		||||
#define LOCAL_consult_level LOCAL->consult_level_
 | 
			
		||||
#define REMOTE_consult_level(wid) REMOTE(wid)->consult_level_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_LocalBase LOCAL->LocalBase_
 | 
			
		||||
#define REMOTE_LocalBase(wid) REMOTE(wid)->LocalBase_
 | 
			
		||||
#define LOCAL_GlobalBase LOCAL->GlobalBase_
 | 
			
		||||
#define REMOTE_GlobalBase(wid) REMOTE(wid)->GlobalBase_
 | 
			
		||||
#define LOCAL_TrailBase LOCAL->TrailBase_
 | 
			
		||||
#define REMOTE_TrailBase(wid) REMOTE(wid)->TrailBase_
 | 
			
		||||
#define LOCAL_TrailTop LOCAL->TrailTop_
 | 
			
		||||
#define REMOTE_TrailTop(wid) REMOTE(wid)->TrailTop_
 | 
			
		||||
#define LOCAL_ErrorMessage LOCAL->ErrorMessage_
 | 
			
		||||
#define REMOTE_ErrorMessage(wid) REMOTE(wid)->ErrorMessage_
 | 
			
		||||
#define LOCAL_Error_Term LOCAL->Error_Term_
 | 
			
		||||
#define REMOTE_Error_Term(wid) REMOTE(wid)->Error_Term_
 | 
			
		||||
#define LOCAL_Error_TYPE LOCAL->Error_TYPE_
 | 
			
		||||
#define REMOTE_Error_TYPE(wid) REMOTE(wid)->Error_TYPE_
 | 
			
		||||
#define LOCAL_Error_File LOCAL->Error_File_
 | 
			
		||||
#define REMOTE_Error_File(wid) REMOTE(wid)->Error_File_
 | 
			
		||||
#define LOCAL_Error_Function LOCAL->Error_Function_
 | 
			
		||||
#define REMOTE_Error_Function(wid) REMOTE(wid)->Error_Function_
 | 
			
		||||
#define LOCAL_Error_Lineno LOCAL->Error_Lineno_
 | 
			
		||||
#define REMOTE_Error_Lineno(wid) REMOTE(wid)->Error_Lineno_
 | 
			
		||||
#define LOCAL_Error_Size LOCAL->Error_Size_
 | 
			
		||||
#define REMOTE_Error_Size(wid) REMOTE(wid)->Error_Size_
 | 
			
		||||
#define LOCAL_ErrorSay LOCAL->ErrorSay_
 | 
			
		||||
#define REMOTE_ErrorSay(wid) REMOTE(wid)->ErrorSay_
 | 
			
		||||
#define LOCAL_IOBotch LOCAL->IOBotch_
 | 
			
		||||
#define REMOTE_IOBotch(wid) REMOTE(wid)->IOBotch_
 | 
			
		||||
#define LOCAL_tokptr LOCAL->tokptr_
 | 
			
		||||
#define REMOTE_tokptr(wid) REMOTE(wid)->tokptr_
 | 
			
		||||
#define LOCAL_toktide LOCAL->toktide_
 | 
			
		||||
#define REMOTE_toktide(wid) REMOTE(wid)->toktide_
 | 
			
		||||
#define LOCAL_VarTable LOCAL->VarTable_
 | 
			
		||||
#define REMOTE_VarTable(wid) REMOTE(wid)->VarTable_
 | 
			
		||||
#define LOCAL_AnonVarTable LOCAL->AnonVarTable_
 | 
			
		||||
#define REMOTE_AnonVarTable(wid) REMOTE(wid)->AnonVarTable_
 | 
			
		||||
#define LOCAL_Comments LOCAL->Comments_
 | 
			
		||||
#define REMOTE_Comments(wid) REMOTE(wid)->Comments_
 | 
			
		||||
#define LOCAL_CommentsTail LOCAL->CommentsTail_
 | 
			
		||||
#define REMOTE_CommentsTail(wid) REMOTE(wid)->CommentsTail_
 | 
			
		||||
#define LOCAL_CommentsNextChar LOCAL->CommentsNextChar_
 | 
			
		||||
#define REMOTE_CommentsNextChar(wid) REMOTE(wid)->CommentsNextChar_
 | 
			
		||||
#define LOCAL_CommentsBuff LOCAL->CommentsBuff_
 | 
			
		||||
#define REMOTE_CommentsBuff(wid) REMOTE(wid)->CommentsBuff_
 | 
			
		||||
#define LOCAL_CommentsBuffPos LOCAL->CommentsBuffPos_
 | 
			
		||||
#define REMOTE_CommentsBuffPos(wid) REMOTE(wid)->CommentsBuffPos_
 | 
			
		||||
#define LOCAL_CommentsBuffLim LOCAL->CommentsBuffLim_
 | 
			
		||||
#define REMOTE_CommentsBuffLim(wid) REMOTE(wid)->CommentsBuffLim_
 | 
			
		||||
#define LOCAL_RestartEnv LOCAL->RestartEnv_
 | 
			
		||||
#define REMOTE_RestartEnv(wid) REMOTE(wid)->RestartEnv_
 | 
			
		||||
#define LOCAL_FileNameBuf LOCAL->FileNameBuf_
 | 
			
		||||
#define REMOTE_FileNameBuf(wid) REMOTE(wid)->FileNameBuf_
 | 
			
		||||
#define LOCAL_FileNameBuf2 LOCAL->FileNameBuf2_
 | 
			
		||||
#define REMOTE_FileNameBuf2(wid) REMOTE(wid)->FileNameBuf2_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_BreakLevel LOCAL->BreakLevel_
 | 
			
		||||
#define REMOTE_BreakLevel(wid) REMOTE(wid)->BreakLevel_
 | 
			
		||||
#define LOCAL_PrologMode LOCAL->PrologMode_
 | 
			
		||||
#define REMOTE_PrologMode(wid) REMOTE(wid)->PrologMode_
 | 
			
		||||
#define LOCAL_CritLocks LOCAL->CritLocks_
 | 
			
		||||
#define REMOTE_CritLocks(wid) REMOTE(wid)->CritLocks_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_Flags LOCAL->Flags_
 | 
			
		||||
#define REMOTE_Flags(wid) REMOTE(wid)->Flags_
 | 
			
		||||
#define LOCAL_flagCount LOCAL->flagCount_
 | 
			
		||||
#define REMOTE_flagCount(wid) REMOTE(wid)->flagCount_
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef ANALYST
 | 
			
		||||
#define LOCAL_opcount LOCAL->opcount_
 | 
			
		||||
#define REMOTE_opcount(wid) REMOTE(wid)->opcount_
 | 
			
		||||
#define LOCAL_2opcount LOCAL->2opcount_
 | 
			
		||||
#define REMOTE_2opcount(wid) REMOTE(wid)->2opcount_
 | 
			
		||||
#endif /* ANALYST */
 | 
			
		||||
 | 
			
		||||
#define LOCAL_s_dbg LOCAL->s_dbg_
 | 
			
		||||
#define REMOTE_s_dbg(wid) REMOTE(wid)->s_dbg_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_matherror LOCAL->matherror_
 | 
			
		||||
#define REMOTE_matherror(wid) REMOTE(wid)->matherror_
 | 
			
		||||
#define LOCAL_mathtt LOCAL->mathtt_
 | 
			
		||||
#define REMOTE_mathtt(wid) REMOTE(wid)->mathtt_
 | 
			
		||||
#define LOCAL_mathstring LOCAL->mathstring_
 | 
			
		||||
#define REMOTE_mathstring(wid) REMOTE(wid)->mathstring_
 | 
			
		||||
#define LOCAL_CurrentError LOCAL->CurrentError_
 | 
			
		||||
#define REMOTE_CurrentError(wid) REMOTE(wid)->CurrentError_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_heap_overflows LOCAL->heap_overflows_
 | 
			
		||||
#define REMOTE_heap_overflows(wid) REMOTE(wid)->heap_overflows_
 | 
			
		||||
#define LOCAL_total_heap_overflow_time LOCAL->total_heap_overflow_time_
 | 
			
		||||
#define REMOTE_total_heap_overflow_time(wid) REMOTE(wid)->total_heap_overflow_time_
 | 
			
		||||
#define LOCAL_stack_overflows LOCAL->stack_overflows_
 | 
			
		||||
#define REMOTE_stack_overflows(wid) REMOTE(wid)->stack_overflows_
 | 
			
		||||
#define LOCAL_total_stack_overflow_time LOCAL->total_stack_overflow_time_
 | 
			
		||||
#define REMOTE_total_stack_overflow_time(wid) REMOTE(wid)->total_stack_overflow_time_
 | 
			
		||||
#define LOCAL_delay_overflows LOCAL->delay_overflows_
 | 
			
		||||
#define REMOTE_delay_overflows(wid) REMOTE(wid)->delay_overflows_
 | 
			
		||||
#define LOCAL_total_delay_overflow_time LOCAL->total_delay_overflow_time_
 | 
			
		||||
#define REMOTE_total_delay_overflow_time(wid) REMOTE(wid)->total_delay_overflow_time_
 | 
			
		||||
#define LOCAL_trail_overflows LOCAL->trail_overflows_
 | 
			
		||||
#define REMOTE_trail_overflows(wid) REMOTE(wid)->trail_overflows_
 | 
			
		||||
#define LOCAL_total_trail_overflow_time LOCAL->total_trail_overflow_time_
 | 
			
		||||
#define REMOTE_total_trail_overflow_time(wid) REMOTE(wid)->total_trail_overflow_time_
 | 
			
		||||
#define LOCAL_atom_table_overflows LOCAL->atom_table_overflows_
 | 
			
		||||
#define REMOTE_atom_table_overflows(wid) REMOTE(wid)->atom_table_overflows_
 | 
			
		||||
#define LOCAL_total_atom_table_overflow_time LOCAL->total_atom_table_overflow_time_
 | 
			
		||||
#define REMOTE_total_atom_table_overflow_time(wid) REMOTE(wid)->total_atom_table_overflow_time_
 | 
			
		||||
 | 
			
		||||
#ifdef LOAD_DYLD
 | 
			
		||||
#define LOCAL_dl_errno LOCAL->dl_errno_
 | 
			
		||||
#define REMOTE_dl_errno(wid) REMOTE(wid)->dl_errno_
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef LOW_LEVEL_TRACER
 | 
			
		||||
#define LOCAL_do_trace_primitives LOCAL->do_trace_primitives_
 | 
			
		||||
#define REMOTE_do_trace_primitives(wid) REMOTE(wid)->do_trace_primitives_
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define LOCAL_ExportAtomHashChain LOCAL->ExportAtomHashChain_
 | 
			
		||||
#define REMOTE_ExportAtomHashChain(wid) REMOTE(wid)->ExportAtomHashChain_
 | 
			
		||||
#define LOCAL_ExportAtomHashTableSize LOCAL->ExportAtomHashTableSize_
 | 
			
		||||
#define REMOTE_ExportAtomHashTableSize(wid) REMOTE(wid)->ExportAtomHashTableSize_
 | 
			
		||||
#define LOCAL_ExportAtomHashTableNum LOCAL->ExportAtomHashTableNum_
 | 
			
		||||
#define REMOTE_ExportAtomHashTableNum(wid) REMOTE(wid)->ExportAtomHashTableNum_
 | 
			
		||||
#define LOCAL_ExportFunctorHashChain LOCAL->ExportFunctorHashChain_
 | 
			
		||||
#define REMOTE_ExportFunctorHashChain(wid) REMOTE(wid)->ExportFunctorHashChain_
 | 
			
		||||
#define LOCAL_ExportFunctorHashTableSize LOCAL->ExportFunctorHashTableSize_
 | 
			
		||||
#define REMOTE_ExportFunctorHashTableSize(wid) REMOTE(wid)->ExportFunctorHashTableSize_
 | 
			
		||||
#define LOCAL_ExportFunctorHashTableNum LOCAL->ExportFunctorHashTableNum_
 | 
			
		||||
#define REMOTE_ExportFunctorHashTableNum(wid) REMOTE(wid)->ExportFunctorHashTableNum_
 | 
			
		||||
#define LOCAL_ExportPredEntryHashChain LOCAL->ExportPredEntryHashChain_
 | 
			
		||||
#define REMOTE_ExportPredEntryHashChain(wid) REMOTE(wid)->ExportPredEntryHashChain_
 | 
			
		||||
#define LOCAL_ExportPredEntryHashTableSize LOCAL->ExportPredEntryHashTableSize_
 | 
			
		||||
#define REMOTE_ExportPredEntryHashTableSize(wid) REMOTE(wid)->ExportPredEntryHashTableSize_
 | 
			
		||||
#define LOCAL_ExportPredEntryHashTableNum LOCAL->ExportPredEntryHashTableNum_
 | 
			
		||||
#define REMOTE_ExportPredEntryHashTableNum(wid) REMOTE(wid)->ExportPredEntryHashTableNum_
 | 
			
		||||
#define LOCAL_ExportDBRefHashChain LOCAL->ExportDBRefHashChain_
 | 
			
		||||
#define REMOTE_ExportDBRefHashChain(wid) REMOTE(wid)->ExportDBRefHashChain_
 | 
			
		||||
#define LOCAL_ExportDBRefHashTableSize LOCAL->ExportDBRefHashTableSize_
 | 
			
		||||
#define REMOTE_ExportDBRefHashTableSize(wid) REMOTE(wid)->ExportDBRefHashTableSize_
 | 
			
		||||
#define LOCAL_ExportDBRefHashTableNum LOCAL->ExportDBRefHashTableNum_
 | 
			
		||||
#define REMOTE_ExportDBRefHashTableNum(wid) REMOTE(wid)->ExportDBRefHashTableNum_
 | 
			
		||||
#define LOCAL_ImportAtomHashChain LOCAL->ImportAtomHashChain_
 | 
			
		||||
#define REMOTE_ImportAtomHashChain(wid) REMOTE(wid)->ImportAtomHashChain_
 | 
			
		||||
#define LOCAL_ImportAtomHashTableSize LOCAL->ImportAtomHashTableSize_
 | 
			
		||||
#define REMOTE_ImportAtomHashTableSize(wid) REMOTE(wid)->ImportAtomHashTableSize_
 | 
			
		||||
#define LOCAL_ImportAtomHashTableNum LOCAL->ImportAtomHashTableNum_
 | 
			
		||||
#define REMOTE_ImportAtomHashTableNum(wid) REMOTE(wid)->ImportAtomHashTableNum_
 | 
			
		||||
#define LOCAL_ImportFunctorHashChain LOCAL->ImportFunctorHashChain_
 | 
			
		||||
#define REMOTE_ImportFunctorHashChain(wid) REMOTE(wid)->ImportFunctorHashChain_
 | 
			
		||||
#define LOCAL_ImportFunctorHashTableSize LOCAL->ImportFunctorHashTableSize_
 | 
			
		||||
#define REMOTE_ImportFunctorHashTableSize(wid) REMOTE(wid)->ImportFunctorHashTableSize_
 | 
			
		||||
#define LOCAL_ImportFunctorHashTableNum LOCAL->ImportFunctorHashTableNum_
 | 
			
		||||
#define REMOTE_ImportFunctorHashTableNum(wid) REMOTE(wid)->ImportFunctorHashTableNum_
 | 
			
		||||
#define LOCAL_ImportOPCODEHashChain LOCAL->ImportOPCODEHashChain_
 | 
			
		||||
#define REMOTE_ImportOPCODEHashChain(wid) REMOTE(wid)->ImportOPCODEHashChain_
 | 
			
		||||
#define LOCAL_ImportOPCODEHashTableSize LOCAL->ImportOPCODEHashTableSize_
 | 
			
		||||
#define REMOTE_ImportOPCODEHashTableSize(wid) REMOTE(wid)->ImportOPCODEHashTableSize_
 | 
			
		||||
#define LOCAL_ImportPredEntryHashChain LOCAL->ImportPredEntryHashChain_
 | 
			
		||||
#define REMOTE_ImportPredEntryHashChain(wid) REMOTE(wid)->ImportPredEntryHashChain_
 | 
			
		||||
#define LOCAL_ImportPredEntryHashTableSize LOCAL->ImportPredEntryHashTableSize_
 | 
			
		||||
#define REMOTE_ImportPredEntryHashTableSize(wid) REMOTE(wid)->ImportPredEntryHashTableSize_
 | 
			
		||||
#define LOCAL_ImportPredEntryHashTableNum LOCAL->ImportPredEntryHashTableNum_
 | 
			
		||||
#define REMOTE_ImportPredEntryHashTableNum(wid) REMOTE(wid)->ImportPredEntryHashTableNum_
 | 
			
		||||
#define LOCAL_ImportDBRefHashChain LOCAL->ImportDBRefHashChain_
 | 
			
		||||
#define REMOTE_ImportDBRefHashChain(wid) REMOTE(wid)->ImportDBRefHashChain_
 | 
			
		||||
#define LOCAL_ImportDBRefHashTableSize LOCAL->ImportDBRefHashTableSize_
 | 
			
		||||
#define REMOTE_ImportDBRefHashTableSize(wid) REMOTE(wid)->ImportDBRefHashTableSize_
 | 
			
		||||
#define LOCAL_ImportDBRefHashTableNum LOCAL->ImportDBRefHashTableNum_
 | 
			
		||||
#define REMOTE_ImportDBRefHashTableNum(wid) REMOTE(wid)->ImportDBRefHashTableNum_
 | 
			
		||||
#define LOCAL_ImportFAILCODE LOCAL->ImportFAILCODE_
 | 
			
		||||
#define REMOTE_ImportFAILCODE(wid) REMOTE(wid)->ImportFAILCODE_
 | 
			
		||||
#if __ANDROID__
 | 
			
		||||
 | 
			
		||||
#define LOCAL_assetManager LOCAL->assetManager_
 | 
			
		||||
#define REMOTE_assetManager(wid) REMOTE(wid)->assetManager_
 | 
			
		||||
#define LOCAL_InAssetDir LOCAL->InAssetDir_
 | 
			
		||||
#define REMOTE_InAssetDir(wid) REMOTE(wid)->InAssetDir_
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define LOCAL_ibnds LOCAL->ibnds_
 | 
			
		||||
#define REMOTE_ibnds(wid) REMOTE(wid)->ibnds_
 | 
			
		||||
#define LOCAL_exo_it LOCAL->exo_it_
 | 
			
		||||
#define REMOTE_exo_it(wid) REMOTE(wid)->exo_it_
 | 
			
		||||
#define LOCAL_exo_base LOCAL->exo_base_
 | 
			
		||||
#define REMOTE_exo_base(wid) REMOTE(wid)->exo_base_
 | 
			
		||||
#define LOCAL_exo_arity LOCAL->exo_arity_
 | 
			
		||||
#define REMOTE_exo_arity(wid) REMOTE(wid)->exo_arity_
 | 
			
		||||
#define LOCAL_exo_arg LOCAL->exo_arg_
 | 
			
		||||
#define REMOTE_exo_arg(wid) REMOTE(wid)->exo_arg_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_search_atoms LOCAL->search_atoms_
 | 
			
		||||
#define REMOTE_search_atoms(wid) REMOTE(wid)->search_atoms_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_CurSlot LOCAL->CurSlot_
 | 
			
		||||
#define REMOTE_CurSlot(wid) REMOTE(wid)->CurSlot_
 | 
			
		||||
#define LOCAL_NSlots LOCAL->NSlots_
 | 
			
		||||
#define REMOTE_NSlots(wid) REMOTE(wid)->NSlots_
 | 
			
		||||
#define LOCAL_SlotBase LOCAL->SlotBase_
 | 
			
		||||
#define REMOTE_SlotBase(wid) REMOTE(wid)->SlotBase_
 | 
			
		||||
 | 
			
		||||
#define LOCAL_Mutexes LOCAL->Mutexes_
 | 
			
		||||
#define REMOTE_Mutexes(wid) REMOTE(wid)->Mutexes_
 | 
			
		||||
#define LOCAL_SourceModule LOCAL->SourceModule_
 | 
			
		||||
#define REMOTE_SourceModule(wid) REMOTE(wid)->SourceModule_
 | 
			
		||||
#define LOCAL_Including LOCAL->Including_
 | 
			
		||||
#define REMOTE_Including(wid) REMOTE(wid)->Including_
 | 
			
		||||
#define LOCAL_MAX_SIZE LOCAL->MAX_SIZE_
 | 
			
		||||
#define REMOTE_MAX_SIZE(wid) REMOTE(wid)->MAX_SIZE_
 | 
			
		||||
 | 
			
		||||
@@ -20,6 +20,7 @@
 | 
			
		||||
  AtomArrayOverflow = Yap_LookupAtom("array_overflow");
 | 
			
		||||
  AtomArrayType = Yap_LookupAtom("array_type");
 | 
			
		||||
  AtomArrow = Yap_LookupAtom("->");
 | 
			
		||||
  AtomAttributedModule = Yap_LookupAtom("attributes_module");
 | 
			
		||||
  AtomDoubleArrow = Yap_LookupAtom("-->");
 | 
			
		||||
  AtomAssert = Yap_LookupAtom(":-");
 | 
			
		||||
  AtomEmptyBrackets = Yap_LookupAtom("()");
 | 
			
		||||
@@ -509,6 +510,7 @@
 | 
			
		||||
  FunctorPlus = Yap_MkFunctor(AtomPlus,2);
 | 
			
		||||
  FunctorPortray = Yap_MkFunctor(AtomPortray,1);
 | 
			
		||||
  FunctorPrintMessage = Yap_MkFunctor(AtomPrintMessage,2);
 | 
			
		||||
  FunctorProcedure = Yap_MkFunctor(AtomProcedure,5);
 | 
			
		||||
  FunctorPrologConstraint = Yap_MkFunctor(AtomProlog,2);
 | 
			
		||||
  FunctorQuery = Yap_MkFunctor(AtomQuery,1);
 | 
			
		||||
  FunctorRecordedWithKey = Yap_MkFunctor(AtomRecordedWithKey,6);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										301
									
								
								H/ihstruct.h
									
									
									
									
									
								
							
							
						
						
									
										301
									
								
								H/ihstruct.h
									
									
									
									
									
								
							@@ -1,301 +0,0 @@
 | 
			
		||||
 | 
			
		||||
  /* This file, ihstruct.h, was generated automatically by "yap -L misc/buildheap"
 | 
			
		||||
     please do not update, update misc/HEAPFIELDS instead */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if USE_DL_MALLOC
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
  INIT_LOCK(DLMallocLock);
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
 | 
			
		||||
#ifndef  HeapUsed
 | 
			
		||||
#define  HeapUsed  Yap_givemallinfo()
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
  INIT_LOCK(FreeBlocksLock);
 | 
			
		||||
  INIT_LOCK(HeapUsedLock);
 | 
			
		||||
  INIT_LOCK(HeapTopLock);
 | 
			
		||||
  HeapTopOwner = -1;
 | 
			
		||||
#endif
 | 
			
		||||
  MaxStack = 0;
 | 
			
		||||
  MaxTrail = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if USE_THREADED_CODE
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  EXECUTE_CPRED_OP_CODE = Yap_opcode(_execute_cpred);
 | 
			
		||||
  EXPAND_OP_CODE = Yap_opcode(_expand_index);
 | 
			
		||||
  FAIL_OPCODE = Yap_opcode(_op_fail);
 | 
			
		||||
  INDEX_OPCODE = Yap_opcode(_index_pred);
 | 
			
		||||
  LOCKPRED_OPCODE = Yap_opcode(_lock_pred);
 | 
			
		||||
  ORLAST_OPCODE = Yap_opcode(_or_last);
 | 
			
		||||
  UNDEF_OPCODE = Yap_opcode(_undef_p);
 | 
			
		||||
  RETRY_USERC_OPCODE = Yap_opcode(_retry_userc);
 | 
			
		||||
  EXECUTE_CPRED_OPCODE = Yap_opcode(_execute_cpred);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  InitInvisibleAtoms();
 | 
			
		||||
  InitWideAtoms();
 | 
			
		||||
  InitAtoms();
 | 
			
		||||
 | 
			
		||||
#include "iatoms.h"
 | 
			
		||||
#ifdef EUROTRA
 | 
			
		||||
  TermDollarU = MkAtomTerm(AtomDollarU);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  USER_MODULE = MkAtomTerm(AtomUser);
 | 
			
		||||
  IDB_MODULE = MkAtomTerm(AtomIDB);
 | 
			
		||||
  ATTRIBUTES_MODULE = MkAtomTerm(AtomAttributes);
 | 
			
		||||
  CHARSIO_MODULE = MkAtomTerm(AtomCharsio);
 | 
			
		||||
  CHTYPE_MODULE = MkAtomTerm(AtomChType);
 | 
			
		||||
  TERMS_MODULE = MkAtomTerm(AtomTerms);
 | 
			
		||||
  SYSTEM_MODULE = MkAtomTerm(AtomSystem);
 | 
			
		||||
  READUTIL_MODULE = MkAtomTerm(AtomReadutil);
 | 
			
		||||
  HACKS_MODULE = MkAtomTerm(AtomYapHacks);
 | 
			
		||||
  ARG_MODULE = MkAtomTerm(AtomArg);
 | 
			
		||||
  GLOBALS_MODULE = MkAtomTerm(AtomNb);
 | 
			
		||||
  SWI_MODULE = MkAtomTerm(AtomSwi);
 | 
			
		||||
  DBLOAD_MODULE = MkAtomTerm(AtomDBLoad);
 | 
			
		||||
  RANGE_MODULE = MkAtomTerm(AtomRange);
 | 
			
		||||
  ERROR_MODULE = MkAtomTerm(AtomError);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  CurrentModules = NULL;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  Yap_InitModules();
 | 
			
		||||
 | 
			
		||||
  HIDDEN_PREDICATES = NULL;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  Yap_InitPlIO();
 | 
			
		||||
  GLOBAL_Flags = 0;
 | 
			
		||||
  Yap_InitFlags(true);
 | 
			
		||||
 | 
			
		||||
  Yap_ExecutionMode = INTERPRETED;
 | 
			
		||||
 | 
			
		||||
  InitPredHash();
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
  PredsInHashTable = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  CreepCode = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomCreep,1),PROLOG_MODULE));
 | 
			
		||||
  UndefCode = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomUndefp,2),PROLOG_MODULE));
 | 
			
		||||
  SpyCode = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomSpy,1),PROLOG_MODULE));
 | 
			
		||||
  PredFail = RepPredProp(PredPropByAtom(AtomFail,PROLOG_MODULE));
 | 
			
		||||
  PredTrue = RepPredProp(PredPropByAtom(AtomTrue,PROLOG_MODULE));
 | 
			
		||||
#ifdef COROUTINING
 | 
			
		||||
  WakeUpCode = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomWakeUpGoal,2),PROLOG_MODULE));
 | 
			
		||||
#endif
 | 
			
		||||
  PredGoalExpansion = RepPredProp(PredPropByFunc(FunctorGoalExpansion,USER_MODULE));
 | 
			
		||||
  PredMetaCall = RepPredProp(PredPropByFunc(FunctorMetaCall,PROLOG_MODULE));
 | 
			
		||||
  PredTraceMetaCall = RepPredProp(PredPropByFunc(FunctorTraceMetaCall,PROLOG_MODULE));
 | 
			
		||||
  PredDollarCatch = RepPredProp(PredPropByFunc(FunctorCatch,PROLOG_MODULE));
 | 
			
		||||
  PredRecordedWithKey = RepPredProp(PredPropByFunc(FunctorRecordedWithKey,PROLOG_MODULE));
 | 
			
		||||
  PredLogUpdClause = RepPredProp(PredPropByFunc(FunctorDoLogUpdClause,PROLOG_MODULE));
 | 
			
		||||
  PredLogUpdClauseErase = RepPredProp(PredPropByFunc(FunctorDoLogUpdClauseErase,PROLOG_MODULE));
 | 
			
		||||
  PredLogUpdClause0 = RepPredProp(PredPropByFunc(FunctorDoLogUpdClause,PROLOG_MODULE));
 | 
			
		||||
  PredStaticClause = RepPredProp(PredPropByFunc(FunctorDoStaticClause,PROLOG_MODULE));
 | 
			
		||||
  PredThrow = RepPredProp(PredPropByFunc(FunctorThrow,PROLOG_MODULE));
 | 
			
		||||
  PredHandleThrow = RepPredProp(PredPropByFunc(FunctorHandleThrow,PROLOG_MODULE));
 | 
			
		||||
  PredIs = RepPredProp(PredPropByFunc(FunctorIs,PROLOG_MODULE));
 | 
			
		||||
  PredSafeCallCleanup = RepPredProp(PredPropByFunc(FunctorSafeCallCleanup,PROLOG_MODULE));
 | 
			
		||||
  PredRestoreRegs = RepPredProp(PredPropByFunc(FunctorRestoreRegs,PROLOG_MODULE));
 | 
			
		||||
  PredCommentHook = RepPredProp(PredPropByFunc(FunctorCommentHook,PROLOG_MODULE));
 | 
			
		||||
#ifdef YAPOR
 | 
			
		||||
  PredGetwork = RepPredProp(PredPropByAtom(AtomGetwork,PROLOG_MODULE));
 | 
			
		||||
  PredGetworkSeq = RepPredProp(PredPropByAtom(AtomGetworkSeq,PROLOG_MODULE));
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
 | 
			
		||||
#ifdef LOW_LEVEL_TRACER
 | 
			
		||||
  Yap_do_low_level_trace = FALSE;
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
  INIT_LOCK(Yap_low_level_trace_lock);
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  Yap_ClauseSpace = 0;
 | 
			
		||||
  Yap_IndexSpace_Tree = 0;
 | 
			
		||||
  Yap_IndexSpace_EXT = 0;
 | 
			
		||||
  Yap_IndexSpace_SW = 0;
 | 
			
		||||
  Yap_LUClauseSpace = 0;
 | 
			
		||||
  Yap_LUIndexSpace_Tree = 0;
 | 
			
		||||
  Yap_LUIndexSpace_CP = 0;
 | 
			
		||||
  Yap_LUIndexSpace_EXT = 0;
 | 
			
		||||
  Yap_LUIndexSpace_SW = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  DUMMYCODE->opc = Yap_opcode(_op_fail);
 | 
			
		||||
  FAILCODE->opc = Yap_opcode(_op_fail);
 | 
			
		||||
  NOCODE->opc = Yap_opcode(_Nstop);
 | 
			
		||||
  InitEnvInst(ENV_FOR_TRUSTFAIL,&TRUSTFAILCODE,_trust_fail,PredFail);
 | 
			
		||||
 | 
			
		||||
  InitEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail);
 | 
			
		||||
 | 
			
		||||
  InitOtaplInst(RTRYCODE,_retry_and_mark,PredFail);
 | 
			
		||||
#ifdef BEAM
 | 
			
		||||
  BEAM_RETRY_CODE->opc = Yap_opcode(_beam_retry_code);
 | 
			
		||||
#endif /* BEAM */
 | 
			
		||||
#ifdef YAPOR
 | 
			
		||||
  InitOtaplInst(GETWORK,_getwork,PredGetwork);
 | 
			
		||||
  InitOtaplInst(GETWORK_SEQ,_getwork_seq,PredGetworkSeq);
 | 
			
		||||
  GETWORK_FIRST_TIME->opc = Yap_opcode(_getwork_first_time);
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
#ifdef TABLING
 | 
			
		||||
  InitOtaplInst(LOAD_ANSWER,_table_load_answer,PredFail);
 | 
			
		||||
  InitOtaplInst(TRY_ANSWER,_table_try_answer,PredFail);
 | 
			
		||||
  InitOtaplInst(ANSWER_RESOLUTION,_table_answer_resolution,PredFail);
 | 
			
		||||
  InitOtaplInst(COMPLETION,_table_completion,PredFail);
 | 
			
		||||
#ifdef THREADS_CONSUMER_SHARING
 | 
			
		||||
  InitOtaplInst(ANSWER_RESOLUTION_COMPLETION,_table_answer_resolution_completion,PredFail);
 | 
			
		||||
#endif /* THREADS_CONSUMER_SHARING */
 | 
			
		||||
#endif /* TABLING */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  P_before_spy = NULL;
 | 
			
		||||
 | 
			
		||||
  RETRY_C_RECORDEDP_CODE = NULL;
 | 
			
		||||
  RETRY_C_RECORDED_K_CODE = NULL;
 | 
			
		||||
 | 
			
		||||
  PROFILING = FALSE;
 | 
			
		||||
  CALL_COUNTING = FALSE;
 | 
			
		||||
  optimizer_on = TRUE;
 | 
			
		||||
  compile_mode = 0;
 | 
			
		||||
  profiling = FALSE;
 | 
			
		||||
  call_counting = FALSE;
 | 
			
		||||
 | 
			
		||||
  compile_arrays = FALSE;
 | 
			
		||||
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
  INIT_LOCK(DBTermsListLock);
 | 
			
		||||
#endif
 | 
			
		||||
  DBTermsList = NULL;
 | 
			
		||||
 | 
			
		||||
  ExpandClausesFirst = NULL;
 | 
			
		||||
  ExpandClausesLast = NULL;
 | 
			
		||||
  Yap_ExpandClauses = 0;
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
  INIT_LOCK(ExpandClausesListLock);
 | 
			
		||||
  INIT_LOCK(OpListLock);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
  Yap_NewCps = 0L;
 | 
			
		||||
  Yap_LiveCps = 0L;
 | 
			
		||||
  Yap_DirtyCps = 0L;
 | 
			
		||||
  Yap_FreedCps = 0L;
 | 
			
		||||
#endif
 | 
			
		||||
  Yap_expand_clauses_sz = 0L;
 | 
			
		||||
 | 
			
		||||
  UdiControlBlocks = NULL;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  STATIC_PREDICATES_MARKED = FALSE;
 | 
			
		||||
 | 
			
		||||
  INT_KEYS = NULL;
 | 
			
		||||
  INT_LU_KEYS = NULL;
 | 
			
		||||
  INT_BB_KEYS = NULL;
 | 
			
		||||
 | 
			
		||||
  INT_KEYS_SIZE = INT_KEYS_DEFAULT_SIZE;
 | 
			
		||||
  INT_KEYS_TIMESTAMP = 0L;
 | 
			
		||||
  INT_BB_KEYS_SIZE = INT_KEYS_DEFAULT_SIZE;
 | 
			
		||||
 | 
			
		||||
  UPDATE_MODE = UPDATE_MODE_LOGICAL;
 | 
			
		||||
 | 
			
		||||
  InitDBErasedMarker();
 | 
			
		||||
  InitLogDBErasedMarker();
 | 
			
		||||
 | 
			
		||||
  DeadStaticClauses = NULL;
 | 
			
		||||
  DeadMegaClauses = NULL;
 | 
			
		||||
  DeadStaticIndices = NULL;
 | 
			
		||||
  DBErasedList = NULL;
 | 
			
		||||
  DBErasedIList = NULL;
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
  INIT_LOCK(DeadStaticClausesLock);
 | 
			
		||||
  INIT_LOCK(DeadMegaClausesLock);
 | 
			
		||||
  INIT_LOCK(DeadStaticIndicesLock);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef COROUTINING
 | 
			
		||||
 | 
			
		||||
  NUM_OF_ATTS = 1;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  OpList = NULL;
 | 
			
		||||
 | 
			
		||||
  ForeignCodeLoaded = NULL;
 | 
			
		||||
  ForeignCodeBase = NULL;
 | 
			
		||||
  ForeignCodeTop = NULL;
 | 
			
		||||
  ForeignCodeMax = NULL;
 | 
			
		||||
 | 
			
		||||
  Yap_Records = NULL;
 | 
			
		||||
 | 
			
		||||
  InitSWIAtoms();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  InitEmptyWakeups();
 | 
			
		||||
  MaxEmptyWakeups = 0;
 | 
			
		||||
 | 
			
		||||
  BlobTypes = NULL;
 | 
			
		||||
  Blobs = NULL;
 | 
			
		||||
  NOfBlobs = 0;
 | 
			
		||||
  NOfBlobsMax = 256;
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
  INIT_LOCK(Blobs_Lock);
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										277
									
								
								H/ilocals.h
									
									
									
									
									
								
							
							
						
						
									
										277
									
								
								H/ilocals.h
									
									
									
									
									
								
							@@ -1,277 +0,0 @@
 | 
			
		||||
 | 
			
		||||
  /* This file, ilocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
 | 
			
		||||
     please do not update, update misc/LOCALS instead */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void InitWorker(int wid) {
 | 
			
		||||
 | 
			
		||||
  REMOTE_FileAliases(wid) = Yap_InitStandardAliases();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  REMOTE_c_input_stream(wid) = 0;
 | 
			
		||||
  REMOTE_c_output_stream(wid) = 1;
 | 
			
		||||
  REMOTE_c_error_stream(wid) = 2;
 | 
			
		||||
  REMOTE_sockets_io(wid) = false;
 | 
			
		||||
  REMOTE_within_print_message(wid) = false;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  REMOTE_newline(wid) = true;
 | 
			
		||||
  REMOTE_AtPrompt(wid) = AtomNil;
 | 
			
		||||
 | 
			
		||||
  REMOTE_encoding(wid) = Yap_DefaultEncoding();
 | 
			
		||||
  REMOTE_quasi_quotations(wid) = false;
 | 
			
		||||
  REMOTE_default_priority(wid) = 1200;
 | 
			
		||||
  REMOTE_eot_before_eof(wid) = false;
 | 
			
		||||
  REMOTE_max_depth(wid) = 0;
 | 
			
		||||
  REMOTE_max_list(wid) = 0;
 | 
			
		||||
  REMOTE_max_write_args(wid) = 0;
 | 
			
		||||
 | 
			
		||||
  REMOTE_OldASP(wid) = NULL;
 | 
			
		||||
  REMOTE_OldLCL0(wid) = NULL;
 | 
			
		||||
  REMOTE_OldTR(wid) = NULL;
 | 
			
		||||
  REMOTE_OldGlobalBase(wid) = NULL;
 | 
			
		||||
  REMOTE_OldH(wid) = NULL;
 | 
			
		||||
  REMOTE_OldH0(wid) = NULL;
 | 
			
		||||
  REMOTE_OldTrailBase(wid) = NULL;
 | 
			
		||||
  REMOTE_OldTrailTop(wid) = NULL;
 | 
			
		||||
  REMOTE_OldHeapBase(wid) = NULL;
 | 
			
		||||
  REMOTE_OldHeapTop(wid) = NULL;
 | 
			
		||||
  REMOTE_ClDiff(wid) = 0L;
 | 
			
		||||
  REMOTE_GDiff(wid) = 0L;
 | 
			
		||||
  REMOTE_HDiff(wid) = 0L;
 | 
			
		||||
  REMOTE_GDiff0(wid) = 0L;
 | 
			
		||||
  REMOTE_GSplit(wid) = NULL;
 | 
			
		||||
  REMOTE_LDiff(wid) = 0L;
 | 
			
		||||
  REMOTE_TrDiff(wid) = 0L;
 | 
			
		||||
  REMOTE_XDiff(wid) = 0L;
 | 
			
		||||
  REMOTE_DelayDiff(wid) = 0L;
 | 
			
		||||
  REMOTE_BaseDiff(wid) = 0L;
 | 
			
		||||
 | 
			
		||||
  REMOTE_ReductionsCounter(wid) = 0L;
 | 
			
		||||
  REMOTE_PredEntriesCounter(wid) = 0L;
 | 
			
		||||
  REMOTE_RetriesCounter(wid) = 0L;
 | 
			
		||||
  REMOTE_ReductionsCounterOn(wid) = 0L;
 | 
			
		||||
  REMOTE_PredEntriesCounterOn(wid) = 0L;
 | 
			
		||||
  REMOTE_RetriesCounterOn(wid) = 0L;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  REMOTE_ConsultSp(wid) = NULL;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  REMOTE_ConsultBase(wid) = NULL;
 | 
			
		||||
 | 
			
		||||
  REMOTE_ConsultLow(wid) = NULL;
 | 
			
		||||
  REMOTE_VarNames(wid) = ((Term)0);
 | 
			
		||||
  REMOTE_SourceFileName(wid) = NULL;
 | 
			
		||||
  REMOTE_SourceFileLineno(wid) = 0;
 | 
			
		||||
 | 
			
		||||
  REMOTE_GlobalArena(wid) = 0L;
 | 
			
		||||
  REMOTE_GlobalArenaOverflows(wid) = 0L;
 | 
			
		||||
  REMOTE_ArenaOverflows(wid) = 0L;
 | 
			
		||||
  REMOTE_DepthArenas(wid) = 0;
 | 
			
		||||
  REMOTE_ArithError(wid) = FALSE;
 | 
			
		||||
  REMOTE_LastAssertedPred(wid) = NULL;
 | 
			
		||||
  REMOTE_TmpPred(wid) = NULL;
 | 
			
		||||
  REMOTE_ScannerStack(wid) = NULL;
 | 
			
		||||
  REMOTE_ScannerExtraBlocks(wid) = NULL;
 | 
			
		||||
  REMOTE_BallTerm(wid) = NULL;
 | 
			
		||||
  REMOTE_MaxActiveSignals(wid) = 64L;
 | 
			
		||||
  REMOTE_Signals(wid) = 0L;
 | 
			
		||||
  REMOTE_IPredArity(wid) = 0L;
 | 
			
		||||
  REMOTE_ProfEnd(wid) = NULL;
 | 
			
		||||
  REMOTE_UncaughtThrow(wid) = FALSE;
 | 
			
		||||
  REMOTE_DoingUndefp(wid) = FALSE;
 | 
			
		||||
  REMOTE_StartCharCount(wid) = 0L;
 | 
			
		||||
  REMOTE_StartLineCount(wid) = 0L;
 | 
			
		||||
  REMOTE_StartLinePos(wid) = 0L;
 | 
			
		||||
  InitScratchPad(wid);
 | 
			
		||||
#ifdef  COROUTINING
 | 
			
		||||
  REMOTE_WokenGoals(wid) = 0L;
 | 
			
		||||
  REMOTE_AttsMutableList(wid) = 0L;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  REMOTE_GcGeneration(wid) = 0L;
 | 
			
		||||
  REMOTE_GcPhase(wid) = 0L;
 | 
			
		||||
  REMOTE_GcCurrentPhase(wid) = 0L;
 | 
			
		||||
  REMOTE_GcCalls(wid) = 0L;
 | 
			
		||||
  REMOTE_TotGcTime(wid) = 0L;
 | 
			
		||||
  REMOTE_TotGcRecovered(wid) = 0L;
 | 
			
		||||
  REMOTE_LastGcTime(wid) = 0L;
 | 
			
		||||
  REMOTE_LastSSTime(wid) = 0L;
 | 
			
		||||
  REMOTE_OpenArray(wid) = NULL;
 | 
			
		||||
 | 
			
		||||
  REMOTE_total_marked(wid) = 0L;
 | 
			
		||||
  REMOTE_total_oldies(wid) = 0L;
 | 
			
		||||
  REMOTE_current_B(wid) = NULL;
 | 
			
		||||
  REMOTE_prev_HB(wid) = NULL;
 | 
			
		||||
  REMOTE_HGEN(wid) = NULL;
 | 
			
		||||
  REMOTE_iptop(wid) = NULL;
 | 
			
		||||
#if defined(GC_NO_TAGS)
 | 
			
		||||
  REMOTE_bp(wid) = NULL;
 | 
			
		||||
#endif
 | 
			
		||||
  REMOTE_sTR(wid) = NULL;
 | 
			
		||||
  REMOTE_sTR0(wid) = NULL;
 | 
			
		||||
  REMOTE_new_TR(wid) = NULL;
 | 
			
		||||
  REMOTE_cont_top0(wid) = NULL;
 | 
			
		||||
  REMOTE_cont_top(wid) = NULL;
 | 
			
		||||
  REMOTE_discard_trail_entries(wid) = 0;
 | 
			
		||||
 | 
			
		||||
  REMOTE_gc_ma_h_top(wid) = NULL;
 | 
			
		||||
  REMOTE_gc_ma_h_list(wid) = NULL;
 | 
			
		||||
  REMOTE_gc_timestamp(wid) = 0L;
 | 
			
		||||
  REMOTE_db_vec(wid) = NULL;
 | 
			
		||||
  REMOTE_db_vec0(wid) = NULL;
 | 
			
		||||
  REMOTE_db_root(wid) = NULL;
 | 
			
		||||
  REMOTE_db_nil(wid) = NULL;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  REMOTE_extra_gc_cells_size(wid) = 256;
 | 
			
		||||
  REMOTE_DynamicArrays(wid) = NULL;
 | 
			
		||||
  REMOTE_StaticArrays(wid) = NULL;
 | 
			
		||||
  REMOTE_GlobalVariables(wid) = NULL;
 | 
			
		||||
  REMOTE_AllowRestart(wid) = FALSE;
 | 
			
		||||
 | 
			
		||||
  REMOTE_CMemFirstBlock(wid) = NULL;
 | 
			
		||||
  REMOTE_CMemFirstBlockSz(wid) = 0L;
 | 
			
		||||
 | 
			
		||||
  REMOTE_nperm(wid) = 0L;
 | 
			
		||||
 | 
			
		||||
  REMOTE_LabelFirstArray(wid) = NULL;
 | 
			
		||||
  REMOTE_LabelFirstArraySz(wid) = 0L;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef THREADS
 | 
			
		||||
  InitThreadHandle(wid);
 | 
			
		||||
#endif /* THREADS */
 | 
			
		||||
#if defined(YAPOR) || defined(TABLING)
 | 
			
		||||
  Yap_init_local_optyap_data(wid);
 | 
			
		||||
  REMOTE_TabMode(wid) = 0L;
 | 
			
		||||
#endif /* YAPOR || TABLING */
 | 
			
		||||
  REMOTE_InterruptsDisabled(wid) = FALSE;
 | 
			
		||||
  REMOTE_execution(wid) = NULL;
 | 
			
		||||
#if LOW_LEVEL_TRACER
 | 
			
		||||
  REMOTE_total_choicepoints(wid) = 0;
 | 
			
		||||
#endif
 | 
			
		||||
  REMOTE_consult_level(wid) = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  REMOTE_BreakLevel(wid) = 0;
 | 
			
		||||
  REMOTE_PrologMode(wid) = BootMode;
 | 
			
		||||
  REMOTE_CritLocks(wid) = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef ANALYST
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif /* ANALYST */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  REMOTE_matherror(wid) = YAP_NO_ERROR;
 | 
			
		||||
 | 
			
		||||
  REMOTE_mathstring(wid) = NULL;
 | 
			
		||||
  REMOTE_CurrentError(wid) = YAP_NO_ERROR;
 | 
			
		||||
 | 
			
		||||
  REMOTE_heap_overflows(wid) = 0;
 | 
			
		||||
  REMOTE_total_heap_overflow_time(wid) = 0;
 | 
			
		||||
  REMOTE_stack_overflows(wid) = 0;
 | 
			
		||||
  REMOTE_total_stack_overflow_time(wid) = 0;
 | 
			
		||||
  REMOTE_delay_overflows(wid) = 0;
 | 
			
		||||
  REMOTE_total_delay_overflow_time(wid) = 0;
 | 
			
		||||
  REMOTE_trail_overflows(wid) = 0;
 | 
			
		||||
  REMOTE_total_trail_overflow_time(wid) = 0;
 | 
			
		||||
  REMOTE_atom_table_overflows(wid) = 0;
 | 
			
		||||
  REMOTE_total_atom_table_overflow_time(wid) = 0;
 | 
			
		||||
 | 
			
		||||
#ifdef LOAD_DYLD
 | 
			
		||||
  REMOTE_dl_errno(wid) = 0;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef LOW_LEVEL_TRACER
 | 
			
		||||
  REMOTE_do_trace_primitives(wid) = TRUE;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  REMOTE_ExportAtomHashChain(wid) = NULL;
 | 
			
		||||
  REMOTE_ExportAtomHashTableSize(wid) = 0;
 | 
			
		||||
  REMOTE_ExportAtomHashTableNum(wid) = 0;
 | 
			
		||||
  REMOTE_ExportFunctorHashChain(wid) = NULL;
 | 
			
		||||
  REMOTE_ExportFunctorHashTableSize(wid) = 0;
 | 
			
		||||
  REMOTE_ExportFunctorHashTableNum(wid) = 0;
 | 
			
		||||
  REMOTE_ExportPredEntryHashChain(wid) = NULL;
 | 
			
		||||
  REMOTE_ExportPredEntryHashTableSize(wid) = 0;
 | 
			
		||||
  REMOTE_ExportPredEntryHashTableNum(wid) = 0;
 | 
			
		||||
  REMOTE_ExportDBRefHashChain(wid) = NULL;
 | 
			
		||||
  REMOTE_ExportDBRefHashTableSize(wid) = 0;
 | 
			
		||||
  REMOTE_ExportDBRefHashTableNum(wid) = 0;
 | 
			
		||||
  REMOTE_ImportAtomHashChain(wid) = NULL;
 | 
			
		||||
  REMOTE_ImportAtomHashTableSize(wid) = 0;
 | 
			
		||||
  REMOTE_ImportAtomHashTableNum(wid) = 0;
 | 
			
		||||
  REMOTE_ImportFunctorHashChain(wid) = NULL;
 | 
			
		||||
  REMOTE_ImportFunctorHashTableSize(wid) = 0;
 | 
			
		||||
  REMOTE_ImportFunctorHashTableNum(wid) = 0;
 | 
			
		||||
  REMOTE_ImportOPCODEHashChain(wid) = NULL;
 | 
			
		||||
  REMOTE_ImportOPCODEHashTableSize(wid) = 0;
 | 
			
		||||
  REMOTE_ImportPredEntryHashChain(wid) = NULL;
 | 
			
		||||
  REMOTE_ImportPredEntryHashTableSize(wid) = 0;
 | 
			
		||||
  REMOTE_ImportPredEntryHashTableNum(wid) = 0;
 | 
			
		||||
  REMOTE_ImportDBRefHashChain(wid) = NULL;
 | 
			
		||||
  REMOTE_ImportDBRefHashTableSize(wid) = 0;
 | 
			
		||||
  REMOTE_ImportDBRefHashTableNum(wid) = 0;
 | 
			
		||||
  REMOTE_ImportFAILCODE(wid) = NULL;
 | 
			
		||||
#if __ANDROID__
 | 
			
		||||
 | 
			
		||||
  REMOTE_assetManager(wid) = GLOBAL_assetManager;
 | 
			
		||||
  REMOTE_InAssetDir(wid) = NULL;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  REMOTE_exo_it(wid) = NULL;
 | 
			
		||||
  REMOTE_exo_base(wid) = NULL;
 | 
			
		||||
  REMOTE_exo_arity(wid) = 0;
 | 
			
		||||
  REMOTE_exo_arg(wid) = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  REMOTE_CurSlot(wid) = 0;
 | 
			
		||||
  REMOTE_NSlots(wid) = 0;
 | 
			
		||||
  REMOTE_SlotBase(wid) = InitHandles(wid);
 | 
			
		||||
 | 
			
		||||
  REMOTE_Mutexes(wid) = NULL;
 | 
			
		||||
  REMOTE_SourceModule(wid) = 0;
 | 
			
		||||
  REMOTE_Including(wid) = TermNil;
 | 
			
		||||
  REMOTE_MAX_SIZE(wid) = 1024L;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										2
									
								
								H/qly.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								H/qly.h
									
									
									
									
									
								
							@@ -104,7 +104,7 @@ typedef enum {
 | 
			
		||||
#define STATIC_PRED_FLAGS (SourcePredFlag|DynamicPredFlag|LogUpdatePredFlag|CompiledPredFlag|MultiFileFlag|TabledPredFlag|MegaClausePredFlag|CountPredFlag|ProfiledPredFlag|ThreadLocalPredFlag|AtomDBPredFlag|ModuleTransparentPredFlag|NumberDBPredFlag|MetaPredFlag|SyncPredFlag|BackCPredFlag)
 | 
			
		||||
#define EXTRA_PRED_FLAGS (QuasiQuotationPredFlag|NoTracePredFlag|NoSpyPredFlag)
 | 
			
		||||
 | 
			
		||||
#define SYSTEM_PRED_FLAGS (BackCPredFlag|UserCPredFlag|CArgsPredFlag|AsmPredFlag|CPredFlag|BinaryPredFlag|StandardPredFlag)
 | 
			
		||||
#define SYSTEM_PRED_FLAGS (BackCPredFlag|UserCPredFlag|CArgsPredFlag|AsmPredFlag|CPredFlag|BinaryPredFlag)
 | 
			
		||||
 | 
			
		||||
#define CHECK(F) { size_t r = (F); if (!r) return r; }
 | 
			
		||||
#define RCHECK(F)  if(!(F)) { QLYR_ERROR(MISMATCH); return; }
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,7 @@
 | 
			
		||||
  AtomArrayOverflow = AtomAdjust(AtomArrayOverflow);
 | 
			
		||||
  AtomArrayType = AtomAdjust(AtomArrayType);
 | 
			
		||||
  AtomArrow = AtomAdjust(AtomArrow);
 | 
			
		||||
  AtomAttributedModule = AtomAdjust(AtomAttributedModule);
 | 
			
		||||
  AtomDoubleArrow = AtomAdjust(AtomDoubleArrow);
 | 
			
		||||
  AtomAssert = AtomAdjust(AtomAssert);
 | 
			
		||||
  AtomEmptyBrackets = AtomAdjust(AtomEmptyBrackets);
 | 
			
		||||
@@ -509,6 +510,7 @@
 | 
			
		||||
  FunctorPlus = FuncAdjust(FunctorPlus);
 | 
			
		||||
  FunctorPortray = FuncAdjust(FunctorPortray);
 | 
			
		||||
  FunctorPrintMessage = FuncAdjust(FunctorPrintMessage);
 | 
			
		||||
  FunctorProcedure = FuncAdjust(FunctorProcedure);
 | 
			
		||||
  FunctorPrologConstraint = FuncAdjust(FunctorPrologConstraint);
 | 
			
		||||
  FunctorQuery = FuncAdjust(FunctorQuery);
 | 
			
		||||
  FunctorRecordedWithKey = FuncAdjust(FunctorRecordedWithKey);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										146
									
								
								H/rglobals.h
									
									
									
									
									
								
							
							
						
						
									
										146
									
								
								H/rglobals.h
									
									
									
									
									
								
							@@ -1,146 +0,0 @@
 | 
			
		||||
 | 
			
		||||
  /* This file, rglobals.h, was generated automatically by "yap -L misc/buildlocalglobal"
 | 
			
		||||
     please do not update, update misc/GLOBALS instead */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void RestoreGlobal(void) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if __ANDROID__
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if THREADS
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  REINIT_LOCK(GLOBAL_ThreadHandlesLock);
 | 
			
		||||
#endif	
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
 | 
			
		||||
  REINIT_LOCK(GLOBAL_BGL);
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(YAPOR) || defined(TABLING)
 | 
			
		||||
 | 
			
		||||
#endif /* YAPOR || TABLING */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined(THREADS)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  REINIT_LOCK(GLOBAL_mboxq_lock);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif /* THREADS */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined(THREADS)||defined(YAPOR)
 | 
			
		||||
  REINIT_LOCK(GLOBAL_StreamDescLock);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef COROUTINING
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if HAVE_MMAP
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(COFF)  || defined(A_OUT)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if  __simplescalar__
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if LOW_PROF
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif /* LOW_PROF */
 | 
			
		||||
 | 
			
		||||
#if THREADS
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  REINIT_LOCK(GLOBAL_MUT_ACCESS);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										301
									
								
								H/rhstruct.h
									
									
									
									
									
								
							
							
						
						
									
										301
									
								
								H/rhstruct.h
									
									
									
									
									
								
							@@ -1,301 +0,0 @@
 | 
			
		||||
 | 
			
		||||
  /* This file, rhstruct.h, was generated automatically by "yap -L misc/buildheap"
 | 
			
		||||
     please do not update, update misc/HEAPFIELDS instead */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if USE_DL_MALLOC
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
  REINIT_LOCK(DLMallocLock);
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
 | 
			
		||||
#ifndef  HeapUsed
 | 
			
		||||
#define  HeapUsed  Yap_givemallinfo()
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
  REINIT_LOCK(FreeBlocksLock);
 | 
			
		||||
  REINIT_LOCK(HeapUsedLock);
 | 
			
		||||
  REINIT_LOCK(HeapTopLock);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if USE_THREADED_CODE
 | 
			
		||||
  OP_RTABLE = OpRTableAdjust(OP_RTABLE);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  EXECUTE_CPRED_OP_CODE = Yap_opcode(_execute_cpred);
 | 
			
		||||
  EXPAND_OP_CODE = Yap_opcode(_expand_index);
 | 
			
		||||
  FAIL_OPCODE = Yap_opcode(_op_fail);
 | 
			
		||||
  INDEX_OPCODE = Yap_opcode(_index_pred);
 | 
			
		||||
  LOCKPRED_OPCODE = Yap_opcode(_lock_pred);
 | 
			
		||||
  ORLAST_OPCODE = Yap_opcode(_or_last);
 | 
			
		||||
  UNDEF_OPCODE = Yap_opcode(_undef_p);
 | 
			
		||||
  RETRY_USERC_OPCODE = Yap_opcode(_retry_userc);
 | 
			
		||||
  EXECUTE_CPRED_OPCODE = Yap_opcode(_execute_cpred);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  RestoreInvisibleAtoms();
 | 
			
		||||
  RestoreWideAtoms();
 | 
			
		||||
  RestoreAtoms();
 | 
			
		||||
 | 
			
		||||
#include "ratoms.h"
 | 
			
		||||
#ifdef EUROTRA
 | 
			
		||||
  TermDollarU = AtomTermAdjust(TermDollarU);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  USER_MODULE = AtomTermAdjust(USER_MODULE);
 | 
			
		||||
  IDB_MODULE = AtomTermAdjust(IDB_MODULE);
 | 
			
		||||
  ATTRIBUTES_MODULE = AtomTermAdjust(ATTRIBUTES_MODULE);
 | 
			
		||||
  CHARSIO_MODULE = AtomTermAdjust(CHARSIO_MODULE);
 | 
			
		||||
  CHTYPE_MODULE = AtomTermAdjust(CHTYPE_MODULE);
 | 
			
		||||
  TERMS_MODULE = AtomTermAdjust(TERMS_MODULE);
 | 
			
		||||
  SYSTEM_MODULE = AtomTermAdjust(SYSTEM_MODULE);
 | 
			
		||||
  READUTIL_MODULE = AtomTermAdjust(READUTIL_MODULE);
 | 
			
		||||
  HACKS_MODULE = AtomTermAdjust(HACKS_MODULE);
 | 
			
		||||
  ARG_MODULE = AtomTermAdjust(ARG_MODULE);
 | 
			
		||||
  GLOBALS_MODULE = AtomTermAdjust(GLOBALS_MODULE);
 | 
			
		||||
  SWI_MODULE = AtomTermAdjust(SWI_MODULE);
 | 
			
		||||
  DBLOAD_MODULE = AtomTermAdjust(DBLOAD_MODULE);
 | 
			
		||||
  RANGE_MODULE = AtomTermAdjust(RANGE_MODULE);
 | 
			
		||||
  ERROR_MODULE = AtomTermAdjust(ERROR_MODULE);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  CurrentModules = ModEntryPtrAdjust(CurrentModules);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  RestoreHiddenPredicates();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  RestoreFlags(GLOBAL_flagCount);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  RestorePredHash();
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  CreepCode = PtoPredAdjust(CreepCode);
 | 
			
		||||
  UndefCode = PtoPredAdjust(UndefCode);
 | 
			
		||||
  SpyCode = PtoPredAdjust(SpyCode);
 | 
			
		||||
  PredFail = PtoPredAdjust(PredFail);
 | 
			
		||||
  PredTrue = PtoPredAdjust(PredTrue);
 | 
			
		||||
#ifdef COROUTINING
 | 
			
		||||
  WakeUpCode = PtoPredAdjust(WakeUpCode);
 | 
			
		||||
#endif
 | 
			
		||||
  PredGoalExpansion = PtoPredAdjust(PredGoalExpansion);
 | 
			
		||||
  PredMetaCall = PtoPredAdjust(PredMetaCall);
 | 
			
		||||
  PredTraceMetaCall = PtoPredAdjust(PredTraceMetaCall);
 | 
			
		||||
  PredDollarCatch = PtoPredAdjust(PredDollarCatch);
 | 
			
		||||
  PredRecordedWithKey = PtoPredAdjust(PredRecordedWithKey);
 | 
			
		||||
  PredLogUpdClause = PtoPredAdjust(PredLogUpdClause);
 | 
			
		||||
  PredLogUpdClauseErase = PtoPredAdjust(PredLogUpdClauseErase);
 | 
			
		||||
  PredLogUpdClause0 = PtoPredAdjust(PredLogUpdClause0);
 | 
			
		||||
  PredStaticClause = PtoPredAdjust(PredStaticClause);
 | 
			
		||||
  PredThrow = PtoPredAdjust(PredThrow);
 | 
			
		||||
  PredHandleThrow = PtoPredAdjust(PredHandleThrow);
 | 
			
		||||
  PredIs = PtoPredAdjust(PredIs);
 | 
			
		||||
  PredSafeCallCleanup = PtoPredAdjust(PredSafeCallCleanup);
 | 
			
		||||
  PredRestoreRegs = PtoPredAdjust(PredRestoreRegs);
 | 
			
		||||
  PredCommentHook = PtoPredAdjust(PredCommentHook);
 | 
			
		||||
#ifdef YAPOR
 | 
			
		||||
  PredGetwork = PtoPredAdjust(PredGetwork);
 | 
			
		||||
  PredGetworkSeq = PtoPredAdjust(PredGetworkSeq);
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
 | 
			
		||||
#ifdef LOW_LEVEL_TRACER
 | 
			
		||||
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
  REINIT_LOCK(Yap_low_level_trace_lock);
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  DUMMYCODE->opc = Yap_opcode(_op_fail);
 | 
			
		||||
  FAILCODE->opc = Yap_opcode(_op_fail);
 | 
			
		||||
  NOCODE->opc = Yap_opcode(_Nstop);
 | 
			
		||||
  RestoreEnvInst(ENV_FOR_TRUSTFAIL,&TRUSTFAILCODE,_trust_fail,PredFail);
 | 
			
		||||
 | 
			
		||||
  RestoreEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail);
 | 
			
		||||
 | 
			
		||||
  RestoreOtaplInst(RTRYCODE,_retry_and_mark,PredFail);
 | 
			
		||||
#ifdef BEAM
 | 
			
		||||
  BEAM_RETRY_CODE->opc = Yap_opcode(_beam_retry_code);
 | 
			
		||||
#endif /* BEAM */
 | 
			
		||||
#ifdef YAPOR
 | 
			
		||||
  RestoreOtaplInst(GETWORK,_getwork,PredGetwork);
 | 
			
		||||
  RestoreOtaplInst(GETWORK_SEQ,_getwork_seq,PredGetworkSeq);
 | 
			
		||||
  GETWORK_FIRST_TIME->opc = Yap_opcode(_getwork_first_time);
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
#ifdef TABLING
 | 
			
		||||
  RestoreOtaplInst(LOAD_ANSWER,_table_load_answer,PredFail);
 | 
			
		||||
  RestoreOtaplInst(TRY_ANSWER,_table_try_answer,PredFail);
 | 
			
		||||
  RestoreOtaplInst(ANSWER_RESOLUTION,_table_answer_resolution,PredFail);
 | 
			
		||||
  RestoreOtaplInst(COMPLETION,_table_completion,PredFail);
 | 
			
		||||
#ifdef THREADS_CONSUMER_SHARING
 | 
			
		||||
  RestoreOtaplInst(ANSWER_RESOLUTION_COMPLETION,_table_answer_resolution_completion,PredFail);
 | 
			
		||||
#endif /* THREADS_CONSUMER_SHARING */
 | 
			
		||||
#endif /* TABLING */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  P_before_spy = PtoOpAdjust(P_before_spy);
 | 
			
		||||
 | 
			
		||||
  RETRY_C_RECORDEDP_CODE = PtoOpAdjust(RETRY_C_RECORDEDP_CODE);
 | 
			
		||||
  RETRY_C_RECORDED_K_CODE = PtoOpAdjust(RETRY_C_RECORDED_K_CODE);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
  REINIT_LOCK(DBTermsListLock);
 | 
			
		||||
#endif
 | 
			
		||||
  RestoreDBTermsList();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  RestoreExpandList();
 | 
			
		||||
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
  REINIT_LOCK(ExpandClausesListLock);
 | 
			
		||||
  REINIT_LOCK(OpListLock);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  RestoreUdiControlBlocks();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  RestoreIntKeys();
 | 
			
		||||
  RestoreIntLUKeys();
 | 
			
		||||
  RestoreIntBBKeys();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  RestoreDBErasedMarker();
 | 
			
		||||
  RestoreLogDBErasedMarker();
 | 
			
		||||
 | 
			
		||||
  RestoreDeadStaticClauses();
 | 
			
		||||
  RestoreDeadMegaClauses();
 | 
			
		||||
  RestoreDeadStaticIndices();
 | 
			
		||||
  RestoreDBErasedList();
 | 
			
		||||
  RestoreDBErasedIList();
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
  REINIT_LOCK(DeadStaticClausesLock);
 | 
			
		||||
  REINIT_LOCK(DeadMegaClausesLock);
 | 
			
		||||
  REINIT_LOCK(DeadStaticIndicesLock);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef COROUTINING
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  OpList = OpListAdjust(OpList);
 | 
			
		||||
 | 
			
		||||
  RestoreForeignCode();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  RestoreYapRecords();
 | 
			
		||||
 | 
			
		||||
  RestoreSWIAtoms();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  RestoreEmptyWakeups();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  RestoreBlobTypes();
 | 
			
		||||
  RestoreBlobs();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
  REINIT_LOCK(Blobs_Lock);
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										277
									
								
								H/rlocals.h
									
									
									
									
									
								
							
							
						
						
									
										277
									
								
								H/rlocals.h
									
									
									
									
									
								
							@@ -1,277 +0,0 @@
 | 
			
		||||
 | 
			
		||||
  /* This file, rlocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
 | 
			
		||||
     please do not update, update misc/LOCALS instead */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void RestoreWorker(int wid USES_REGS) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  REMOTE_GlobalArena(wid) = TermToGlobalOrAtomAdjust(REMOTE_GlobalArena(wid));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  RestoreBallTerm(wid);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef  COROUTINING
 | 
			
		||||
  REMOTE_WokenGoals(wid) = TermToGlobalAdjust(REMOTE_WokenGoals(wid));
 | 
			
		||||
  REMOTE_AttsMutableList(wid) = TermToGlobalAdjust(REMOTE_AttsMutableList(wid));
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  REMOTE_GcGeneration(wid) = TermToGlobalAdjust(REMOTE_GcGeneration(wid));
 | 
			
		||||
  REMOTE_GcPhase(wid) = TermToGlobalAdjust(REMOTE_GcPhase(wid));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined(GC_NO_TAGS)
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  REMOTE_DynamicArrays(wid) = PtoArrayEAdjust(REMOTE_DynamicArrays(wid));
 | 
			
		||||
  REMOTE_StaticArrays(wid) = PtoArraySAdjust(REMOTE_StaticArrays(wid));
 | 
			
		||||
  REMOTE_GlobalVariables(wid) = PtoGlobalEAdjust(REMOTE_GlobalVariables(wid));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef THREADS
 | 
			
		||||
 | 
			
		||||
#endif /* THREADS */
 | 
			
		||||
#if defined(YAPOR) || defined(TABLING)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif /* YAPOR || TABLING */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if LOW_LEVEL_TRACER
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef ANALYST
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif /* ANALYST */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef LOAD_DYLD
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef LOW_LEVEL_TRACER
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if __ANDROID__
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -56,6 +56,9 @@
 | 
			
		||||
  Atom AtomArrow_;
 | 
			
		||||
#define AtomArrow Yap_heap_regs->AtomArrow_
 | 
			
		||||
#define TermArrow MkAtomTerm( Yap_heap_regs->AtomArrow_ )
 | 
			
		||||
  Atom AtomAttributedModule_;
 | 
			
		||||
#define AtomAttributedModule Yap_heap_regs->AtomAttributedModule_
 | 
			
		||||
#define TermAttributedModule MkAtomTerm( Yap_heap_regs->AtomAttributedModule_ )
 | 
			
		||||
  Atom AtomDoubleArrow_;
 | 
			
		||||
#define AtomDoubleArrow Yap_heap_regs->AtomDoubleArrow_
 | 
			
		||||
#define TermDoubleArrow MkAtomTerm( Yap_heap_regs->AtomDoubleArrow_ )
 | 
			
		||||
@@ -1426,6 +1429,8 @@
 | 
			
		||||
#define FunctorPortray Yap_heap_regs->FunctorPortray_
 | 
			
		||||
  Functor FunctorPrintMessage_;
 | 
			
		||||
#define FunctorPrintMessage Yap_heap_regs->FunctorPrintMessage_
 | 
			
		||||
  Functor FunctorProcedure_;
 | 
			
		||||
#define FunctorProcedure Yap_heap_regs->FunctorProcedure_
 | 
			
		||||
  Functor FunctorPrologConstraint_;
 | 
			
		||||
#define FunctorPrologConstraint Yap_heap_regs->FunctorPrologConstraint_
 | 
			
		||||
  Functor FunctorQuery_;
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,7 @@ if (WITH_TABLING)
 | 
			
		||||
  #and it is used across several files outside OPTYap
 | 
			
		||||
  set_property(DIRECTORY ..   APPEND PROPERTY COMPILE_DEFINITIONS  TABLING=1)
 | 
			
		||||
  include_directories (OPTYap )
 | 
			
		||||
  set(YAP_SYSTEM_OPTIONS "tabling " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
 | 
			
		||||
endif(WITH_TABLING)
 | 
			
		||||
 | 
			
		||||
option (WITH_YAPOR "Experimental Support for Or-parallelism" OFF)
 | 
			
		||||
@@ -44,24 +45,28 @@ OPTION (WITH_YAPOR_COPY "Copy-based Or-parallelism" OFF)
 | 
			
		||||
if (WITH_YAPOR_COPY)
 | 
			
		||||
  set_property(DIRECTORY ..  APPEND PROPERTY COMPILE_DEFINITIONS  YAPOR_COPY=1;USE_DL_MALLOC=1)
 | 
			
		||||
  set(WITH_YAPOR ON)
 | 
			
		||||
  set(YAP_SYSTEM_OPTIONS "or_parallelism " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
 | 
			
		||||
 endif (WITH_YAPOR_COPY)
 | 
			
		||||
 | 
			
		||||
OPTION (WITH_YAPOR_THOR "Thread-based Or-parallelism" OFF)
 | 
			
		||||
if (WITH_YAPOR_THOR)
 | 
			
		||||
  set_property(DIRECTORY .. APPEND PROPERTY COMPILE_DEFINITIONS YAPOR_THREADS=1;USE_SYSTEM_MALLOC=1)
 | 
			
		||||
  set(WITH_YAPOR ON)
 | 
			
		||||
  set(YAP_SYSTEM_OPTIONS "or_parallelism " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
 | 
			
		||||
endif (WITH_YAPOR_THOR)
 | 
			
		||||
 | 
			
		||||
OPTION (WITH_YAPOR_ACOW "Process-based Copy-On-Write Or-parallelism" OFF)
 | 
			
		||||
if (WITH_YAPOR_ACOW)
 | 
			
		||||
  set_property(DIRECTORY .. APPEND PROPERTY COMPILE_DEFINITIONS  YAPOR_COW=1;USE_SYSTEM_MALLOC=1)
 | 
			
		||||
  set(WITH_YAPOR ON)
 | 
			
		||||
  set(YAP_SYSTEM_OPTIONS "or_parallelism " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
 | 
			
		||||
endif (WITH_YAPOR_ACOW)
 | 
			
		||||
 | 
			
		||||
OPTION (WITH_YAPOR_SBA "Sparse Bind Array-based Or-parallelism" OFF)
 | 
			
		||||
if (WITH_YAPOR_SBA)
 | 
			
		||||
  set_property(DIRECTORY .. APPEND PROPERTY COMPILE_DEFINITIONS  YAPOR_SBA=1;USE_SYSTEM_MALLOC=1)
 | 
			
		||||
  set(WITH_YAPOR ON)
 | 
			
		||||
  set(YAP_SYSTEM_OPTIONS "or_parallelism, " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
 | 
			
		||||
endif (WITH_YAPOR_SBA)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -79,6 +84,7 @@ set (POSITION_INDEPENDENT_CODE TRUE)
 | 
			
		||||
add_library (libOPTYap  OBJECT
 | 
			
		||||
		${OPTYap_SOURCES} )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
set_target_properties(libOPTYap
 | 
			
		||||
  PROPERTIES
 | 
			
		||||
  #  RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
 | 
			
		||||
 
 | 
			
		||||
@@ -34,14 +34,14 @@
 | 
			
		||||
#include "sys/wait.h"
 | 
			
		||||
#endif /* YAPOR_COW */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*********************
 | 
			
		||||
**      Macros      **
 | 
			
		||||
*********************/
 | 
			
		||||
 | 
			
		||||
#ifdef USE_PAGES_MALLOC
 | 
			
		||||
#define STRUCTS_PER_PAGE(STR_TYPE)  ((Yap_page_size - ADJUST_SIZE(sizeof(struct page_header))) / ADJUST_SIZE(sizeof(STR_TYPE)))
 | 
			
		||||
#define STRUCTS_PER_PAGE(STR_TYPE)                                             \
 | 
			
		||||
  ((Yap_page_size - ADJUST_SIZE(sizeof(struct page_header))) /                 \
 | 
			
		||||
   ADJUST_SIZE(sizeof(STR_TYPE)))
 | 
			
		||||
 | 
			
		||||
#define INIT_GLOBAL_PAGE_ENTRY(PG, STR_TYPE)                                   \
 | 
			
		||||
  INIT_LOCK(PgEnt_lock(PG));                                                   \
 | 
			
		||||
@@ -61,13 +61,12 @@
 | 
			
		||||
#define INIT_LOCAL_PAGE_ENTRY(PG, STR_TYPE) PgEnt_strs_in_use(PG) = 0
 | 
			
		||||
#endif /* USE_PAGES_MALLOC */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*******************************
 | 
			
		||||
**      Global functions      **
 | 
			
		||||
*******************************/
 | 
			
		||||
 | 
			
		||||
void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop, int delay_load) {
 | 
			
		||||
void Yap_init_global_optyap_data(int max_table_size, int n_workers,
 | 
			
		||||
                                 int sch_loop, int delay_load) {
 | 
			
		||||
  int i;
 | 
			
		||||
 | 
			
		||||
/* global data related to memory management */
 | 
			
		||||
@@ -94,14 +93,18 @@ void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop
 | 
			
		||||
#endif /* TABLING */
 | 
			
		||||
#ifdef YAPOR
 | 
			
		||||
  INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_or_fr, struct or_frame);
 | 
			
		||||
  INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_qg_sol_fr, struct query_goal_solution_frame);
 | 
			
		||||
  INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_qg_ans_fr, struct query_goal_answer_frame);
 | 
			
		||||
  INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_qg_sol_fr,
 | 
			
		||||
                         struct query_goal_solution_frame);
 | 
			
		||||
  INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_qg_ans_fr,
 | 
			
		||||
                         struct query_goal_answer_frame);
 | 
			
		||||
#ifdef TABLING
 | 
			
		||||
  INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_susp_fr, struct suspension_frame);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef TABLING_INNER_CUTS
 | 
			
		||||
  INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_tg_sol_fr, struct table_subgoal_solution_frame);
 | 
			
		||||
  INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_tg_ans_fr, struct table_subgoal_answer_frame);
 | 
			
		||||
  INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_tg_sol_fr,
 | 
			
		||||
                         struct table_subgoal_solution_frame);
 | 
			
		||||
  INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_tg_ans_fr,
 | 
			
		||||
                         struct table_subgoal_answer_frame);
 | 
			
		||||
#endif
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
 | 
			
		||||
@@ -109,7 +112,8 @@ void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop
 | 
			
		||||
  /* global static data */
 | 
			
		||||
  GLOBAL_number_workers = n_workers;
 | 
			
		||||
  GLOBAL_worker_pid(0) = getpid();
 | 
			
		||||
  for (i = 1; i < GLOBAL_number_workers; i++) GLOBAL_worker_pid(i) = 0;
 | 
			
		||||
  for (i = 1; i < GLOBAL_number_workers; i++)
 | 
			
		||||
    GLOBAL_worker_pid(i) = 0;
 | 
			
		||||
  GLOBAL_scheduler_loop = sch_loop;
 | 
			
		||||
  GLOBAL_delayed_release_load = delay_load;
 | 
			
		||||
 | 
			
		||||
@@ -146,7 +150,8 @@ void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop
 | 
			
		||||
  GLOBAL_root_tab_ent = NULL;
 | 
			
		||||
#ifdef LIMIT_TABLING
 | 
			
		||||
  if (max_table_size)
 | 
			
		||||
    GLOBAL_max_pages = ((max_table_size - 1) * 1024 * 1024 / SHMMAX + 1) * SHMMAX / Yap_page_size;
 | 
			
		||||
    GLOBAL_max_pages = ((max_table_size - 1) * 1024 * 1024 / SHMMAX + 1) *
 | 
			
		||||
                       SHMMAX / Yap_page_size;
 | 
			
		||||
  else
 | 
			
		||||
    GLOBAL_max_pages = -1;
 | 
			
		||||
  GLOBAL_first_sg_fr = NULL;
 | 
			
		||||
@@ -154,7 +159,8 @@ void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop
 | 
			
		||||
  GLOBAL_check_sg_fr = NULL;
 | 
			
		||||
#endif /* LIMIT_TABLING */
 | 
			
		||||
#ifdef YAPOR
 | 
			
		||||
  new_dependency_frame(GLOBAL_root_dep_fr, FALSE, NULL, NULL, NULL, NULL, FALSE, NULL);
 | 
			
		||||
  new_dependency_frame(GLOBAL_root_dep_fr, FALSE, NULL, NULL, NULL, NULL, FALSE,
 | 
			
		||||
                       NULL);
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
  for (i = 0; i < MAX_TABLE_VARS; i++) {
 | 
			
		||||
    CELL *pt = GLOBAL_table_var_enumerator_addr(i);
 | 
			
		||||
@@ -169,7 +175,6 @@ void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop
 | 
			
		||||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void Yap_init_local_optyap_data(int wid) {
 | 
			
		||||
#if defined(YAPOR_THREADS) || defined(THREADS_CONSUMER_SHARING)
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
@@ -234,7 +239,6 @@ void Yap_init_local_optyap_data(int wid) {
 | 
			
		||||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void Yap_init_root_frames(void) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
 | 
			
		||||
@@ -267,18 +271,21 @@ void Yap_init_root_frames(void) {
 | 
			
		||||
  new_global_trie_node(GLOBAL_root_gt, 0, NULL, NULL, NULL);
 | 
			
		||||
/* root dependency frame */
 | 
			
		||||
#ifdef YAPOR
 | 
			
		||||
  DepFr_cons_cp(GLOBAL_root_dep_fr) = B;  /* with YAPOR, at that point, LOCAL_top_dep_fr shouldn't be the same as GLOBAL_root_dep_fr ? */
 | 
			
		||||
  DepFr_cons_cp(GLOBAL_root_dep_fr) = B; /* with YAPOR, at that point,
 | 
			
		||||
                                            LOCAL_top_dep_fr shouldn't be the
 | 
			
		||||
                                            same as GLOBAL_root_dep_fr ? */
 | 
			
		||||
#else
 | 
			
		||||
  new_dependency_frame(LOCAL_top_dep_fr, FALSE, NULL, NULL, B, NULL, FALSE, NULL); 
 | 
			
		||||
  new_dependency_frame(LOCAL_top_dep_fr, FALSE, NULL, NULL, B, NULL, FALSE,
 | 
			
		||||
                       NULL);
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
#endif /* TABLING */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void itos(int i, char *s) {
 | 
			
		||||
  int n, r, j;
 | 
			
		||||
  n = 10;
 | 
			
		||||
  while (n <= i) n *= 10;
 | 
			
		||||
  while (n <= i)
 | 
			
		||||
    n *= 10;
 | 
			
		||||
  j = 0;
 | 
			
		||||
  while (n > 1) {
 | 
			
		||||
    n = n / 10;
 | 
			
		||||
 
 | 
			
		||||
@@ -75,32 +75,43 @@ static inline struct page_statistics show_statistics_table_entries(FILE *out);
 | 
			
		||||
static inline struct page_statistics show_statistics_subgoal_entries(FILE *out);
 | 
			
		||||
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
 | 
			
		||||
static inline struct page_statistics show_statistics_subgoal_frames(FILE *out);
 | 
			
		||||
static inline struct page_statistics show_statistics_dependency_frames(FILE *out);
 | 
			
		||||
static inline struct page_statistics show_statistics_subgoal_trie_nodes(FILE *out);
 | 
			
		||||
static inline struct page_statistics show_statistics_subgoal_trie_hashes(FILE *out);
 | 
			
		||||
static inline struct page_statistics show_statistics_answer_trie_nodes(FILE *out);
 | 
			
		||||
static inline struct page_statistics show_statistics_answer_trie_hashes(FILE *out);
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_dependency_frames(FILE *out);
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_subgoal_trie_nodes(FILE *out);
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_subgoal_trie_hashes(FILE *out);
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_answer_trie_nodes(FILE *out);
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_answer_trie_hashes(FILE *out);
 | 
			
		||||
#if defined(THREADS_FULL_SHARING)
 | 
			
		||||
static inline struct page_statistics show_statistics_answer_ref_nodes(FILE *out);
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_answer_ref_nodes(FILE *out);
 | 
			
		||||
#endif /* THREADS_FULL_SHARING */
 | 
			
		||||
static inline struct page_statistics show_statistics_global_trie_nodes(FILE *out);
 | 
			
		||||
static inline struct page_statistics show_statistics_global_trie_hashes(FILE *out);
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_global_trie_nodes(FILE *out);
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_global_trie_hashes(FILE *out);
 | 
			
		||||
#endif /* TABLING */
 | 
			
		||||
#ifdef YAPOR
 | 
			
		||||
static inline struct page_statistics show_statistics_or_frames(FILE *out);
 | 
			
		||||
static inline struct page_statistics show_statistics_query_goal_solution_frames(FILE *out);
 | 
			
		||||
static inline struct page_statistics show_statistics_query_goal_answer_frames(FILE *out);
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_query_goal_solution_frames(FILE *out);
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_query_goal_answer_frames(FILE *out);
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
#if defined(YAPOR) && defined(TABLING)
 | 
			
		||||
static inline struct page_statistics show_statistics_suspension_frames(FILE *out);
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_suspension_frames(FILE *out);
 | 
			
		||||
#ifdef TABLING_INNER_CUTS
 | 
			
		||||
static inline struct page_statistics show_statistics_table_subgoal_solution_frames(FILE *out);
 | 
			
		||||
static inline struct page_statistics show_statistics_table_subgoal_answer_frames(FILE *out);
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_table_subgoal_solution_frames(FILE *out);
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_table_subgoal_answer_frames(FILE *out);
 | 
			
		||||
#endif /* TABLING_INNER_CUTS */
 | 
			
		||||
#endif /* YAPOR && TABLING */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/************************************
 | 
			
		||||
**      Macros & Declarations      **
 | 
			
		||||
************************************/
 | 
			
		||||
@@ -118,7 +129,8 @@ struct page_statistics {
 | 
			
		||||
#ifdef USE_PAGES_MALLOC
 | 
			
		||||
#ifdef DEBUG_TABLING
 | 
			
		||||
#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE, PAGE)                                \
 | 
			
		||||
        { pg_hd_ptr pg_hd;                                                                 \
 | 
			
		||||
  {                                                                            \
 | 
			
		||||
    pg_hd_ptr pg_hd;                                                           \
 | 
			
		||||
    STR_TYPE *aux_ptr;                                                         \
 | 
			
		||||
    long cont = 0;                                                             \
 | 
			
		||||
    pg_hd = PgEnt_first(PAGE);                                                 \
 | 
			
		||||
@@ -130,7 +142,8 @@ struct page_statistics {
 | 
			
		||||
      }                                                                        \
 | 
			
		||||
      pg_hd = PgHd_next(pg_hd);                                                \
 | 
			
		||||
    }                                                                          \
 | 
			
		||||
          TABLING_ERROR_CHECKING(CHECK_PAGE_FREE_STRUCTS, PgEnt_strs_free(PAGE) != cont);  \
 | 
			
		||||
    TABLING_ERROR_CHECKING(CHECK_PAGE_FREE_STRUCTS,                            \
 | 
			
		||||
                           PgEnt_strs_free(PAGE) != cont);                     \
 | 
			
		||||
  }
 | 
			
		||||
#else
 | 
			
		||||
#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE, PAGE)
 | 
			
		||||
@@ -144,27 +157,31 @@ struct page_statistics {
 | 
			
		||||
#define INCREMENT_AUX_STATS(STATS, BYTES, PAGES)                               \
 | 
			
		||||
  BYTES += PgEnt_bytes_in_use(STATS);                                          \
 | 
			
		||||
  PAGES += PgEnt_pages_in_use(STATS)
 | 
			
		||||
#define SHOW_PAGE_STATS_MSG(STR_NAME)          "  " STR_NAME "   %10ld bytes (%ld pages and %ld structs in use)\n"
 | 
			
		||||
#define SHOW_PAGE_STATS_ARGS(STATS, STR_TYPE)  PgEnt_strs_in_use(STATS) * sizeof(STR_TYPE), PgEnt_pages_in_use(STATS), PgEnt_strs_in_use(STATS)
 | 
			
		||||
#define SHOW_PAGE_STATS_MSG(STR_NAME)                                          \
 | 
			
		||||
  "  " STR_NAME "   %10ld bytes (%ld pages and %ld structs in use)\n"
 | 
			
		||||
#define SHOW_PAGE_STATS_ARGS(STATS, STR_TYPE)                                  \
 | 
			
		||||
  PgEnt_strs_in_use(STATS) * sizeof(STR_TYPE), PgEnt_pages_in_use(STATS),      \
 | 
			
		||||
      PgEnt_strs_in_use(STATS)
 | 
			
		||||
#else /* !USE_PAGES_MALLOC */
 | 
			
		||||
#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE, PAGE)
 | 
			
		||||
#define INIT_PAGE_STATS(STATS)                                  \
 | 
			
		||||
        PgEnt_strs_in_use(STATS) = 0
 | 
			
		||||
#define INIT_PAGE_STATS(STATS) PgEnt_strs_in_use(STATS) = 0
 | 
			
		||||
#define INCREMENT_PAGE_STATS(STATS, PAGE)                                      \
 | 
			
		||||
  PgEnt_strs_in_use(STATS) += PgEnt_strs_in_use(PAGE)
 | 
			
		||||
#define INCREMENT_AUX_STATS(STATS, BYTES, PAGES)                               \
 | 
			
		||||
  BYTES += PgEnt_bytes_in_use(STATS)
 | 
			
		||||
#define SHOW_PAGE_STATS_MSG(STR_NAME)          "  " STR_NAME "   %10ld bytes (%ld structs in use)\n"
 | 
			
		||||
#define SHOW_PAGE_STATS_ARGS(STATS, STR_TYPE)  PgEnt_strs_in_use(STATS) * sizeof(STR_TYPE), PgEnt_strs_in_use(STATS)
 | 
			
		||||
#define SHOW_PAGE_STATS_MSG(STR_NAME)                                          \
 | 
			
		||||
  "  " STR_NAME "   %10ld bytes (%ld structs in use)\n"
 | 
			
		||||
#define SHOW_PAGE_STATS_ARGS(STATS, STR_TYPE)                                  \
 | 
			
		||||
  PgEnt_strs_in_use(STATS) * sizeof(STR_TYPE), PgEnt_strs_in_use(STATS)
 | 
			
		||||
#endif /* USE_PAGES_MALLOC */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined(THREADS) && defined(TABLING)
 | 
			
		||||
#define GET_ALL_PAGE_STATS(STATS, STR_TYPE, _PAGES)                            \
 | 
			
		||||
  LOCK(GLOBAL_ThreadHandlesLock);                                              \
 | 
			
		||||
  CHECK_PAGE_FREE_STRUCTS(STR_TYPE, GLOBAL##_PAGES);                           \
 | 
			
		||||
  INCREMENT_PAGE_STATS(STATS, GLOBAL##_PAGES);                                 \
 | 
			
		||||
        { int wid;                                                     \
 | 
			
		||||
  {                                                                            \
 | 
			
		||||
    int wid;                                                                   \
 | 
			
		||||
    for (wid = 0; wid < MAX_THREADS; wid++) {                                  \
 | 
			
		||||
      if (!Yap_local[wid])                                                     \
 | 
			
		||||
        break;                                                                 \
 | 
			
		||||
@@ -186,29 +203,39 @@ struct page_statistics {
 | 
			
		||||
  GET_ALL_PAGE_STATS(STATS, STR_TYPE, _PAGES);                                 \
 | 
			
		||||
  PgEnt_bytes_in_use(STATS) = PgEnt_strs_in_use(STATS) * sizeof(STR_TYPE)
 | 
			
		||||
#define SHOW_PAGE_STATS(OUT_STREAM, STR_TYPE, _PAGES, STR_NAME)                \
 | 
			
		||||
        { struct page_statistics stats;                                                                \
 | 
			
		||||
  {                                                                            \
 | 
			
		||||
    struct page_statistics stats;                                              \
 | 
			
		||||
    GET_PAGE_STATS(stats, STR_TYPE, _PAGES);                                   \
 | 
			
		||||
          fprintf(OUT_STREAM, SHOW_PAGE_STATS_MSG(STR_NAME), SHOW_PAGE_STATS_ARGS(stats, STR_TYPE));  \
 | 
			
		||||
    fprintf(OUT_STREAM, SHOW_PAGE_STATS_MSG(STR_NAME),                         \
 | 
			
		||||
            SHOW_PAGE_STATS_ARGS(stats, STR_TYPE));                            \
 | 
			
		||||
    return stats;                                                              \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*******************************
 | 
			
		||||
**      Global functions      **
 | 
			
		||||
*******************************/
 | 
			
		||||
 | 
			
		||||
void Yap_init_optyap_preds(void) {
 | 
			
		||||
  Yap_InitCPred("$c_yapor_workers", 1, p_yapor_workers, SafePredFlag|SyncPredFlag);    
 | 
			
		||||
  Yap_InitCPred("$c_yapor_workers", 1, p_yapor_workers,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
#ifdef TABLING
 | 
			
		||||
  Yap_InitCPred("freeze_choice_point", 1, p_freeze_choice_point, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("wake_choice_point", 1, p_wake_choice_point, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("abolish_frozen_choice_points", 1, p_abolish_frozen_choice_points_until, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("abolish_frozen_choice_points", 0, p_abolish_frozen_choice_points_all, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("freeze_choice_point", 1, p_freeze_choice_point,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("wake_choice_point", 1, p_wake_choice_point,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("abolish_frozen_choice_points", 1,
 | 
			
		||||
                p_abolish_frozen_choice_points_until,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("abolish_frozen_choice_points", 0,
 | 
			
		||||
                p_abolish_frozen_choice_points_all,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$c_table", 3, p_table, SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$c_tabling_mode", 3, p_tabling_mode, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$c_abolish_table", 2, p_abolish_table, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("abolish_all_tables", 0, p_abolish_all_tables, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$c_tabling_mode", 3, p_tabling_mode,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$c_abolish_table", 2, p_abolish_table,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("abolish_all_tables", 0, p_abolish_all_tables,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  /** @pred abolish_all_tables/0
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -217,29 +244,41 @@ predicates. The predicates remain as tabled predicates.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  */
 | 
			
		||||
  Yap_InitCPred("show_tabled_predicates", 1, p_show_tabled_predicates, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("show_tabled_predicates", 1, p_show_tabled_predicates,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$c_show_table", 3, p_show_table, SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("show_all_tables", 1, p_show_all_tables, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("show_global_trie", 1, p_show_global_trie, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$c_table_statistics", 3, p_show_statistics_table, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("tabling_statistics", 1, p_show_statistics_tabling, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("global_trie_statistics", 1, p_show_statistics_global_trie, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("show_all_tables", 1, p_show_all_tables,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("show_global_trie", 1, p_show_global_trie,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$c_table_statistics", 3, p_show_statistics_table,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("tabling_statistics", 1, p_show_statistics_tabling,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("global_trie_statistics", 1, p_show_statistics_global_trie,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
#endif /* TABLING */
 | 
			
		||||
#ifdef YAPOR
 | 
			
		||||
  Yap_InitCPred("parallel_mode", 1, p_parallel_mode, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$c_yapor_start", 0, p_yapor_start, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("parallel_mode", 1, p_parallel_mode,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$c_yapor_start", 0, p_yapor_start,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$c_worker", 0, p_worker, SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$c_parallel_new_answer", 1, p_parallel_new_answer, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$c_parallel_get_answers", 1, p_parallel_get_answers, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("or_statistics", 1, p_show_statistics_or, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$c_parallel_new_answer", 1, p_parallel_new_answer,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$c_parallel_get_answers", 1, p_parallel_get_answers,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("or_statistics", 1, p_show_statistics_or,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
#if defined(YAPOR) && defined(TABLING)
 | 
			
		||||
  Yap_InitCPred("opt_statistics", 1, p_show_statistics_opt, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("opt_statistics", 1, p_show_statistics_opt,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
#endif /* YAPOR && TABLING */
 | 
			
		||||
  Yap_InitCPred("$c_get_optyap_statistics", 3, p_get_optyap_statistics, SafePredFlag|SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("$c_get_optyap_statistics", 3, p_get_optyap_statistics,
 | 
			
		||||
                SafePredFlag | SyncPredFlag);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef YAPOR
 | 
			
		||||
void finish_yapor(void) {
 | 
			
		||||
  GLOBAL_execution_time = current_time() - GLOBAL_execution_time;
 | 
			
		||||
@@ -248,8 +287,6 @@ void finish_yapor(void) {
 | 
			
		||||
}
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/***********************************
 | 
			
		||||
**      Tabling C Predicates      **
 | 
			
		||||
***********************************/
 | 
			
		||||
@@ -263,7 +300,6 @@ static Int p_freeze_choice_point( USES_REGS1 ) {
 | 
			
		||||
  return (FALSE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_wake_choice_point(USES_REGS1) {
 | 
			
		||||
  Term term_offset = Deref(ARG1);
 | 
			
		||||
  if (IsIntegerTerm(term_offset))
 | 
			
		||||
@@ -271,7 +307,6 @@ static Int p_wake_choice_point( USES_REGS1 ) {
 | 
			
		||||
  return (FALSE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_abolish_frozen_choice_points_until(USES_REGS1) {
 | 
			
		||||
  Term term_offset = Deref(ARG1);
 | 
			
		||||
  if (IsIntegerTerm(term_offset))
 | 
			
		||||
@@ -279,13 +314,11 @@ static Int p_abolish_frozen_choice_points_until( USES_REGS1 ) {
 | 
			
		||||
  return (TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_abolish_frozen_choice_points_all(USES_REGS1) {
 | 
			
		||||
  abolish_frozen_cps_all();
 | 
			
		||||
  return (TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_table(USES_REGS1) {
 | 
			
		||||
  Term mod, t, list;
 | 
			
		||||
  PredEntry *pe;
 | 
			
		||||
@@ -312,13 +345,17 @@ static Int p_table( USES_REGS1 ) {
 | 
			
		||||
    return (FALSE);
 | 
			
		||||
  if (list != TermNil) { /* non-empty list */
 | 
			
		||||
#ifndef MODE_DIRECTED_TABLING
 | 
			
		||||
    Yap_Error(SYSTEM_ERROR_COMPILER, TermNil, "invalid tabling declaration for %s/%d (mode directed tabling not enabled)", AtomName(at), arity);
 | 
			
		||||
    Yap_Error(SYSTEM_ERROR_COMPILER, TermNil, "invalid tabling declaration for "
 | 
			
		||||
                                              "%s/%d (mode directed tabling "
 | 
			
		||||
                                              "not enabled)",
 | 
			
		||||
              AtomName(at), arity);
 | 
			
		||||
    return (FALSE);
 | 
			
		||||
#else
 | 
			
		||||
    /*************************************************************************************
 | 
			
		||||
      The mode operator declaration is reordered as follows:
 | 
			
		||||
         1. arguments with mode 'index'         (any number)
 | 
			
		||||
         2. arguments with mode 'min' and 'max' (any number, following the original order)
 | 
			
		||||
         2. arguments with mode 'min' and 'max' (any number, following the
 | 
			
		||||
    original order)
 | 
			
		||||
         3. arguments with mode 'all'           (any number)
 | 
			
		||||
         4. arguments with mode 'sum' or 'last' (only one of the two is allowed)
 | 
			
		||||
         5. arguments with mode 'first'         (any number)
 | 
			
		||||
@@ -343,7 +380,10 @@ static Int p_table( USES_REGS1 ) {
 | 
			
		||||
      else if (mode == MODE_DIRECTED_SUM || mode == MODE_DIRECTED_LAST) {
 | 
			
		||||
        if (pos_sum_last) {
 | 
			
		||||
          free(aux_mode_directed);
 | 
			
		||||
          Yap_Error(SYSTEM_ERROR_COMPILER, TermNil, "invalid tabling declaration for %s/%d (more than one argument with modes 'sum' and/or 'last')", AtomName(at), arity);
 | 
			
		||||
          Yap_Error(SYSTEM_ERROR_COMPILER, TermNil,
 | 
			
		||||
                    "invalid tabling declaration for %s/%d (more than one "
 | 
			
		||||
                    "argument with modes 'sum' and/or 'last')",
 | 
			
		||||
                    AtomName(at), arity);
 | 
			
		||||
          return (FALSE);
 | 
			
		||||
        } else
 | 
			
		||||
          pos_sum_last = 1;
 | 
			
		||||
@@ -361,11 +401,13 @@ static Int p_table( USES_REGS1 ) {
 | 
			
		||||
      int aux_pos = 0;
 | 
			
		||||
      if (aux_mode_directed[i] == MODE_DIRECTED_INDEX)
 | 
			
		||||
        aux_pos = pos_index++;
 | 
			
		||||
      else if (aux_mode_directed[i] == MODE_DIRECTED_MIN || aux_mode_directed[i] == MODE_DIRECTED_MAX)
 | 
			
		||||
      else if (aux_mode_directed[i] == MODE_DIRECTED_MIN ||
 | 
			
		||||
               aux_mode_directed[i] == MODE_DIRECTED_MAX)
 | 
			
		||||
        aux_pos = pos_min_max++;
 | 
			
		||||
      else if (aux_mode_directed[i] == MODE_DIRECTED_ALL)
 | 
			
		||||
        aux_pos = pos_all++;
 | 
			
		||||
      else if (aux_mode_directed[i] == MODE_DIRECTED_SUM || aux_mode_directed[i] == MODE_DIRECTED_LAST)
 | 
			
		||||
      else if (aux_mode_directed[i] == MODE_DIRECTED_SUM ||
 | 
			
		||||
               aux_mode_directed[i] == MODE_DIRECTED_LAST)
 | 
			
		||||
        aux_pos = pos_sum_last++;
 | 
			
		||||
      else if (aux_mode_directed[i] == MODE_DIRECTED_FIRST)
 | 
			
		||||
        aux_pos = pos_first++;
 | 
			
		||||
@@ -386,7 +428,6 @@ static Int p_table( USES_REGS1 ) {
 | 
			
		||||
  return (TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_tabling_mode(USES_REGS1) {
 | 
			
		||||
  Term mod, t, tvalue;
 | 
			
		||||
  tab_ent_ptr tab_ent;
 | 
			
		||||
@@ -470,7 +511,8 @@ static Int p_tabling_mode( USES_REGS1 ) {
 | 
			
		||||
        SetMode_GlobalTrie(TabEnt_mode(tab_ent));
 | 
			
		||||
        return (TRUE);
 | 
			
		||||
      }
 | 
			
		||||
    }  else if (value == 7) {  /* coinductive */ //only affect the predicate flag. Also it cant be unset
 | 
			
		||||
    } else if (value == 7) {
 | 
			
		||||
      /* coinductive */ // only affect the predicate flag. Also it cant be unset
 | 
			
		||||
      SetMode_CoInductive(TabEnt_flags(tab_ent));
 | 
			
		||||
      return (TRUE);
 | 
			
		||||
    }
 | 
			
		||||
@@ -478,7 +520,6 @@ static Int p_tabling_mode( USES_REGS1 ) {
 | 
			
		||||
  return (FALSE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_abolish_table(USES_REGS1) {
 | 
			
		||||
  Term mod, t;
 | 
			
		||||
  tab_ent_ptr tab_ent;
 | 
			
		||||
@@ -495,7 +536,6 @@ static Int p_abolish_table( USES_REGS1 ) {
 | 
			
		||||
  return (TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_abolish_all_tables(USES_REGS1) {
 | 
			
		||||
  tab_ent_ptr tab_ent;
 | 
			
		||||
 | 
			
		||||
@@ -507,7 +547,6 @@ static Int p_abolish_all_tables( USES_REGS1 ) {
 | 
			
		||||
  return (TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_show_tabled_predicates(USES_REGS1) {
 | 
			
		||||
  FILE *out;
 | 
			
		||||
  tab_ent_ptr tab_ent;
 | 
			
		||||
@@ -521,15 +560,16 @@ static Int p_show_tabled_predicates( USES_REGS1 ) {
 | 
			
		||||
  fprintf(out, "Tabled predicates\n");
 | 
			
		||||
  if (tab_ent == NULL)
 | 
			
		||||
    fprintf(out, "  NONE\n");
 | 
			
		||||
  else while(tab_ent) {
 | 
			
		||||
    fprintf(out, "  %s/%d\n", AtomName(TabEnt_atom(tab_ent)), TabEnt_arity(tab_ent));
 | 
			
		||||
  else
 | 
			
		||||
    while (tab_ent) {
 | 
			
		||||
      fprintf(out, "  %s/%d\n", AtomName(TabEnt_atom(tab_ent)),
 | 
			
		||||
              TabEnt_arity(tab_ent));
 | 
			
		||||
      tab_ent = TabEnt_next(tab_ent);
 | 
			
		||||
    }
 | 
			
		||||
  // PL_release_stream(out);
 | 
			
		||||
  return (TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_show_table(USES_REGS1) {
 | 
			
		||||
  Term mod, t;
 | 
			
		||||
  tab_ent_ptr tab_ent;
 | 
			
		||||
@@ -553,7 +593,6 @@ static Int p_show_table( USES_REGS1 ) {
 | 
			
		||||
  return (TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_show_all_tables(USES_REGS1) {
 | 
			
		||||
  tab_ent_ptr tab_ent;
 | 
			
		||||
  Term t = Deref(ARG1);
 | 
			
		||||
@@ -571,7 +610,6 @@ static Int p_show_all_tables( USES_REGS1 ) {
 | 
			
		||||
  return (TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_show_global_trie(USES_REGS1) {
 | 
			
		||||
  Term t = Deref(ARG1);
 | 
			
		||||
  FILE *out;
 | 
			
		||||
@@ -584,7 +622,6 @@ static Int p_show_global_trie( USES_REGS1 ) {
 | 
			
		||||
  return (TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_show_statistics_table(USES_REGS1) {
 | 
			
		||||
  Term mod, t;
 | 
			
		||||
  tab_ent_ptr tab_ent;
 | 
			
		||||
@@ -609,7 +646,6 @@ static Int p_show_statistics_table( USES_REGS1 ) {
 | 
			
		||||
  return (TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_show_statistics_tabling(USES_REGS1) {
 | 
			
		||||
  struct page_statistics stats;
 | 
			
		||||
  long bytes, total_bytes = 0;
 | 
			
		||||
@@ -662,10 +698,14 @@ static Int p_show_statistics_tabling( USES_REGS1 ) {
 | 
			
		||||
  fprintf(out, "  Memory in use (III):             %10ld bytes\n\n", bytes);
 | 
			
		||||
  total_bytes += bytes;
 | 
			
		||||
#ifdef USE_PAGES_MALLOC
 | 
			
		||||
  fprintf(out, "Total memory in use (I+II+III):    %10ld bytes (%ld pages in use)\n",
 | 
			
		||||
  fprintf(out,
 | 
			
		||||
          "Total memory in use (I+II+III):    %10ld bytes (%ld pages in use)\n",
 | 
			
		||||
          total_bytes, total_pages);
 | 
			
		||||
  fprintf(out, "Total memory allocated:            %10ld bytes (%ld pages in total)\n",
 | 
			
		||||
          PgEnt_pages_in_use(GLOBAL_pages_alloc) * Yap_page_size, PgEnt_pages_in_use(GLOBAL_pages_alloc));
 | 
			
		||||
  fprintf(
 | 
			
		||||
      out,
 | 
			
		||||
      "Total memory allocated:            %10ld bytes (%ld pages in total)\n",
 | 
			
		||||
      PgEnt_pages_in_use(GLOBAL_pages_alloc) * Yap_page_size,
 | 
			
		||||
      PgEnt_pages_in_use(GLOBAL_pages_alloc));
 | 
			
		||||
#else
 | 
			
		||||
  fprintf(out, "Total memory in use (I+II+III):    %10ld bytes\n", total_bytes);
 | 
			
		||||
#endif /* USE_PAGES_MALLOC */
 | 
			
		||||
@@ -673,7 +713,6 @@ static Int p_show_statistics_tabling( USES_REGS1 ) {
 | 
			
		||||
  return (TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_show_statistics_global_trie(USES_REGS1) {
 | 
			
		||||
  Term t = Deref(ARG1);
 | 
			
		||||
  FILE *out;
 | 
			
		||||
@@ -687,8 +726,6 @@ static Int p_show_statistics_global_trie( USES_REGS1 ) {
 | 
			
		||||
}
 | 
			
		||||
#endif /* TABLING */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*********************************
 | 
			
		||||
**      YapOr C Predicates      **
 | 
			
		||||
*********************************/
 | 
			
		||||
@@ -724,7 +761,6 @@ static Int p_parallel_mode( USES_REGS1 ) {
 | 
			
		||||
  return (FALSE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_yapor_start(USES_REGS1) {
 | 
			
		||||
#ifdef TIMESTAMP_CHECK
 | 
			
		||||
  GLOBAL_timestamp = 0;
 | 
			
		||||
@@ -742,7 +778,6 @@ static Int p_yapor_start( USES_REGS1 ) {
 | 
			
		||||
  return (TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_yapor_workers(USES_REGS1) {
 | 
			
		||||
#ifdef YAPOR_THREADS
 | 
			
		||||
  return Yap_unify(MkIntegerTerm(GLOBAL_number_workers), ARG1);
 | 
			
		||||
@@ -751,14 +786,12 @@ static Int p_yapor_workers( USES_REGS1 ) {
 | 
			
		||||
#endif /* YAPOR_THREADS */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_worker(USES_REGS1) {
 | 
			
		||||
  CurrentModule = USER_MODULE;
 | 
			
		||||
  P = GETWORK_FIRST_TIME;
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_parallel_new_answer(USES_REGS1) {
 | 
			
		||||
  qg_ans_fr_ptr actual_answer;
 | 
			
		||||
  or_fr_ptr leftmost_or_fr;
 | 
			
		||||
@@ -778,7 +811,6 @@ static Int p_parallel_new_answer( USES_REGS1 ) {
 | 
			
		||||
  return (TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_parallel_get_answers(USES_REGS1) {
 | 
			
		||||
  Term t = TermNil;
 | 
			
		||||
 | 
			
		||||
@@ -798,7 +830,6 @@ static Int p_parallel_get_answers( USES_REGS1 ){
 | 
			
		||||
  return (TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_show_statistics_or(USES_REGS1) {
 | 
			
		||||
  struct page_statistics stats;
 | 
			
		||||
  long bytes, total_bytes = 0;
 | 
			
		||||
@@ -809,7 +840,8 @@ static Int p_show_statistics_or( USES_REGS1 ) {
 | 
			
		||||
 | 
			
		||||
  if (!IsStreamTerm(t))
 | 
			
		||||
    return FALSE;
 | 
			
		||||
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\  bytes = 0;
 | 
			
		||||
  \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ bytes =
 | 
			
		||||
      0;
 | 
			
		||||
  fprintf(out, "Execution data structures\n");
 | 
			
		||||
  stats = show_statistics_or_frames(out);
 | 
			
		||||
  INCREMENT_AUX_STATS(stats, bytes, total_pages);
 | 
			
		||||
@@ -824,10 +856,14 @@ static Int p_show_statistics_or( USES_REGS1 ) {
 | 
			
		||||
  fprintf(out, "  Memory in use (II):              %10ld bytes\n\n", bytes);
 | 
			
		||||
  total_bytes += bytes;
 | 
			
		||||
#ifdef USE_PAGES_MALLOC
 | 
			
		||||
  fprintf(out, "Total memory in use (I+II):        %10ld bytes (%ld pages in use)\n",
 | 
			
		||||
  fprintf(out,
 | 
			
		||||
          "Total memory in use (I+II):        %10ld bytes (%ld pages in use)\n",
 | 
			
		||||
          total_bytes, total_pages);
 | 
			
		||||
  fprintf(out, "Total memory allocated:            %10ld bytes (%ld pages in total)\n",
 | 
			
		||||
          PgEnt_pages_in_use(GLOBAL_pages_alloc) * Yap_page_size, PgEnt_pages_in_use(GLOBAL_pages_alloc));
 | 
			
		||||
  fprintf(
 | 
			
		||||
      out,
 | 
			
		||||
      "Total memory allocated:            %10ld bytes (%ld pages in total)\n",
 | 
			
		||||
      PgEnt_pages_in_use(GLOBAL_pages_alloc) * Yap_page_size,
 | 
			
		||||
      PgEnt_pages_in_use(GLOBAL_pages_alloc));
 | 
			
		||||
#else
 | 
			
		||||
  fprintf(out, "Total memory in use (I+II):        %10ld bytes\n", total_bytes);
 | 
			
		||||
#endif /* USE_PAGES_MALLOC */
 | 
			
		||||
@@ -837,13 +873,9 @@ static Int p_show_statistics_or( USES_REGS1 ) {
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
static Int p_yapor_workers( USES_REGS1 ) {
 | 
			
		||||
  return FALSE;
 | 
			
		||||
}
 | 
			
		||||
static Int p_yapor_workers(USES_REGS1) { return FALSE; }
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**********************************
 | 
			
		||||
 **      OPTYap C Predicates      **
 | 
			
		||||
**********************************/
 | 
			
		||||
@@ -919,10 +951,14 @@ static Int p_show_statistics_opt( USES_REGS1 ) {
 | 
			
		||||
  fprintf(out, "  Memory in use (IV):              %10ld bytes\n\n", bytes);
 | 
			
		||||
  total_bytes += bytes;
 | 
			
		||||
#ifdef USE_PAGES_MALLOC
 | 
			
		||||
  fprintf(out, "Total memory in use (I+II+III+IV): %10ld bytes (%ld pages in use)\n",
 | 
			
		||||
  fprintf(out,
 | 
			
		||||
          "Total memory in use (I+II+III+IV): %10ld bytes (%ld pages in use)\n",
 | 
			
		||||
          total_bytes, total_pages);
 | 
			
		||||
  fprintf(out, "Total memory allocated:            %10ld bytes (%ld pages in total)\n",
 | 
			
		||||
          PgEnt_pages_in_use(GLOBAL_pages_alloc) * Yap_page_size, PgEnt_pages_in_use(GLOBAL_pages_alloc));
 | 
			
		||||
  fprintf(
 | 
			
		||||
      out,
 | 
			
		||||
      "Total memory allocated:            %10ld bytes (%ld pages in total)\n",
 | 
			
		||||
      PgEnt_pages_in_use(GLOBAL_pages_alloc) * Yap_page_size,
 | 
			
		||||
      PgEnt_pages_in_use(GLOBAL_pages_alloc));
 | 
			
		||||
#else
 | 
			
		||||
  fprintf(out, "Total memory in use (I+II+III+IV): %10ld bytes\n", total_bytes);
 | 
			
		||||
#endif /* USE_PAGES_MALLOC */
 | 
			
		||||
@@ -931,7 +967,6 @@ static Int p_show_statistics_opt( USES_REGS1 ) {
 | 
			
		||||
}
 | 
			
		||||
#endif /* YAPOR && TABLING */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static Int p_get_optyap_statistics(USES_REGS1) {
 | 
			
		||||
  struct page_statistics stats;
 | 
			
		||||
  Int value, bytes = 0, structs = -1;
 | 
			
		||||
@@ -942,96 +977,114 @@ static Int p_get_optyap_statistics( USES_REGS1 ) {
 | 
			
		||||
  if (value == 0 || value == 1) { /* table_entries */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct table_entry, _pages_tab_ent);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
 | 
			
		||||
  if (value == 0 || value == 16) { /* subgoal_entries */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct subgoal_entry, _pages_sg_ent);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
  if (value == 0 || value == 2) { /* subgoal_frames */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct subgoal_frame, _pages_sg_fr);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
  if (value == 0 || value == 3) { /* dependency_frames */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct dependency_frame, _pages_dep_fr);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
  if (value == 0 || value == 6) { /* subgoal_trie_nodes */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct subgoal_trie_node, _pages_sg_node);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
  if (value == 0 || value == 8) { /* subgoal_trie_hashes */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct subgoal_trie_hash, _pages_sg_hash);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
  if (value == 0 || value == 7) { /* answer_trie_nodes */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct answer_trie_node, _pages_ans_node);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
  if (value == 0 || value == 9) { /* answer_trie_hashes */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct answer_trie_hash, _pages_ans_hash);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
#if defined(THREADS_FULL_SHARING)
 | 
			
		||||
  if (value == 0 || value == 17) { /* answer_ref_nodes */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct answer_ref_node, _pages_ans_ref_node);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
  if (value == 0 || value == 10) { /* global_trie_nodes */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct global_trie_node, _pages_gt_node);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
  if (value == 0 || value == 11) { /* global_trie_hashes */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct global_trie_hash, _pages_gt_hash);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
#endif /* TABLING */
 | 
			
		||||
#ifdef YAPOR
 | 
			
		||||
  if (value == 0 || value == 4) { /* or_frames */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct or_frame, _pages_or_fr);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
  if (value == 0 || value == 12) { /* query_goal_solution_frames */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct query_goal_solution_frame, _pages_qg_sol_fr);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
  if (value == 0 || value == 13) { /* query_goal_answer_frames */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct query_goal_answer_frame, _pages_qg_ans_fr);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
#if defined(YAPOR) && defined(TABLING)
 | 
			
		||||
  if (value == 0 || value == 5) { /* suspension_frames */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct suspension_frame, _pages_susp_fr);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
#ifdef TABLING_INNER_CUTS
 | 
			
		||||
  if (value == 0 || value == 14) { /* table_subgoal_solution_frames */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct table_subgoal_solution_frame, _pages_tg_sol_fr);
 | 
			
		||||
    GET_PAGE_STATS(stats, struct table_subgoal_solution_frame,
 | 
			
		||||
                   _pages_tg_sol_fr);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
  if (value == 0 || value == 15) { /* table_subgoal_answer_frames */
 | 
			
		||||
    GET_PAGE_STATS(stats, struct table_subgoal_answer_frame, _pages_tg_ans_fr);
 | 
			
		||||
    bytes += PgEnt_bytes_in_use(stats);
 | 
			
		||||
    if (value != 0) structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
    if (value != 0)
 | 
			
		||||
      structs = PgEnt_strs_in_use(stats);
 | 
			
		||||
  }
 | 
			
		||||
#endif /* TABLING_INNER_CUTS */
 | 
			
		||||
#endif /* YAPOR && TABLING */
 | 
			
		||||
@@ -1058,8 +1111,6 @@ static Int p_get_optyap_statistics( USES_REGS1 ) {
 | 
			
		||||
  return (TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/******************************
 | 
			
		||||
**      Local functions      **
 | 
			
		||||
******************************/
 | 
			
		||||
@@ -1079,99 +1130,113 @@ static inline realtime current_time(void) {
 | 
			
		||||
}
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef TABLING
 | 
			
		||||
static inline struct page_statistics show_statistics_table_entries(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct table_entry, _pages_tab_ent, "Table entries:                ");
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct table_entry, _pages_tab_ent,
 | 
			
		||||
                  "Table entries:                ");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
 | 
			
		||||
static inline struct page_statistics show_statistics_subgoal_entries(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct subgoal_entry, _pages_sg_ent, "Subgoal entries:              ");
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_subgoal_entries(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct subgoal_entry, _pages_sg_ent,
 | 
			
		||||
                  "Subgoal entries:              ");
 | 
			
		||||
}
 | 
			
		||||
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static inline struct page_statistics show_statistics_subgoal_frames(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct subgoal_frame, _pages_sg_fr, "Subgoal frames:               ");
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct subgoal_frame, _pages_sg_fr,
 | 
			
		||||
                  "Subgoal frames:               ");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static inline struct page_statistics show_statistics_dependency_frames(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct dependency_frame, _pages_dep_fr, "Dependency frames:            ");
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_dependency_frames(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct dependency_frame, _pages_dep_fr,
 | 
			
		||||
                  "Dependency frames:            ");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static inline struct page_statistics show_statistics_subgoal_trie_nodes(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct subgoal_trie_node, _pages_sg_node, "Subgoal trie nodes:           ");
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_subgoal_trie_nodes(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct subgoal_trie_node, _pages_sg_node,
 | 
			
		||||
                  "Subgoal trie nodes:           ");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static inline struct page_statistics show_statistics_subgoal_trie_hashes(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct subgoal_trie_hash, _pages_sg_hash, "Subgoal trie hashes:          ");
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_subgoal_trie_hashes(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct subgoal_trie_hash, _pages_sg_hash,
 | 
			
		||||
                  "Subgoal trie hashes:          ");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static inline struct page_statistics show_statistics_answer_trie_nodes(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct answer_trie_node, _pages_ans_node, "Answer trie nodes:            ");
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_answer_trie_nodes(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct answer_trie_node, _pages_ans_node,
 | 
			
		||||
                  "Answer trie nodes:            ");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static inline struct page_statistics show_statistics_answer_trie_hashes(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct answer_trie_hash, _pages_ans_hash, "Answer trie hashes:           ");
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_answer_trie_hashes(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct answer_trie_hash, _pages_ans_hash,
 | 
			
		||||
                  "Answer trie hashes:           ");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined(THREADS_FULL_SHARING)
 | 
			
		||||
static inline struct page_statistics show_statistics_answer_ref_nodes(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct answer_ref_node, _pages_ans_ref_node, "Answer ref nodes:             ");
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_answer_ref_nodes(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct answer_ref_node, _pages_ans_ref_node,
 | 
			
		||||
                  "Answer ref nodes:             ");
 | 
			
		||||
}
 | 
			
		||||
#endif /* THREADS_FULL_SHARING */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static inline struct page_statistics show_statistics_global_trie_nodes(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct global_trie_node, _pages_gt_node, "Global trie nodes:            ");
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_global_trie_nodes(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct global_trie_node, _pages_gt_node,
 | 
			
		||||
                  "Global trie nodes:            ");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static inline struct page_statistics show_statistics_global_trie_hashes(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct global_trie_hash, _pages_gt_hash, "Global trie hashes:           ");
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_global_trie_hashes(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct global_trie_hash, _pages_gt_hash,
 | 
			
		||||
                  "Global trie hashes:           ");
 | 
			
		||||
}
 | 
			
		||||
#endif /* TABLING */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef YAPOR
 | 
			
		||||
static inline struct page_statistics show_statistics_or_frames(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct or_frame, _pages_or_fr, "Or-frames:                    ");
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct or_frame, _pages_or_fr,
 | 
			
		||||
                  "Or-frames:                    ");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static inline struct page_statistics show_statistics_query_goal_solution_frames(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct query_goal_solution_frame, _pages_qg_sol_fr, "Query goal solution frames:   ");
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_query_goal_solution_frames(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct query_goal_solution_frame, _pages_qg_sol_fr,
 | 
			
		||||
                  "Query goal solution frames:   ");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static inline struct page_statistics show_statistics_query_goal_answer_frames(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct query_goal_answer_frame, _pages_qg_ans_fr, "Query goal answer frames:     ");
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_query_goal_answer_frames(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct query_goal_answer_frame, _pages_qg_ans_fr,
 | 
			
		||||
                  "Query goal answer frames:     ");
 | 
			
		||||
}
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined(YAPOR) && defined(TABLING)
 | 
			
		||||
static inline struct page_statistics show_statistics_suspension_frames(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct suspension_frame, _pages_susp_fr, "Suspension frames:            ");
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_suspension_frames(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct suspension_frame, _pages_susp_fr,
 | 
			
		||||
                  "Suspension frames:            ");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef TABLING_INNER_CUTS
 | 
			
		||||
static inline struct page_statistics show_statistics_table_subgoal_solution_frames(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct table_subgoal_solution_frame, _pages_tg_sol_fr, "Table subgoal solution frames:");
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_table_subgoal_solution_frames(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct table_subgoal_solution_frame, _pages_tg_sol_fr,
 | 
			
		||||
                  "Table subgoal solution frames:");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static inline struct page_statistics show_statistics_table_subgoal_answer_frames(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct table_subgoal_answer_frame, _pages_tg_ans_fr, "Table subgoal answer frames:  ");
 | 
			
		||||
static inline struct page_statistics
 | 
			
		||||
show_statistics_table_subgoal_answer_frames(FILE *out) {
 | 
			
		||||
  SHOW_PAGE_STATS(out, struct table_subgoal_answer_frame, _pages_tg_ans_fr,
 | 
			
		||||
                  "Table subgoal answer frames:  ");
 | 
			
		||||
}
 | 
			
		||||
#endif /* TABLING_INNER_CUTS */
 | 
			
		||||
#endif /* YAPOR && TABLING */
 | 
			
		||||
 
 | 
			
		||||
@@ -22,31 +22,48 @@
 | 
			
		||||
#include "eval.h"
 | 
			
		||||
#include "tab.macros.h"
 | 
			
		||||
 | 
			
		||||
static inline sg_node_ptr subgoal_trie_check_insert_entry(tab_ent_ptr, sg_node_ptr, Term USES_REGS);
 | 
			
		||||
static inline sg_node_ptr subgoal_trie_check_insert_gt_entry(tab_ent_ptr, sg_node_ptr, Term USES_REGS);
 | 
			
		||||
static inline ans_node_ptr answer_trie_check_insert_entry(sg_fr_ptr, ans_node_ptr, Term, int USES_REGS);
 | 
			
		||||
static inline ans_node_ptr answer_trie_check_insert_gt_entry(sg_fr_ptr, ans_node_ptr, Term, int USES_REGS);
 | 
			
		||||
static inline gt_node_ptr global_trie_check_insert_entry(gt_node_ptr, Term USES_REGS);
 | 
			
		||||
static inline sg_node_ptr
 | 
			
		||||
subgoal_trie_check_insert_entry(tab_ent_ptr, sg_node_ptr, Term USES_REGS);
 | 
			
		||||
static inline sg_node_ptr
 | 
			
		||||
subgoal_trie_check_insert_gt_entry(tab_ent_ptr, sg_node_ptr, Term USES_REGS);
 | 
			
		||||
static inline ans_node_ptr
 | 
			
		||||
answer_trie_check_insert_entry(sg_fr_ptr, ans_node_ptr, Term, int USES_REGS);
 | 
			
		||||
static inline ans_node_ptr
 | 
			
		||||
answer_trie_check_insert_gt_entry(sg_fr_ptr, ans_node_ptr, Term, int USES_REGS);
 | 
			
		||||
static inline gt_node_ptr global_trie_check_insert_entry(gt_node_ptr,
 | 
			
		||||
                                                         Term USES_REGS);
 | 
			
		||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
 | 
			
		||||
static inline gt_node_ptr global_trie_check_insert_gt_entry(gt_node_ptr, Term USES_REGS);
 | 
			
		||||
static inline gt_node_ptr global_trie_check_insert_gt_entry(gt_node_ptr,
 | 
			
		||||
                                                            Term USES_REGS);
 | 
			
		||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
 | 
			
		||||
static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr, sg_node_ptr, Term, int *, CELL ** USES_REGS);
 | 
			
		||||
static inline sg_node_ptr subgoal_search_terms_loop(tab_ent_ptr, sg_node_ptr, Term, int *, CELL ** USES_REGS);
 | 
			
		||||
static inline ans_node_ptr answer_search_loop(sg_fr_ptr, ans_node_ptr, Term, int * USES_REGS);
 | 
			
		||||
static inline ans_node_ptr answer_search_terms_loop(sg_fr_ptr, ans_node_ptr, Term, int * USES_REGS);
 | 
			
		||||
static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr, sg_node_ptr, Term,
 | 
			
		||||
                                              int *, CELL **USES_REGS);
 | 
			
		||||
static inline sg_node_ptr subgoal_search_terms_loop(tab_ent_ptr, sg_node_ptr,
 | 
			
		||||
                                                    Term, int *,
 | 
			
		||||
                                                    CELL **USES_REGS);
 | 
			
		||||
static inline ans_node_ptr answer_search_loop(sg_fr_ptr, ans_node_ptr, Term,
 | 
			
		||||
                                              int *USES_REGS);
 | 
			
		||||
static inline ans_node_ptr answer_search_terms_loop(sg_fr_ptr, ans_node_ptr,
 | 
			
		||||
                                                    Term, int *USES_REGS);
 | 
			
		||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
 | 
			
		||||
static inline gt_node_ptr subgoal_search_global_trie_terms_loop(Term, int *, CELL **, CELL * USES_REGS);
 | 
			
		||||
static inline gt_node_ptr answer_search_global_trie_terms_loop(Term, int *, CELL * USES_REGS);
 | 
			
		||||
static inline gt_node_ptr
 | 
			
		||||
subgoal_search_global_trie_terms_loop(Term, int *, CELL **, CELL *USES_REGS);
 | 
			
		||||
static inline gt_node_ptr answer_search_global_trie_terms_loop(Term, int *,
 | 
			
		||||
                                                               CELL *USES_REGS);
 | 
			
		||||
#else
 | 
			
		||||
static inline gt_node_ptr subgoal_search_global_trie_loop(Term, int *, CELL ** USES_REGS);
 | 
			
		||||
static inline gt_node_ptr subgoal_search_global_trie_loop(Term, int *,
 | 
			
		||||
                                                          CELL **USES_REGS);
 | 
			
		||||
static inline gt_node_ptr answer_search_global_trie_loop(Term, int *USES_REGS);
 | 
			
		||||
#endif /* GLOBAL_TRIE_MODE */
 | 
			
		||||
static inline CELL *load_answer_loop(ans_node_ptr USES_REGS);
 | 
			
		||||
static inline CELL *load_substitution_loop(gt_node_ptr, int *, CELL *USES_REGS);
 | 
			
		||||
static inline CELL *exec_substitution_loop(gt_node_ptr, CELL **, CELL * USES_REGS);
 | 
			
		||||
static inline CELL *exec_substitution_loop(gt_node_ptr, CELL **,
 | 
			
		||||
                                           CELL *USES_REGS);
 | 
			
		||||
#ifdef MODE_DIRECTED_TABLING
 | 
			
		||||
static inline ans_node_ptr answer_search_min_max(sg_fr_ptr, ans_node_ptr, Term, int USES_REGS);
 | 
			
		||||
static inline ans_node_ptr answer_search_sum(sg_fr_ptr, ans_node_ptr, Term USES_REGS);
 | 
			
		||||
static inline ans_node_ptr answer_search_min_max(sg_fr_ptr, ans_node_ptr, Term,
 | 
			
		||||
                                                 int USES_REGS);
 | 
			
		||||
static inline ans_node_ptr answer_search_sum(sg_fr_ptr, ans_node_ptr,
 | 
			
		||||
                                             Term USES_REGS);
 | 
			
		||||
static void invalidate_answer_trie(ans_node_ptr, sg_fr_ptr, int USES_REGS);
 | 
			
		||||
#endif /* MODE_DIRECTED_TABLING */
 | 
			
		||||
 | 
			
		||||
@@ -64,15 +81,18 @@ static void free_global_trie_branch(gt_node_ptr, int USES_REGS);
 | 
			
		||||
#else
 | 
			
		||||
static void free_global_trie_branch(gt_node_ptr USES_REGS);
 | 
			
		||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
 | 
			
		||||
static void traverse_subgoal_trie(sg_node_ptr, char *, int, int *, int, int USES_REGS);
 | 
			
		||||
static void traverse_answer_trie(ans_node_ptr, char *, int, int *, int, int, int USES_REGS);
 | 
			
		||||
static void traverse_global_trie(gt_node_ptr, char *, int, int *, int, int USES_REGS);
 | 
			
		||||
static void traverse_global_trie_for_term(gt_node_ptr, char *, int *, int *, int *, int USES_REGS);
 | 
			
		||||
static inline void traverse_trie_node(Term, char *, int *, int *, int *, int USES_REGS);
 | 
			
		||||
static void traverse_subgoal_trie(sg_node_ptr, char *, int, int *, int,
 | 
			
		||||
                                  int USES_REGS);
 | 
			
		||||
static void traverse_answer_trie(ans_node_ptr, char *, int, int *, int, int,
 | 
			
		||||
                                 int USES_REGS);
 | 
			
		||||
static void traverse_global_trie(gt_node_ptr, char *, int, int *, int,
 | 
			
		||||
                                 int USES_REGS);
 | 
			
		||||
static void traverse_global_trie_for_term(gt_node_ptr, char *, int *, int *,
 | 
			
		||||
                                          int *, int USES_REGS);
 | 
			
		||||
static inline void traverse_trie_node(Term, char *, int *, int *, int *,
 | 
			
		||||
                                      int USES_REGS);
 | 
			
		||||
static inline void traverse_update_arity(char *, int *, int *);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*******************************
 | 
			
		||||
**      Structs & Macros      **
 | 
			
		||||
*******************************/
 | 
			
		||||
@@ -128,14 +148,18 @@ static struct trie_statistics{
 | 
			
		||||
#define TrStat_gt_refs trie_stats.global_trie_references
 | 
			
		||||
#endif /*THREADS */
 | 
			
		||||
 | 
			
		||||
#if defined(THREADS_SUBGOAL_SHARING) || defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
 | 
			
		||||
#define IF_ABOLISH_SUBGOAL_TRIE_SHARED_DATA_STRUCTURES  if (GLOBAL_NOfThreads == 1)
 | 
			
		||||
#if defined(THREADS_SUBGOAL_SHARING) || defined(THREADS_FULL_SHARING) ||       \
 | 
			
		||||
    defined(THREADS_CONSUMER_SHARING)
 | 
			
		||||
#define IF_ABOLISH_SUBGOAL_TRIE_SHARED_DATA_STRUCTURES                         \
 | 
			
		||||
  if (GLOBAL_NOfThreads == 1)
 | 
			
		||||
#else
 | 
			
		||||
#define IF_ABOLISH_SUBGOAL_TRIE_SHARED_DATA_STRUCTURES
 | 
			
		||||
#endif /* THREADS_SUBGOAL_SHARING || THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
 | 
			
		||||
#endif /* THREADS_SUBGOAL_SHARING || THREADS_FULL_SHARING ||                   \
 | 
			
		||||
          THREADS_CONSUMER_SHARING */
 | 
			
		||||
 | 
			
		||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
 | 
			
		||||
#define IF_ABOLISH_ANSWER_TRIE_SHARED_DATA_STRUCTURES  if (GLOBAL_NOfThreads == 1)
 | 
			
		||||
#define IF_ABOLISH_ANSWER_TRIE_SHARED_DATA_STRUCTURES                          \
 | 
			
		||||
  if (GLOBAL_NOfThreads == 1)
 | 
			
		||||
#else
 | 
			
		||||
#define IF_ABOLISH_ANSWER_TRIE_SHARED_DATA_STRUCTURES
 | 
			
		||||
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
 | 
			
		||||
@@ -147,9 +171,11 @@ static struct trie_statistics{
 | 
			
		||||
  fprintf(TrStat_out, MESG, ##ARGS)
 | 
			
		||||
 | 
			
		||||
#define CHECK_DECREMENT_GLOBAL_TRIE_REFERENCE(REF, MODE)                       \
 | 
			
		||||
        if (MODE == TRAVERSE_MODE_NORMAL && IsVarTerm(REF) && REF > VarIndexOfTableTerm(MAX_TABLE_VARS)) {  \
 | 
			
		||||
  if (MODE == TRAVERSE_MODE_NORMAL && IsVarTerm(REF) &&                        \
 | 
			
		||||
      REF > VarIndexOfTableTerm(MAX_TABLE_VARS)) {                             \
 | 
			
		||||
    register gt_node_ptr gt_node = (gt_node_ptr)(REF);                         \
 | 
			
		||||
          TrNode_child(gt_node) = (gt_node_ptr) ((uintptr_t) TrNode_child(gt_node) - 1);            \
 | 
			
		||||
    TrNode_child(gt_node) =                                                    \
 | 
			
		||||
        (gt_node_ptr)((uintptr_t)TrNode_child(gt_node) - 1);                   \
 | 
			
		||||
    if (TrNode_child(gt_node) == 0)                                            \
 | 
			
		||||
      FREE_GLOBAL_TRIE_BRANCH(gt_node, TRAVERSE_MODE_NORMAL);                  \
 | 
			
		||||
  }
 | 
			
		||||
@@ -171,12 +197,12 @@ static struct trie_statistics{
 | 
			
		||||
#include "tab.rational.h"
 | 
			
		||||
#endif /* RATIONAL TERM SUPPORT FOR TRIES */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/******************************
 | 
			
		||||
**      Local functions      **
 | 
			
		||||
******************************/
 | 
			
		||||
 | 
			
		||||
#define INCLUDE_SUBGOAL_TRIE_CHECK_INSERT  /* subgoal_trie_check_insert_entry */
 | 
			
		||||
#define INCLUDE_SUBGOAL_TRIE_CHECK_INSERT /* subgoal_trie_check_insert_entry   \
 | 
			
		||||
                                             */
 | 
			
		||||
#define INCLUDE_ANSWER_TRIE_CHECK_INSERT  /* answer_trie_check_insert_entry */
 | 
			
		||||
#define INCLUDE_GLOBAL_TRIE_CHECK_INSERT  /* global_trie_check_insert_entry */
 | 
			
		||||
#include "tab.tries.h"
 | 
			
		||||
@@ -185,10 +211,13 @@ static struct trie_statistics{
 | 
			
		||||
#undef INCLUDE_SUBGOAL_TRIE_CHECK_INSERT
 | 
			
		||||
 | 
			
		||||
#define MODE_GLOBAL_TRIE_ENTRY
 | 
			
		||||
#define INCLUDE_SUBGOAL_TRIE_CHECK_INSERT  /* subgoal_trie_check_insert_gt_entry */
 | 
			
		||||
#define INCLUDE_ANSWER_TRIE_CHECK_INSERT   /* answer_trie_check_insert_gt_entry */
 | 
			
		||||
#define INCLUDE_SUBGOAL_TRIE_CHECK_INSERT /* subgoal_trie_check_insert_gt_entry \
 | 
			
		||||
                                             */
 | 
			
		||||
#define INCLUDE_ANSWER_TRIE_CHECK_INSERT  /* answer_trie_check_insert_gt_entry \
 | 
			
		||||
                                             */
 | 
			
		||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
 | 
			
		||||
#define INCLUDE_GLOBAL_TRIE_CHECK_INSERT   /* global_trie_check_insert_gt_entry */
 | 
			
		||||
#define INCLUDE_GLOBAL_TRIE_CHECK_INSERT /* global_trie_check_insert_gt_entry  \
 | 
			
		||||
                                            */
 | 
			
		||||
#endif                                   /* GLOBAL_TRIE_FOR_SUBTERMS */
 | 
			
		||||
#include "tab.tries.h"
 | 
			
		||||
#undef INCLUDE_GLOBAL_TRIE_CHECK_INSERT
 | 
			
		||||
@@ -219,8 +248,10 @@ static struct trie_statistics{
 | 
			
		||||
#undef MODE_TERMS_LOOP
 | 
			
		||||
 | 
			
		||||
#define MODE_GLOBAL_TRIE_LOOP
 | 
			
		||||
#define INCLUDE_SUBGOAL_SEARCH_LOOP        /* subgoal_search_global_trie_(terms)_loop */
 | 
			
		||||
#define INCLUDE_ANSWER_SEARCH_LOOP         /* answer_search_global_trie_(terms)_loop */
 | 
			
		||||
#define INCLUDE_SUBGOAL_SEARCH_LOOP /* subgoal_search_global_trie_(terms)_loop \
 | 
			
		||||
                                       */
 | 
			
		||||
#define INCLUDE_ANSWER_SEARCH_LOOP  /* answer_search_global_trie_(terms)_loop  \
 | 
			
		||||
                                       */
 | 
			
		||||
#define INCLUDE_LOAD_ANSWER_LOOP    /* load_substitution_loop */
 | 
			
		||||
#ifdef TRIE_RATIONAL_TERMS
 | 
			
		||||
#undef TRIE_RATIONAL_TERMS
 | 
			
		||||
@@ -240,9 +271,9 @@ static struct trie_statistics{
 | 
			
		||||
#undef INCLUDE_ANSWER_SEARCH_MODE_DIRECTED
 | 
			
		||||
#endif /* MODE_DIRECTED_TABLING */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static inline CELL *exec_substitution_loop(gt_node_ptr current_node, CELL **stack_vars_ptr, CELL *stack_terms USES_REGS) {
 | 
			
		||||
static inline CELL *exec_substitution_loop(gt_node_ptr current_node,
 | 
			
		||||
                                           CELL **stack_vars_ptr,
 | 
			
		||||
                                           CELL *stack_terms USES_REGS) {
 | 
			
		||||
  /************************************************************************
 | 
			
		||||
                       ===========
 | 
			
		||||
                       |         |
 | 
			
		||||
@@ -274,7 +305,8 @@ static inline CELL *exec_substitution_loop(gt_node_ptr current_node, CELL **stac
 | 
			
		||||
                       |  TERM_N |  <-- stack_terms
 | 
			
		||||
                       ----------|           *
 | 
			
		||||
                       |   ...   |          /|\
 | 
			
		||||
                     ----------|           |  stack_terms_pair_offset (TRIE_COMPACT_PAIRS)
 | 
			
		||||
                       ----------|           |  stack_terms_pair_offset
 | 
			
		||||
  (TRIE_COMPACT_PAIRS)
 | 
			
		||||
                       |  TERM_1 |          \|/
 | 
			
		||||
                       ===========           *
 | 
			
		||||
   LOCAL_TrailTop -->  |         |  <-- stack_terms_base (TRIE_COMPACT_PAIRS)
 | 
			
		||||
@@ -293,7 +325,8 @@ static inline CELL *exec_substitution_loop(gt_node_ptr current_node, CELL **stac
 | 
			
		||||
    if (IsVarTerm(t)) {
 | 
			
		||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
 | 
			
		||||
      if (t > VarIndexOfTableTerm(MAX_TABLE_VARS)) {
 | 
			
		||||
	stack_terms = exec_substitution_loop((gt_node_ptr) t, &stack_vars, stack_terms PASS_REGS);
 | 
			
		||||
        stack_terms = exec_substitution_loop((gt_node_ptr)t, &stack_vars,
 | 
			
		||||
                                             stack_terms PASS_REGS);
 | 
			
		||||
      } else
 | 
			
		||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
 | 
			
		||||
      {
 | 
			
		||||
@@ -415,10 +448,10 @@ static inline CELL *exec_substitution_loop(gt_node_ptr current_node, CELL **stac
 | 
			
		||||
#endif /* TRIE_COMPACT_PAIRS */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef YAPOR
 | 
			
		||||
#ifdef TABLING_INNER_CUTS
 | 
			
		||||
static int update_answer_trie_branch(ans_node_ptr previous_node, ans_node_ptr current_node) {
 | 
			
		||||
static int update_answer_trie_branch(ans_node_ptr previous_node,
 | 
			
		||||
                                     ans_node_ptr current_node) {
 | 
			
		||||
  int ltt;
 | 
			
		||||
  if (!IS_ANSWER_LEAF_NODE(current_node)) {
 | 
			
		||||
    if (TrNode_child(current_node)) {
 | 
			
		||||
@@ -432,7 +465,8 @@ static int update_answer_trie_branch(ans_node_ptr previous_node, ans_node_ptr cu
 | 
			
		||||
      TrNode_next(previous_node) = TrNode_next(current_node);
 | 
			
		||||
      FREE_ANSWER_TRIE_NODE(current_node);
 | 
			
		||||
      if (TrNode_next(previous_node)) {
 | 
			
		||||
        return update_answer_trie_branch(previous_node, TrNode_next(previous_node));
 | 
			
		||||
        return update_answer_trie_branch(previous_node,
 | 
			
		||||
                                         TrNode_next(previous_node));
 | 
			
		||||
      } else {
 | 
			
		||||
        TrNode_instr(previous_node) -= 2; /* retry --> trust : try --> do */
 | 
			
		||||
        return 0;
 | 
			
		||||
@@ -449,7 +483,8 @@ static int update_answer_trie_branch(ans_node_ptr previous_node, ans_node_ptr cu
 | 
			
		||||
  }
 | 
			
		||||
update_next_trie_branch:
 | 
			
		||||
  if (TrNode_next(current_node)) {
 | 
			
		||||
    ltt = 1 + update_answer_trie_branch(current_node, TrNode_next(current_node));
 | 
			
		||||
    ltt =
 | 
			
		||||
        1 + update_answer_trie_branch(current_node, TrNode_next(current_node));
 | 
			
		||||
  } else {
 | 
			
		||||
    TrNode_instr(current_node) -= 2; /* retry --> trust : try --> do */
 | 
			
		||||
    ltt = 1;
 | 
			
		||||
@@ -480,27 +515,31 @@ static int update_answer_trie_branch(ans_node_ptr current_node) {
 | 
			
		||||
#else /* ! YAPOR */
 | 
			
		||||
static void update_answer_trie_branch(ans_node_ptr current_node, int position) {
 | 
			
		||||
  if (!IS_ANSWER_LEAF_NODE(current_node))
 | 
			
		||||
    update_answer_trie_branch(TrNode_child(current_node), TRAVERSE_POSITION_FIRST);  /* retry --> try */
 | 
			
		||||
    update_answer_trie_branch(TrNode_child(current_node),
 | 
			
		||||
                              TRAVERSE_POSITION_FIRST); /* retry --> try */
 | 
			
		||||
  if (position == TRAVERSE_POSITION_FIRST) {
 | 
			
		||||
    ans_node_ptr next = TrNode_next(current_node);
 | 
			
		||||
    if (next) {
 | 
			
		||||
      while (TrNode_next(next)) {
 | 
			
		||||
	update_answer_trie_branch(next, TRAVERSE_POSITION_NEXT);  /* retry --> retry */
 | 
			
		||||
        update_answer_trie_branch(next,
 | 
			
		||||
                                  TRAVERSE_POSITION_NEXT); /* retry --> retry */
 | 
			
		||||
        next = TrNode_next(next);
 | 
			
		||||
      }
 | 
			
		||||
      update_answer_trie_branch(next, TRAVERSE_POSITION_LAST);  /* retry --> trust */
 | 
			
		||||
      update_answer_trie_branch(next,
 | 
			
		||||
                                TRAVERSE_POSITION_LAST); /* retry --> trust */
 | 
			
		||||
    } else
 | 
			
		||||
      position += TRAVERSE_POSITION_LAST; /* try --> do */
 | 
			
		||||
  }
 | 
			
		||||
  TrNode_instr(current_node) = Yap_opcode(TrNode_instr(current_node) - position);
 | 
			
		||||
  TrNode_instr(current_node) =
 | 
			
		||||
      Yap_opcode(TrNode_instr(current_node) - position);
 | 
			
		||||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
 | 
			
		||||
static void free_global_trie_branch(gt_node_ptr current_node, int mode USES_REGS) {
 | 
			
		||||
static void free_global_trie_branch(gt_node_ptr current_node,
 | 
			
		||||
                                    int mode USES_REGS) {
 | 
			
		||||
  Term t = TrNode_entry(current_node);
 | 
			
		||||
#else
 | 
			
		||||
static void free_global_trie_branch(gt_node_ptr current_node USES_REGS) {
 | 
			
		||||
@@ -511,7 +550,9 @@ static void free_global_trie_branch(gt_node_ptr current_node USES_REGS) {
 | 
			
		||||
  child_node = TrNode_child(parent_node);
 | 
			
		||||
  if (IS_GLOBAL_TRIE_HASH(child_node)) {
 | 
			
		||||
    gt_hash_ptr hash = (gt_hash_ptr)child_node;
 | 
			
		||||
    gt_node_ptr *bucket = Hash_buckets(hash) + HASH_ENTRY(TrNode_entry(current_node), Hash_num_buckets(hash));
 | 
			
		||||
    gt_node_ptr *bucket =
 | 
			
		||||
        Hash_buckets(hash) +
 | 
			
		||||
        HASH_ENTRY(TrNode_entry(current_node), Hash_num_buckets(hash));
 | 
			
		||||
    int num_nodes = --Hash_num_nodes(hash);
 | 
			
		||||
    child_node = *bucket;
 | 
			
		||||
    if (child_node != current_node) {
 | 
			
		||||
@@ -560,13 +601,15 @@ static void free_global_trie_branch(gt_node_ptr current_node USES_REGS) {
 | 
			
		||||
        TrNode_child(parent_node) = NULL;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  } else if (child_node != current_node) {
 | 
			
		||||
}
 | 
			
		||||
else if (child_node != current_node) {
 | 
			
		||||
  while (TrNode_next(child_node) != current_node)
 | 
			
		||||
    child_node = TrNode_next(child_node);
 | 
			
		||||
  TrNode_next(child_node) = TrNode_next(current_node);
 | 
			
		||||
  CHECK_DECREMENT_GLOBAL_TRIE_FOR_SUBTERMS_REFERENCE(t, mode);
 | 
			
		||||
  FREE_GLOBAL_TRIE_NODE(current_node);
 | 
			
		||||
  } else if (TrNode_next(current_node) == NULL) {
 | 
			
		||||
}
 | 
			
		||||
else if (TrNode_next(current_node) == NULL) {
 | 
			
		||||
  CHECK_DECREMENT_GLOBAL_TRIE_FOR_SUBTERMS_REFERENCE(t, mode);
 | 
			
		||||
  FREE_GLOBAL_TRIE_NODE(current_node);
 | 
			
		||||
  if (parent_node != GLOBAL_root_gt) {
 | 
			
		||||
@@ -600,7 +643,8 @@ static void free_global_trie_branch(gt_node_ptr current_node USES_REGS) {
 | 
			
		||||
    FREE_GLOBAL_TRIE_BRANCH(parent_node, mode);
 | 
			
		||||
  } else
 | 
			
		||||
    TrNode_child(parent_node) = NULL;
 | 
			
		||||
  } else {
 | 
			
		||||
}
 | 
			
		||||
else {
 | 
			
		||||
  TrNode_child(parent_node) = TrNode_next(current_node);
 | 
			
		||||
  CHECK_DECREMENT_GLOBAL_TRIE_FOR_SUBTERMS_REFERENCE(t, mode);
 | 
			
		||||
  FREE_GLOBAL_TRIE_NODE(current_node);
 | 
			
		||||
@@ -608,8 +652,9 @@ static void free_global_trie_branch(gt_node_ptr current_node USES_REGS) {
 | 
			
		||||
return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_index, int *arity, int mode, int position USES_REGS) {
 | 
			
		||||
static void traverse_subgoal_trie(sg_node_ptr current_node, char *str,
 | 
			
		||||
                                  int str_index, int *arity, int mode,
 | 
			
		||||
                                  int position USES_REGS) {
 | 
			
		||||
  int *current_arity = NULL, current_str_index = 0, current_mode = 0;
 | 
			
		||||
 | 
			
		||||
  /* test if hashing */
 | 
			
		||||
@@ -623,7 +668,8 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
 | 
			
		||||
    memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
 | 
			
		||||
    do {
 | 
			
		||||
      if (*bucket) {
 | 
			
		||||
        traverse_subgoal_trie(*bucket, str, str_index, arity, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
        traverse_subgoal_trie(*bucket, str, str_index, arity, mode,
 | 
			
		||||
                              TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
        memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
 | 
			
		||||
#ifdef TRIE_COMPACT_PAIRS
 | 
			
		||||
        if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
 | 
			
		||||
@@ -648,7 +694,8 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
 | 
			
		||||
 | 
			
		||||
  /* process current trie node */
 | 
			
		||||
  TrStat_sg_nodes++;
 | 
			
		||||
  traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode, TRAVERSE_TYPE_SUBGOAL PASS_REGS);
 | 
			
		||||
  traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode,
 | 
			
		||||
                     TRAVERSE_TYPE_SUBGOAL PASS_REGS);
 | 
			
		||||
 | 
			
		||||
  /* show answers ... */
 | 
			
		||||
  if (IS_SUBGOAL_LEAF_NODE(current_node)) {
 | 
			
		||||
@@ -671,7 +718,9 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
 | 
			
		||||
        SHOW_TABLE_STRUCTURE("    TRUE\n");
 | 
			
		||||
      } else {
 | 
			
		||||
        arity[0] = 0;
 | 
			
		||||
	traverse_answer_trie(TrNode_child(SgFr_answer_trie(sg_fr)), &str[str_index], 0, arity, 0, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
        traverse_answer_trie(TrNode_child(SgFr_answer_trie(sg_fr)),
 | 
			
		||||
                             &str[str_index], 0, arity, 0, TRAVERSE_MODE_NORMAL,
 | 
			
		||||
                             TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
        if (SgFr_state(sg_fr) < complete) {
 | 
			
		||||
          TrStat_sg_incomplete++;
 | 
			
		||||
          SHOW_TABLE_STRUCTURE("    ---> INCOMPLETE\n");
 | 
			
		||||
@@ -680,7 +729,8 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
 | 
			
		||||
    }
 | 
			
		||||
  } else
 | 
			
		||||
    /* ... or continue with child node */
 | 
			
		||||
    traverse_subgoal_trie(TrNode_child(current_node), str, str_index, arity, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
    traverse_subgoal_trie(TrNode_child(current_node), str, str_index, arity,
 | 
			
		||||
                          mode, TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
  /* restore the initial state and continue with sibling nodes */
 | 
			
		||||
  if (position == TRAVERSE_POSITION_FIRST) {
 | 
			
		||||
    str_index = current_str_index;
 | 
			
		||||
@@ -695,7 +745,8 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
 | 
			
		||||
      if (arity[arity[0]] == -1)
 | 
			
		||||
        str[str_index - 1] = '|';
 | 
			
		||||
#endif /* TRIE_COMPACT_PAIRS */
 | 
			
		||||
      traverse_subgoal_trie(current_node, str, str_index, arity, mode, TRAVERSE_POSITION_NEXT PASS_REGS);
 | 
			
		||||
      traverse_subgoal_trie(current_node, str, str_index, arity, mode,
 | 
			
		||||
                            TRAVERSE_POSITION_NEXT PASS_REGS);
 | 
			
		||||
      current_node = TrNode_next(current_node);
 | 
			
		||||
    }
 | 
			
		||||
    free(current_arity);
 | 
			
		||||
@@ -703,9 +754,11 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
 | 
			
		||||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_index, int *arity, int var_index, int mode, int position USES_REGS) {
 | 
			
		||||
  int *current_arity = NULL, current_str_index = 0, current_var_index = 0, current_mode = 0;
 | 
			
		||||
static void traverse_answer_trie(ans_node_ptr current_node, char *str,
 | 
			
		||||
                                 int str_index, int *arity, int var_index,
 | 
			
		||||
                                 int mode, int position USES_REGS) {
 | 
			
		||||
  int *current_arity = NULL, current_str_index = 0, current_var_index = 0,
 | 
			
		||||
      current_mode = 0;
 | 
			
		||||
 | 
			
		||||
  /* test if hashing */
 | 
			
		||||
  if (IS_ANSWER_TRIE_HASH(current_node)) {
 | 
			
		||||
@@ -718,7 +771,8 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_i
 | 
			
		||||
    memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
 | 
			
		||||
    do {
 | 
			
		||||
      if (*bucket) {
 | 
			
		||||
        traverse_answer_trie(*bucket, str, str_index, arity, var_index, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
        traverse_answer_trie(*bucket, str, str_index, arity, var_index, mode,
 | 
			
		||||
                             TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
        memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
 | 
			
		||||
#ifdef TRIE_COMPACT_PAIRS
 | 
			
		||||
        if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
 | 
			
		||||
@@ -750,7 +804,8 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_i
 | 
			
		||||
 | 
			
		||||
  /* process current trie node */
 | 
			
		||||
  TrStat_ans_nodes++;
 | 
			
		||||
  traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode, TRAVERSE_TYPE_ANSWER PASS_REGS);
 | 
			
		||||
  traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode,
 | 
			
		||||
                     TRAVERSE_TYPE_ANSWER PASS_REGS);
 | 
			
		||||
 | 
			
		||||
  /* show answer .... */
 | 
			
		||||
  if (IS_ANSWER_LEAF_NODE(current_node)) {
 | 
			
		||||
@@ -767,7 +822,8 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_i
 | 
			
		||||
#endif /* TABLING_INNER_CUTS */
 | 
			
		||||
  /* ... or continue with child node */
 | 
			
		||||
  else
 | 
			
		||||
    traverse_answer_trie(TrNode_child(current_node), str, str_index, arity, var_index, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
    traverse_answer_trie(TrNode_child(current_node), str, str_index, arity,
 | 
			
		||||
                         var_index, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
 | 
			
		||||
  /* restore the initial state and continue with sibling nodes */
 | 
			
		||||
  if (position == TRAVERSE_POSITION_FIRST) {
 | 
			
		||||
@@ -784,7 +840,8 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_i
 | 
			
		||||
      if (arity[arity[0]] == -1)
 | 
			
		||||
        str[str_index - 1] = '|';
 | 
			
		||||
#endif /* TRIE_COMPACT_PAIRS */
 | 
			
		||||
      traverse_answer_trie(current_node, str, str_index, arity, var_index, mode, TRAVERSE_POSITION_NEXT PASS_REGS);
 | 
			
		||||
      traverse_answer_trie(current_node, str, str_index, arity, var_index, mode,
 | 
			
		||||
                           TRAVERSE_POSITION_NEXT PASS_REGS);
 | 
			
		||||
      current_node = TrNode_next(current_node);
 | 
			
		||||
    }
 | 
			
		||||
    free(current_arity);
 | 
			
		||||
@@ -793,8 +850,9 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_i
 | 
			
		||||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_index, int *arity, int mode, int position USES_REGS) {
 | 
			
		||||
static void traverse_global_trie(gt_node_ptr current_node, char *str,
 | 
			
		||||
                                 int str_index, int *arity, int mode,
 | 
			
		||||
                                 int position USES_REGS) {
 | 
			
		||||
  int *current_arity = NULL, current_str_index = 0, current_mode = 0;
 | 
			
		||||
 | 
			
		||||
  /* test if hashing */
 | 
			
		||||
@@ -808,7 +866,8 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_in
 | 
			
		||||
    memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
 | 
			
		||||
    do {
 | 
			
		||||
      if (*bucket) {
 | 
			
		||||
        traverse_global_trie(*bucket, str, str_index, arity, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
        traverse_global_trie(*bucket, str, str_index, arity, mode,
 | 
			
		||||
                             TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
        memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
 | 
			
		||||
#ifdef TRIE_COMPACT_PAIRS
 | 
			
		||||
        if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
 | 
			
		||||
@@ -833,16 +892,19 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_in
 | 
			
		||||
 | 
			
		||||
  /* process current trie node */
 | 
			
		||||
  TrStat_gt_nodes++;
 | 
			
		||||
  traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode, TRAVERSE_TYPE_GT_SUBGOAL PASS_REGS);
 | 
			
		||||
  traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode,
 | 
			
		||||
                     TRAVERSE_TYPE_GT_SUBGOAL PASS_REGS);
 | 
			
		||||
 | 
			
		||||
  /* continue with child node ... */
 | 
			
		||||
  if (arity[0] != 0 || mode != TRAVERSE_MODE_NORMAL)
 | 
			
		||||
    traverse_global_trie(TrNode_child(current_node), str, str_index, arity, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
    traverse_global_trie(TrNode_child(current_node), str, str_index, arity,
 | 
			
		||||
                         mode, TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
  /* ... or show term */
 | 
			
		||||
  else {
 | 
			
		||||
    TrStat_gt_terms++;
 | 
			
		||||
    str[str_index] = 0;
 | 
			
		||||
    SHOW_TABLE_STRUCTURE("  TERMx" UInt_FORMAT ": %s\n", (CELL) TrNode_child(current_node), str);
 | 
			
		||||
    SHOW_TABLE_STRUCTURE("  TERMx" UInt_FORMAT ": %s\n",
 | 
			
		||||
                         (CELL)TrNode_child(current_node), str);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* restore the initial state and continue with sibling nodes */
 | 
			
		||||
@@ -859,7 +921,8 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_in
 | 
			
		||||
      if (arity[arity[0]] == -1)
 | 
			
		||||
        str[str_index - 1] = '|';
 | 
			
		||||
#endif /* TRIE_COMPACT_PAIRS */
 | 
			
		||||
      traverse_global_trie(current_node, str, str_index, arity, mode, TRAVERSE_POSITION_NEXT PASS_REGS);
 | 
			
		||||
      traverse_global_trie(current_node, str, str_index, arity, mode,
 | 
			
		||||
                           TRAVERSE_POSITION_NEXT PASS_REGS);
 | 
			
		||||
      current_node = TrNode_next(current_node);
 | 
			
		||||
    }
 | 
			
		||||
    free(current_arity);
 | 
			
		||||
@@ -868,16 +931,20 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_in
 | 
			
		||||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void traverse_global_trie_for_term(gt_node_ptr current_node, char *str, int *str_index, int *arity, int *mode, int type USES_REGS) {
 | 
			
		||||
static void traverse_global_trie_for_term(gt_node_ptr current_node, char *str,
 | 
			
		||||
                                          int *str_index, int *arity, int *mode,
 | 
			
		||||
                                          int type USES_REGS) {
 | 
			
		||||
  if (TrNode_parent(current_node) != GLOBAL_root_gt)
 | 
			
		||||
    traverse_global_trie_for_term(TrNode_parent(current_node), str, str_index, arity, mode, type PASS_REGS);
 | 
			
		||||
  traverse_trie_node(TrNode_entry(current_node), str, str_index, arity, mode, type PASS_REGS);
 | 
			
		||||
    traverse_global_trie_for_term(TrNode_parent(current_node), str, str_index,
 | 
			
		||||
                                  arity, mode, type PASS_REGS);
 | 
			
		||||
  traverse_trie_node(TrNode_entry(current_node), str, str_index, arity, mode,
 | 
			
		||||
                     type PASS_REGS);
 | 
			
		||||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int *arity, int *mode_ptr, int type USES_REGS) {
 | 
			
		||||
static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr,
 | 
			
		||||
                                      int *arity, int *mode_ptr,
 | 
			
		||||
                                      int type USES_REGS) {
 | 
			
		||||
  int mode = *mode_ptr;
 | 
			
		||||
  int str_index = *str_index_ptr;
 | 
			
		||||
 | 
			
		||||
@@ -907,7 +974,8 @@ static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int
 | 
			
		||||
    traverse_update_arity(str, &str_index, arity);
 | 
			
		||||
    if (type == TRAVERSE_TYPE_SUBGOAL)
 | 
			
		||||
      mode = TRAVERSE_MODE_NORMAL;
 | 
			
		||||
    else  /* TRAVERSE_TYPE_ANSWER || TRAVERSE_TYPE_GT_SUBGOAL || TRAVERSE_TYPE_GT_ANSWER */
 | 
			
		||||
    else /* TRAVERSE_TYPE_ANSWER || TRAVERSE_TYPE_GT_SUBGOAL ||
 | 
			
		||||
            TRAVERSE_TYPE_GT_ANSWER */
 | 
			
		||||
      mode = TRAVERSE_MODE_DOUBLE_END;
 | 
			
		||||
  } else if (mode == TRAVERSE_MODE_DOUBLE_END) {
 | 
			
		||||
    mode = TRAVERSE_MODE_NORMAL;
 | 
			
		||||
@@ -917,7 +985,8 @@ static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int
 | 
			
		||||
    traverse_update_arity(str, &str_index, arity);
 | 
			
		||||
    if (type == TRAVERSE_TYPE_SUBGOAL)
 | 
			
		||||
      mode = TRAVERSE_MODE_NORMAL;
 | 
			
		||||
    else  /* TRAVERSE_TYPE_ANSWER || TRAVERSE_TYPE_GT_SUBGOAL || TRAVERSE_TYPE_GT_ANSWER */
 | 
			
		||||
    else /* TRAVERSE_TYPE_ANSWER || TRAVERSE_TYPE_GT_SUBGOAL ||
 | 
			
		||||
            TRAVERSE_TYPE_GT_ANSWER */
 | 
			
		||||
      mode = TRAVERSE_MODE_LONGINT_END;
 | 
			
		||||
  } else if (mode == TRAVERSE_MODE_LONGINT_END) {
 | 
			
		||||
    mode = TRAVERSE_MODE_NORMAL;
 | 
			
		||||
@@ -926,13 +995,17 @@ static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int
 | 
			
		||||
    traverse_update_arity(str, &str_index, arity);
 | 
			
		||||
    if (type == TRAVERSE_TYPE_SUBGOAL)
 | 
			
		||||
      mode = TRAVERSE_MODE_NORMAL;
 | 
			
		||||
    else  /* TRAVERSE_TYPE_ANSWER || TRAVERSE_TYPE_GT_SUBGOAL || TRAVERSE_TYPE_GT_ANSWER */
 | 
			
		||||
    else /* TRAVERSE_TYPE_ANSWER || TRAVERSE_TYPE_GT_SUBGOAL ||
 | 
			
		||||
            TRAVERSE_TYPE_GT_ANSWER */
 | 
			
		||||
      mode = TRAVERSE_MODE_BIGINT_OR_STRING_END;
 | 
			
		||||
  } else if (mode == TRAVERSE_MODE_BIGINT_OR_STRING_END) {
 | 
			
		||||
    mode = TRAVERSE_MODE_NORMAL;
 | 
			
		||||
  } else if (IsVarTerm(t)) {
 | 
			
		||||
#ifdef TRIE_RATIONAL_TERMS
 | 
			
		||||
    if (t > VarIndexOfTableTerm(MAX_TABLE_VARS) && TrNode_child((gt_node_ptr) t) != (gt_node_ptr)1)  { //TODO: substitute the != 1 test to something more appropriate
 | 
			
		||||
    if (t > VarIndexOfTableTerm(MAX_TABLE_VARS) &&
 | 
			
		||||
        TrNode_child((gt_node_ptr)t) !=
 | 
			
		||||
            (gt_node_ptr)1) { // TODO: substitute the != 1 test to something
 | 
			
		||||
                              // more appropriate
 | 
			
		||||
      /* Rational term */
 | 
			
		||||
      str_index += sprintf(&str[str_index], "**");
 | 
			
		||||
      traverse_update_arity(str, &str_index, arity);
 | 
			
		||||
@@ -942,12 +1015,14 @@ static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int
 | 
			
		||||
      TrStat_gt_refs++;
 | 
			
		||||
      /* (type % 2 + 2): TRAVERSE_TYPE_ANSWER  --> TRAVERSE_TYPE_GT_ANSWER  */
 | 
			
		||||
      /* (type % 2 + 2): TRAVERSE_TYPE_SUBGOAL --> TRAVERSE_TYPE_GT_SUBGOAL */
 | 
			
		||||
      traverse_global_trie_for_term((gt_node_ptr) t, str, &str_index, arity, &mode, type % 2 + 2 PASS_REGS);
 | 
			
		||||
      traverse_global_trie_for_term((gt_node_ptr)t, str, &str_index, arity,
 | 
			
		||||
                                    &mode, type % 2 + 2 PASS_REGS);
 | 
			
		||||
    } else {
 | 
			
		||||
      if (type == TRAVERSE_TYPE_SUBGOAL || type == TRAVERSE_TYPE_GT_SUBGOAL)
 | 
			
		||||
        str_index += sprintf(&str[str_index], "VAR%d", VarIndexOfTableTerm(t));
 | 
			
		||||
      else /* TRAVERSE_TYPE_ANSWER || TRAVERSE_TYPE_GT_ANSWER */
 | 
			
		||||
	str_index += sprintf(& str[str_index], "ANSVAR%d", VarIndexOfTableTerm(t));
 | 
			
		||||
        str_index +=
 | 
			
		||||
            sprintf(&str[str_index], "ANSVAR%d", VarIndexOfTableTerm(t));
 | 
			
		||||
      traverse_update_arity(str, &str_index, arity);
 | 
			
		||||
    }
 | 
			
		||||
  } else if (IsIntTerm(t)) {
 | 
			
		||||
@@ -1005,8 +1080,8 @@ static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int
 | 
			
		||||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static inline void traverse_update_arity(char *str, int *str_index_ptr, int *arity) {
 | 
			
		||||
static inline void traverse_update_arity(char *str, int *str_index_ptr,
 | 
			
		||||
                                         int *arity) {
 | 
			
		||||
  int str_index = *str_index_ptr;
 | 
			
		||||
  while (arity[0]) {
 | 
			
		||||
    if (arity[arity[0]] > 0) {
 | 
			
		||||
@@ -1043,8 +1118,6 @@ static inline void traverse_update_arity(char *str, int *str_index_ptr, int *ari
 | 
			
		||||
  *str_index_ptr = str_index;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*******************************
 | 
			
		||||
**      Global functions      **
 | 
			
		||||
*******************************/
 | 
			
		||||
@@ -1074,14 +1147,22 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
 | 
			
		||||
    int old_subs_arity = subs_arity;
 | 
			
		||||
    for (i = 1; i <= pred_arity; i++) {
 | 
			
		||||
      int j = MODE_DIRECTED_GET_ARG(mode_directed[i - 1]) + 1;
 | 
			
		||||
      current_sg_node = subgoal_search_loop(tab_ent, current_sg_node, Deref(XREGS[j]), &subs_arity, &stack_vars PASS_REGS);
 | 
			
		||||
      current_sg_node =
 | 
			
		||||
          subgoal_search_loop(tab_ent, current_sg_node, Deref(XREGS[j]),
 | 
			
		||||
                              &subs_arity, &stack_vars PASS_REGS);
 | 
			
		||||
      if (subs_arity != old_subs_arity) {
 | 
			
		||||
	if (subs_pos && MODE_DIRECTED_GET_MODE(aux_mode_directed[subs_pos-1]) == MODE_DIRECTED_GET_MODE(mode_directed[i-1])) {
 | 
			
		||||
	  /* same mode as before -> use the current entry in the aux_mode_directed[] array */
 | 
			
		||||
	  aux_mode_directed[subs_pos-1] += MODE_DIRECTED_SET(subs_arity - old_subs_arity, 0);
 | 
			
		||||
        if (subs_pos &&
 | 
			
		||||
            MODE_DIRECTED_GET_MODE(aux_mode_directed[subs_pos - 1]) ==
 | 
			
		||||
                MODE_DIRECTED_GET_MODE(mode_directed[i - 1])) {
 | 
			
		||||
          /* same mode as before -> use the current entry in the
 | 
			
		||||
           * aux_mode_directed[] array */
 | 
			
		||||
          aux_mode_directed[subs_pos - 1] +=
 | 
			
		||||
              MODE_DIRECTED_SET(subs_arity - old_subs_arity, 0);
 | 
			
		||||
        } else {
 | 
			
		||||
          /* new mode -> init a new entry in the aux_mode_directed[] array */
 | 
			
		||||
	  aux_mode_directed[subs_pos] = MODE_DIRECTED_SET(subs_arity - old_subs_arity, MODE_DIRECTED_GET_MODE(mode_directed[i-1]));
 | 
			
		||||
          aux_mode_directed[subs_pos] =
 | 
			
		||||
              MODE_DIRECTED_SET(subs_arity - old_subs_arity,
 | 
			
		||||
                                MODE_DIRECTED_GET_MODE(mode_directed[i - 1]));
 | 
			
		||||
          subs_pos++;
 | 
			
		||||
        }
 | 
			
		||||
        old_subs_arity = subs_arity;
 | 
			
		||||
@@ -1091,10 +1172,14 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
 | 
			
		||||
#endif /* MODE_DIRECTED_TABLING */
 | 
			
		||||
      if (IsMode_GlobalTrie(TabEnt_mode(tab_ent))) {
 | 
			
		||||
    for (i = 1; i <= pred_arity; i++)
 | 
			
		||||
      current_sg_node = subgoal_search_terms_loop(tab_ent, current_sg_node, Deref(XREGS[i]), &subs_arity, &stack_vars PASS_REGS);
 | 
			
		||||
      current_sg_node =
 | 
			
		||||
          subgoal_search_terms_loop(tab_ent, current_sg_node, Deref(XREGS[i]),
 | 
			
		||||
                                    &subs_arity, &stack_vars PASS_REGS);
 | 
			
		||||
  } else {
 | 
			
		||||
    for (i = 1; i <= pred_arity; i++)
 | 
			
		||||
      current_sg_node = subgoal_search_loop(tab_ent, current_sg_node, Deref(XREGS[i]), &subs_arity, &stack_vars PASS_REGS);
 | 
			
		||||
      current_sg_node =
 | 
			
		||||
          subgoal_search_loop(tab_ent, current_sg_node, Deref(XREGS[i]),
 | 
			
		||||
                              &subs_arity, &stack_vars PASS_REGS);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  STACK_PUSH_UP(subs_arity, stack_vars);
 | 
			
		||||
@@ -1105,7 +1190,8 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
 | 
			
		||||
    RESET_VARIABLE(t);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  sg_fr_ptr *sg_fr_end = get_insert_subgoal_frame_addr(current_sg_node PASS_REGS);
 | 
			
		||||
  sg_fr_ptr *sg_fr_end =
 | 
			
		||||
      get_insert_subgoal_frame_addr(current_sg_node PASS_REGS);
 | 
			
		||||
#ifndef THREADS
 | 
			
		||||
  LOCK_SUBGOAL_NODE(current_sg_node);
 | 
			
		||||
#endif /* !THREADS */
 | 
			
		||||
@@ -1114,7 +1200,8 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
 | 
			
		||||
#ifdef MODE_DIRECTED_TABLING
 | 
			
		||||
    if (subs_pos) {
 | 
			
		||||
      ALLOC_BLOCK(mode_directed, subs_pos * sizeof(int), int);
 | 
			
		||||
      memcpy((void *)mode_directed, (void *)aux_mode_directed, subs_pos*sizeof(int));
 | 
			
		||||
      memcpy((void *)mode_directed, (void *)aux_mode_directed,
 | 
			
		||||
             subs_pos * sizeof(int));
 | 
			
		||||
    } else
 | 
			
		||||
      mode_directed = NULL;
 | 
			
		||||
#endif /* MODE_DIRECTED_TABLING */
 | 
			
		||||
@@ -1125,7 +1212,8 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
 | 
			
		||||
    TAG_AS_SUBGOAL_LEAF_NODE(current_sg_node);
 | 
			
		||||
    UNLOCK_SUBGOAL_NODE(current_sg_node);
 | 
			
		||||
#else /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
 | 
			
		||||
    sg_ent_ptr sg_ent = (sg_ent_ptr) UNTAG_SUBGOAL_NODE(TrNode_sg_ent(current_sg_node));
 | 
			
		||||
    sg_ent_ptr sg_ent =
 | 
			
		||||
        (sg_ent_ptr)UNTAG_SUBGOAL_NODE(TrNode_sg_ent(current_sg_node));
 | 
			
		||||
    new_subgoal_frame(sg_fr, sg_ent);
 | 
			
		||||
#ifdef THREADS_CONSUMER_SHARING
 | 
			
		||||
    SgFr_state(sg_fr) = ready_external;
 | 
			
		||||
@@ -1163,7 +1251,6 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
 | 
			
		||||
  return sg_fr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
 | 
			
		||||
#define subs_arity *subs_ptr
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
@@ -1177,12 +1264,14 @@ ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
 | 
			
		||||
  if (IsMode_GlobalTrie(TabEnt_mode(SgFr_tab_ent(sg_fr)))) {
 | 
			
		||||
    for (i = subs_arity; i >= 1; i--) {
 | 
			
		||||
      TABLING_ERROR_CHECKING(answer_search, IsNonVarTerm(subs_ptr[i]));
 | 
			
		||||
      current_ans_node = answer_search_terms_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
 | 
			
		||||
      current_ans_node = answer_search_terms_loop(
 | 
			
		||||
          sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
 | 
			
		||||
    }
 | 
			
		||||
  } else {
 | 
			
		||||
    for (i = subs_arity; i >= 1; i--) {
 | 
			
		||||
      TABLING_ERROR_CHECKING(answer_search, IsNonVarTerm(subs_ptr[i]));
 | 
			
		||||
      current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
 | 
			
		||||
      current_ans_node = answer_search_loop(
 | 
			
		||||
          sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -1197,7 +1286,6 @@ ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
 | 
			
		||||
#undef subs_arity
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef MODE_DIRECTED_TABLING
 | 
			
		||||
ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
 | 
			
		||||
#define subs_arity *subs_ptr
 | 
			
		||||
@@ -1219,51 +1307,69 @@ ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
 | 
			
		||||
    do {
 | 
			
		||||
      TABLING_ERROR_CHECKING(answer_search, IsNonVarTerm(subs_ptr[i]));
 | 
			
		||||
      if (mode == MODE_DIRECTED_INDEX || mode == MODE_DIRECTED_ALL) {
 | 
			
		||||
	current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
 | 
			
		||||
        current_ans_node = answer_search_loop(
 | 
			
		||||
            sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
 | 
			
		||||
      } else {
 | 
			
		||||
        LOCK_ANSWER_NODE(current_ans_node);
 | 
			
		||||
        if (TrNode_child(current_ans_node) == NULL) {
 | 
			
		||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
 | 
			
		||||
	  struct answer_trie_node virtual_ans_node;  /* necessary because the answer_search_loop() procedure also locks the parent node */
 | 
			
		||||
          struct answer_trie_node
 | 
			
		||||
              virtual_ans_node; /* necessary because the answer_search_loop()
 | 
			
		||||
                                   procedure also locks the parent node */
 | 
			
		||||
          ans_node_ptr parent_ans_node = current_ans_node;
 | 
			
		||||
          AnsNode_init_lock_field(&virtual_ans_node);
 | 
			
		||||
          TrNode_parent(&virtual_ans_node) = NULL;
 | 
			
		||||
          TrNode_child(&virtual_ans_node) = NULL;
 | 
			
		||||
	  current_ans_node = answer_search_loop(sg_fr, &virtual_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
 | 
			
		||||
          current_ans_node =
 | 
			
		||||
              answer_search_loop(sg_fr, &virtual_ans_node, Deref(subs_ptr[i]),
 | 
			
		||||
                                 &vars_arity PASS_REGS);
 | 
			
		||||
          TrNode_child(parent_ans_node) = TrNode_child(&virtual_ans_node);
 | 
			
		||||
          TrNode_parent(TrNode_child(&virtual_ans_node)) = parent_ans_node;
 | 
			
		||||
#else
 | 
			
		||||
	  current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
 | 
			
		||||
          current_ans_node =
 | 
			
		||||
              answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]),
 | 
			
		||||
                                 &vars_arity PASS_REGS);
 | 
			
		||||
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
 | 
			
		||||
        } else if (mode == MODE_DIRECTED_MIN || mode == MODE_DIRECTED_MAX) {
 | 
			
		||||
          ans_node_ptr parent_ans_node = current_ans_node;
 | 
			
		||||
	  invalid_ans_node = TrNode_child(parent_ans_node);  /* by default, assume a better answer */
 | 
			
		||||
	  current_ans_node = answer_search_min_max(sg_fr, current_ans_node, Deref(subs_ptr[i]), mode PASS_REGS);
 | 
			
		||||
	  if (invalid_ans_node == TrNode_child(parent_ans_node))  /* worse or equal answer */
 | 
			
		||||
          invalid_ans_node = TrNode_child(
 | 
			
		||||
              parent_ans_node); /* by default, assume a better answer */
 | 
			
		||||
          current_ans_node = answer_search_min_max(
 | 
			
		||||
              sg_fr, current_ans_node, Deref(subs_ptr[i]), mode PASS_REGS);
 | 
			
		||||
          if (invalid_ans_node ==
 | 
			
		||||
              TrNode_child(parent_ans_node)) /* worse or equal answer */
 | 
			
		||||
            invalid_ans_node = NULL;
 | 
			
		||||
        } else if (mode == MODE_DIRECTED_SUM) {
 | 
			
		||||
          invalid_ans_node = TrNode_child(current_ans_node);
 | 
			
		||||
	  current_ans_node = answer_search_sum(sg_fr, current_ans_node, Deref(subs_ptr[i]) PASS_REGS);
 | 
			
		||||
          current_ans_node = answer_search_sum(sg_fr, current_ans_node,
 | 
			
		||||
                                               Deref(subs_ptr[i]) PASS_REGS);
 | 
			
		||||
        } else if (mode == MODE_DIRECTED_LAST) {
 | 
			
		||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
 | 
			
		||||
	  struct answer_trie_node virtual_ans_node;  /* necessary because the answer_search_loop() procedure also locks the parent node */
 | 
			
		||||
          struct answer_trie_node
 | 
			
		||||
              virtual_ans_node; /* necessary because the answer_search_loop()
 | 
			
		||||
                                   procedure also locks the parent node */
 | 
			
		||||
          ans_node_ptr parent_ans_node = current_ans_node;
 | 
			
		||||
          invalid_ans_node = TrNode_child(parent_ans_node);
 | 
			
		||||
          AnsNode_init_lock_field(&virtual_ans_node);
 | 
			
		||||
          TrNode_parent(&virtual_ans_node) = NULL;
 | 
			
		||||
          TrNode_child(&virtual_ans_node) = NULL;
 | 
			
		||||
	  current_ans_node = answer_search_loop(sg_fr, &virtual_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
 | 
			
		||||
          current_ans_node =
 | 
			
		||||
              answer_search_loop(sg_fr, &virtual_ans_node, Deref(subs_ptr[i]),
 | 
			
		||||
                                 &vars_arity PASS_REGS);
 | 
			
		||||
          TrNode_child(parent_ans_node) = TrNode_child(&virtual_ans_node);
 | 
			
		||||
          TrNode_parent(TrNode_child(&virtual_ans_node)) = parent_ans_node;
 | 
			
		||||
#else
 | 
			
		||||
          invalid_ans_node = TrNode_child(current_ans_node);
 | 
			
		||||
          TrNode_child(current_ans_node) = NULL;
 | 
			
		||||
	  current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
 | 
			
		||||
          current_ans_node =
 | 
			
		||||
              answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]),
 | 
			
		||||
                                 &vars_arity PASS_REGS);
 | 
			
		||||
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
 | 
			
		||||
        } else if (mode == MODE_DIRECTED_FIRST) {
 | 
			
		||||
          current_ans_node = NULL;
 | 
			
		||||
        } else
 | 
			
		||||
	  Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "mode_directed_answer_search: unknown mode");
 | 
			
		||||
          Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
 | 
			
		||||
                    "mode_directed_answer_search: unknown mode");
 | 
			
		||||
        UNLOCK_ANSWER_NODE(current_ans_node);
 | 
			
		||||
      }
 | 
			
		||||
      n_subs--;
 | 
			
		||||
@@ -1274,7 +1380,8 @@ ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
 | 
			
		||||
    j++;
 | 
			
		||||
  }
 | 
			
		||||
  if (invalid_ans_node)
 | 
			
		||||
    invalidate_answer_trie(invalid_ans_node, sg_fr, TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
    invalidate_answer_trie(invalid_ans_node, sg_fr,
 | 
			
		||||
                           TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
 | 
			
		||||
  /* reset variables */
 | 
			
		||||
  stack_vars = (CELL *)TR;
 | 
			
		||||
@@ -1288,7 +1395,6 @@ ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
 | 
			
		||||
}
 | 
			
		||||
#endif /* MODE_DIRECTED_TABLING */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void load_answer(ans_node_ptr current_ans_node, CELL *subs_ptr) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
#define subs_arity *subs_ptr
 | 
			
		||||
@@ -1311,7 +1417,6 @@ void load_answer(ans_node_ptr current_ans_node, CELL *subs_ptr) {
 | 
			
		||||
#undef subs_arity
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
CELL *exec_substitution(gt_node_ptr current_node, CELL *aux_stack) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
#define subs_arity *subs_ptr
 | 
			
		||||
@@ -1319,32 +1424,35 @@ CELL *exec_substitution(gt_node_ptr current_node, CELL *aux_stack) {
 | 
			
		||||
  Term t;
 | 
			
		||||
 | 
			
		||||
  ++aux_stack; /* skip the heap_arity entry */
 | 
			
		||||
  stack_terms = exec_substitution_loop(current_node, &aux_stack, (CELL *) LOCAL_TrailTop PASS_REGS);
 | 
			
		||||
  stack_terms = exec_substitution_loop(current_node, &aux_stack,
 | 
			
		||||
                                       (CELL *)LOCAL_TrailTop PASS_REGS);
 | 
			
		||||
  *--aux_stack = 0; /* restore the heap_arity entry */
 | 
			
		||||
 | 
			
		||||
  subs_ptr = aux_stack + aux_stack[1] + 2;
 | 
			
		||||
  t = STACK_POP_DOWN(stack_terms);
 | 
			
		||||
  YapBind((CELL *)subs_ptr[subs_arity], t);
 | 
			
		||||
  TABLING_ERROR_CHECKING(exec_substitution, stack_terms != (CELL *)LOCAL_TrailTop);
 | 
			
		||||
  TABLING_ERROR_CHECKING(exec_substitution,
 | 
			
		||||
                         stack_terms != (CELL *)LOCAL_TrailTop);
 | 
			
		||||
  *subs_ptr = subs_arity - 1;
 | 
			
		||||
 | 
			
		||||
  return aux_stack;
 | 
			
		||||
#undef subs_arity
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void update_answer_trie(sg_fr_ptr sg_fr) {
 | 
			
		||||
  ans_node_ptr current_node;
 | 
			
		||||
 | 
			
		||||
  free_answer_hash_chain(SgFr_hash_chain(sg_fr));
 | 
			
		||||
  SgFr_hash_chain(sg_fr) = NULL;
 | 
			
		||||
  SgFr_state(sg_fr) += 2;  /* complete --> compiled : complete_in_use --> compiled_in_use */
 | 
			
		||||
  SgFr_state(sg_fr) +=
 | 
			
		||||
      2; /* complete --> compiled : complete_in_use --> compiled_in_use */
 | 
			
		||||
 | 
			
		||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
 | 
			
		||||
  SgFr_sg_ent_state(sg_fr) += 2; /* complete --> compiled */
 | 
			
		||||
#ifdef THREADS_FULL_SHARING
 | 
			
		||||
  if (IsMode_Batched(TabEnt_mode(SgFr_tab_ent(sg_fr)))) {
 | 
			
		||||
    /* cleaning bits used by batched mode and shifting the instruction back to the original place */
 | 
			
		||||
    /* cleaning bits used by batched mode and shifting the instruction back to
 | 
			
		||||
     * the original place */
 | 
			
		||||
    ans_node_ptr leaf_ans_trie_node = SgFr_first_answer(sg_fr);
 | 
			
		||||
    while (TrNode_child(leaf_ans_trie_node) != NULL) {
 | 
			
		||||
      ANSWER_LEAF_NODE_INSTR_ABSOLUTE(leaf_ans_trie_node);
 | 
			
		||||
@@ -1370,7 +1478,6 @@ void update_answer_trie(sg_fr_ptr sg_fr) {
 | 
			
		||||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void free_subgoal_trie(sg_node_ptr current_node, int mode, int position) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
 | 
			
		||||
@@ -1426,7 +1533,8 @@ void free_subgoal_trie(sg_node_ptr current_node, int mode, int position) {
 | 
			
		||||
    } else {
 | 
			
		||||
      child_mode = TRAVERSE_MODE_NORMAL;
 | 
			
		||||
    }
 | 
			
		||||
    free_subgoal_trie(TrNode_child(current_node), child_mode, TRAVERSE_POSITION_FIRST);
 | 
			
		||||
    free_subgoal_trie(TrNode_child(current_node), child_mode,
 | 
			
		||||
                      TRAVERSE_POSITION_FIRST);
 | 
			
		||||
  } else {
 | 
			
		||||
    sg_fr_ptr sg_fr = get_subgoal_frame_for_abolish(current_node PASS_REGS);
 | 
			
		||||
    if (sg_fr) {
 | 
			
		||||
@@ -1434,7 +1542,8 @@ void free_subgoal_trie(sg_node_ptr current_node, int mode, int position) {
 | 
			
		||||
      free_answer_hash_chain(SgFr_hash_chain(sg_fr));
 | 
			
		||||
      ans_node = SgFr_answer_trie(sg_fr);
 | 
			
		||||
      if (TrNode_child(ans_node))
 | 
			
		||||
	free_answer_trie(TrNode_child(ans_node), TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST);
 | 
			
		||||
        free_answer_trie(TrNode_child(ans_node), TRAVERSE_MODE_NORMAL,
 | 
			
		||||
                         TRAVERSE_POSITION_FIRST);
 | 
			
		||||
      IF_ABOLISH_ANSWER_TRIE_SHARED_DATA_STRUCTURES {
 | 
			
		||||
        FREE_ANSWER_TRIE_NODE(ans_node);
 | 
			
		||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
 | 
			
		||||
@@ -1459,10 +1568,12 @@ void free_subgoal_trie(sg_node_ptr current_node, int mode, int position) {
 | 
			
		||||
#ifdef LIMIT_TABLING
 | 
			
		||||
      remove_from_global_sg_fr_list(sg_fr);
 | 
			
		||||
#endif /* LIMIT_TABLING */
 | 
			
		||||
#if defined(MODE_DIRECTED_TABLING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING)
 | 
			
		||||
#if defined(MODE_DIRECTED_TABLING) && !defined(THREADS_FULL_SHARING) &&        \
 | 
			
		||||
    !defined(THREADS_CONSUMER_SHARING)
 | 
			
		||||
      if (SgFr_mode_directed(sg_fr))
 | 
			
		||||
        FREE_BLOCK(SgFr_mode_directed(sg_fr));
 | 
			
		||||
#endif /* MODE_DIRECTED_TABLING && !THREADS_FULL_SHARING && !THREADS_CONSUMER_SHARING */
 | 
			
		||||
#endif /* MODE_DIRECTED_TABLING && !THREADS_FULL_SHARING &&                    \
 | 
			
		||||
          !THREADS_CONSUMER_SHARING */
 | 
			
		||||
      FREE_SUBGOAL_FRAME(sg_fr);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
@@ -1486,7 +1597,6 @@ void free_subgoal_trie(sg_node_ptr current_node, int mode, int position) {
 | 
			
		||||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void free_answer_trie(ans_node_ptr current_node, int mode, int position) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
 | 
			
		||||
@@ -1524,7 +1634,8 @@ void free_answer_trie(ans_node_ptr current_node, int mode, int position) {
 | 
			
		||||
    } else {
 | 
			
		||||
      child_mode = TRAVERSE_MODE_NORMAL;
 | 
			
		||||
    }
 | 
			
		||||
    free_answer_trie(TrNode_child(current_node), child_mode, TRAVERSE_POSITION_FIRST);
 | 
			
		||||
    free_answer_trie(TrNode_child(current_node), child_mode,
 | 
			
		||||
                     TRAVERSE_POSITION_FIRST);
 | 
			
		||||
  }
 | 
			
		||||
  if (position == TRAVERSE_POSITION_FIRST) {
 | 
			
		||||
    ans_node_ptr next_node = TrNode_next(current_node);
 | 
			
		||||
@@ -1546,7 +1657,6 @@ void free_answer_trie(ans_node_ptr current_node, int mode, int position) {
 | 
			
		||||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void free_answer_hash_chain(ans_hash_ptr hash) {
 | 
			
		||||
#if defined(THREADS_NO_SHARING) || defined(THREADS_SUBGOAL_SHARING)
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
@@ -1561,7 +1671,8 @@ void free_answer_hash_chain(ans_hash_ptr hash) {
 | 
			
		||||
    while (!*bucket)
 | 
			
		||||
      bucket++;
 | 
			
		||||
    chain_node = *bucket;
 | 
			
		||||
    TrNode_child((ans_node_ptr) UNTAG_ANSWER_NODE(TrNode_parent(chain_node))) = chain_node;
 | 
			
		||||
    TrNode_child((ans_node_ptr)UNTAG_ANSWER_NODE(TrNode_parent(chain_node))) =
 | 
			
		||||
        chain_node;
 | 
			
		||||
    while (++bucket != last_bucket) {
 | 
			
		||||
      if (*bucket) {
 | 
			
		||||
        while (TrNode_next(chain_node))
 | 
			
		||||
@@ -1578,10 +1689,11 @@ void free_answer_hash_chain(ans_hash_ptr hash) {
 | 
			
		||||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*****************************************************************************************
 | 
			
		||||
** all threads abolish their local data structures, and the main thread also abolishes  **
 | 
			
		||||
** all shared data structures, if no other thread is running (GLOBAL_NOfThreads == 1).  **
 | 
			
		||||
** all threads abolish their local data structures, and the main thread also
 | 
			
		||||
*abolishes  **
 | 
			
		||||
** all shared data structures, if no other thread is running (GLOBAL_NOfThreads
 | 
			
		||||
*== 1).  **
 | 
			
		||||
*****************************************************************************************/
 | 
			
		||||
void abolish_table(tab_ent_ptr tab_ent) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
@@ -1610,7 +1722,8 @@ void abolish_table(tab_ent_ptr tab_ent) {
 | 
			
		||||
  if (sg_node) {
 | 
			
		||||
    if (TrNode_child(sg_node)) {
 | 
			
		||||
      if (TabEnt_arity(tab_ent)) {
 | 
			
		||||
	free_subgoal_trie(TrNode_child(sg_node), TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST);
 | 
			
		||||
        free_subgoal_trie(TrNode_child(sg_node), TRAVERSE_MODE_NORMAL,
 | 
			
		||||
                          TRAVERSE_POSITION_FIRST);
 | 
			
		||||
      } else {
 | 
			
		||||
        sg_fr_ptr sg_fr = get_subgoal_frame_for_abolish(sg_node PASS_REGS);
 | 
			
		||||
        if (sg_fr) {
 | 
			
		||||
@@ -1636,7 +1749,6 @@ void abolish_table(tab_ent_ptr tab_ent) {
 | 
			
		||||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void showTable(tab_ent_ptr tab_ent, int show_mode, FILE *out) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  sg_node_ptr sg_node;
 | 
			
		||||
@@ -1655,9 +1767,11 @@ void showTable(tab_ent_ptr tab_ent, int show_mode, FILE *out) {
 | 
			
		||||
  TrStat_ans_nodes = 0;
 | 
			
		||||
  TrStat_gt_refs = 0;
 | 
			
		||||
  if (show_mode == SHOW_MODE_STATISTICS)
 | 
			
		||||
    fprintf(TrStat_out, "Table statistics for predicate '%s", AtomName(TabEnt_atom(tab_ent)));
 | 
			
		||||
    fprintf(TrStat_out, "Table statistics for predicate '%s",
 | 
			
		||||
            AtomName(TabEnt_atom(tab_ent)));
 | 
			
		||||
  else /* SHOW_MODE_STRUCTURE */
 | 
			
		||||
    fprintf(TrStat_out, "Table structure for predicate '%s", AtomName(TabEnt_atom(tab_ent)));
 | 
			
		||||
    fprintf(TrStat_out, "Table structure for predicate '%s",
 | 
			
		||||
            AtomName(TabEnt_atom(tab_ent)));
 | 
			
		||||
#ifdef MODE_DIRECTED_TABLING
 | 
			
		||||
  if (TabEnt_mode_directed(tab_ent)) {
 | 
			
		||||
    int i, *mode_directed = TabEnt_mode_directed(tab_ent);
 | 
			
		||||
@@ -1681,7 +1795,8 @@ void showTable(tab_ent_ptr tab_ent, int show_mode, FILE *out) {
 | 
			
		||||
      } else
 | 
			
		||||
        Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "show_table: unknown mode");
 | 
			
		||||
      if (i != MODE_DIRECTED_GET_ARG(mode_directed[i]))
 | 
			
		||||
	fprintf(TrStat_out, "(ARG%d)", MODE_DIRECTED_GET_ARG(mode_directed[i]) + 1);
 | 
			
		||||
        fprintf(TrStat_out, "(ARG%d)",
 | 
			
		||||
                MODE_DIRECTED_GET_ARG(mode_directed[i]) + 1);
 | 
			
		||||
      if (i + 1 != TabEnt_arity(tab_ent))
 | 
			
		||||
        fprintf(TrStat_out, ",");
 | 
			
		||||
    }
 | 
			
		||||
@@ -1697,8 +1812,11 @@ void showTable(tab_ent_ptr tab_ent, int show_mode, FILE *out) {
 | 
			
		||||
        int *arity = (int *)malloc(sizeof(int) * SHOW_TABLE_ARITY_ARRAY_SIZE);
 | 
			
		||||
        arity[0] = 1;
 | 
			
		||||
        arity[1] = TabEnt_arity(tab_ent);
 | 
			
		||||
	int str_index = sprintf(str, "  ?- %s(", AtomName(TabEnt_atom(tab_ent)));
 | 
			
		||||
	traverse_subgoal_trie(TrNode_child(sg_node), str, str_index, arity, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
        int str_index =
 | 
			
		||||
            sprintf(str, "  ?- %s(", AtomName(TabEnt_atom(tab_ent)));
 | 
			
		||||
        traverse_subgoal_trie(TrNode_child(sg_node), str, str_index, arity,
 | 
			
		||||
                              TRAVERSE_MODE_NORMAL,
 | 
			
		||||
                              TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
        free(str);
 | 
			
		||||
        free(arity);
 | 
			
		||||
      } else {
 | 
			
		||||
@@ -1727,11 +1845,13 @@ void showTable(tab_ent_ptr tab_ent, int show_mode, FILE *out) {
 | 
			
		||||
    SHOW_TABLE_STRUCTURE("  EMPTY\n");
 | 
			
		||||
  if (show_mode == SHOW_MODE_STATISTICS) {
 | 
			
		||||
    fprintf(TrStat_out, "  Subgoal trie structure\n");
 | 
			
		||||
    fprintf(TrStat_out, "    Subgoals: %ld (%ld incomplete)\n", TrStat_subgoals, TrStat_sg_incomplete);
 | 
			
		||||
    fprintf(TrStat_out, "    Subgoals: %ld (%ld incomplete)\n", TrStat_subgoals,
 | 
			
		||||
            TrStat_sg_incomplete);
 | 
			
		||||
    fprintf(TrStat_out, "    Subgoal trie nodes: %ld\n", TrStat_sg_nodes);
 | 
			
		||||
    fprintf(TrStat_out, "  Answer trie structure(s)\n");
 | 
			
		||||
#ifdef TABLING_INNER_CUTS
 | 
			
		||||
    fprintf(TrStat_out, "    Answers: %ld (%ld pruned)\n", TrStat_answers, TrStat_answers_pruned);
 | 
			
		||||
    fprintf(TrStat_out, "    Answers: %ld (%ld pruned)\n", TrStat_answers,
 | 
			
		||||
            TrStat_answers_pruned);
 | 
			
		||||
#else
 | 
			
		||||
    fprintf(TrStat_out, "    Answers: %ld\n", TrStat_answers);
 | 
			
		||||
#endif /* TABLING_INNER_CUTS */
 | 
			
		||||
@@ -1743,7 +1863,6 @@ void showTable(tab_ent_ptr tab_ent, int show_mode, FILE *out) {
 | 
			
		||||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void showGlobalTrie(int show_mode, FILE *out) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
 | 
			
		||||
@@ -1760,7 +1879,9 @@ void showGlobalTrie(int show_mode, FILE *out) {
 | 
			
		||||
    char *str = (char *)malloc(sizeof(char) * SHOW_TABLE_STR_ARRAY_SIZE);
 | 
			
		||||
    int *arity = (int *)malloc(sizeof(int) * SHOW_TABLE_ARITY_ARRAY_SIZE);
 | 
			
		||||
    arity[0] = 0;
 | 
			
		||||
    traverse_global_trie(TrNode_child(GLOBAL_root_gt), str, 0, arity, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
    traverse_global_trie(TrNode_child(GLOBAL_root_gt), str, 0, arity,
 | 
			
		||||
                         TRAVERSE_MODE_NORMAL,
 | 
			
		||||
                         TRAVERSE_POSITION_FIRST PASS_REGS);
 | 
			
		||||
    free(str);
 | 
			
		||||
    free(arity);
 | 
			
		||||
  } else
 | 
			
		||||
 
 | 
			
		||||
@@ -128,26 +128,26 @@ set(C_INTERFACE_SOURCES
 | 
			
		||||
  	H/compile.h
 | 
			
		||||
  	H/corout.h
 | 
			
		||||
  	H/dlmalloc.h
 | 
			
		||||
  	H/dglobals.h
 | 
			
		||||
  	H/dlocals.h
 | 
			
		||||
  	H/dhstruct.h
 | 
			
		||||
  	H/heap/dglobals.h
 | 
			
		||||
  	H/heap/dlocals.h
 | 
			
		||||
  	H/heap/dhstruct.h
 | 
			
		||||
  	H/eval.h
 | 
			
		||||
  	H/heapgc.h
 | 
			
		||||
  	H/hglobals.h
 | 
			
		||||
  	H/hlocals.h
 | 
			
		||||
  	H/hstruct.h
 | 
			
		||||
  	H/iglobals.h
 | 
			
		||||
  	H/ihstruct.h
 | 
			
		||||
  	H/ilocals.h
 | 
			
		||||
  	H/heap/hglobals.h
 | 
			
		||||
  	H/heap/hlocals.h
 | 
			
		||||
  	H/heap/hstruct.h
 | 
			
		||||
  	H/heap/iglobals.h
 | 
			
		||||
  	H/heap/ihstruct.h
 | 
			
		||||
  	H/heap/ilocals.h
 | 
			
		||||
  	H/index.h
 | 
			
		||||
  	H/inline-only.h
 | 
			
		||||
  	H/iswiatoms.h
 | 
			
		||||
  	H/qly.h
 | 
			
		||||
  	H/rclause.h
 | 
			
		||||
  	H/rglobals.h
 | 
			
		||||
  	H/rlocals.h
 | 
			
		||||
  	H/heap/rglobals.h
 | 
			
		||||
  	H/heap/rlocals.h
 | 
			
		||||
  	H/rheap.h
 | 
			
		||||
  	H/rhstruct.h
 | 
			
		||||
  	H/heap/rhstruct.h
 | 
			
		||||
  	H/threads.h
 | 
			
		||||
  	H/tracer.h
 | 
			
		||||
  	H/trim_trail.h
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@
 | 
			
		||||
 #define CONFIG_H
 | 
			
		||||
 | 
			
		||||
 /* config.h.in.  Generated from configure.in by autoheader.  */
 | 
			
		||||
 #define SYSTEM_OPTIONS  "${YAP_SYSTEM_OPTIONS}"
 | 
			
		||||
 | 
			
		||||
/* Define if building universal (internal helper macro) */
 | 
			
		||||
#ifndef AC_APPLE_UNIVERSAL_BUILD
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,8 @@ BEGIN_ERRORS()
 | 
			
		||||
 | 
			
		||||
E0(YAP_NO_ERROR, NO_ERROR)
 | 
			
		||||
 | 
			
		||||
    E(DOMAIN_ERROR_ABSOLUTE_FILE_NAME_OPTION, DOMAIN_ERROR, "absolute_file_name_option")
 | 
			
		||||
E(DOMAIN_ERROR_ABSOLUTE_FILE_NAME_OPTION, DOMAIN_ERROR,
 | 
			
		||||
  "absolute_file_name_option")
 | 
			
		||||
E(DOMAIN_ERROR_ARRAY_OVERFLOW, DOMAIN_ERROR, "array_overflow")
 | 
			
		||||
E(DOMAIN_ERROR_ARRAY_TYPE, DOMAIN_ERROR, "array_type")
 | 
			
		||||
E(DOMAIN_ERROR_FILE_ERRORS, DOMAIN_ERROR, "file_errors")
 | 
			
		||||
@@ -66,34 +67,32 @@ BEGIN_ERRORS()
 | 
			
		||||
 | 
			
		||||
E0(INSTANTIATION_ERROR, INSTANTIATION_ERROR_CLASS)
 | 
			
		||||
 | 
			
		||||
    E2(PERMISSION_ERROR_ACCESS_PRIVATE_PROCEDURE, PERMISSION_ERROR, "access","private_procedure")
 | 
			
		||||
    E2(PERMISSION_ERROR_NEW_ALIAS_FOR_STREAM, PERMISSION_ERROR,
 | 
			
		||||
       "add_alias", "stream")
 | 
			
		||||
E2(PERMISSION_ERROR_ACCESS_PRIVATE_PROCEDURE, PERMISSION_ERROR, "access",
 | 
			
		||||
   "private_procedure")
 | 
			
		||||
E2(PERMISSION_ERROR_NEW_ALIAS_FOR_STREAM, PERMISSION_ERROR, "add_alias",
 | 
			
		||||
   "stream")
 | 
			
		||||
E2(PERMISSION_ERROR_CREATE_ARRAY, PERMISSION_ERROR, "create", "array")
 | 
			
		||||
E2(PERMISSION_ERROR_CREATE_OPERATOR, PERMISSION_ERROR, "create", "operator")
 | 
			
		||||
    E2(PERMISSION_ERROR_INPUT_BINARY_STREAM, PERMISSION_ERROR,
 | 
			
		||||
      "input", "binary_stream")
 | 
			
		||||
    E2(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM, PERMISSION_ERROR,
 | 
			
		||||
      "input", "past_end_of_stream")
 | 
			
		||||
E2(PERMISSION_ERROR_INPUT_BINARY_STREAM, PERMISSION_ERROR, "input",
 | 
			
		||||
   "binary_stream")
 | 
			
		||||
E2(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM, PERMISSION_ERROR, "input",
 | 
			
		||||
   "past_end_of_stream")
 | 
			
		||||
E2(PERMISSION_ERROR_INPUT_STREAM, PERMISSION_ERROR, "input", "stream")
 | 
			
		||||
    E2(PERMISSION_ERROR_INPUT_TEXT_STREAM, PERMISSION_ERROR,
 | 
			
		||||
      "input","text_stream")
 | 
			
		||||
    E2(PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE, PERMISSION_ERROR,
 | 
			
		||||
      "modify","static_procedure")
 | 
			
		||||
E2(PERMISSION_ERROR_INPUT_TEXT_STREAM, PERMISSION_ERROR, "input", "text_stream")
 | 
			
		||||
E2(PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE, PERMISSION_ERROR, "modify",
 | 
			
		||||
   "static_procedure")
 | 
			
		||||
E2(PERMISSION_ERROR_OPEN_SOURCE_SINK, PERMISSION_ERROR, "open", "source_sink")
 | 
			
		||||
    E2(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, PERMISSION_ERROR,
 | 
			
		||||
      "output","binary_stream")
 | 
			
		||||
E2(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, PERMISSION_ERROR, "output",
 | 
			
		||||
   "binary_stream")
 | 
			
		||||
E2(PERMISSION_ERROR_OUTPUT_STREAM, PERMISSION_ERROR, "output", "stream")
 | 
			
		||||
    E2(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, PERMISSION_ERROR,
 | 
			
		||||
      "output","text_stream")
 | 
			
		||||
E2(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, PERMISSION_ERROR, "output",
 | 
			
		||||
   "text_stream")
 | 
			
		||||
E2(PERMISSION_ERROR_READ_ONLY_FLAG, PERMISSION_ERROR, "read_only", "flag")
 | 
			
		||||
E2(PERMISSION_ERROR_RESIZE_ARRAY, PERMISSION_ERROR, "resize", "array")
 | 
			
		||||
    E2(PERMISSION_ERROR_REPOSITION_STREAM, PERMISSION_ERROR,
 | 
			
		||||
      "reposition","stream")
 | 
			
		||||
E2(PERMISSION_ERROR_REPOSITION_STREAM, PERMISSION_ERROR, "reposition", "stream")
 | 
			
		||||
 | 
			
		||||
E(REPRESENTATION_ERROR_CHARACTER, REPRESENTATION_ERROR, "character")
 | 
			
		||||
    E(REPRESENTATION_ERROR_CHARACTER_CODE, REPRESENTATION_ERROR,
 | 
			
		||||
      "character_code")
 | 
			
		||||
E(REPRESENTATION_ERROR_CHARACTER_CODE, REPRESENTATION_ERROR, "character_code")
 | 
			
		||||
E(REPRESENTATION_ERROR_INT, REPRESENTATION_ERROR, "int")
 | 
			
		||||
E(REPRESENTATION_ERROR_MAX_ARITY, REPRESENTATION_ERROR, "max_arity")
 | 
			
		||||
E(REPRESENTATION_ERROR_VARIABLE, REPRESENTATION_ERROR, "variable")
 | 
			
		||||
@@ -102,8 +101,7 @@ BEGIN_ERRORS()
 | 
			
		||||
E(RESOURCE_ERROR_MAX_STREAMS, RESOURCE_ERROR, "max_streams")
 | 
			
		||||
E(RESOURCE_ERROR_MAX_THREADS, RESOURCE_ERROR, "max_threads")
 | 
			
		||||
E(RESOURCE_ERROR_AUXILIARY_STACK, RESOURCE_ERROR, "auxiliary_stack")
 | 
			
		||||
    E(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, RESOURCE_ERROR,
 | 
			
		||||
      "attributed_variables")
 | 
			
		||||
E(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, RESOURCE_ERROR, "attributed_variables")
 | 
			
		||||
E(RESOURCE_ERROR_HEAP, RESOURCE_ERROR, "database_space")
 | 
			
		||||
E(RESOURCE_ERROR_TRAIL, RESOURCE_ERROR, "trail_space")
 | 
			
		||||
E(RESOURCE_ERROR_STACK, RESOURCE_ERROR, "stack_space")
 | 
			
		||||
@@ -119,8 +117,7 @@ BEGIN_ERRORS()
 | 
			
		||||
 | 
			
		||||
E(ABORT_EVENT, EVENT, "abort")
 | 
			
		||||
E(CALL_COUNTER_UNDERFLOW_EVENT, EVENT, "call_counter_underflow")
 | 
			
		||||
    E(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT, EVENT,
 | 
			
		||||
      "pred_entry_counter_underflow")
 | 
			
		||||
E(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT, EVENT, "pred_entry_counter_underflow")
 | 
			
		||||
E(RETRY_COUNTER_UNDERFLOW_EVENT, EVENT, "retry_counter_underflow")
 | 
			
		||||
E(INTERRUPT_EVENT, EVENT, "interrupt")
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,11 +9,11 @@ set (LIBRARY_PL
 | 
			
		||||
  avl.yap
 | 
			
		||||
  bhash.yap
 | 
			
		||||
  charsio.yap
 | 
			
		||||
  clauses.yap
 | 
			
		||||
  coinduction.yap
 | 
			
		||||
  dbqueues.yap
 | 
			
		||||
  dbusage.yap
 | 
			
		||||
  dgraphs.yap
 | 
			
		||||
  error.yap
 | 
			
		||||
  exo_interval.yap
 | 
			
		||||
  expand_macros.yap
 | 
			
		||||
  gensym.yap
 | 
			
		||||
@@ -70,6 +70,7 @@ add_subdirectory(regex)
 | 
			
		||||
add_subdirectory(rltree)
 | 
			
		||||
add_subdirectory(system)
 | 
			
		||||
add_subdirectory(tries)
 | 
			
		||||
add_subdirectory(ytest)
 | 
			
		||||
 | 
			
		||||
add_custom_target (library SOURCES ${LIBRARY_PL} ) # WORKING_DIRECTORY ${CMAKE_BINARY_DIR} )
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
/**
 | 
			
		||||
s/**
 | 
			
		||||
 * @file   dbqueues.yap
 | 
			
		||||
 * @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
 | 
			
		||||
 * @date   Tue Nov 17 15:01:49 2015
 | 
			
		||||
@@ -25,9 +25,9 @@ A library to implement queues of NB Terms
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
:- unhide('$init_nb_queue').
 | 
			
		||||
:- unhide('$nb_enqueue').
 | 
			
		||||
:- unhide('$nb_dequeue').
 | 
			
		||||
:- unhide_atom('$init_nb_queue').
 | 
			
		||||
:- unhide_atom('$nb_enqueue').
 | 
			
		||||
:- unhide_atom('$nb_dequeue').
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
nb_enqueue(Name,El) :- var(Name),
 | 
			
		||||
 
 | 
			
		||||
@@ -1,324 +0,0 @@
 | 
			
		||||
 | 
			
		||||
% SWI emulation.
 | 
			
		||||
% written in an on-demand basis.
 | 
			
		||||
 | 
			
		||||
%% @defgroup swi Compatibility with SWI-Prolog and Other Prolog systems
 | 
			
		||||
 | 
			
		||||
/** 
 | 
			
		||||
 | 
			
		||||
@defgroup System SWI Dialect Support
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
This library provides a number of SWI-Prolog builtins that are not by
 | 
			
		||||
default in YAP. This support is loaded with the
 | 
			
		||||
~~~~~
 | 
			
		||||
expects_dialect(swi)
 | 
			
		||||
~~~~~
 | 
			
		||||
 | 
			
		||||
 command.
 | 
			
		||||
 | 
			
		||||
@{
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/** @pred  time_file(+ _File_,- _Time_) 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Unify the last modification time of  _File_ with
 | 
			
		||||
 _Time_.  _Time_ is a floating point number expressing the seconds
 | 
			
		||||
elapsed since Jan 1, 1970.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
*/
 | 
			
		||||
/** @pred concat_atom(+ _List_,- _Atom_) 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 _List_ is a list of atoms, integers or floating point numbers. Succeeds
 | 
			
		||||
if  _Atom_ can be unified with the concatenated elements of  _List_. If
 | 
			
		||||
 _List_ has exactly 2 elements it is equivalent to `atom_concat/3`,
 | 
			
		||||
allowing for variables in the list.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
:- module(system, [concat_atom/2,
 | 
			
		||||
		   concat_atom/3,
 | 
			
		||||
		   read_clause/1,
 | 
			
		||||
		   chdir/1,
 | 
			
		||||
		   compile_aux_clauses/1,
 | 
			
		||||
		   convert_time/2,
 | 
			
		||||
		   convert_time/8,
 | 
			
		||||
		   '$declare_module'/5,
 | 
			
		||||
		   '$set_predicate_attribute'/3,
 | 
			
		||||
		   stamp_date_time/3,
 | 
			
		||||
		   date_time_stamp/2,
 | 
			
		||||
		   time_file/2,
 | 
			
		||||
		   flag/3,
 | 
			
		||||
		   require/1,
 | 
			
		||||
		   normalize_space/2,
 | 
			
		||||
		   current_flag/1
 | 
			
		||||
		]).
 | 
			
		||||
 | 
			
		||||
:- reexport(library(charsio),[
 | 
			
		||||
			      write_to_chars/2,
 | 
			
		||||
			      read_from_chars/2
 | 
			
		||||
			     ]).
 | 
			
		||||
 | 
			
		||||
:- reexport(library(lists),[append/2,
 | 
			
		||||
			    append/3,
 | 
			
		||||
			    delete/3,
 | 
			
		||||
			    member/2,
 | 
			
		||||
			    flatten/2,
 | 
			
		||||
			    intersection/3,
 | 
			
		||||
			    last/2,
 | 
			
		||||
			    memberchk/2,
 | 
			
		||||
			    max_list/2,
 | 
			
		||||
			    min_list/2,
 | 
			
		||||
			    nextto/3,
 | 
			
		||||
			    permutation/2,
 | 
			
		||||
			    reverse/2,
 | 
			
		||||
			    select/3,
 | 
			
		||||
			    selectchk/3,
 | 
			
		||||
			    sublist/2,
 | 
			
		||||
			    sumlist/2,
 | 
			
		||||
			    nth1/4,
 | 
			
		||||
			    nth0/4,
 | 
			
		||||
			    nth1/3,
 | 
			
		||||
			    nth0/3]).
 | 
			
		||||
 | 
			
		||||
:- reexport(library(apply),[maplist/2,
 | 
			
		||||
			    maplist/3,
 | 
			
		||||
			    maplist/4,
 | 
			
		||||
			    maplist/5,
 | 
			
		||||
			    include/3,
 | 
			
		||||
			    exclude/3,
 | 
			
		||||
			    partition/4,
 | 
			
		||||
			    partition/5
 | 
			
		||||
			   ]).
 | 
			
		||||
 | 
			
		||||
:- reexport(library(system),
 | 
			
		||||
	      [datime/1,
 | 
			
		||||
	       mktime/2,
 | 
			
		||||
	       file_property/2,
 | 
			
		||||
	       delete_file/1]).
 | 
			
		||||
 | 
			
		||||
:- reexport(library(arg),
 | 
			
		||||
	      [genarg/3]).
 | 
			
		||||
 | 
			
		||||
:- reexport(library(apply_macros),
 | 
			
		||||
	      []).
 | 
			
		||||
 | 
			
		||||
:- reexport(library(terms),
 | 
			
		||||
	      [subsumes/2,
 | 
			
		||||
	       subsumes_chk/2,
 | 
			
		||||
	       term_hash/2,
 | 
			
		||||
	       unifiable/3,
 | 
			
		||||
	       cyclic_term/1,
 | 
			
		||||
	       variant/2]).
 | 
			
		||||
 | 
			
		||||
:- use_module(library(error),[must_be/2]).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
:- source.
 | 
			
		||||
 | 
			
		||||
:- style_check(all).
 | 
			
		||||
 | 
			
		||||
:- yap_flag(unknown,error).
 | 
			
		||||
 | 
			
		||||
:- yap_flag(open_expands_filename,false).
 | 
			
		||||
 | 
			
		||||
:- yap_flag(autoload,true).
 | 
			
		||||
 | 
			
		||||
:- set_prolog_flag(user_flags,silent).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% Time is given as a float in SWI-Prolog.
 | 
			
		||||
swi_get_time(FSecs) :- datime(Datime),  mktime(Datime, Secs), FSecs is Secs*1.0.
 | 
			
		||||
 | 
			
		||||
goal_expansion(atom_concat(A,B),atomic_concat(A,B)).
 | 
			
		||||
/** @pred  atom_concat(? _A1_,? _A2_,? _A12_) is iso
 | 
			
		||||
 | 
			
		||||
The predicate holds when the third argument unifies with an atom, and
 | 
			
		||||
the first and second unify with atoms such that their representations
 | 
			
		||||
concatenated are the representation for  _A12_.
 | 
			
		||||
 | 
			
		||||
If  _A1_ and  _A2_ are unbound, the built-in will find all the atoms
 | 
			
		||||
that concatenated give  _A12_.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
goal_expansion(atom_concat(A,B,C),atomic_concat(A,B,C)).
 | 
			
		||||
%goal_expansion(arg(A,_,_),_) :- nonvar(A), !, fail.
 | 
			
		||||
goal_expansion(arg(A,B,C),genarg(A,B,C)).
 | 
			
		||||
 | 
			
		||||
% make sure we also use 
 | 
			
		||||
:- user:library_directory(X),
 | 
			
		||||
	atom(X),
 | 
			
		||||
	atom_concat([X,'/dialect/swi'],SwiDir),
 | 
			
		||||
	\+ user:library_directory(SwiDir),
 | 
			
		||||
	asserta(user:library_directory(SwiDir)),
 | 
			
		||||
	fail
 | 
			
		||||
	;
 | 
			
		||||
	true.
 | 
			
		||||
 | 
			
		||||
:- multifile
 | 
			
		||||
   user:file_search_path/2.
 | 
			
		||||
 | 
			
		||||
:- dynamic
 | 
			
		||||
   user:file_search_path/2.
 | 
			
		||||
 | 
			
		||||
/** @pred concat_atom(? _List_,+ _Separator_,? _Atom_)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Creates an atom just like concat_atom/2, but inserts  _Separator_
 | 
			
		||||
between each pair of atoms.  For example:
 | 
			
		||||
 | 
			
		||||
~~~~~
 | 
			
		||||
?- concat_atom([gnu, gnat], ', ', A).
 | 
			
		||||
 | 
			
		||||
A = 'gnu, gnat'
 | 
			
		||||
~~~~~
 | 
			
		||||
 | 
			
		||||
(Unimplemented) This predicate can also be used to split atoms by
 | 
			
		||||
instantiating  _Separator_ and  _Atom_:
 | 
			
		||||
 | 
			
		||||
~~~~~
 | 
			
		||||
?- concat_atom(L, -, 'gnu-gnat').
 | 
			
		||||
 | 
			
		||||
L = [gnu, gnat]
 | 
			
		||||
~~~~~
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
*/
 | 
			
		||||
concat_atom([A|List], Separator, New) :- var(List), !,
 | 
			
		||||
	atom_codes(Separator,[C]),
 | 
			
		||||
	atom_codes(New, NewChars),
 | 
			
		||||
	split_atom_by_chars(NewChars,C,L,L,A,List).
 | 
			
		||||
concat_atom(List, Separator, New) :-
 | 
			
		||||
	add_separator_to_list(List, Separator, NewList),
 | 
			
		||||
	atomic_concat(NewList, New).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
split_atom_by_chars([],_,[],L,A,[]):-
 | 
			
		||||
	atom_codes(A,L).
 | 
			
		||||
split_atom_by_chars([C|NewChars],C,[],L,A,[NA|Atoms]) :- !,
 | 
			
		||||
	atom_codes(A,L),
 | 
			
		||||
	split_atom_by_chars(NewChars,C,NL,NL,NA,Atoms).
 | 
			
		||||
split_atom_by_chars([C1|NewChars],C,[C1|LF],LAtom,Atom,Atoms) :-
 | 
			
		||||
	split_atom_by_chars(NewChars,C,LF,LAtom,Atom,Atoms).
 | 
			
		||||
 | 
			
		||||
add_separator_to_list([], _, []).
 | 
			
		||||
add_separator_to_list([T], _, [T]) :- !.
 | 
			
		||||
add_separator_to_list([H|T], Separator, [H,Separator|NT]) :-
 | 
			
		||||
	add_separator_to_list(T, Separator, NT).
 | 
			
		||||
 | 
			
		||||
concat_atom(List, New) :-
 | 
			
		||||
	atomic_concat(List, New).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bindings_message(V) -->
 | 
			
		||||
       { cvt_bindings(V, Bindings) },
 | 
			
		||||
       prolog:message(query(_YesNo,Bindings)), !.
 | 
			
		||||
 | 
			
		||||
cvt_bindings([],[]).
 | 
			
		||||
cvt_bindings([[Name|Value]|L],[AName=Value|Bindings]) :-
 | 
			
		||||
	atom_codes(AName, Name),
 | 
			
		||||
	cvt_bindings(L,Bindings).
 | 
			
		||||
 | 
			
		||||
/** @pred chdir(+ _Dir_) 
 | 
			
		||||
 | 
			
		||||
Compatibility predicate.  New code should use working_directory/2.
 | 
			
		||||
*/
 | 
			
		||||
chdir(X) :- cd(X).
 | 
			
		||||
 | 
			
		||||
%%	convert_time(+Stamp, -String)
 | 
			
		||||
%
 | 
			
		||||
%	Convert  a time-stamp as  obtained though get_time/1 into a  textual
 | 
			
		||||
%	representation  using the C-library function ctime().  The  value is
 | 
			
		||||
%	returned  as a  SWI-Prolog string object  (see section  4.23).   See
 | 
			
		||||
%	also convert_time/8.
 | 
			
		||||
%
 | 
			
		||||
%	@deprecated Use format_time/3.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
convert_time(Stamp, String) :-
 | 
			
		||||
	format_time(string(String), '%+', Stamp).
 | 
			
		||||
 | 
			
		||||
%%	convert_time(+Stamp, -Y, -Mon, -Day, -Hour, -Min, -Sec, -MilliSec)
 | 
			
		||||
%
 | 
			
		||||
%	Convert   a  time  stamp,   provided  by   get_time/1,   time_file/2,
 | 
			
		||||
%	etc.   Year is  unified with the year,  Month with the month  number
 | 
			
		||||
%	(January  is 1), Day  with the day of  the month (starting with  1),
 | 
			
		||||
%	Hour  with  the hour  of the  day (0--23),  Minute  with the  minute
 | 
			
		||||
%	(0--59).   Second with the  second (0--59) and MilliSecond with  the
 | 
			
		||||
%	milliseconds  (0--999).  Note that the latter might not  be accurate
 | 
			
		||||
%	or  might always be 0, depending  on the timing capabilities of  the
 | 
			
		||||
%	system.  See also convert_time/2.
 | 
			
		||||
%
 | 
			
		||||
%	@deprecated Use stamp_date_time/3.
 | 
			
		||||
 | 
			
		||||
convert_time(Stamp, Y, Mon, Day, Hour, Min, Sec, MilliSec) :-
 | 
			
		||||
	stamp_date_time(Stamp,
 | 
			
		||||
			date(Y, Mon, Day,
 | 
			
		||||
			     Hour, Min, FSec,
 | 
			
		||||
			     _, _, _),
 | 
			
		||||
			local),
 | 
			
		||||
	Sec is integer(float_integer_part(FSec)),
 | 
			
		||||
	MilliSec is integer(float_fractional_part(FSec)*1000).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
compile_aux_clauses([]).
 | 
			
		||||
compile_aux_clauses([(:- G)|Cls]) :- !,
 | 
			
		||||
	prolog_load_context(module, M),
 | 
			
		||||
	once(M:G),
 | 
			
		||||
	compile_aux_clauses(Cls).
 | 
			
		||||
compile_aux_clauses([Cl|Cls]) :-
 | 
			
		||||
	prolog_load_context(module, M),
 | 
			
		||||
	assert_static(M:Cl),
 | 
			
		||||
	compile_aux_clauses(Cls).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
flag(Key, Old, New) :-
 | 
			
		||||
	recorded(Key, Old, R), !,
 | 
			
		||||
	(
 | 
			
		||||
	 Old \== New
 | 
			
		||||
	->
 | 
			
		||||
	 erase(R),
 | 
			
		||||
	 recorda(Key, New, _)
 | 
			
		||||
	;
 | 
			
		||||
	 true
 | 
			
		||||
	).
 | 
			
		||||
flag(Key, 0, New) :-
 | 
			
		||||
	functor(Key, N, Ar),
 | 
			
		||||
	functor(K, N, Ar),
 | 
			
		||||
	assert(flag(K)),
 | 
			
		||||
	recorda(K, New, _).
 | 
			
		||||
 | 
			
		||||
current_flag(Key) :-
 | 
			
		||||
	swi:flag(Key).
 | 
			
		||||
 | 
			
		||||
require(F) :-
 | 
			
		||||
	must_be(list, F),
 | 
			
		||||
	% notice that this must be used as a declaration.
 | 
			
		||||
	prolog_load_context(module, Mod),
 | 
			
		||||
	required_predicates(F, Mod).
 | 
			
		||||
 | 
			
		||||
required_predicates([], _).
 | 
			
		||||
required_predicates([F|Fs], M) :-
 | 
			
		||||
	required_predicate(F, M),
 | 
			
		||||
	required_predicates(Fs, M).
 | 
			
		||||
 | 
			
		||||
required_predicate(Na/Ar, M) :-
 | 
			
		||||
	functor(G, Na, Ar),
 | 
			
		||||
	(
 | 
			
		||||
	 predicate_property(M:G, _) ->
 | 
			
		||||
	 true
 | 
			
		||||
	;
 | 
			
		||||
         autoloader:find_predicate(G, _)
 | 
			
		||||
	).
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@}
 | 
			
		||||
*/
 | 
			
		||||
@@ -117,9 +117,6 @@ allowing for variables in the list.
 | 
			
		||||
	       cyclic_term/1,
 | 
			
		||||
	       variant/2]).
 | 
			
		||||
 | 
			
		||||
:- use_module(library(error),[must_be/2]).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
:- source.
 | 
			
		||||
 | 
			
		||||
:- style_check(all).
 | 
			
		||||
 
 | 
			
		||||
@@ -102,7 +102,7 @@ PL_put_blob(term_t t, void *blob, size_t len, PL_blob_t *type)
 | 
			
		||||
  if (type->acquire) {
 | 
			
		||||
    type->acquire(AtomToSWIAtom(AbsAtom(ae)));
 | 
			
		||||
  }
 | 
			
		||||
  Yap_PutInSlot(t, MkAtomTerm(AbsAtom(ae))  PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(t, MkAtomTerm(AbsAtom(ae)));
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -371,7 +371,7 @@ X_API void PL_reset_term_refs(term_t after)
 | 
			
		||||
{
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  term_t new = Yap_NewSlots(1);
 | 
			
		||||
  Yap_RecoverSlots(after-new, new PASS_REGS);
 | 
			
		||||
  Yap_RecoverSlots(after-new, new);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** @}
 | 
			
		||||
@@ -430,10 +430,10 @@ X_API int PL_get_arg(int index, term_t ts, term_t a)
 | 
			
		||||
  if ( !IsApplTerm(t) ) {
 | 
			
		||||
    if (IsPairTerm(t)) {
 | 
			
		||||
      if (index == 1){
 | 
			
		||||
        Yap_PutInSlot(a,HeadOfTerm(t) PASS_REGS);
 | 
			
		||||
        Yap_PutInSlot(a,HeadOfTerm(t));
 | 
			
		||||
        return 1;
 | 
			
		||||
      } else if (index == 2) {
 | 
			
		||||
        Yap_PutInSlot(a,TailOfTerm(t) PASS_REGS);
 | 
			
		||||
        Yap_PutInSlot(a,TailOfTerm(t));
 | 
			
		||||
        return 1;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
@@ -444,7 +444,7 @@ X_API int PL_get_arg(int index, term_t ts, term_t a)
 | 
			
		||||
    return 0;
 | 
			
		||||
    if (index < 1 || index > ArityOfFunctor(f))
 | 
			
		||||
    return 0;
 | 
			
		||||
    Yap_PutInSlot(a,ArgOfTerm(index, t) PASS_REGS);
 | 
			
		||||
    Yap_PutInSlot(a,ArgOfTerm(index, t));
 | 
			
		||||
    return 1;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -792,8 +792,8 @@ X_API int PL_get_list(term_t ts, term_t h, term_t tl)
 | 
			
		||||
  if (IsVarTerm(t) || !IsPairTerm(t) ) {
 | 
			
		||||
    return 0;
 | 
			
		||||
  }
 | 
			
		||||
  Yap_PutInSlot(h,HeadOfTerm(t) PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(tl,TailOfTerm(t) PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(h,HeadOfTerm(t));
 | 
			
		||||
  Yap_PutInSlot(tl,TailOfTerm(t));
 | 
			
		||||
  return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -808,7 +808,7 @@ X_API int PL_get_head(term_t ts, term_t h)
 | 
			
		||||
  if (!YAP_IsPairTerm(t) ) {
 | 
			
		||||
    return 0;
 | 
			
		||||
  }
 | 
			
		||||
  Yap_PutInSlot(h,YAP_HeadOfTerm(t) PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(h,YAP_HeadOfTerm(t));
 | 
			
		||||
  return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -925,7 +925,7 @@ X_API int PL_get_tail(term_t ts, term_t tl)
 | 
			
		||||
  if (!YAP_IsPairTerm(t) ) {
 | 
			
		||||
    return 0;
 | 
			
		||||
  }
 | 
			
		||||
  Yap_PutInSlot(tl,YAP_TailOfTerm(t) PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(tl,YAP_TailOfTerm(t) );
 | 
			
		||||
  return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1035,7 +1035,7 @@ X_API int PL_cons_functor(term_t d, functor_t f,...)
 | 
			
		||||
  Functor ff = SWIFunctorToFunctor(f);
 | 
			
		||||
 | 
			
		||||
  if (IsAtomTerm((Term)ff)) {
 | 
			
		||||
    Yap_PutInSlot(d, (YAP_Term)f PASS_REGS);
 | 
			
		||||
    Yap_PutInSlot(d, (YAP_Term)f );
 | 
			
		||||
    return TRUE;
 | 
			
		||||
  }
 | 
			
		||||
  arity = ArityOfFunctor(ff);
 | 
			
		||||
@@ -1056,7 +1056,7 @@ X_API int PL_cons_functor(term_t d, functor_t f,...)
 | 
			
		||||
    Yap_unify(tmp[i],Yap_GetFromSlot(va_arg(ap, term_t)));
 | 
			
		||||
  }
 | 
			
		||||
  va_end (ap);
 | 
			
		||||
  Yap_PutInSlot(d,t PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(d,t );
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1068,7 +1068,7 @@ X_API int PL_cons_functor_v(term_t d, functor_t f, term_t a0)
 | 
			
		||||
  Functor ff = SWIFunctorToFunctor(f);
 | 
			
		||||
 | 
			
		||||
  if (IsAtomTerm((Term)ff)) {
 | 
			
		||||
    Yap_PutInSlot(d, (YAP_Term)f PASS_REGS);
 | 
			
		||||
    Yap_PutInSlot(d, (YAP_Term)f );
 | 
			
		||||
    return TRUE;
 | 
			
		||||
  }
 | 
			
		||||
  arity = ArityOfFunctor(ff);
 | 
			
		||||
@@ -1088,7 +1088,7 @@ X_API int PL_cons_functor_v(term_t d, functor_t f, term_t a0)
 | 
			
		||||
    Yap_unify(tmp[i] , Yap_GetFromSlot(a0 ) );
 | 
			
		||||
    a0++;
 | 
			
		||||
  }
 | 
			
		||||
  Yap_PutInSlot(d,t PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(d,t );
 | 
			
		||||
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
@@ -1101,14 +1101,14 @@ X_API int PL_cons_list(term_t d, term_t h, term_t t)
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  Yap_PutInSlot(d,MkPairTerm(Yap_GetFromSlot(h),Yap_GetFromSlot(t)) PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(d,MkPairTerm(Yap_GetFromSlot(h),Yap_GetFromSlot(t)));
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
X_API int PL_put_atom(term_t t, atom_t a)
 | 
			
		||||
{
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  Yap_PutInSlot(t,MkAtomTerm(SWIAtomToAtom(a)) PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(t,MkAtomTerm(SWIAtomToAtom(a)));
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1121,7 +1121,8 @@ X_API int PL_put_atom_chars(term_t t, const char *s)
 | 
			
		||||
    return FALSE;
 | 
			
		||||
  }
 | 
			
		||||
  Yap_AtomIncreaseHold(at);
 | 
			
		||||
  Yap_PutInSlot(t,MkAtomTerm(at) PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(t,MkAtomTerm(at));
 | 
			
		||||
  
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1134,14 +1135,14 @@ X_API int PL_put_atom_nchars(term_t t, size_t len, const char *s)
 | 
			
		||||
    return FALSE;
 | 
			
		||||
  }
 | 
			
		||||
  Yap_AtomIncreaseHold(at);
 | 
			
		||||
  Yap_PutInSlot(t,MkAtomTerm(at) PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(t,MkAtomTerm(at));
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
X_API int PL_put_float(term_t t, double fl)
 | 
			
		||||
{
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  Yap_PutInSlot(t,YAP_MkFloatTerm(fl) PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(t,YAP_MkFloatTerm(fl) );
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1152,7 +1153,7 @@ X_API int PL_put_functor(term_t t, functor_t f)
 | 
			
		||||
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  if (IsAtomTerm((Term)ff)) {
 | 
			
		||||
    Yap_PutInSlot(t,(Term)ff PASS_REGS);
 | 
			
		||||
    Yap_PutInSlot(t,(Term)ff);
 | 
			
		||||
  } else {
 | 
			
		||||
    arity = ArityOfFunctor(ff);
 | 
			
		||||
    if (Unsigned(HR)+arity > Unsigned(ASP)-CreepFlag) {
 | 
			
		||||
@@ -1160,10 +1161,9 @@ X_API int PL_put_functor(term_t t, functor_t f)
 | 
			
		||||
        return FALSE;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    if (arity == 2 && ff == FunctorDot)
 | 
			
		||||
    Yap_PutInSlot(t,YAP_MkNewPairTerm() PASS_REGS);
 | 
			
		||||
    else
 | 
			
		||||
    Yap_PutInSlot(t,YAP_MkNewApplTerm((YAP_Functor)ff,arity) PASS_REGS);
 | 
			
		||||
    if (arity == 2 && ff == FunctorDot){
 | 
			
		||||
    } else
 | 
			
		||||
    Yap_PutInSlot(t,YAP_MkNewApplTerm((YAP_Functor)ff,arity) );
 | 
			
		||||
  }
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
@@ -1171,14 +1171,14 @@ X_API int PL_put_functor(term_t t, functor_t f)
 | 
			
		||||
X_API int PL_put_integer(term_t t, long n)
 | 
			
		||||
{
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
    Yap_PutInSlot(t,YAP_MkIntTerm(n) PASS_REGS);
 | 
			
		||||
    Yap_PutInSlot(t,YAP_MkIntTerm(n));
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
X_API int PL_put_boolean(term_t t, uintptr_t n)
 | 
			
		||||
{
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  Yap_PutInSlot(t,(n==0?TermFalse:TermTrue) PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(t,(n==0?TermFalse:TermTrue));
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1186,7 +1186,7 @@ X_API int PL_put_int64(term_t t, int64_t n)
 | 
			
		||||
{
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  #if SIZEOF_INT_P==8
 | 
			
		||||
  Yap_PutInSlot(t,MkIntegerTerm(n) PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(t,MkIntegerTerm(n) );
 | 
			
		||||
  return TRUE;
 | 
			
		||||
  #elif USE_GMP
 | 
			
		||||
  char s[64];
 | 
			
		||||
@@ -1221,21 +1221,21 @@ X_API int PL_put_int64(term_t t, int64_t n)
 | 
			
		||||
X_API int PL_put_intptr(term_t t, intptr_t n)
 | 
			
		||||
{
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
    Yap_PutInSlot(t,YAP_MkIntTerm(n) PASS_REGS);
 | 
			
		||||
    Yap_PutInSlot(t,YAP_MkIntTerm(n));
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
X_API int PL_put_uintptr(term_t t, uintptr_t n)
 | 
			
		||||
{
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
    Yap_PutInSlot(t,YAP_MkIntTerm(n) PASS_REGS);
 | 
			
		||||
    Yap_PutInSlot(t,YAP_MkIntTerm(n) );
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
X_API int PL_put_list(term_t t)
 | 
			
		||||
{
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  Yap_PutInSlot(t,YAP_MkNewPairTerm() PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(t,YAP_MkNewPairTerm() );
 | 
			
		||||
  if (Unsigned(HR) > Unsigned(ASP)-CreepFlag) {
 | 
			
		||||
    if (!do_gc(0)) {
 | 
			
		||||
      return FALSE;
 | 
			
		||||
@@ -1252,14 +1252,14 @@ X_API int PL_put_list_chars(term_t t, const char *s)
 | 
			
		||||
    if (LOCAL_Error_TYPE && !Yap_SWIHandleError( "PL_put_string_nchars" ))
 | 
			
		||||
    return FALSE;
 | 
			
		||||
  }
 | 
			
		||||
  Yap_PutInSlot(t, nt PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(t, nt);
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
X_API void PL_put_nil(term_t t)
 | 
			
		||||
{
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  Yap_PutInSlot(t,TermNil PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(t,TermNil);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*  void PL_put_pointer(term_t -t, void *ptr)
 | 
			
		||||
@@ -1269,7 +1269,7 @@ X_API int PL_put_pointer(term_t t, void *ptr)
 | 
			
		||||
{
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  YAP_Term tptr = YAP_MkIntTerm((YAP_Int)ptr);
 | 
			
		||||
  Yap_PutInSlot(t,tptr PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(t,tptr );
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1282,7 +1282,7 @@ X_API int PL_put_string_chars(term_t t, const char *chars)
 | 
			
		||||
    if (LOCAL_Error_TYPE && !Yap_SWIHandleError( "PL_putPL_put_string_chars" ))
 | 
			
		||||
    return FALSE;
 | 
			
		||||
  }
 | 
			
		||||
  Yap_PutInSlot(t, nt PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(t, nt);
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1295,21 +1295,21 @@ X_API int PL_put_string_nchars(term_t t, size_t len, const char *chars)
 | 
			
		||||
    if (LOCAL_Error_TYPE && !Yap_SWIHandleError( "PL_putPL_put_string_chars" ))
 | 
			
		||||
    return FALSE;
 | 
			
		||||
  }
 | 
			
		||||
  Yap_PutInSlot(t, nt PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(t, nt);
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
X_API int PL_put_term(term_t d, term_t s)
 | 
			
		||||
{
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  Yap_PutInSlot(d,Yap_GetFromSlot(s ) PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(d,Yap_GetFromSlot(s ) );
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
X_API int PL_put_variable(term_t t)
 | 
			
		||||
{
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  Yap_PutInSlot(t,MkVarTerm() PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(t,MkVarTerm());
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1518,8 +1518,8 @@ X_API int PL_unify_list(term_t tt, term_t h, term_t tail)
 | 
			
		||||
  } else if (!IsPairTerm(t)) {
 | 
			
		||||
    return FALSE;
 | 
			
		||||
  }
 | 
			
		||||
  Yap_PutInSlot(h,HeadOfTerm(t) PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(tail,TailOfTerm(t) PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(h,HeadOfTerm(t));
 | 
			
		||||
  Yap_PutInSlot(tail,TailOfTerm(t) );
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -2207,7 +2207,7 @@ PL_recorded_external
 | 
			
		||||
  Term t = Yap_ImportTerm((void *)tp);
 | 
			
		||||
  if (t == 0)
 | 
			
		||||
  return FALSE;
 | 
			
		||||
  Yap_PutInSlot(ts, t PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(ts, t );
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -2234,7 +2234,7 @@ PL_recorded(record_t db, term_t ts)
 | 
			
		||||
  Term t = YAP_Recorded((void *)db);
 | 
			
		||||
  if (t == ((CELL)0))
 | 
			
		||||
  return FALSE;
 | 
			
		||||
  Yap_PutInSlot(ts,t PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(ts,t );
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -2311,7 +2311,7 @@ PL_exception(qid_t q)
 | 
			
		||||
  if (YAP_GoalHasException(&t)) {
 | 
			
		||||
    CACHE_REGS
 | 
			
		||||
    term_t to = Yap_NewSlots(1);
 | 
			
		||||
    Yap_PutInSlot(to,t PASS_REGS);
 | 
			
		||||
    Yap_PutInSlot(to,t );
 | 
			
		||||
    return to;
 | 
			
		||||
  } else {
 | 
			
		||||
    return 0L;
 | 
			
		||||
@@ -2391,7 +2391,7 @@ PL_strip_module(term_t raw, module_t *m, term_t plain)
 | 
			
		||||
  if (!t)
 | 
			
		||||
  return FALSE;
 | 
			
		||||
  *m = Yap_GetModuleEntry(m0);
 | 
			
		||||
  Yap_PutInSlot(plain, t PASS_REGS);
 | 
			
		||||
  Yap_PutInSlot(plain, t );
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -15,11 +15,22 @@
 | 
			
		||||
%%
 | 
			
		||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
:- module( expand_macros,
 | 
			
		||||
           [compile_aux/2,
 | 
			
		||||
            pred_name/4,
 | 
			
		||||
            transformation_id/1,
 | 
			
		||||
            allowed_expansion/1,
 | 
			
		||||
            allowed_module/2] ).
 | 
			
		||||
            
 | 
			
		||||
       
 | 
			
		||||
:- use_module(library(lists), [append/3]).
 | 
			
		||||
:- use_module(library(charsio), [format_to_chars/3, read_from_chars/2]).
 | 
			
		||||
:- use_module(library(error), [must_be/2]).
 | 
			
		||||
:- use_module(library(occurs), [sub_term/2]).
 | 
			
		||||
 | 
			
		||||
:- multifile allowed_module/2.
 | 
			
		||||
 | 
			
		||||
:- dynamic number_of_expansions/1.
 | 
			
		||||
 | 
			
		||||
number_of_expansions(0).
 | 
			
		||||
@@ -32,15 +43,18 @@ number_of_expansions(0).
 | 
			
		||||
 | 
			
		||||
compile_aux([Clause|Clauses], Module) :-
 | 
			
		||||
	% compile the predicat declaration if needed
 | 
			
		||||
	( Clause = (Head :- _)
 | 
			
		||||
	; Clause = Head ),
 | 
			
		||||
	(
 | 
			
		||||
     Clause = (Head :- _)
 | 
			
		||||
	;
 | 
			
		||||
     Clause = Head
 | 
			
		||||
    ),
 | 
			
		||||
	!,
 | 
			
		||||
	functor(Head, F, N),
 | 
			
		||||
	( current_predicate(Module:F/N)
 | 
			
		||||
	->
 | 
			
		||||
	    true
 | 
			
		||||
	;
 | 
			
		||||
%	    format("*** Creating auxiliary predicate ~q~n", [F/N]),
 | 
			
		||||
%	    format'*** Creating auxiliary predicate ~q~n', [F/N]),
 | 
			
		||||
%	    checklist(portray_clause, [Clause|Clauses]),
 | 
			
		||||
	    compile_term([Clause|Clauses], Module)
 | 
			
		||||
	).
 | 
			
		||||
@@ -84,14 +98,16 @@ harmless_dcgexception(instantiation_error).	% ex: phrase(([1],x:X,[3]),L)
 | 
			
		||||
harmless_dcgexception(type_error(callable,_)).	% ex: phrase(27,L)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
'$expand':allowed_expansion(QExpand) :-
 | 
			
		||||
allowed_expansion(QExpand) :-
 | 
			
		||||
    strip_module(QExpand, Mod, Pred),
 | 
			
		||||
    goal_expansion_allowed(Pred, Mod).
 | 
			
		||||
 | 
			
		||||
goal_expansion_allowed(Pred, Mod) :-
 | 
			
		||||
	allowed_module(Pred,Mod),
 | 
			
		||||
	once( prolog_load_context(_, _) ), % make sure we are compiling.
 | 
			
		||||
	\+ current_prolog_flag(xref, true).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
allowed_module(checklist(_,_),expand_macros).
 | 
			
		||||
allowed_module(checklist(_,_),apply_macros).
 | 
			
		||||
@@ -147,5 +163,3 @@ allowed_module(checknodes(_,_),maplist).
 | 
			
		||||
allowed_module(sumnodes(_,_,_,_),expand_macros).
 | 
			
		||||
allowed_module(sumnodes(_,_,_,_),apply_macros).
 | 
			
		||||
allowed_module(sumnodes(_,_,_,_),maplist).
 | 
			
		||||
allowed_module(phrase(_,_),_).
 | 
			
		||||
allowed_module(phrase(_,_,_),_).
 | 
			
		||||
 
 | 
			
		||||
@@ -68,5 +68,3 @@ virtual_alarm(Interval.USecs, Goal, Left.LUSecs) :-
 | 
			
		||||
 | 
			
		||||
fully_strip_module(T,M,S) :-
 | 
			
		||||
    '$hacks':fully_strip_module(T,M,S).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -48,10 +48,6 @@
 | 
			
		||||
	  ]).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
:- use_module(library(error),
 | 
			
		||||
		 [must_be/2]).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/** @defgroup lists List Manipulation
 | 
			
		||||
@ingroup library
 | 
			
		||||
@{
 | 
			
		||||
 
 | 
			
		||||
@@ -156,7 +156,6 @@ triple. See the example above.
 | 
			
		||||
:- use_module(library(maputils)).
 | 
			
		||||
:- use_module(library(lists), [append/3]).
 | 
			
		||||
:- use_module(library(charsio), [format_to_chars/3, read_from_chars/2]).
 | 
			
		||||
:- use_module(library(error), [must_be/2]).
 | 
			
		||||
:- use_module(library(occurs), [sub_term/2]).
 | 
			
		||||
 | 
			
		||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
			
		||||
@@ -1245,4 +1244,3 @@ goal_expansion(sumnodes(Meta, Term, AccIn, AccOut), Mod:Goal) :-
 | 
			
		||||
/**
 | 
			
		||||
@}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -126,7 +126,6 @@ random number generator. The integer `X` must be in the range
 | 
			
		||||
 | 
			
		||||
 */
 | 
			
		||||
:- use_module(library(pairs)).
 | 
			
		||||
:- use_module(library(error)).
 | 
			
		||||
:- use_module(library(lists)).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -219,7 +218,3 @@ setrand(rand(X,Y,Z)) :-
 | 
			
		||||
 | 
			
		||||
getrand(rand(X,Y,Z)) :-
 | 
			
		||||
	getrand(X,Y,Z).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,9 +3,13 @@
 | 
			
		||||
                   run_tests/0,
 | 
			
		||||
                   test_mode/0,
 | 
			
		||||
                   op(1150, fx, test),
 | 
			
		||||
                   op(999, xfx, returns)] ).
 | 
			
		||||
                   op(995, xfx, given),
 | 
			
		||||
                   op(990, xfx, returns)] ).
 | 
			
		||||
 | 
			
		||||
:- use_module( clauses ).
 | 
			
		||||
:- use_module( library(clauses) ).
 | 
			
		||||
:- use_module( library(maplist) ).
 | 
			
		||||
:- use_module( library(gensym) ).
 | 
			
		||||
:- use_module( library(lists) ).
 | 
			
		||||
 | 
			
		||||
:- multifile test/1.
 | 
			
		||||
 | 
			
		||||
@@ -17,21 +21,31 @@ user:term_expansion( test( (A, B) ), ytest:test( Lab, Cond, Done ) ) :-
 | 
			
		||||
    info((A,B), Lab, Cond , Done ).
 | 
			
		||||
 | 
			
		||||
run_tests :-
 | 
			
		||||
    run_test(_Lab),
 | 
			
		||||
    source_module(M),
 | 
			
		||||
    run_test(_Lab,M),
 | 
			
		||||
    fail.
 | 
			
		||||
run_tests :-
 | 
			
		||||
    show_bad.
 | 
			
		||||
 | 
			
		||||
run_test(Lab) :-
 | 
			
		||||
    current_module(M,M),
 | 
			
		||||
run_test(Lab, M) :-
 | 
			
		||||
    test(Lab, (G returns Sols given Program ), Done),
 | 
			
		||||
    ensure_ground( Done),
 | 
			
		||||
    format('~w  :    ',[ Lab ]),
 | 
			
		||||
    reset( Streams ),
 | 
			
		||||
    assertall(Program, Refs),
 | 
			
		||||
    conj2list( Sols, LSols ),
 | 
			
		||||
%    trace,
 | 
			
		||||
    catch( do_returns(M:G, LSols, Lab), Ball,  end( Ball ) ),
 | 
			
		||||
    shutdown( Streams, Refs ).
 | 
			
		||||
run_test(Lab,M) :-
 | 
			
		||||
    test(Lab, (G returns Sols ), Done),
 | 
			
		||||
    ground( Done), 
 | 
			
		||||
    ensure_ground( Done),
 | 
			
		||||
    format('~w  :    ',[ Lab ]),
 | 
			
		||||
    reset( Streams ),
 | 
			
		||||
    conj2list( Sols, LSols ),
 | 
			
		||||
%    trace,
 | 
			
		||||
    catch( do_returns(M:G, LSols, Lab), Ball,  end( Ball ) ),
 | 
			
		||||
    shutdown( Streams ).
 | 
			
		||||
    shutdown( Streams, _ ).
 | 
			
		||||
 | 
			
		||||
info((A,B), Lab, Cl, G) :- !,
 | 
			
		||||
    info(A, Lab, Cl, G),
 | 
			
		||||
@@ -112,9 +126,9 @@ counter( I ) :-
 | 
			
		||||
    nb_getval( counter,( I ) ).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
shutdown( _Streams ) :- 
 | 
			
		||||
shutdown( _Streams, Refs ) :-
 | 
			
		||||
                                %    close_io( Streams ).
 | 
			
		||||
    true.
 | 
			
		||||
    maplist( erase, Refs ).
 | 
			
		||||
 | 
			
		||||
test_error( Ball, e( Ball ) ).
 | 
			
		||||
 | 
			
		||||
@@ -148,3 +162,13 @@ end(done) :-
 | 
			
		||||
end(Ball) :-
 | 
			
		||||
    writeln( bad:Ball ).
 | 
			
		||||
 | 
			
		||||
assertall(Cls, REfs) :-
 | 
			
		||||
    conj2list(Cls, LCls),
 | 
			
		||||
    maplist( assert, LCls, Refs).
 | 
			
		||||
 | 
			
		||||
ensure_ground( g(Lab,Ok)) :-
 | 
			
		||||
        ground(Ok),
 | 
			
		||||
        gensym( tmp_, Lab ).
 | 
			
		||||
ensure_ground( g(Lab,Ok)) :-
 | 
			
		||||
        ground(Ok),
 | 
			
		||||
        ground(Lab).
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,5 @@
 | 
			
		||||
:- [library(hacks)].
 | 
			
		||||
 | 
			
		||||
'$predicate_flags'(P, M, Flags0, Flags1) :-
 | 
			
		||||
    var(Flags0),
 | 
			
		||||
    Flags0 ==  Flags1,
 | 
			
		||||
@@ -55,7 +57,6 @@ user:term_expansion( ( :- '$meta_predicate'( _ ) ), [] ).
 | 
			
		||||
user:goal_expansion(_:'_user_expand_goal'(A, M, B), user:user_expand_goal(A, M, B) ).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                   
 | 
			
		||||
user_expand_goal(A, M, B) :-
 | 
			
		||||
    (
 | 
			
		||||
     current_predicate(M:goal_expansion/2),
 | 
			
		||||
@@ -85,6 +86,4 @@ mt(N,M,A,D) :-
 | 
			
		||||
 | 
			
		||||
:- hide( expand_goal ).
 | 
			
		||||
 | 
			
		||||
:- include('pl/meta').
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
:- include(library(boot/meta)).
 | 
			
		||||
 
 | 
			
		||||
@@ -25,6 +25,7 @@ A	ArrayAccess		F	"$array_arg"
 | 
			
		||||
A	ArrayOverflow		N	"array_overflow"
 | 
			
		||||
A	ArrayType		N	"array_type"
 | 
			
		||||
A	Arrow			N	"->"
 | 
			
		||||
A   AttributedModule    N   "attributes_module"
 | 
			
		||||
A	DoubleArrow		N	"-->"
 | 
			
		||||
A	Assert			N	":-"
 | 
			
		||||
A	EmptyBrackets		N	"()"
 | 
			
		||||
@@ -514,6 +515,7 @@ F	PermissionError		PermissionError	3
 | 
			
		||||
F	Plus			Plus		2
 | 
			
		||||
F	Portray			Portray		1
 | 
			
		||||
F	PrintMessage		PrintMessage	2
 | 
			
		||||
F   Procedure       Procedure       5
 | 
			
		||||
F	PrologConstraint	Prolog		2
 | 
			
		||||
F	Query			Query		1
 | 
			
		||||
F	RecordedWithKey		RecordedWithKey	6
 | 
			
		||||
@@ -545,4 +547,3 @@ F	UMinus			Minus		1
 | 
			
		||||
F	UPlus			Plus		1
 | 
			
		||||
F	VBar			VBar		2
 | 
			
		||||
F	HiddenVar		HiddenVar	1
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										358
									
								
								misc/HEAPFIELDS
									
									
									
									
									
								
							
							
						
						
									
										358
									
								
								misc/HEAPFIELDS
									
									
									
									
									
								
							@@ -25,193 +25,195 @@
 | 
			
		||||
// Restore... sets up call to RestoreFunc
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
START_HEAP
 | 
			
		||||
 | 
			
		||||
/* memory management */
 | 
			
		||||
UInt		hole_size		Yap_HoleSize		void void
 | 
			
		||||
struct malloc_state *av_		Yap_av			void void
 | 
			
		||||
UInt		Yap_HoleSize		void    void
 | 
			
		||||
struct malloc_state *Yap_av			void void
 | 
			
		||||
#if USE_DL_MALLOC
 | 
			
		||||
struct memory_hole memory_holes[MAX_DLMALLOC_HOLES] Yap_MemoryHoles void void
 | 
			
		||||
UInt		nof_memory_holes	Yap_NOfMemoryHoles	void void
 | 
			
		||||
struct Yap_MemoryHoles[MAX_DLMALLOC_HOLES]  void void
 | 
			
		||||
UInt		Yap_NOfMemoryHoles	void void
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
lockvar         dlmalloc_lock		DLMallocLock		MkLock
 | 
			
		||||
lockvar         DLMallocLock		MkLock
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
 | 
			
		||||
#ifndef  HeapUsed
 | 
			
		||||
#define  HeapUsed  Yap_givemallinfo()
 | 
			
		||||
#endif
 | 
			
		||||
Int		heap_used		NotHeapUsed		void void
 | 
			
		||||
Int		NotHeapUsed		void void
 | 
			
		||||
#else
 | 
			
		||||
Int		heap_used		HeapUsed		void void
 | 
			
		||||
Int		HeapUsed		void void
 | 
			
		||||
#endif
 | 
			
		||||
Int		heap_max		HeapMax			void void
 | 
			
		||||
ADDR		heap_top		HeapTop			void void
 | 
			
		||||
ADDR		heap_lim		HeapLim			void void
 | 
			
		||||
struct FREEB    *free_blocks		FreeBlocks		void void
 | 
			
		||||
Int		HeapMax			void void
 | 
			
		||||
ADDR		HeapTop			void void
 | 
			
		||||
ADDR		HeapLim			void void
 | 
			
		||||
struct FREEB    *FreeBlocks		void void
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
lockvar		free_blocks_lock	FreeBlocksLock		MkLock
 | 
			
		||||
lockvar		heap_used_lock		HeapUsedLock		MkLock
 | 
			
		||||
lockvar		heap_top_lock		HeapTopLock		MkLock
 | 
			
		||||
int		heap_top_owner		HeapTopOwner		=-1 void
 | 
			
		||||
lockvar		FreeBlocksLock		MkLock
 | 
			
		||||
lockvar		HeapUsedLock		MkLock
 | 
			
		||||
lockvar		HeapTopLock		MkLock
 | 
			
		||||
int		HeapTopOwner		=-1 void
 | 
			
		||||
#endif
 | 
			
		||||
UInt		MaxStack_		MaxStack		=0 void
 | 
			
		||||
UInt		MaxTrail_		MaxTrail		=0 void
 | 
			
		||||
UInt		MaxStack		=0 void
 | 
			
		||||
UInt		MaxTrail		=0 void
 | 
			
		||||
 | 
			
		||||
/* execution info */
 | 
			
		||||
/* OPCODE REVERSE TABLE, needed to recover op tables */
 | 
			
		||||
#if USE_THREADED_CODE
 | 
			
		||||
op_entry	*op_rtable		OP_RTABLE		void	OpRTableAdjust
 | 
			
		||||
op_entry	*OP_RTABLE		void	OpRTableAdjust
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* popular opcodes */
 | 
			
		||||
OPCODE		execute_cpred_op_code	EXECUTE_CPRED_OP_CODE	MkOp _execute_cpred
 | 
			
		||||
OPCODE		expand_op_code		EXPAND_OP_CODE		MkOp _expand_index
 | 
			
		||||
OPCODE		fail_op			FAIL_OPCODE		MkOp _op_fail
 | 
			
		||||
OPCODE		index_op		INDEX_OPCODE		MkOp _index_pred
 | 
			
		||||
OPCODE		lockpred_op		LOCKPRED_OPCODE		MkOp _lock_pred
 | 
			
		||||
OPCODE		orlast_op		ORLAST_OPCODE		MkOp _or_last
 | 
			
		||||
OPCODE		undef_op		UNDEF_OPCODE		MkOp _undef_p
 | 
			
		||||
OPCODE		retry_userc_op		RETRY_USERC_OPCODE	MkOp _retry_userc
 | 
			
		||||
OPCODE		execute_cpred_op	EXECUTE_CPRED_OPCODE	MkOp _execute_cpred
 | 
			
		||||
OPCODE		EXECUTE_CPRED_OP_CODE	MkOp _execute_cpred
 | 
			
		||||
OPCODE		EXPAND_OP_CODE		MkOp _expand_index
 | 
			
		||||
OPCODE		FAIL_OPCODE		MkOp _op_fail
 | 
			
		||||
OPCODE		INDEX_OPCODE		MkOp _index_pred
 | 
			
		||||
OPCODE		LOCKPRED_OPCODE		MkOp _lock_pred
 | 
			
		||||
OPCODE		ORLAST_OPCODE		MkOp _or_last
 | 
			
		||||
OPCODE		UNDEF_OPCODE		MkOp _undef_p
 | 
			
		||||
OPCODE		RETRY_USERC_OPCODE	MkOp _retry_userc
 | 
			
		||||
OPCODE		EXECUTE_CPRED_OPCODE	MkOp _execute_cpred
 | 
			
		||||
 | 
			
		||||
/* atom tables */
 | 
			
		||||
UInt		n_of_atoms		NOfAtoms		void void
 | 
			
		||||
UInt		atom_hash_table_size	AtomHashTableSize	void void
 | 
			
		||||
UInt		wide_atom_hash_table_size WideAtomHashTableSize void void
 | 
			
		||||
UInt		n_of_wide_atoms		NOfWideAtoms		void void
 | 
			
		||||
AtomHashEntry	invisiblechain		INVISIBLECHAIN		InitInvisibleAtoms() RestoreInvisibleAtoms()
 | 
			
		||||
AtomHashEntry	*wide_hash_chain	WideHashChain		InitWideAtoms()  RestoreWideAtoms()
 | 
			
		||||
AtomHashEntry	*hash_chain		HashChain		InitAtoms() RestoreAtoms()
 | 
			
		||||
UInt		NOfAtoms		void void
 | 
			
		||||
UInt		AtomHashTableSize	void void
 | 
			
		||||
UInt		WideAtomHashTableSize void void
 | 
			
		||||
UInt		NOfWideAtoms		void void
 | 
			
		||||
AtomHashEntry	INVISIBLECHAIN		InitInvisibleAtoms() RestoreInvisibleAtoms()
 | 
			
		||||
AtomHashEntry	*WideHashChain		InitWideAtoms()  RestoreWideAtoms()
 | 
			
		||||
AtomHashEntry	*HashChain		InitAtoms() RestoreAtoms()
 | 
			
		||||
 | 
			
		||||
/* use atom defs here */
 | 
			
		||||
ATOMS
 | 
			
		||||
 | 
			
		||||
#ifdef EUROTRA
 | 
			
		||||
Term		term_dollar_u		TermDollarU		MkAT AtomDollarU
 | 
			
		||||
Term		TermDollarU		MkAT AtomDollarU
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
//modules
 | 
			
		||||
Term		user_module		USER_MODULE		MkAT AtomUser
 | 
			
		||||
Term		idb_module		IDB_MODULE		MkAT AtomIDB
 | 
			
		||||
Term		attributes_module	ATTRIBUTES_MODULE	MkAT AtomAttributes
 | 
			
		||||
Term		charsio_module		CHARSIO_MODULE		MkAT AtomCharsio
 | 
			
		||||
Term		chtype_module		CHTYPE_MODULE		MkAT AtomChType
 | 
			
		||||
Term		terms_module		TERMS_MODULE		MkAT AtomTerms
 | 
			
		||||
Term		system_module		SYSTEM_MODULE		MkAT AtomSystem
 | 
			
		||||
Term		readutil_module		READUTIL_MODULE		MkAT AtomReadutil
 | 
			
		||||
Term		hacks_module		HACKS_MODULE		MkAT AtomYapHacks
 | 
			
		||||
Term		arg_module		ARG_MODULE		MkAT AtomArg
 | 
			
		||||
Term		globals_module		GLOBALS_MODULE		MkAT AtomNb
 | 
			
		||||
Term		swi_module		SWI_MODULE		MkAT AtomSwi
 | 
			
		||||
Term		dbload_module		DBLOAD_MODULE		MkAT AtomDBLoad
 | 
			
		||||
Term		range_module		RANGE_MODULE		MkAT AtomRange
 | 
			
		||||
Term		error_module		ERROR_MODULE		MkAT AtomError
 | 
			
		||||
Term		USER_MODULE		MkAT AtomUser
 | 
			
		||||
Term		IDB_MODULE		MkAT AtomIDB
 | 
			
		||||
Term		ATTRIBUTES_MODULE	MkAT AtomAttributes
 | 
			
		||||
Term		CHARSIO_MODULE		MkAT AtomCharsio
 | 
			
		||||
Term		CHTYPE_MODULE		MkAT AtomChType
 | 
			
		||||
Term		TERMS_MODULE		MkAT AtomTerms
 | 
			
		||||
Term		SYSTEM_MODULE		MkAT AtomSystem
 | 
			
		||||
Term		READUTIL_MODULE		MkAT AtomReadutil
 | 
			
		||||
Term		HACKS_MODULE		MkAT AtomYapHacks
 | 
			
		||||
Term		ARG_MODULE		MkAT AtomArg
 | 
			
		||||
Term		GLOBALS_MODULE		MkAT AtomNb
 | 
			
		||||
Term		SWI_MODULE		MkAT AtomSwi
 | 
			
		||||
Term		DBLOAD_MODULE		MkAT AtomDBLoad
 | 
			
		||||
Term		RANGE_MODULE		MkAT AtomRange
 | 
			
		||||
Term		ERROR_MODULE		MkAT AtomError
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// Module list
 | 
			
		||||
//
 | 
			
		||||
struct mod_entry *current_modules	CurrentModules		=NULL	ModEntryPtrAdjust
 | 
			
		||||
struct mod_entry *CurrentModules		=NULL	ModEntryPtrAdjust
 | 
			
		||||
// make sure we have the modules set at this point.
 | 
			
		||||
// don't actually want to define a field
 | 
			
		||||
void		void			void			Yap_InitModules()  void
 | 
			
		||||
void		void			Yap_InitModules()  void
 | 
			
		||||
 | 
			
		||||
// hidden predicates
 | 
			
		||||
Prop		hidden_predicates	HIDDEN_PREDICATES	=NULL RestoreHiddenPredicates()
 | 
			
		||||
Prop		HIDDEN_PREDICATES	=NULL RestoreHiddenPredicates()
 | 
			
		||||
 | 
			
		||||
// make sure we have the streams  set at this point.
 | 
			
		||||
// don't actually want to define a field
 | 
			
		||||
void		void			void			Yap_InitPlIO()  void
 | 
			
		||||
void		void			Yap_InitPlIO()  void
 | 
			
		||||
 | 
			
		||||
union flagTerm*	GLOBAL_Flags_		GLOBAL_Flags		=0 void
 | 
			
		||||
UInt	  	GLOBAL_flagCount_	GLOBAL_flagCount	Yap_InitFlags(true)  RestoreFlags(GLOBAL_flagCount)
 | 
			
		||||
union flagTerm*	GLOBAL_Flags		=0 void
 | 
			
		||||
UInt	  	GLOBAL_flagCount	Yap_InitFlags(true)  RestoreFlags(GLOBAL_flagCount)
 | 
			
		||||
 | 
			
		||||
/* Anderson's JIT */
 | 
			
		||||
yap_exec_mode	execution_mode		Yap_ExecutionMode	=INTERPRETED void
 | 
			
		||||
yap_exec_mode	Yap_ExecutionMode	=INTERPRETED void
 | 
			
		||||
 | 
			
		||||
/*  The Predicate Hash Table: fast access to predicates. */
 | 
			
		||||
struct pred_entry **pred_hash		PredHash		InitPredHash() RestorePredHash()
 | 
			
		||||
struct pred_entry **PredHash		InitPredHash() RestorePredHash()
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
rwlock_t	pred_hash_rw_lock	PredHashRWLock		void
 | 
			
		||||
rwlock_t	PredHashRWLock		void
 | 
			
		||||
#endif
 | 
			
		||||
UInt		preds_in_hash_table	PredsInHashTable	=0 void
 | 
			
		||||
UInt		pred_hash_table_size	PredHashTableSize	void
 | 
			
		||||
UInt		PredsInHashTable	=0 void
 | 
			
		||||
uint64_t	PredHashTableSize	=0 void
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Well-Known Predicates */
 | 
			
		||||
struct pred_entry *creep_code		CreepCode		MkPred AtomCreep 1 PROLOG_MODULE
 | 
			
		||||
struct pred_entry *undef_code		UndefCode		MkPred AtomUndefp 2 PROLOG_MODULE
 | 
			
		||||
struct pred_entry *spy_code		SpyCode			MkPred AtomSpy 1 PROLOG_MODULE
 | 
			
		||||
struct pred_entry *pred_fail		PredFail		MkPred AtomFail 0 PROLOG_MODULE
 | 
			
		||||
struct pred_entry *pred_true		PredTrue		MkPred AtomTrue 0 PROLOG_MODULE
 | 
			
		||||
struct pred_entry *CreepCode		MkPred AtomCreep 1 PROLOG_MODULE
 | 
			
		||||
struct pred_entry *UndefCode		MkPred AtomUndefp 2 PROLOG_MODULE
 | 
			
		||||
struct pred_entry *SpyCode			MkPred AtomSpy 1 PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredFail		MkPred AtomFail 0 PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredTrue		MkPred AtomTrue 0 PROLOG_MODULE
 | 
			
		||||
#ifdef COROUTINING
 | 
			
		||||
struct pred_entry  *wake_up_code	WakeUpCode		MkPred AtomWakeUpGoal 2 PROLOG_MODULE
 | 
			
		||||
struct pred_entry  *WakeUpCode		MkPred AtomWakeUpGoal 2 PROLOG_MODULE
 | 
			
		||||
#endif
 | 
			
		||||
struct pred_entry *pred_goal_expansion	PredGoalExpansion	MkPred FunctorGoalExpansion USER_MODULE
 | 
			
		||||
struct pred_entry *pred_meta_call	PredMetaCall		MkPred FunctorMetaCall PROLOG_MODULE
 | 
			
		||||
struct pred_entry *pred_trace_meta_call	PredTraceMetaCall	MkPred FunctorTraceMetaCall PROLOG_MODULE
 | 
			
		||||
struct pred_entry *pred_dollar_catch	PredDollarCatch         MkPred FunctorCatch PROLOG_MODULE
 | 
			
		||||
struct pred_entry *pred_recorded_with_key PredRecordedWithKey	MkPred FunctorRecordedWithKey PROLOG_MODULE
 | 
			
		||||
struct pred_entry *pred_log_upd_clause	PredLogUpdClause	MkPred FunctorDoLogUpdClause PROLOG_MODULE
 | 
			
		||||
struct pred_entry *pred_log_upd_clause_erase PredLogUpdClauseErase MkPred FunctorDoLogUpdClauseErase PROLOG_MODULE
 | 
			
		||||
struct pred_entry *pred_log_upd_clause0	PredLogUpdClause0	MkPred FunctorDoLogUpdClause PROLOG_MODULE
 | 
			
		||||
struct pred_entry *pred_static_clause	PredStaticClause	MkPred FunctorDoStaticClause PROLOG_MODULE
 | 
			
		||||
struct pred_entry *pred_throw		PredThrow		MkPred FunctorThrow PROLOG_MODULE
 | 
			
		||||
struct pred_entry *pred_handle_throw	PredHandleThrow		MkPred FunctorHandleThrow PROLOG_MODULE
 | 
			
		||||
struct pred_entry *pred_is		PredIs			MkPred FunctorIs PROLOG_MODULE
 | 
			
		||||
struct pred_entry *pred_safe_call_cleanup PredSafeCallCleanup	MkPred FunctorSafeCallCleanup PROLOG_MODULE
 | 
			
		||||
struct pred_entry *pred_restore_regs	PredRestoreRegs		MkPred FunctorRestoreRegs PROLOG_MODULE
 | 
			
		||||
struct pred_entry *pred_comment_hook	PredCommentHook		MkPred FunctorCommentHook PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredGoalExpansion	MkPred FunctorGoalExpansion USER_MODULE
 | 
			
		||||
struct pred_entry *PredMetaCall		MkPred FunctorMetaCall PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredTraceMetaCall	MkPred FunctorTraceMetaCall PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredDollarCatch         MkPred FunctorCatch PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredRecordedWithKey	MkPred FunctorRecordedWithKey PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredLogUpdClause	MkPred FunctorDoLogUpdClause PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredLogUpdClauseErase MkPred FunctorDoLogUpdClauseErase PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredLogUpdClause0	MkPred FunctorDoLogUpdClause PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredStaticClause	MkPred FunctorDoStaticClause PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredThrow		MkPred FunctorThrow PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredHandleThrow		MkPred FunctorHandleThrow PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredIs			MkPred FunctorIs PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredSafeCallCleanup	MkPred FunctorSafeCallCleanup PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredRestoreRegs		MkPred FunctorRestoreRegs PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredCommentHook		MkPred FunctorCommentHook PROLOG_MODULE
 | 
			
		||||
#ifdef YAPOR
 | 
			
		||||
struct pred_entry *pred_getwork		PredGetwork		MkPred AtomGetwork 0 PROLOG_MODULE
 | 
			
		||||
struct pred_entry *pred_getwork_seq	PredGetworkSeq		MkPred AtomGetworkSeq 0 PROLOG_MODULE
 | 
			
		||||
struct pred_entry *PredGetwork		MkPred AtomGetwork 0 PROLOG_MODULE
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
struct pred_entry *PredProcedure		MkLogPred FunctorProcedure   PROLOG_MODULE
 | 
			
		||||
 | 
			
		||||
/* low-level tracer */
 | 
			
		||||
#ifdef LOW_LEVEL_TRACER
 | 
			
		||||
int		yap_do_low_level_trace	Yap_do_low_level_trace	=FALSE void
 | 
			
		||||
int		Yap_do_low_level_trace	=FALSE void
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
lockvar		low_level_trace_lock	Yap_low_level_trace_lock MkLock
 | 
			
		||||
lockvar		Yap_low_level_trace_lock MkLock
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* code management info */
 | 
			
		||||
UInt		clause_space		Yap_ClauseSpace		=0 void
 | 
			
		||||
UInt		index_space_Tree	Yap_IndexSpace_Tree	=0 void
 | 
			
		||||
UInt		index_space_EXT		Yap_IndexSpace_EXT	=0 void
 | 
			
		||||
UInt		index_space_SW		Yap_IndexSpace_SW	=0 void
 | 
			
		||||
UInt		lu_clause_space		Yap_LUClauseSpace	=0 void
 | 
			
		||||
UInt		lu_index_space_Tree	Yap_LUIndexSpace_Tree	=0 void
 | 
			
		||||
UInt		lu_index_space_CP	Yap_LUIndexSpace_CP	=0 void
 | 
			
		||||
UInt		lu_index_space_EXT	Yap_LUIndexSpace_EXT	=0 void
 | 
			
		||||
UInt		lu_index_space_SW	Yap_LUIndexSpace_SW	=0 void
 | 
			
		||||
UInt		Yap_ClauseSpace		=0 void
 | 
			
		||||
UInt		Yap_IndexSpace_Tree	=0 void
 | 
			
		||||
UInt		Yap_IndexSpace_EXT	=0 void
 | 
			
		||||
UInt		Yap_IndexSpace_SW	=0 void
 | 
			
		||||
UInt		Yap_LUClauseSpace	=0 void
 | 
			
		||||
UInt		Yap_LUIndexSpace_Tree	=0 void
 | 
			
		||||
UInt		Yap_LUIndexSpace_CP	=0 void
 | 
			
		||||
UInt		Yap_LUIndexSpace_EXT	=0 void
 | 
			
		||||
UInt		Yap_LUIndexSpace_SW	=0 void
 | 
			
		||||
 | 
			
		||||
/* static code: may be shared by many predicate or may be used for meta-execution */
 | 
			
		||||
yamop		comma_code[5]		COMMA_CODE		void void
 | 
			
		||||
yamop		dummycode[1]		DUMMYCODE		MkInstE _op_fail
 | 
			
		||||
yamop		failcode[1]		FAILCODE		MkInstE _op_fail
 | 
			
		||||
yamop		nocode[1]		NOCODE			MkInstE _Nstop
 | 
			
		||||
yamop		COMMA_CODE[5]		void void
 | 
			
		||||
yamop		DUMMYCODE[1]		MkInstE _op_fail
 | 
			
		||||
yamop		FAILCODE[1]		MkInstE _op_fail
 | 
			
		||||
yamop		NOCODE[1]			MkInstE _Nstop
 | 
			
		||||
 | 
			
		||||
yamop		env_for_trustfail[2]	ENV_FOR_TRUSTFAIL	InitEnvInst(ENV_FOR_TRUSTFAIL,&TRUSTFAILCODE,_trust_fail,PredFail) RestoreEnvInst(ENV_FOR_TRUSTFAIL,&TRUSTFAILCODE,_trust_fail,PredFail)
 | 
			
		||||
yamop		*trustfailcode		TRUSTFAILCODE		void
 | 
			
		||||
yamop		env_for_yescode[2]	ENV_FOR_YESCODE		InitEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail) RestoreEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail)
 | 
			
		||||
yamop		*yescode		YESCODE			void
 | 
			
		||||
yamop	ENV_FOR_TRUSTFAIL[2]	InitEnvInst(ENV_FOR_TRUSTFAIL,&TRUSTFAILCODE,_trust_fail,PredFail) RestoreEnvInst(ENV_FOR_TRUSTFAIL,&TRUSTFAILCODE,_trust_fail,PredFail)
 | 
			
		||||
yamop		*TRUSTFAILCODE		void
 | 
			
		||||
yamop	ENV_FOR_YESCODE[2]		InitEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail) RestoreEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail)
 | 
			
		||||
yamop		*YESCODE			void
 | 
			
		||||
 | 
			
		||||
  yamop		rtrycode[1]		RTRYCODE		InitOtaplInst(RTRYCODE,_retry_and_mark,PredFail) RestoreOtaplInst(RTRYCODE,_retry_and_mark,PredFail)
 | 
			
		||||
yamop		RTRYCODE[1]		InitOtaplInst(RTRYCODE,_retry_and_mark,PredFail) RestoreOtaplInst(RTRYCODE,_retry_and_mark,PredFail)
 | 
			
		||||
 | 
			
		||||
#ifdef BEAM
 | 
			
		||||
yamop		beam_retry_code[1]	BEAM_RETRY_CODE		MkInstE _beam_retry_code
 | 
			
		||||
yamop	BEAM_RETRY_CODE[1]		MkInstE _beam_retry_code
 | 
			
		||||
#endif /* BEAM */
 | 
			
		||||
#ifdef YAPOR
 | 
			
		||||
yamop		getwork_code[1]		GETWORK			InitOtaplInst(GETWORK,_getwork,PredGetwork) RestoreOtaplInst(GETWORK,_getwork,PredGetwork)
 | 
			
		||||
yamop		getwork_seq_code[1]	GETWORK_SEQ		InitOtaplInst(GETWORK_SEQ,_getwork_seq,PredGetworkSeq) RestoreOtaplInst(GETWORK_SEQ,_getwork_seq,PredGetworkSeq)
 | 
			
		||||
yamop		getwork_first_time[1]	GETWORK_FIRST_TIME	MkInstE _getwork_first_time
 | 
			
		||||
yamop		GETWORK[1]			InitOtaplInst(GETWORK,_getwork,PredGetwork) RestoreOtaplInst(GETWORK,_getwork,PredGetwork)
 | 
			
		||||
yamop		GETWORK_SEQ[1]   	InitOtaplInst(GETWORK_SEQ,_getwork_seq,PredGetworkSeq) RestoreOtaplInst(GETWORK_SEQ,_getwork_seq,PredGetworkSeq)
 | 
			
		||||
yamop	    GETWORK_FIRST_TIME[1]	MkInstE _getwork_first_time
 | 
			
		||||
#endif /* YAPOR */
 | 
			
		||||
#ifdef TABLING
 | 
			
		||||
yamop		table_load_answer_code[1] LOAD_ANSWER		InitOtaplInst(LOAD_ANSWER,_table_load_answer,PredFail) RestoreOtaplInst(LOAD_ANSWER,_table_load_answer,PredFail)
 | 
			
		||||
yamop		table_try_answer_code[1] TRY_ANSWER		InitOtaplInst(TRY_ANSWER,_table_try_answer,PredFail) RestoreOtaplInst(TRY_ANSWER,_table_try_answer,PredFail)
 | 
			
		||||
yamop		table_answer_resolution_code[1]	ANSWER_RESOLUTION InitOtaplInst(ANSWER_RESOLUTION,_table_answer_resolution,PredFail) RestoreOtaplInst(ANSWER_RESOLUTION,_table_answer_resolution,PredFail)
 | 
			
		||||
yamop		table_completion_code[1]	COMPLETION	InitOtaplInst(COMPLETION,_table_completion,PredFail) RestoreOtaplInst(COMPLETION,_table_completion,PredFail)
 | 
			
		||||
yamop		 LOAD_ANSWER[1]		InitOtaplInst(LOAD_ANSWER,_table_load_answer,PredFail) RestoreOtaplInst(LOAD_ANSWER,_table_load_answer,PredFail)
 | 
			
		||||
yamop		TRY_ANSWER[1] 		InitOtaplInst(TRY_ANSWER,_table_try_answer,PredFail) RestoreOtaplInst(TRY_ANSWER,_table_try_answer,PredFail)
 | 
			
		||||
yamop		ANSWER_RESOLUTION[1]	 InitOtaplInst(ANSWER_RESOLUTION,_table_answer_resolution,PredFail) RestoreOtaplInst(ANSWER_RESOLUTION,_table_answer_resolution,PredFail)
 | 
			
		||||
yamop		COMPLETION[1]	InitOtaplInst(COMPLETION,_table_completion,PredFail) RestoreOtaplInst(COMPLETION,_table_completion,PredFail)
 | 
			
		||||
#ifdef THREADS_CONSUMER_SHARING
 | 
			
		||||
yamop           table_answer_resolution_completion_code[1]      ANSWER_RESOLUTION_COMPLETION InitOtaplInst(ANSWER_RESOLUTION_COMPLETION,_table_answer_resolution_completion,PredFail) RestoreOtaplInst(ANSWER_RESOLUTION_COMPLETION,_table_answer_resolution_completion,PredFail)
 | 
			
		||||
yamop       ANSWER_RESOLUTION_COMPLETION[1] InitOtaplInst(ANSWER_RESOLUTION_COMPLETION,_table_answer_resolution_completion,PredFail) RestoreOtaplInst(ANSWER_RESOLUTION_COMPLETION,_table_answer_resolution_completion,PredFail)
 | 
			
		||||
#endif /* THREADS_CONSUMER_SHARING */
 | 
			
		||||
#endif /* TABLING */
 | 
			
		||||
 | 
			
		||||
@@ -219,123 +221,125 @@ yamop           table_answer_resolution_completion_code[1]      ANSWER_RESOLUTIO
 | 
			
		||||
/*    PREG just before we enter $spy. We use that to find out the clause which  */
 | 
			
		||||
/*    was calling the debugged goal.  */
 | 
			
		||||
/*  */
 | 
			
		||||
yamop		*debugger_p_before_spy	P_before_spy		=NULL PtoOpAdjust
 | 
			
		||||
yamop		*P_before_spy		=NULL PtoOpAdjust
 | 
			
		||||
 | 
			
		||||
/* support recorded_k  */
 | 
			
		||||
yamop		*retry_recordedp_code	RETRY_C_RECORDEDP_CODE	=NULL PtoOpAdjust
 | 
			
		||||
yamop		*retry_recorded_k_code	RETRY_C_RECORDED_K_CODE =NULL PtoOpAdjust
 | 
			
		||||
 | 
			
		||||
yamop		*RETRY_C_RECORDEDP_CODE	=NULL PtoOpAdjust
 | 
			
		||||
yamop		*RETRY_C_RECORDED_K_CODE =NULL PtoOpAdjust
 | 
			
		||||
R
 | 
			
		||||
/* compiler flags */
 | 
			
		||||
int		system_profiling	PROFILING		=FALSE void
 | 
			
		||||
int		system_call_counting	CALL_COUNTING		=FALSE void
 | 
			
		||||
int		compiler_optimizer_on	optimizer_on		=TRUE void
 | 
			
		||||
int		compiler_compile_mode	compile_mode		=0 void
 | 
			
		||||
int		compiler_profiling	profiling		=FALSE void
 | 
			
		||||
int		compiler_call_counting	call_counting		=FALSE void
 | 
			
		||||
int		PROFILING		=FALSE void
 | 
			
		||||
int		CALL_COUNTING		=FALSE void
 | 
			
		||||
int		optimizer_on		=TRUE void
 | 
			
		||||
int		compile_mode		=0 void
 | 
			
		||||
int		profiling		=FALSE void
 | 
			
		||||
int		call_counting		=FALSE void
 | 
			
		||||
/********* whether we should try to compile array references ******************/
 | 
			
		||||
int		compiler_compile_arrays	compile_arrays		=FALSE void
 | 
			
		||||
int		compile_arrays		=FALSE void
 | 
			
		||||
 | 
			
		||||
/* DBTerms: pre-compiled ground terms */
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
lockvar		dbterms_list_lock	DBTermsListLock		MkLock
 | 
			
		||||
lockvar		DBTermsListLock		MkLock
 | 
			
		||||
#endif
 | 
			
		||||
struct dbterm_list *dbterms_list	DBTermsList		=NULL RestoreDBTermsList()
 | 
			
		||||
struct dbterm_list *DBTermsList		=NULL RestoreDBTermsList()
 | 
			
		||||
 | 
			
		||||
/* JITI support */
 | 
			
		||||
yamop		*expand_clauses_first	ExpandClausesFirst	=NULL void
 | 
			
		||||
yamop		*expand_clauses_last	ExpandClausesLast	=NULL RestoreExpandList()
 | 
			
		||||
UInt		expand_clauses		Yap_ExpandClauses	=0 void
 | 
			
		||||
yamop		*ExpandClausesFirst	=NULL void
 | 
			
		||||
yamop		*ExpandClausesLast	=NULL RestoreExpandList()
 | 
			
		||||
UInt		Yap_ExpandClauses	=0 void
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
lockvar		expand_clauses_list_lock ExpandClausesListLock	MkLock
 | 
			
		||||
lockvar		op_list_lock		OpListLock		MkLock
 | 
			
		||||
lockvar		ExpandClausesListLock	MkLock
 | 
			
		||||
lockvar		OpListLock		MkLock
 | 
			
		||||
#endif
 | 
			
		||||
/* instrumentation */
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
UInt		new_cps			Yap_NewCps		=0L void
 | 
			
		||||
UInt		live_cps		Yap_LiveCps		=0L void
 | 
			
		||||
UInt		dirty_cps		Yap_DirtyCps		=0L void
 | 
			
		||||
UInt		freed_cps		Yap_FreedCps		=0L void
 | 
			
		||||
UInt		Yap_NewCps		=0L void
 | 
			
		||||
UInt		Yap_LiveCps		=0L void
 | 
			
		||||
UInt		Yap_DirtyCps		=0L void
 | 
			
		||||
UInt		Yap_FreedCps		=0L void
 | 
			
		||||
#endif
 | 
			
		||||
UInt		expand_clauses_sz	Yap_expand_clauses_sz	=0L void
 | 
			
		||||
UInt		Yap_expand_clauses_sz	=0L void
 | 
			
		||||
 | 
			
		||||
/* UDI support */
 | 
			
		||||
struct udi_info *udi_control_blocks	UdiControlBlocks	=NULL RestoreUdiControlBlocks()
 | 
			
		||||
struct udi_info *UdiControlBlocks	=NULL RestoreUdiControlBlocks()
 | 
			
		||||
 | 
			
		||||
/* data-base statistics */
 | 
			
		||||
/* system boots in compile mode */
 | 
			
		||||
Int		static_predicates_marked STATIC_PREDICATES_MARKED   =FALSE void
 | 
			
		||||
Int		STATIC_PREDICATES_MARKED   =FALSE void
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Internal Database */
 | 
			
		||||
Prop		*IntKeys		INT_KEYS		=NULL RestoreIntKeys()
 | 
			
		||||
Prop		*IntLUKeys		INT_LU_KEYS		=NULL RestoreIntLUKeys()
 | 
			
		||||
Prop		*IntBBKeys		INT_BB_KEYS		=NULL RestoreIntBBKeys()
 | 
			
		||||
Prop		*INT_KEYS		=NULL RestoreIntKeys()
 | 
			
		||||
Prop		*INT_LU_KEYS		=NULL RestoreIntLUKeys()
 | 
			
		||||
Prop		*INT_BB_KEYS		=NULL RestoreIntBBKeys()
 | 
			
		||||
 | 
			
		||||
/* Internal Database Statistics */
 | 
			
		||||
UInt		int_keys_size		INT_KEYS_SIZE		=INT_KEYS_DEFAULT_SIZE void
 | 
			
		||||
UInt		int_keys_timestamp	INT_KEYS_TIMESTAMP	=0L void
 | 
			
		||||
UInt		int_bb_keys_size	INT_BB_KEYS_SIZE	=INT_KEYS_DEFAULT_SIZE void
 | 
			
		||||
UInt		INT_KEYS_SIZE		=INT_KEYS_DEFAULT_SIZE void
 | 
			
		||||
UInt		INT_KEYS_TIMESTAMP	=0L void
 | 
			
		||||
UInt		INT_BB_KEYS_SIZE	=INT_KEYS_DEFAULT_SIZE void
 | 
			
		||||
 | 
			
		||||
/* Internal Data-Base Control */
 | 
			
		||||
int		update_mode		UPDATE_MODE	        =UPDATE_MODE_LOGICAL void
 | 
			
		||||
int		UPDATE_MODE	        =UPDATE_MODE_LOGICAL void
 | 
			
		||||
 | 
			
		||||
/* nasty IDB stuff */
 | 
			
		||||
struct DB_STRUCT *db_erased_marker	DBErasedMarker		InitDBErasedMarker() RestoreDBErasedMarker()
 | 
			
		||||
struct logic_upd_clause *logdb_erased_marker LogDBErasedMarker	InitLogDBErasedMarker() RestoreLogDBErasedMarker()
 | 
			
		||||
struct DB_STRUCT *DBErasedMarker		InitDBErasedMarker() RestoreDBErasedMarker()
 | 
			
		||||
struct logic_upd_clause *LogDBErasedMarker	InitLogDBErasedMarker() RestoreLogDBErasedMarker()
 | 
			
		||||
 | 
			
		||||
/* Dead clauses and IDB entries */
 | 
			
		||||
struct static_clause *dead_static_clauses DeadStaticClauses	=NULL RestoreDeadStaticClauses()
 | 
			
		||||
struct static_mega_clause *dead_mega_clauses DeadMegaClauses	=NULL RestoreDeadMegaClauses()
 | 
			
		||||
struct static_index *dead_static_indices DeadStaticIndices	=NULL RestoreDeadStaticIndices()
 | 
			
		||||
struct logic_upd_clause *db_erased_list	DBErasedList		=NULL RestoreDBErasedList()
 | 
			
		||||
struct logic_upd_index *db_erased_ilist DBErasedIList		=NULL RestoreDBErasedIList()
 | 
			
		||||
struct static_clause *DeadStaticClauses	=NULL RestoreDeadStaticClauses()
 | 
			
		||||
struct static_mega_clause *DeadMegaClauses	=NULL RestoreDeadMegaClauses()
 | 
			
		||||
struct static_index *DeadStaticIndices	=NULL RestoreDeadStaticIndices()
 | 
			
		||||
struct logic_upd_clause *DBErasedList		=NULL RestoreDBErasedList()
 | 
			
		||||
struct logic_upd_index *DBErasedIList		=NULL RestoreDBErasedIList()
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
lockvar  dead_static_clauses_lock	DeadStaticClausesLock	MkLock
 | 
			
		||||
lockvar  dead_mega_clauses_lock		DeadMegaClausesLock	MkLock
 | 
			
		||||
lockvar  dead_static_indices_lock	DeadStaticIndicesLock	MkLock
 | 
			
		||||
lockvar  DeadStaticClausesLock	MkLock
 | 
			
		||||
lockvar  DeadMegaClausesLock	MkLock
 | 
			
		||||
lockvar  DeadStaticIndicesLock	MkLock
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef COROUTINING
 | 
			
		||||
/* number of attribute modules */
 | 
			
		||||
int		num_of_atts		NUM_OF_ATTS		=1	void
 | 
			
		||||
int		NUM_OF_ATTS		=1	void
 | 
			
		||||
/* initialised by memory allocator */
 | 
			
		||||
UInt		atts_size		Yap_AttsSize		void void
 | 
			
		||||
UInt		Yap_AttsSize		void void
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Operators */
 | 
			
		||||
struct operator_entry	*op_list	OpList			=NULL OpListAdjust
 | 
			
		||||
struct operator_entry	*OpList			=NULL OpListAdjust
 | 
			
		||||
 | 
			
		||||
/* foreign code loaded */
 | 
			
		||||
struct ForeignLoadItem 	*foreign_code_loaded	ForeignCodeLoaded	=NULL RestoreForeignCode()
 | 
			
		||||
ADDR		foreign_code_base	ForeignCodeBase		=NULL void
 | 
			
		||||
ADDR		foreign_code_top	ForeignCodeTop		=NULL void
 | 
			
		||||
ADDR		foreign_code_max	ForeignCodeMax		=NULL void
 | 
			
		||||
struct ForeignLoadItem 	*ForeignCodeLoaded	=NULL RestoreForeignCode()
 | 
			
		||||
ADDR		ForeignCodeBase		=NULL void
 | 
			
		||||
ADDR		ForeignCodeTop		=NULL void
 | 
			
		||||
ADDR		ForeignCodeMax		=NULL void
 | 
			
		||||
 | 
			
		||||
/* recorded terms */
 | 
			
		||||
struct record_list *yap_records		Yap_Records		=NULL		RestoreYapRecords()
 | 
			
		||||
struct record_list *Yap_Records		=NULL		RestoreYapRecords()
 | 
			
		||||
 | 
			
		||||
/* SWI atoms and functors */
 | 
			
		||||
Atom		*swi_atoms	SWI_Atoms		InitSWIAtoms() RestoreSWIAtoms()
 | 
			
		||||
Functor		*swi_functors   SWI_Functors	void void
 | 
			
		||||
Atom		*SWI_Atoms		InitSWIAtoms() RestoreSWIAtoms()
 | 
			
		||||
Functor		*SWI_Functors	void void
 | 
			
		||||
 | 
			
		||||
struct swi_reverse_hash	swi_reverse_hash[N_SWI_HASH] SWI_ReverseHash	void void
 | 
			
		||||
swi_rev_hash     SWI_ReverseHash[N_SWI_HASH]	void void
 | 
			
		||||
 | 
			
		||||
/* integer access to atoms */
 | 
			
		||||
Int            atom_translations	AtomTranslations	void  void
 | 
			
		||||
Int            max_atom_translations	MaxAtomTranslations	void  void
 | 
			
		||||
Int            AtomTranslations	void  void
 | 
			
		||||
Int            MaxAtomTranslations	void  void
 | 
			
		||||
 | 
			
		||||
/* integer access to functors */
 | 
			
		||||
Int            functor_translations	FunctorTranslations	void  void
 | 
			
		||||
Int            max_functor_translations	MaxFunctorTranslations	void  void
 | 
			
		||||
Int            FunctorTranslations	void  void
 | 
			
		||||
Int            MaxFunctorTranslations	void  void
 | 
			
		||||
 | 
			
		||||
Atom		empty_wakeups[MAX_EMPTY_WAKEUPS]	EmptyWakeups		InitEmptyWakeups() RestoreEmptyWakeups()
 | 
			
		||||
int		max_empty_wakeups	MaxEmptyWakeups		=0
 | 
			
		||||
Atom	EmptyWakeups[MAX_EMPTY_WAKEUPS]		InitEmptyWakeups() RestoreEmptyWakeups()
 | 
			
		||||
int		MaxEmptyWakeups		=0
 | 
			
		||||
 | 
			
		||||
/* SWI blobs */
 | 
			
		||||
struct YAP_blob_t		*swi_blob_types		BlobTypes		=NULL		RestoreBlobTypes()
 | 
			
		||||
struct AtomEntryStruct	*swi_blobs	Blobs		=NULL		RestoreBlobs()
 | 
			
		||||
UInt   			nofblobs	NOfBlobs		=0
 | 
			
		||||
UInt   			nofblobsmax	NOfBlobsMax		=256
 | 
			
		||||
struct YAP_blob_t		*BlobTypes		=NULL		RestoreBlobTypes()
 | 
			
		||||
struct AtomEntryStruct	*Blobs		=NULL		RestoreBlobs()
 | 
			
		||||
UInt   			NOfBlobs		=0
 | 
			
		||||
UInt   			NOfBlobsMax		=256
 | 
			
		||||
#if defined(YAPOR) || defined(THREADS)
 | 
			
		||||
lockvar         blobs_lock		Blobs_Lock		MkLock
 | 
			
		||||
lockvar         Blobs_Lock		MkLock
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
END_HEAP
 | 
			
		||||
 
 | 
			
		||||
@@ -33,8 +33,6 @@ main :-
 | 
			
		||||
 | 
			
		||||
warning('~n  /* This file, ~a, was generated automatically by \"yap -L misc/buildheap\"~n     please do not update, update misc/~a instead */~n~n').
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* define the field */
 | 
			
		||||
gen_struct(Inp,"") :-
 | 
			
		||||
	Inp = [0'/,0'/|_], !.
 | 
			
		||||
@@ -50,6 +48,12 @@ gen_struct(Inp,Out) :-
 | 
			
		||||
gen_struct(Inp,Out) :-
 | 
			
		||||
	Inp = "END_WORKER_LOCAL", !,
 | 
			
		||||
	Out = "} w_local;".
 | 
			
		||||
gen_struct(Inp,Out) :-
 | 
			
		||||
	Inp = "START_HEAP", !,
 | 
			
		||||
	Out = "typedef struct worker_local {".
 | 
			
		||||
gen_struct(Inp,Out) :-
 | 
			
		||||
	Inp = "END_HEAP", !,
 | 
			
		||||
	Out = "} w_local;".
 | 
			
		||||
gen_struct(Inp,Out) :-
 | 
			
		||||
	Inp = "START_GLOBAL_DATA", !,
 | 
			
		||||
	Out = "typedef struct global_data {".
 | 
			
		||||
@@ -146,7 +150,7 @@ cut_c_stuff(Name, RName) :-
 | 
			
		||||
 | 
			
		||||
cut_mat([], []).
 | 
			
		||||
cut_mat([0'[|_], []) :- !. %'
 | 
			
		||||
cut_mat(H.Name, H.RName) :- 
 | 
			
		||||
cut_mat([H|Name], [H|RName]) :-
 | 
			
		||||
	cut_mat(Name, RName).
 | 
			
		||||
 | 
			
		||||
gen_hstruct(Inp,"") :-
 | 
			
		||||
@@ -257,6 +261,14 @@ gen_init(Inp,Out) :-
 | 
			
		||||
	Inp = "END_GLOBAL_DATA", !,
 | 
			
		||||
	Out = "}",
 | 
			
		||||
	retract(globals(all)).
 | 
			
		||||
gen_init(Inp,Out) :-
 | 
			
		||||
	Inp = "START_HEAP", !,
 | 
			
		||||
	Out = "static void InitGlobal(void) {",
 | 
			
		||||
	assert(globals(heap)).
 | 
			
		||||
gen_init(Inp,Out) :-
 | 
			
		||||
	Inp = "END_HEAP", !,
 | 
			
		||||
	Out = "}",
 | 
			
		||||
	retract(globals(heap)).
 | 
			
		||||
gen_init(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",["struct"|Inp2]), !,
 | 
			
		||||
	glue(Inp2, " ", Inp3),
 | 
			
		||||
@@ -306,20 +318,20 @@ gen_init(Inp,Out) :-
 | 
			
		||||
	fetch_name(Global,RField,MacroName),
 | 
			
		||||
	append(["  ",Global,"->opc = Yap_opcode(",OP,");"], Out).
 | 
			
		||||
gen_init(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[_, Field, MacroName, "MkPred", Atom, "0", Module]), !,
 | 
			
		||||
	split(Inp,"	 ",[_, Field, MacroName, "MkLogPred", Atom, "0", Module]), !,
 | 
			
		||||
	cut_c_stuff(Field, RField),
 | 
			
		||||
	fetch_name(Global,RField,MacroName),
 | 
			
		||||
	append(["  ",Global," = RepPredProp(PredPropByAtom(",Atom,",",Module,"));"], Out).
 | 
			
		||||
	append(["  ",Global," = Yap_MkLogPred(RepPredProp(PredPropByAtom(",Atom,",",Module,")));"], Out).
 | 
			
		||||
gen_init(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[_, Field, MacroName, "MkPred", Atom, Arity, Module]), !,
 | 
			
		||||
	split(Inp,"	 ",[_, Field, MacroName, "MkLogPred", Atom, Arity, Module]), !,
 | 
			
		||||
	cut_c_stuff(Field, RField),
 | 
			
		||||
	fetch_name(Global,RField,MacroName),
 | 
			
		||||
	append(["  ",Global," = RepPredProp(PredPropByFunc(Yap_MkFunctor(",Atom,",",Arity,"),",Module,"));"], Out).
 | 
			
		||||
	append(["  ",Global," = Yap_MkLogPred(RepPredProp(PredPropByFunc(Yap_MkFunctor(",Atom,",",Arity,"),",Module,")));"], Out).
 | 
			
		||||
gen_init(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[_, Field, MacroName, "MkPred", Fun, Module]), !,
 | 
			
		||||
	split(Inp,"	 ",[_, Field, MacroName, "MkLogPred", Fun, Module]), !,
 | 
			
		||||
	cut_c_stuff(Field, RField),
 | 
			
		||||
	fetch_name(Global,RField,MacroName),
 | 
			
		||||
	append(["  ",Global," = RepPredProp(PredPropByFunc(",Fun,",",Module,"));"], Out).
 | 
			
		||||
	append(["  ",Global," = Yap_MkLogPred(RepPredProp(PredPropByFunc(",Fun,",",Module,")));"], Out).
 | 
			
		||||
gen_init(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[_, Field, MacroName, F0|_]),
 | 
			
		||||
	append("=",F,F0), !,
 | 
			
		||||
@@ -329,4 +341,3 @@ gen_init(Inp,Out) :-
 | 
			
		||||
gen_init(Inp,_) :-
 | 
			
		||||
	split(Inp,"	 ",[_, _, _| _]),
 | 
			
		||||
	format(user_error,"OOPS: could not gen_init for ~s~n",[Inp]).
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -21,27 +21,29 @@ file_filter_with_initialization(A,B,C,D,E) :-
 | 
			
		||||
 | 
			
		||||
main :-
 | 
			
		||||
	warning(Warning),
 | 
			
		||||
	%file_filter_with_initialization('misc/HEAPFIELDS','H/hstruct.h',gen_struct,Warning,['hstruct.h','HEAPFIELDS']),
 | 
			
		||||
	%file_filter_with_initialization('misc/HEAPFIELDS','H/dhstruct.h',gen_dstruct,Warning,['dhstruct.h','HEAPFIELDS']),
 | 
			
		||||
	%file_filter_with_initialization('misc/HEAPFIELDS','H/rhstruct.h',gen_hstruct,Warning,['rhstruct.h','HEAPFIELDS']),
 | 
			
		||||
	%file_filter_with_initialization('misc/HEAPFIELDS','H/ihstruct.h',gen_init,Warning,['ihstruct.h','HEAPFIELDS']),
 | 
			
		||||
	file_filter_with_initialization('misc/GLOBALS','H/hglobals.h',gen_struct,Warning,['hglobals.h','GLOBALS']),
 | 
			
		||||
	file_filter_with_initialization('misc/GLOBALS','H/dglobals.h',gen_dstruct,Warning,['dglobals.h','GLOBALS']),
 | 
			
		||||
	file_filter_with_initialization('misc/GLOBALS','H/rglobals.h',gen_hstruct,Warning,['rglobals.h','GLOBALS']),
 | 
			
		||||
	file_filter_with_initialization('misc/GLOBALS','H/iglobals.h',gen_init,Warning,['iglobals.h','GLOBALS']),
 | 
			
		||||
	file_filter_with_initialization('misc/LOCALS','H/hlocals.h',gen_struct,Warning,['hlocals.h','LOCALS']),
 | 
			
		||||
	file_filter_with_initialization('misc/LOCALS','H/dlocals.h',gen_dstruct,Warning,['dlocals.h','LOCALS']),
 | 
			
		||||
	file_filter_with_initialization('misc/LOCALS','H/rlocals.h',gen_hstruct,Warning,['rlocals.h','LOCALS']),
 | 
			
		||||
	file_filter_with_initialization('misc/LOCALS','H/ilocals.h',gen_init,Warning,['ilocals.h','LOCALS']).
 | 
			
		||||
	file_filter_with_initialization('misc/HEAPFIELDS','H/heap/hstruct.h',gen_struct,Warning,['hstruct.h','HEAPFIELDS']),
 | 
			
		||||
	file_filter_with_initialization('misc/HEAPFIELDS','H/heap/dhstruct.h',gen_dstruct,Warning,['dhstruct.h','HEAPFIELDS']),
 | 
			
		||||
	file_filter_with_initialization('misc/HEAPFIELDS','H/heap/h0struct.h',gen_0struct,Warning,['d0hstruct.h','HEAPFIELDS']),
 | 
			
		||||
	file_filter_with_initialization('misc/HEAPFIELDS','H/heap/rhstruct.h',gen_hstruct,Warning,['rhstruct.h','HEAPFIELDS']),
 | 
			
		||||
	file_filter_with_initialization('misc/HEAPFIELDS','H/heap/ihstruct.h',gen_init,Warning,['ihstruct.h','HEAPFIELDS']),
 | 
			
		||||
	file_filter_with_initialization('misc/GLOBALS','H/heap/h0globals.h',gen_0struct,Warning,['hglobals.h','GLOBALS']),
 | 
			
		||||
	file_filter_with_initialization('misc/GLOBALS','H/heap/hglobals.h',gen_struct,Warning,['hglobals.h','GLOBALS']),
 | 
			
		||||
	file_filter_with_initialization('misc/GLOBALS','H/heap/dglobals.h',gen_dstruct,Warning,['dglobals.h','GLOBALS']),
 | 
			
		||||
	file_filter_with_initialization('misc/GLOBALS','H/heap/iglobals.h',gen_init,Warning,['iglobals.h','GLOBALS']),
 | 
			
		||||
	file_filter_with_initialization('misc/GLOBALS','H/heap/i0globals.h',gen_0init,Warning,['iglobals.h','GLOBALS']),
 | 
			
		||||
	file_filter_with_initialization('misc/LOCALS','H/heap/hlocals.h',gen_struct,Warning,['hlocals.h','LOCALS']),
 | 
			
		||||
	file_filter_with_initialization('misc/LOCALS','H/heap/dlocals.h',gen_dstruct,Warning,['dlocals.h','LOCALS']),
 | 
			
		||||
	file_filter_with_initialization('misc/LOCALS','H/heap/rlocals.h',gen_hstruct,Warning,['rlocals.h','LOCALS']),
 | 
			
		||||
	file_filter_with_initialization('misc/LOCALS','H/heap/ilocals.h',gen_init,Warning,['ilocals.h','LOCALS']).
 | 
			
		||||
 | 
			
		||||
warning('~n  /* This file, ~a, was generated automatically by \"yap -L misc/buildlocalglobal\"~n     please do not update, update misc/~a instead */~n~n').
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* define the field */
 | 
			
		||||
gen_struct(Inp,"") :-
 | 
			
		||||
gen_struct(Inp,Inp) :-
 | 
			
		||||
	Inp = [0'/,0'/|_], !.
 | 
			
		||||
gen_struct(Inp,"") :-
 | 
			
		||||
gen_struct(Inp,Inp) :-
 | 
			
		||||
	Inp = [0'/,0'*|_], !.
 | 
			
		||||
gen_struct(Inp, Out) :-
 | 
			
		||||
	Inp = [0'#|_], !, Out = Inp. % '
 | 
			
		||||
@@ -59,6 +61,12 @@ gen_struct(Inp,Out) :-
 | 
			
		||||
gen_struct(Inp,Out) :-
 | 
			
		||||
	Inp = "END_GLOBAL_DATA", !,
 | 
			
		||||
	Out = "} w_shared;".
 | 
			
		||||
gen_struct(Inp,Out) :-
 | 
			
		||||
	Inp = "START_HEAP", !,
 | 
			
		||||
	Out = "".
 | 
			
		||||
gen_struct(Inp,Out) :-
 | 
			
		||||
	Inp = "END_HEAP", !,
 | 
			
		||||
	Out = "".
 | 
			
		||||
gen_struct(Inp,Out) :-
 | 
			
		||||
	Inp = "ATOMS", !,
 | 
			
		||||
	Out = "#include \"tatoms.h\"".
 | 
			
		||||
@@ -84,6 +92,67 @@ gen_struct(Inp,_) :-
 | 
			
		||||
	split(Inp,"	 ",[_, _, _| _]),
 | 
			
		||||
	format(user_error,"OOPS: could not gen_struct for ~s~n",[Inp]).
 | 
			
		||||
 | 
			
		||||
/* define the field */
 | 
			
		||||
gen_0struct(Inp,Inp) :-
 | 
			
		||||
	Inp = [0'/,0'/|_], !.
 | 
			
		||||
gen_0struct(Inp,Inp) :-
 | 
			
		||||
	Inp = [0'/,0'*|_], !.
 | 
			
		||||
gen_0struct(Inp, Out) :-
 | 
			
		||||
	Inp = [0'#|_], !, Out = Inp. % '
 | 
			
		||||
gen_0struct(Inp,"") :-
 | 
			
		||||
	Inp = [0'.|_], !. %'
 | 
			
		||||
gen_0struct(Inp,Out) :-
 | 
			
		||||
	Inp = "START_GLOBAL_DATA", !,
 | 
			
		||||
	Out = "",
 | 
			
		||||
    assert(globals(all)).
 | 
			
		||||
gen_0struct(Inp,Out) :-
 | 
			
		||||
	Inp = "END_GLOBAL_DATA", !,
 | 
			
		||||
	Out = "",
 | 
			
		||||
    retract(globals(all)).
 | 
			
		||||
gen_0struct(Inp,Out) :-
 | 
			
		||||
	Inp = "START_HEAP", !,
 | 
			
		||||
	Out = "",
 | 
			
		||||
    assert(globals(heap)).
 | 
			
		||||
gen_0struct(Inp,Out) :-
 | 
			
		||||
	Inp = "END_HEAP", !,
 | 
			
		||||
	Out = "",
 | 
			
		||||
    retract(globals(heap)).
 | 
			
		||||
gen_0struct(Inp,Out) :-
 | 
			
		||||
	Inp = "ATOMS", !,
 | 
			
		||||
	Out = "#include \"tatoms.h\"".
 | 
			
		||||
gen_0struct(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",["struct",Type, Field|L]), !,
 | 
			
		||||
    extract("struct", Inp, NInp),
 | 
			
		||||
    gen_0struct( NInp, NOut ),
 | 
			
		||||
    extract("EXTERNAL", NOut, IOut),
 | 
			
		||||
	append("EXTERNAL    struct ", IOut, Out).
 | 
			
		||||
gen_0struct(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",["const",Type, Field|L]), !,
 | 
			
		||||
    extract("const", Inp, NInp),
 | 
			
		||||
    gen_0struct( NInp, NOut ),
 | 
			
		||||
    extract("EXTERNAL", NOut, IOut),
 | 
			
		||||
	append("EXTERNAL    const ", IOut, Out).
 | 
			
		||||
gen_0struct(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",["union",Type, Field|L]), !,
 | 
			
		||||
    extract("union", Inp, NInp),
 | 
			
		||||
    gen_0struct( NInp, NOut ),
 | 
			
		||||
    extract("EXTERNAL", NOut, IOut),
 | 
			
		||||
	append("EXTERNAL    union ", IOut, Out).
 | 
			
		||||
gen_0struct(Inp,"") :-
 | 
			
		||||
	split(Inp,"	 ",["void","void"|_]), !.
 | 
			
		||||
gen_0struct(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[Type, Field|_]),
 | 
			
		||||
	split(Field,"[",[RField,VECField]), !,
 | 
			
		||||
    fetch_name(Name, RField),
 | 
			
		||||
	append(["EXTERNAL  ",Type,"  ",Name,"[",VECField,";"], Out).
 | 
			
		||||
gen_0struct(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[Type, Field|_]), !,
 | 
			
		||||
    fetch_name(Name, Field),
 | 
			
		||||
	append(["EXTERNAL  ",Type,"  ",Name,";"], Out).
 | 
			
		||||
gen_0struct(Inp,_) :-
 | 
			
		||||
	split(Inp,"	 ",[_, _, _| _]),
 | 
			
		||||
	format(user_error,"OOPS: could not gen_0struct for ~s~n",[Inp]).
 | 
			
		||||
 | 
			
		||||
gen_dstruct(Inp,"") :-
 | 
			
		||||
	Inp = [0'/,0'/|_], !.
 | 
			
		||||
gen_dstruct(Inp,"") :-
 | 
			
		||||
@@ -102,6 +171,12 @@ gen_dstruct(Inp,"") :-
 | 
			
		||||
gen_dstruct(Inp,"") :-
 | 
			
		||||
	Inp = "END_GLOBAL_DATA", !,
 | 
			
		||||
	retract(globals(all)).
 | 
			
		||||
gen_dstruct(Inp,"") :-
 | 
			
		||||
	Inp = "START_HEAP", !,
 | 
			
		||||
	assert(globals(heap)).
 | 
			
		||||
gen_dstruct(Inp,"") :-
 | 
			
		||||
	Inp = "END_HEAP", !,
 | 
			
		||||
	retract(globals(heap)).
 | 
			
		||||
gen_dstruct(Inp,Out) :-
 | 
			
		||||
	Inp = "ATOMS", !,
 | 
			
		||||
	Out = "".
 | 
			
		||||
@@ -138,6 +213,9 @@ fetch_name(Global,Global2,RField," ") :-
 | 
			
		||||
	globals(all), !,
 | 
			
		||||
	append(["GLOBAL_", RField],Global),
 | 
			
		||||
	append(["Yap_global->", RField,"_"],Global2).
 | 
			
		||||
fetch_name(RField,Global2,RField," ") :-
 | 
			
		||||
	globals(heap), !,
 | 
			
		||||
	append(["Yap_heap_regs->", RField,"_"],Global2).
 | 
			
		||||
fetch_name(Global,Global2,RField," ") :-
 | 
			
		||||
	globals(worker),
 | 
			
		||||
	append(["LOCAL_", RField],Global),
 | 
			
		||||
@@ -161,6 +239,8 @@ fetch_name(Global, RField) :-
 | 
			
		||||
fetch_name(Global, RField) :-
 | 
			
		||||
	globals(all), !,
 | 
			
		||||
	append(["GLOBAL_", RField],Global).
 | 
			
		||||
fetch_name(RField, RField) :-
 | 
			
		||||
	globals(heap), !.
 | 
			
		||||
 | 
			
		||||
                                % handle *field[4]
 | 
			
		||||
cut_c_stuff([0'*|Name], RName) :- !, % 'cut *
 | 
			
		||||
@@ -198,6 +278,14 @@ gen_hstruct(Inp,Out) :-
 | 
			
		||||
    Inp = "END_GLOBAL_DATA", !,
 | 
			
		||||
    Out = "}",
 | 
			
		||||
    retract(globals(all)).
 | 
			
		||||
gen_hstruct(Inp,Out) :-
 | 
			
		||||
    Inp = "START_HEAP", !,
 | 
			
		||||
    Out = "",
 | 
			
		||||
    assert(globals(heap)).
 | 
			
		||||
gen_hstruct(Inp,Out) :-
 | 
			
		||||
    Inp = "END_HEAP", !,
 | 
			
		||||
    Out = "",
 | 
			
		||||
    retract(globals(heap)).
 | 
			
		||||
gen_hstruct(Inp, Out) :-
 | 
			
		||||
	Inp = [0'#|_], !, Out = Inp. % '
 | 
			
		||||
gen_hstruct(Inp,Out) :-
 | 
			
		||||
@@ -213,18 +301,28 @@ gen_hstruct(Inp,Out) :-
 | 
			
		||||
	glue(Inp2, " ", Inp3),
 | 
			
		||||
	gen_hstruct(Inp3,Out).
 | 
			
		||||
gen_hstruct(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[_, Field, "MkAT", _]), !,
 | 
			
		||||
	split(Inp,"	 ",[_, Field, "MkAT", _]),
 | 
			
		||||
    globals(heap),
 | 
			
		||||
    !,
 | 
			
		||||
	fetch_name(Global,Field),
 | 
			
		||||
	append(["  ",Global,Field," = AtomTermAdjust(Yap_heap_regs->",Field,");"], Out).
 | 
			
		||||
	append(["  ",Global," = AtomTermAdjust(",Global,");"], Out).
 | 
			
		||||
gen_hstruct(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[_, Field, "MkPred"| _]), !,
 | 
			
		||||
    globals(heap),
 | 
			
		||||
	split(Inp,"	 ",[_, Field, "MkPred"| _]),
 | 
			
		||||
    !,
 | 
			
		||||
	cut_c_stuff(Field, RField),
 | 
			
		||||
	fetch_name(Global,RField),
 | 
			
		||||
	append(["  ",Global,RField," = PtoPredAdjust(Yap_heap_regs->",RField,");"], Out).
 | 
			
		||||
	append(["  ",Global," = PtoPredAdjust(",Global,");"], Out).
 | 
			
		||||
gen_hstruct(Inp,Out) :-
 | 
			
		||||
    globals(heap),
 | 
			
		||||
	split(Inp,"	 ",[_, Field, "MkLogPred"| _]), !,
 | 
			
		||||
	cut_c_stuff(Field, RField),
 | 
			
		||||
	fetch_name(Global,RField),
 | 
			
		||||
	append(["  ",Global," = PtoPredAdjust(",Global,");"], Out).
 | 
			
		||||
gen_hstruct(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[_, Field, "MkOp", Name]), !,
 | 
			
		||||
	fetch_name(Global,Field),
 | 
			
		||||
	append(["  ",Global,Field," = Yap_opcode(",Name,");"], Out).
 | 
			
		||||
	append(["  ",Global," = Yap_opcode(",Name,");"], Out).
 | 
			
		||||
gen_hstruct(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[_, Field, "MkLock"]), !,
 | 
			
		||||
	fetch_name(Global,Field),
 | 
			
		||||
@@ -232,12 +330,12 @@ gen_hstruct(Inp,Out) :-
 | 
			
		||||
gen_hstruct(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[_, Field,"MkRWLock"]), !,
 | 
			
		||||
	fetch_name(Global,Field),
 | 
			
		||||
	append(["  REINIT_RWLOCK(",Global,Field,");"], Out).
 | 
			
		||||
	append(["  REINIT_RWLOCK(",Global,");"], Out).
 | 
			
		||||
gen_hstruct(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[_, Field,"MkInstE",OP]), !,
 | 
			
		||||
	cut_c_stuff(Field, RField),
 | 
			
		||||
	fetch_name(Global,RField),
 | 
			
		||||
	append(["  ",Global,RField,"->opc = Yap_opcode(",OP,");"], Out).
 | 
			
		||||
	append(["  ",Global,"->opc = Yap_opcode(",OP,");"], Out).
 | 
			
		||||
gen_hstruct(Inp,"") :-
 | 
			
		||||
	split(Inp,"	 ",[_, _, _]), !.
 | 
			
		||||
gen_hstruct(Inp,"") :-
 | 
			
		||||
@@ -246,6 +344,10 @@ gen_hstruct(Inp,Restore) :-
 | 
			
		||||
	split(Inp,"	 ",[_, _, _, Restore0]),
 | 
			
		||||
	append("Restore",_,Restore0), !,
 | 
			
		||||
	append(["  ",Restore0,";"],Restore). %'
 | 
			
		||||
gen_hstruct(Inp,Restore) :-
 | 
			
		||||
	split(Inp,"	 ",[_, _, _, Restore0]),
 | 
			
		||||
	append("Restore",_,Restore0), !,
 | 
			
		||||
	append(["  ",Restore0,";"],Restore). %'
 | 
			
		||||
gen_hstruct(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[_, Field, _, Adjust]),
 | 
			
		||||
	append(Adjust,"Adjust",_), !,
 | 
			
		||||
@@ -281,6 +383,14 @@ gen_init(Inp,Out) :-
 | 
			
		||||
    Inp = "END_GLOBAL_DATA", !,
 | 
			
		||||
    Out = "}",
 | 
			
		||||
    retract(globals(all)).
 | 
			
		||||
gen_init(Inp,Out) :-
 | 
			
		||||
    Inp = "START_HEAP", !,
 | 
			
		||||
    Out = "",
 | 
			
		||||
    assert(globals(heap)).
 | 
			
		||||
gen_init(Inp,Out) :-
 | 
			
		||||
    Inp = "END_HEAP", !,
 | 
			
		||||
    Out = "",
 | 
			
		||||
    retract(globals(heap)).
 | 
			
		||||
gen_init(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",["struct"|Inp2]), !,
 | 
			
		||||
	glue(Inp2, " ", Inp3),
 | 
			
		||||
@@ -342,6 +452,21 @@ gen_init(Inp,Out) :-
 | 
			
		||||
	cut_c_stuff(Field, RField),
 | 
			
		||||
	fetch_name(Global,RField),
 | 
			
		||||
	append(["  ",Global," = RepPredProp(PredPropByFunc(",Fun,",",Module,"));"], Out).
 | 
			
		||||
gen_init(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[_, Field, "MkLogPred", Atom, "0", Module]), !,
 | 
			
		||||
	cut_c_stuff(Field, RField),
 | 
			
		||||
	fetch_name(Global,RField),
 | 
			
		||||
	append(["  ",Global," = Yap_MkLogPred(RepPredProp(PredPropByAtom(",Atom,",",Module,")));"], Out).
 | 
			
		||||
gen_init(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[_, Field, "MkLogPred", Atom, Arity, Module]), !,
 | 
			
		||||
	cut_c_stuff(Field, RField),
 | 
			
		||||
	fetch_name(Global,RField),
 | 
			
		||||
	append(["  ",Global," = Yap_MkLogPred(RepPredProp(PredPropByFunc(Yap_MkFunctor(",Atom,",",Arity,"),",Module,")));"], Out).
 | 
			
		||||
gen_init(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[_, Field, "MkLogPred", Fun, Module]), !,
 | 
			
		||||
	cut_c_stuff(Field, RField),
 | 
			
		||||
	fetch_name(Global,RField),
 | 
			
		||||
	append(["  ",Global," = Yap_MkLogPred(RepPredProp(PredPropByFunc(",Fun,",",Module,")));"], Out).
 | 
			
		||||
gen_init(Inp,Out) :-
 | 
			
		||||
	split(Inp,"	 ",[".", Field,F0|_]), !,
 | 
			
		||||
	cut_c_stuff(Field, RField),
 | 
			
		||||
@@ -359,3 +484,18 @@ gen_init(Inp,_) :-
 | 
			
		||||
	split(Inp,"	 ",[_, _, _| _]),
 | 
			
		||||
	format(user_error,"OOPS: could not gen_init for ~s~n",[Inp]).
 | 
			
		||||
 | 
			
		||||
extract(X, Y, F) :-
 | 
			
		||||
    append(X, R, Y),
 | 
			
		||||
    !,
 | 
			
		||||
    extract(R, F).
 | 
			
		||||
 | 
			
		||||
extract([0' |H], IF) :- !,
 | 
			
		||||
    extract( H, IF).
 | 
			
		||||
extract([0'\t |H], IF) :- !,
 | 
			
		||||
    extract( H, IF).
 | 
			
		||||
extract(H,H).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -69,6 +69,7 @@
 | 
			
		||||
;;                            ; see `prolog-system' below for possible values
 | 
			
		||||
;; (setq auto-mode-alist (append '(("\\.pl$" . prolog-mode)
 | 
			
		||||
;;                                 ("\\.yap$" . prolog-mode)
 | 
			
		||||
;;                                 ("\\.ypp$" . prolog-mode)
 | 
			
		||||
;;                                 ("\\.prolog$" . prolog-mode)
 | 
			
		||||
;;                                 ("\\.m$" . mercury-mode))
 | 
			
		||||
;;                                auto-mode-alist))
 | 
			
		||||
@@ -447,9 +448,10 @@ Legal values:
 | 
			
		||||
      "meta_predicate" "module" "module_transparent" "multifile" "require"
 | 
			
		||||
      "use_module" "volatile"))
 | 
			
		||||
   (yap
 | 
			
		||||
     ("discontiguous" "dynamic" "ensure_loaded" "export" "export_list" "import"
 | 
			
		||||
    ("block" "char_conversion" "discontiguous" "dynamic" "encoding"
 | 
			
		||||
    "ensure_loaded" "export" "expects_dialect" "export_list" "import"
 | 
			
		||||
      "meta_predicate" "module" "module_transparent" "multifile" "require"
 | 
			
		||||
      "table" "use_module" "volatile"))
 | 
			
		||||
      "table" "thread_local" "use_module" "wait"))
 | 
			
		||||
    (gnu
 | 
			
		||||
     ("built_in" "char_conversion" "discontiguous" "dynamic" "ensure_linked"
 | 
			
		||||
      "ensure_loaded" "foreign" "include" "initialization" "multifile" "op"
 | 
			
		||||
@@ -650,6 +652,7 @@ nil means send actual operating system end of file."
 | 
			
		||||
  '((eclipse "^[a-zA-Z0-9()]* *\\?- \\|^\\[[a-zA-Z]* [0-9]*\\]:")
 | 
			
		||||
    (sicstus "| [ ?][- ] *")
 | 
			
		||||
    (swi "^\\(\\[[a-zA-Z]*\\] \\)?[1-9]?[0-9]*[ ]?\\?- \\|^| +")
 | 
			
		||||
    (yap "^\\(\\[[a-zA-Z]*\\] \\)?[1-9]?[0-9]*[ ]?\\?- \\|^| +")
 | 
			
		||||
    (t "^ *\\?-"))
 | 
			
		||||
  "*Alist of prompts of the prolog system command line."
 | 
			
		||||
  :group 'prolog-inferior
 | 
			
		||||
@@ -657,6 +660,7 @@ nil means send actual operating system end of file."
 | 
			
		||||
 | 
			
		||||
(defcustom prolog-continued-prompt-regexp
 | 
			
		||||
  '((sicstus "^\\(| +\\|     +\\)")
 | 
			
		||||
    (yap` "^\\(| +\\|     +\\)")
 | 
			
		||||
    (t "^|: +"))
 | 
			
		||||
  "*Alist of regexps matching the prompt when consulting `user'."
 | 
			
		||||
  :group 'prolog-inferior
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										831
									
								
								misc/sysgraph
									
									
									
									
									
								
							
							
						
						
									
										831
									
								
								misc/sysgraph
									
									
									
									
									
								
							@@ -1,831 +0,0 @@
 | 
			
		||||
#!/usr/local/bin/yap -L -- $*
 | 
			
		||||
#.
 | 
			
		||||
 | 
			
		||||
:- style_check(all).
 | 
			
		||||
 | 
			
		||||
:- yap_flag( write_strings, on).
 | 
			
		||||
:- yap_flag( gc_trace, verbose ).
 | 
			
		||||
 | 
			
		||||
:- use_module(library(readutil)).
 | 
			
		||||
:- use_module(library(lineutils)).
 | 
			
		||||
:- use_module(library(lists)).
 | 
			
		||||
:- use_module(library(maplist)).
 | 
			
		||||
:- use_module(library(system)).
 | 
			
		||||
 | 
			
		||||
:- use_module(library(analysis/graphs)).
 | 
			
		||||
:- use_module(library(analysis/load)).
 | 
			
		||||
 | 
			
		||||
:- initialization(main).
 | 
			
		||||
 | 
			
		||||
:- style_check(all).
 | 
			
		||||
 | 
			
		||||
:- yap_flag( double_quotes, string ).
 | 
			
		||||
%:- yap_flag( dollar_as_lower_case, on ).
 | 
			
		||||
 | 
			
		||||
:- dynamic
 | 
			
		||||
    node/4,
 | 
			
		||||
    edge/1,
 | 
			
		||||
    public/2,
 | 
			
		||||
    private/2,
 | 
			
		||||
    module_on/3,
 | 
			
		||||
    exported/1,
 | 
			
		||||
    dir/2,
 | 
			
		||||
    consulted/2,
 | 
			
		||||
    op_export/3,
 | 
			
		||||
    library/1,
 | 
			
		||||
    undef/2,
 | 
			
		||||
    c_dep/2,
 | 
			
		||||
    do_comment/5,
 | 
			
		||||
    module_file/2.
 | 
			
		||||
 | 
			
		||||
% @short node(?Module:module, ?Predicate:pred_indicator, ?File:file, ?Generator:atom) is nondet
 | 
			
		||||
%
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
inline( !/0 ).
 | 
			
		||||
inline( (\+)/1 ).
 | 
			
		||||
inline( (fail)/0 ).
 | 
			
		||||
inline( (false)/0 ).
 | 
			
		||||
inline( (repeat)/0 ).
 | 
			
		||||
inline( (true)/0 ).
 | 
			
		||||
inline( []/0 ).
 | 
			
		||||
 | 
			
		||||
% @short edge(+SourceModule:module, +SourcePredicate:pred_indicator, +TargetPredicate:pred_indicator, +InFile:file) is nondet
 | 
			
		||||
%
 | 
			
		||||
 | 
			
		||||
main :-
 | 
			
		||||
    init,
 | 
			
		||||
    fail.
 | 
			
		||||
main :-
 | 
			
		||||
	unix(argv([D])),
 | 
			
		||||
	Dirs = ['C'-prolog,
 | 
			
		||||
		   'os'-prolog,
 | 
			
		||||
		   'pl'-prolog,
 | 
			
		||||
		   'OPTYap'-prolog,
 | 
			
		||||
		   'library'-user,
 | 
			
		||||
%		   'swi/console'-user
 | 
			
		||||
		   'packages'-user
 | 
			
		||||
		 ],
 | 
			
		||||
%    maplist(distribute(D), Dirs, Paths),          
 | 
			
		||||
    load( D, Dirs ),
 | 
			
		||||
    maplist( pl_graphs, Dirs ),
 | 
			
		||||
	fail.
 | 
			
		||||
main :-
 | 
			
		||||
    %%% phase 4: construct graph
 | 
			
		||||
    retractall( consulted(_,_) ),
 | 
			
		||||
    undefs,
 | 
			
		||||
    doubles,
 | 
			
		||||
    %     pl_exported(pl).
 | 
			
		||||
    c_links,
 | 
			
		||||
    mkdocs.
 | 
			
		||||
 | 
			
		||||
distribute( Root, File-Class, Path-Class) :-
 | 
			
		||||
    sub_atom(Root,_,_,1,/),
 | 
			
		||||
    !,
 | 
			
		||||
    atom_concat(Root, File, Path ).
 | 
			
		||||
distribute( Root, File-Class, Path-Class) :-
 | 
			
		||||
    atom_concat([Root, /, File], Path ).
 | 
			
		||||
 | 
			
		||||
init :-
 | 
			
		||||
        retractall(dir(_)),
 | 
			
		||||
        retractall(edge(_)),
 | 
			
		||||
        retractall(private(_,_)),
 | 
			
		||||
        retractall(public(_,_)),
 | 
			
		||||
        retractall(undef(_,_)),
 | 
			
		||||
        retractall(consulted(_,_)),
 | 
			
		||||
        retractall(module_on(_,_,_)),
 | 
			
		||||
        retractall(op_export(_,_,_)),
 | 
			
		||||
        retractall(exported(_)),
 | 
			
		||||
        retractall(do_comment(_,_,_,_,_)).
 | 
			
		||||
init :-
 | 
			
		||||
        user_c_dep(A,B),
 | 
			
		||||
        do_user_c_dep(A,B),
 | 
			
		||||
        fail.
 | 
			
		||||
init :-
 | 
			
		||||
        user_skip(A),
 | 
			
		||||
        do_user_skip(A),
 | 
			
		||||
        fail.
 | 
			
		||||
init :-
 | 
			
		||||
        user_expand(N,A),
 | 
			
		||||
        do_user_expand(N,A),
 | 
			
		||||
        fail.
 | 
			
		||||
init :-
 | 
			
		||||
        catch( make_directory(tmp), _, fail),
 | 
			
		||||
        fail.
 | 
			
		||||
init.
 | 
			
		||||
 | 
			
		||||
init_loop( _Dirs ).
 | 
			
		||||
 | 
			
		||||
doubles :-
 | 
			
		||||
    node(M, P, F-_, _),
 | 
			
		||||
    node(M1, P, F1-_, _),
 | 
			
		||||
    M @< M1,
 | 
			
		||||
    is_public( P, M, F),
 | 
			
		||||
    is_public( P, M1, F1),
 | 
			
		||||
    format('~w vs ~w~n', [M:P,M1:P]),
 | 
			
		||||
    fail.
 | 
			
		||||
doubles.
 | 
			
		||||
 | 
			
		||||
undefs :-
 | 
			
		||||
    trace,
 | 
			
		||||
    format('UNDEFINED procedure calls:~n',[]),
 | 
			
		||||
    setof(M, Target^F^Line^NA^undef( ( Target :- F-M:NA ), Line  ), Ms ),
 | 
			
		||||
    member( Mod, Ms ),
 | 
			
		||||
    format('    module ~a:~n',[Mod]),
 | 
			
		||||
    setof(NA, Target^F^Line^undef( ( Target :- F-Mod:NA ), Line  ), Ns ),
 | 
			
		||||
    member( NA, Ns ),
 | 
			
		||||
    \+ node( Mod , NA , _File1, _ ),
 | 
			
		||||
    \+ node( prolog , NA , _File2, _ ),
 | 
			
		||||
    format('      predicate ~w:~n',[NA]),
 | 
			
		||||
    (
 | 
			
		||||
        setof(F-Line, Target^undef( ( Target :- F-Mod:NA ), Line ), FLs ),
 | 
			
		||||
	member(F-L, FLs ),
 | 
			
		||||
	format('        line ~w, file ~a~n',[L,F]),
 | 
			
		||||
	fail
 | 
			
		||||
    ;
 | 
			
		||||
         setof(F-M,Type^node( M, NA, F, Type ) , FMs ),
 | 
			
		||||
	 format('      same name at:~n',[]),
 | 
			
		||||
	 member((F-L)-M, FMs ),
 | 
			
		||||
	 format('        module ~a, file ~a, line ~d~n',[M,F,L]),
 | 
			
		||||
	 fail
 | 
			
		||||
    ).
 | 
			
		||||
undefs.
 | 
			
		||||
 | 
			
		||||
out_list([]) :-
 | 
			
		||||
    format('[]', []).
 | 
			
		||||
out_list([El]) :-
 | 
			
		||||
    format('[~q]', [El]).
 | 
			
		||||
out_list([E1,E2|Es]) :-
 | 
			
		||||
    format('[~q', [E1]),
 | 
			
		||||
    maplist(out_el, [E2|Es]),
 | 
			
		||||
    format(']', []).
 | 
			
		||||
 | 
			
		||||
out_el( El ) :-
 | 
			
		||||
    format(',~n        ~q',[El]).
 | 
			
		||||
 | 
			
		||||
pub(M, P) :-
 | 
			
		||||
    node(M, P, _, _),
 | 
			
		||||
    P = N/_A,
 | 
			
		||||
    \+ sub_atom(N,0,1,_,'$').
 | 
			
		||||
 | 
			
		||||
has_edge(M1, P1, M, F) :-
 | 
			
		||||
	edge(M1:P1, _P, F:_),
 | 
			
		||||
	node(M1, P1, _, _),
 | 
			
		||||
	M1 \= prolog,
 | 
			
		||||
	M1 \= M,
 | 
			
		||||
	\+ is_public(P1, M1, _).
 | 
			
		||||
 | 
			
		||||
mod_priv(M, P) :-
 | 
			
		||||
    node(M, P, _, _),
 | 
			
		||||
    node(M, P, _, _),
 | 
			
		||||
    \+ is_public(P, M, _),
 | 
			
		||||
    edge(M1:P, _P0, _), M1 \= M.
 | 
			
		||||
 | 
			
		||||
priv(M, P) :-
 | 
			
		||||
    node(M, P, F:_, _),
 | 
			
		||||
    \+ is_public(P, M, _),
 | 
			
		||||
    edge(_:P, _P1, F1:_), F1 \= F.
 | 
			
		||||
 | 
			
		||||
% utilities
 | 
			
		||||
 | 
			
		||||
split_string( S , Cs, N) :-
 | 
			
		||||
    string_codes(S, S1),
 | 
			
		||||
    string_codes(Cs, NCs),
 | 
			
		||||
    split(S1, NCs, Ncs0),
 | 
			
		||||
    maplist(remove_escapes, Ncs0, Ncs),
 | 
			
		||||
    maplist(string_codes, N, Ncs).
 | 
			
		||||
 | 
			
		||||
remove_escapes([0'\\ ,A|Cs], [A|NCs]) :- !, %'
 | 
			
		||||
    remove_escapes(Cs, NCs).
 | 
			
		||||
remove_escapes([A|Cs], [A|NCs]) :-
 | 
			
		||||
    remove_escapes(Cs, NCs).
 | 
			
		||||
remove_escapes( [], [] ).
 | 
			
		||||
 | 
			
		||||
always_strip_module(V, M, V1) :- var(V), !,
 | 
			
		||||
		V = M:call(V1).
 | 
			
		||||
always_strip_module(M0:A, M0, call(A)) :- var(A), !.
 | 
			
		||||
always_strip_module(_:M0:A, M1, B) :- !,
 | 
			
		||||
	always_strip_module(M0:A, M1, B).
 | 
			
		||||
always_strip_module(M0:A, M0, call(A)) :- var(A),!.
 | 
			
		||||
always_strip_module(M0:A, M0, A).
 | 
			
		||||
 | 
			
		||||
c_links :-
 | 
			
		||||
    open('tmp/foreigns.yap', write, S),
 | 
			
		||||
    clinks(S),
 | 
			
		||||
    fail.
 | 
			
		||||
c_links :-
 | 
			
		||||
    open('tmp/foreigns.c', write, S),
 | 
			
		||||
    cclinks(S),
 | 
			
		||||
    fail.
 | 
			
		||||
 | 
			
		||||
clinks(S) :-
 | 
			
		||||
	module_file( F, NM ),
 | 
			
		||||
	format( S, 'mod( ~q , ~q ).~n', [NM, F] ),
 | 
			
		||||
	fail.
 | 
			
		||||
clinks(S) :-
 | 
			
		||||
    system_predicate(C),
 | 
			
		||||
	functor(C, N, A),
 | 
			
		||||
	format( S, 'sys ~q/~d.~n', [N, A] ),
 | 
			
		||||
	fail.
 | 
			
		||||
clinks(S) :-
 | 
			
		||||
    exported( ( Fi0-M:F/A :- Fi1-M1:F1/A ) ),
 | 
			
		||||
    ( M \= M1 -> M \= prolog ; F \= F1 ),
 | 
			
		||||
%    functor(S0, F, A),
 | 
			
		||||
%    S0 =.. [F| Args],
 | 
			
		||||
%    S1 =.. [F1| Args],
 | 
			
		||||
%    numbervars(Args, 0, _),
 | 
			
		||||
    format( S, '% ~q <- ~q.~n~q:~q imports ~q:~q. ~n', [Fi0, Fi1, M,F/A, M1,F1/A] ),
 | 
			
		||||
    fail.
 | 
			
		||||
clinks(S) :-
 | 
			
		||||
    close(S).
 | 
			
		||||
 | 
			
		||||
cclinks(S) :-
 | 
			
		||||
    node( M, F/A, File-_Line, c(F)),
 | 
			
		||||
%    functor( S0, F, A),
 | 
			
		||||
%    S0 =.. [F| Args],
 | 
			
		||||
%    S1 =.. [foreign, F| Args],
 | 
			
		||||
%    numbervars(Args, 0, _),
 | 
			
		||||
    format( S, '/// @file ~a~n', [File] ),
 | 
			
		||||
    format( S, '/// @memberof ~a ~a:~a/~d~n', [F, M, F, A] ),
 | 
			
		||||
    fail.
 | 
			
		||||
cclinks(S) :-
 | 
			
		||||
    close(S).
 | 
			
		||||
 | 
			
		||||
warn_singletons(_Vars, _Pos).
 | 
			
		||||
 | 
			
		||||
%%
 | 
			
		||||
% comment( +Comment )
 | 
			
		||||
%
 | 
			
		||||
% Handle documentation comments
 | 
			
		||||
%
 | 
			
		||||
comment( _Pos - Comment) :-
 | 
			
		||||
    skip_blanks(1, Comment, N),
 | 
			
		||||
    doc( Comment, N ),
 | 
			
		||||
    format( "%s\n", [Comment] ),
 | 
			
		||||
    !.
 | 
			
		||||
comment( _Pos - _Comment).
 | 
			
		||||
 | 
			
		||||
skip_blanks(I, Comment, N) :-
 | 
			
		||||
    get_string_code( I, Comment, Code ),
 | 
			
		||||
    code_type( Code, space ),
 | 
			
		||||
    I1 is I+1,
 | 
			
		||||
    skip_blanks(I1, Comment, N).
 | 
			
		||||
skip_blanks(N, _Comment, N).
 | 
			
		||||
 | 
			
		||||
doc( Comment , N ) :-
 | 
			
		||||
    N1 is N+1,
 | 
			
		||||
    sub_string( Comment, N1, 3, _, Header ),
 | 
			
		||||
    ( Header == "/**" -> true ; Header == "/*!" ), !, % */
 | 
			
		||||
    N4 is N+4,
 | 
			
		||||
    get_string_code( N4, Comment, Code ),
 | 
			
		||||
    code_type( Code, space ).
 | 
			
		||||
doc( Comment, N ) :-
 | 
			
		||||
    N1 is N+1,
 | 
			
		||||
    sub_string( Comment, N1, 2, _, Header ),
 | 
			
		||||
    ( Header == "%%" -> true ; Header == "%!" ),
 | 
			
		||||
    N3 is N+3,
 | 
			
		||||
    get_string_code( N3, Comment, Code ),
 | 
			
		||||
    code_type( Code, space ).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
%%
 | 
			
		||||
% search_file( +Target, +Location, +FileType, -File )
 | 
			
		||||
%
 | 
			
		||||
%
 | 
			
		||||
% Directories into atoms
 | 
			
		||||
search_file(  Loc , F, Type, FN ) :-
 | 
			
		||||
    search_file0(  Loc , F, Type, FN ),
 | 
			
		||||
    !.
 | 
			
		||||
search_file(  Loc , F, _FN ) :-
 | 
			
		||||
    format('~n~n~n###############~n~n FAILED TO FIND ~w when at  ~a~n~n###############~n~n~n', [Loc, F ]),
 | 
			
		||||
     fail.
 | 
			
		||||
 | 
			
		||||
%
 | 
			
		||||
% handle some special cases.
 | 
			
		||||
%
 | 
			
		||||
search_file0( F, _, _Type, FN ) :-
 | 
			
		||||
    doexpand(F, FN), !.
 | 
			
		||||
search_file0( A/B, F, Type, FN ) :- !,
 | 
			
		||||
    term_to_atom(A/B, AB),
 | 
			
		||||
    search_file0( AB, F, Type, FN ).
 | 
			
		||||
% libraries can be anywhere in the source.
 | 
			
		||||
search_file0( LibLoc, F, Type, FN ) :-
 | 
			
		||||
    LibLoc =.. [Dir,File],
 | 
			
		||||
	!,
 | 
			
		||||
    ( term_to_atom( Dir/File, Full ) ; Full = File ),
 | 
			
		||||
    search_file0( Full, F, Type, FN ).
 | 
			
		||||
%try to use your base
 | 
			
		||||
search_file0(  Loc , F, c, FN ) :-
 | 
			
		||||
    atom_concat( D, '.yap', F),
 | 
			
		||||
    atom_concat( [ D, '/', Loc], F1),
 | 
			
		||||
    check_suffix(  F1 , c, NLoc ),
 | 
			
		||||
    absolute_file_name( NLoc, FN),
 | 
			
		||||
    file_base_name( FN, LocNam),
 | 
			
		||||
    file_directory_name( FN, D),
 | 
			
		||||
    dir( D, LocNam ).
 | 
			
		||||
search_file0(  Loc , F, Type, FN ) :-
 | 
			
		||||
    file_directory_name( F, FD),
 | 
			
		||||
    check_suffix(  Loc , Type, LocS ),
 | 
			
		||||
    atom_concat( [ FD, '/', LocS], NLoc),
 | 
			
		||||
    absolute_file_name( NLoc, FN),
 | 
			
		||||
    file_base_name( FN, LocNam),
 | 
			
		||||
    file_directory_name( FN, D),
 | 
			
		||||
    dir( D, LocNam).
 | 
			
		||||
search_file0(  Loc , _F, Type, FN ) :-
 | 
			
		||||
    file_base_name( Loc, Loc0),
 | 
			
		||||
    file_directory_name( Loc, LocD),
 | 
			
		||||
    check_suffix(  Loc0 , Type, LocS ),
 | 
			
		||||
    dir( D, LocS),
 | 
			
		||||
    sub_dir( D, DD),
 | 
			
		||||
    atom_concat( [ DD, '/', LocD], NLoc),
 | 
			
		||||
    absolute_file_name( NLoc, D),
 | 
			
		||||
    atom_concat( [D,'/', LocS], FN).
 | 
			
		||||
search_file0(  Loc , _F, Type, FN ) :-
 | 
			
		||||
    file_base_name( Loc, Loc0),
 | 
			
		||||
    check_suffix(  Loc0 , Type, LocS ),
 | 
			
		||||
    dir( D, LocS),
 | 
			
		||||
    atom_concat( [D,'/', LocS], FN).
 | 
			
		||||
% you try using the parent
 | 
			
		||||
 | 
			
		||||
sub_dir( D, D ).
 | 
			
		||||
sub_dir( D, DD) :-
 | 
			
		||||
	D \= '/',
 | 
			
		||||
	atom_concat( D, '/..', DD0),
 | 
			
		||||
	absolute_file_name( DD0, DDA),
 | 
			
		||||
	sub_dir( DDA, DD).
 | 
			
		||||
 | 
			
		||||
% files must be called .yap or .pl
 | 
			
		||||
% if it is .yap...
 | 
			
		||||
check_suffix(  Loc , pl, Loc ) :-
 | 
			
		||||
    atom_concat( _, '.yap', Loc ), !.
 | 
			
		||||
%, otherwise, .pl
 | 
			
		||||
check_suffix(  Loc , pl,  Loc ) :-
 | 
			
		||||
    atom_concat( _, '.pl', Loc ), !.
 | 
			
		||||
%, otherwise, .prolog
 | 
			
		||||
check_suffix(  Loc , pl,  Loc ) :-
 | 
			
		||||
    atom_concat( _, '.prolog', Loc ), !.
 | 
			
		||||
%, otherwise, .P
 | 
			
		||||
% try adding suffix
 | 
			
		||||
check_suffix(  Loc0 , pl, Loc ) :-
 | 
			
		||||
    member( Suf , ['.yap', '.ypp', '.pl' , '.prolog']),
 | 
			
		||||
    atom_concat( Loc0, Suf, Loc ).
 | 
			
		||||
check_suffix(  Loc , c, Loc ) :-
 | 
			
		||||
    atom_concat( _, '.c', Loc ), !.
 | 
			
		||||
%, otherwise, .pl
 | 
			
		||||
check_suffix(  Loc , c,  Loc ) :-
 | 
			
		||||
    atom_concat( _, '.icc', Loc ), !.
 | 
			
		||||
%, otherwise, .prolog
 | 
			
		||||
check_suffix(  Loc , c,  Loc ) :-
 | 
			
		||||
    atom_concat( _, '.cpp', Loc ), !.
 | 
			
		||||
%, otherwise, .P
 | 
			
		||||
% try adding suffix
 | 
			
		||||
check_suffix(  Loc0 , c, Loc ) :-
 | 
			
		||||
    member( Suf , ['.c', '.icc' , '.cpp']),
 | 
			
		||||
    atom_concat( Loc0, Suf, Loc ).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
match_file( LocD, Loc0, Type, FN ) :-
 | 
			
		||||
	var(LocD), !,
 | 
			
		||||
	dir( LocD, Loc0 ),
 | 
			
		||||
	atom_concat( [LocD, '/', Loc0], F ),
 | 
			
		||||
	absolute_file_name( F, Type, FN ),
 | 
			
		||||
	exists( FN ).
 | 
			
		||||
match_file( SufLocD, Loc0, Type, FN ) :-
 | 
			
		||||
	dir( LocD, Loc0 ),
 | 
			
		||||
	atom_concat(_, SufLocD, LocD ),
 | 
			
		||||
	atom_concat( [LocD, '/', Loc0], Type, FN ).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
new_op( F, M, op(X,Y,Z) ) :-
 | 
			
		||||
    nb_getval( private, true ),
 | 
			
		||||
    !,
 | 
			
		||||
    private( F, M, op(X,Y,Z) ),
 | 
			
		||||
    op( X, Y, Z).
 | 
			
		||||
new_op( F, M, op( X, Y, Z) ) :-
 | 
			
		||||
    public( F, M, op( X, Y, Z) ).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
ypp(F, error(syntax_error(syntax_error),[syntax_error(read(_228515),between(K,L,M),_,_L,_)-_]) ) :-
 | 
			
		||||
	format('SYNTAX ERROR at file ~a, line ~d (~d - ~d).~n', [F,L,K,M] ),
 | 
			
		||||
	break.
 | 
			
		||||
 | 
			
		||||
preprocess_file(F,NF) :-
 | 
			
		||||
    atom_concat(_, '.ypp', F ), !,
 | 
			
		||||
    atom_concat( [ 'cpp -CC -w -DMYDDAS_MYSQL -DMYDDAS_ODBC -DMYDDAS_STATS -DMYDDAS_TOP_LEVEL -P ',F], OF ),
 | 
			
		||||
    NF = pipe( OF ).
 | 
			
		||||
preprocess_file(F,F).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
%%%%%%%
 | 
			
		||||
%% declare a concept export1able
 | 
			
		||||
public( F, M, op(X,Y,Z) ) :-
 | 
			
		||||
    retract( private( F, M:op(X,Y,Z) ) ),
 | 
			
		||||
    fail.
 | 
			
		||||
public( F, M, op(X,Y,Z) ) :- !,
 | 
			
		||||
    assert( op_export(F, _M, op(X,Y,Z) ) ),
 | 
			
		||||
    assert_new( public( F, M:op(X,Y,Z) ) ),
 | 
			
		||||
    (
 | 
			
		||||
	( M == user ; M == prolog )
 | 
			
		||||
      ->
 | 
			
		||||
	  op( X, Y, prolog:Z )
 | 
			
		||||
      ;
 | 
			
		||||
	  op( X, Y, M:Z )
 | 
			
		||||
    ).
 | 
			
		||||
public( F, M, M:N/Ar ) :-
 | 
			
		||||
    retract( private( F, M:N/Ar ) ),
 | 
			
		||||
    fail.
 | 
			
		||||
public( F, M, N/Ar ) :-
 | 
			
		||||
    assert_new( public( F, M:N/Ar ) ),
 | 
			
		||||
    \+ node( M, N/Ar, F-_, _ ),
 | 
			
		||||
    nb_getval( line, L ),
 | 
			
		||||
    assert( node( M, N/Ar, F-L, prolog ) ), !.
 | 
			
		||||
public( _F, _M, _/_Ar ).
 | 
			
		||||
public( F, M, M:N//Ar ) :-
 | 
			
		||||
	Ar2 is Ar+2,
 | 
			
		||||
    retract( private( F, M:N/Ar2 ) ),
 | 
			
		||||
    fail.
 | 
			
		||||
public( F, M, N//Ar ) :-
 | 
			
		||||
	Ar2 is Ar+2,
 | 
			
		||||
    assert_new( public( F, M:N/Ar2 ) ),
 | 
			
		||||
    \+ node( M, N/Ar2, F-_, _ ),
 | 
			
		||||
    nb_getval( line, L ),
 | 
			
		||||
    assert( node( M, N/Ar2, F-L, prolog ) ), !.
 | 
			
		||||
public( _F, _M, _//_Ar ).
 | 
			
		||||
 | 
			
		||||
private( F, M, op(X,Y,Z) ) :-
 | 
			
		||||
    assert_new( private( F, M:op(X,Y,Z) ) ),
 | 
			
		||||
    (
 | 
			
		||||
	( M == user ; M == prolog )
 | 
			
		||||
      ->
 | 
			
		||||
	  op( X, Y, prolog:Z )
 | 
			
		||||
      ;
 | 
			
		||||
	  op( X, Y, M:Z )
 | 
			
		||||
    ), !.
 | 
			
		||||
private( _F, _M, op(_X,_Y,_Z) ).
 | 
			
		||||
private( F, M, N/Ar ) :-
 | 
			
		||||
    assert_new( private( F, M:N/Ar ) ),
 | 
			
		||||
    \+ node( M, N/Ar, F-_, _ ),
 | 
			
		||||
    nb_getval( line, L ),
 | 
			
		||||
    assert( node( M, N/Ar, F-L, prolog ) ), !.
 | 
			
		||||
private( _F, _M, _N/_Ar ).
 | 
			
		||||
private( F, M, N//Ar ) :-
 | 
			
		||||
	Ar2 is Ar+2,
 | 
			
		||||
    assert_new( private( F, M:N/Ar2 ) ),
 | 
			
		||||
    \+ node( M, N/Ar2, F-_, _ ),
 | 
			
		||||
    nb_getval( line, L ),
 | 
			
		||||
    assert_new( node( M, N/Ar2, F-L, prolog ) ), !.
 | 
			
		||||
private( _F, _M, _N//_Ar ).
 | 
			
		||||
 | 
			
		||||
is_public( F, M, OP ) :-
 | 
			
		||||
    public( F, M:OP ).
 | 
			
		||||
 | 
			
		||||
is_private( F, M, OP ) :-
 | 
			
		||||
     private( F, M :OP ).
 | 
			
		||||
 | 
			
		||||
assert_new( G ) :- G, !.
 | 
			
		||||
assert_new( G ) :- assert( G ).
 | 
			
		||||
 | 
			
		||||
error( Error ) :- throw(Error ).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
%% mkdocs inserts a file with a sequence of comments into a sequence of Prolog/C files.
 | 
			
		||||
%
 | 
			
		||||
%
 | 
			
		||||
mkdocs :-
 | 
			
		||||
  open( 'tmp/pages', write, S1),
 | 
			
		||||
  close( S1 ),
 | 
			
		||||
  open( 'tmp/bads', write, S2),
 | 
			
		||||
  close( S2 ),
 | 
			
		||||
  open( 'tmp/groups', write, S3),
 | 
			
		||||
  close( S3 ),
 | 
			
		||||
  open( 'tmp/groups.yap', write, S4),
 | 
			
		||||
  close( S4 ),
 | 
			
		||||
  open( 'docs/yapdocs.yap', read, S),
 | 
			
		||||
    repeat,
 | 
			
		||||
    (
 | 
			
		||||
	blanks(S, Comment, Rest)
 | 
			
		||||
    ->
 | 
			
		||||
	get_comment(S, Rest),
 | 
			
		||||
	store_comment( Comment ),
 | 
			
		||||
	fail
 | 
			
		||||
    ;
 | 
			
		||||
        close(S),
 | 
			
		||||
	!,
 | 
			
		||||
	add_comments
 | 
			
		||||
    ).
 | 
			
		||||
 | 
			
		||||
blanks( S , T, TF) :-
 | 
			
		||||
    read_line_to_codes(S, T1, T2),
 | 
			
		||||
    ( T1 == end_of_file -> fail;
 | 
			
		||||
      T2 == [] -> fail;
 | 
			
		||||
      T1 \== T2, foldl( check, [0'/,0'*,0'*],T1, _) -> TF = T2, T = T1 ; % '
 | 
			
		||||
      blanks( S , T, TF) ).
 | 
			
		||||
 | 
			
		||||
get_comment( S , T) :-
 | 
			
		||||
    read_line_to_codes(S, T, T0),
 | 
			
		||||
    ( T == end_of_file -> T = [];
 | 
			
		||||
      T0 == [] -> T=[];
 | 
			
		||||
      diff_end( [0'*,0'/,10],T, T0 ) -> true ;
 | 
			
		||||
      get_comment( S , T0) ).
 | 
			
		||||
 | 
			
		||||
check(C, [C0|L], L) :-
 | 
			
		||||
  C == C0.
 | 
			
		||||
 | 
			
		||||
diff_end( L, T, [] ) :-
 | 
			
		||||
   append(_, L, T).
 | 
			
		||||
 | 
			
		||||
store_comment(Comment) :-
 | 
			
		||||
  header( Pred, A, Comment, _ ),
 | 
			
		||||
  atom_codes( P, Pred),
 | 
			
		||||
  ( node( Mod, P/A, File-Line, Type) ->
 | 
			
		||||
    true
 | 
			
		||||
  ;
 | 
			
		||||
    format('Missing definition for ~q.~n', [P/A] ),
 | 
			
		||||
    node( Mod, P/Ar, File-Line, Type),
 | 
			
		||||
    format('  ~w exists.~n',[Mod:P/Ar]),
 | 
			
		||||
    fail
 | 
			
		||||
  ),
 | 
			
		||||
  ( node( M1, P/A, _, _),  M1 \= Mod -> Dup = true ; Dup = false),
 | 
			
		||||
  !,
 | 
			
		||||
  string_codes( C, Comment ),
 | 
			
		||||
  assert( do_comment( File, Line, C, Type, Dup ) ).
 | 
			
		||||
store_comment(Comment) :-
 | 
			
		||||
  page( Comment, _ ), !,
 | 
			
		||||
  open( 'tmp/pages', append, S),
 | 
			
		||||
  format(S, '*******************************~n~n~s~n~n', [Comment]),
 | 
			
		||||
  close(S).
 | 
			
		||||
store_comment(Comment) :-
 | 
			
		||||
  defgroup( Comment, _ ), !,
 | 
			
		||||
  open( 'tmp/groups', append, S),
 | 
			
		||||
  format(S, '*******************************~n~n~s~n~n', [Comment]),
 | 
			
		||||
  close(S).
 | 
			
		||||
store_comment(Comment) :-
 | 
			
		||||
  open( 'tmp/bads', append, S),
 | 
			
		||||
  format(S, '*******************************~n~n~s~n~n', [Comment]),
 | 
			
		||||
  close(S).
 | 
			
		||||
 | 
			
		||||
defgroup -->
 | 
			
		||||
  "/**", % */
 | 
			
		||||
  blanks_or_stars,
 | 
			
		||||
  "@defgroup".
 | 
			
		||||
defgroup -->
 | 
			
		||||
  "%%", % */
 | 
			
		||||
  blanks_or_percs,
 | 
			
		||||
  "@defgroup".
 | 
			
		||||
 | 
			
		||||
page -->
 | 
			
		||||
  "/**", % */
 | 
			
		||||
  blanks,
 | 
			
		||||
  "@page".
 | 
			
		||||
 | 
			
		||||
header(Pred, Arity) -->
 | 
			
		||||
  "/**", % */
 | 
			
		||||
  blanks,
 | 
			
		||||
  "@pred",
 | 
			
		||||
  blanks,
 | 
			
		||||
  atom(_),
 | 
			
		||||
  ":",
 | 
			
		||||
  !,
 | 
			
		||||
  atom(Pred),
 | 
			
		||||
  atom_pred(Arity).
 | 
			
		||||
header(Pred, Arity) -->
 | 
			
		||||
  "/**", % */
 | 
			
		||||
  blanks,
 | 
			
		||||
  "@pred",
 | 
			
		||||
  blanks,
 | 
			
		||||
  atom(Pred),
 | 
			
		||||
  atom_pred(Arity),
 | 
			
		||||
  !.
 | 
			
		||||
header(Pred, 2, Comment, _) :-
 | 
			
		||||
    split(Comment, [[0'/,0'*,0'*],[0'@,0'p,0'r,0'e,0'd],_,Pred,_,[0'i,0's]|_]), !.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
atom_pred(Arity) -->
 | 
			
		||||
  "/", !,
 | 
			
		||||
  int( 0, Arity ).
 | 
			
		||||
atom_pred(N) -->
 | 
			
		||||
  "(",
 | 
			
		||||
  !,
 | 
			
		||||
  decl(1,N).
 | 
			
		||||
atom_pred(0) -->
 | 
			
		||||
  blanks, !.
 | 
			
		||||
 | 
			
		||||
int(I0, I) -->
 | 
			
		||||
    [A],
 | 
			
		||||
    { A >= "0", A =< "9" },
 | 
			
		||||
    !,
 | 
			
		||||
    { I1 is I0*10+(A-"0") },
 | 
			
		||||
    int(I1, I).
 | 
			
		||||
int( I, I ) --> [].
 | 
			
		||||
 | 
			
		||||
decl(I, I) -->
 | 
			
		||||
  ")", !.
 | 
			
		||||
decl(I0, I) -->
 | 
			
		||||
  ",", !,
 | 
			
		||||
  { I1 is I0+1 },
 | 
			
		||||
  decl(I1, I).
 | 
			
		||||
decl(I0, I) -->
 | 
			
		||||
  [_],
 | 
			
		||||
  decl( I0, I).
 | 
			
		||||
 | 
			
		||||
  skip_early_comment(C) -->
 | 
			
		||||
    [C], !,
 | 
			
		||||
    skip_early_comment(C).
 | 
			
		||||
skip_early_comment(C) -->
 | 
			
		||||
    ( " " ; "\t" ; "\n" ), !,
 | 
			
		||||
    skip_early_comment(C).
 | 
			
		||||
  skip_early_comment(C) -->
 | 
			
		||||
    "@", ( "{" ; "}" ), !,
 | 
			
		||||
    skip_early_comment(C).
 | 
			
		||||
  skip_early_comment(_) --> [].
 | 
			
		||||
 | 
			
		||||
  blanks --> " ", !, blanks.
 | 
			
		||||
  blanks --> "\t", !, blanks.
 | 
			
		||||
  blanks --> [].
 | 
			
		||||
 | 
			
		||||
  atom([A|As]) -->
 | 
			
		||||
  [A],
 | 
			
		||||
  { A >= "a", A =< "z" },
 | 
			
		||||
  atom2( As ).
 | 
			
		||||
 | 
			
		||||
atom2([A|As]) -->
 | 
			
		||||
  [A],
 | 
			
		||||
  { A >= "a", A =< "z" -> true ;
 | 
			
		||||
    A >= "A", A =< "Z" -> true ;
 | 
			
		||||
    A >= "0", A =< "9" -> true ;
 | 
			
		||||
    A =:= "_"
 | 
			
		||||
  },
 | 
			
		||||
  !,
 | 
			
		||||
  atom2( As ).
 | 
			
		||||
atom2([]) --> [].
 | 
			
		||||
 | 
			
		||||
add_comments :-
 | 
			
		||||
 open('tmp/comments.yap', write, S),
 | 
			
		||||
 findall(File, do_comment( File, Line, C, Type, Dup), Fs0 ),
 | 
			
		||||
  (
 | 
			
		||||
      sort(Fs0, Fs),
 | 
			
		||||
      member( File, Fs ),
 | 
			
		||||
      setof(Line-C-Type-Dup, do_comment( File, Line, C, Type, Dup) , Lines0 ),
 | 
			
		||||
      reverse( Lines0, Lines),
 | 
			
		||||
      member(Line-Comment-Type-Dup, Lines),
 | 
			
		||||
      check_comment( Comment, CN, Line, File ),
 | 
			
		||||
      Line1 is Line-1,
 | 
			
		||||
      format(S, '#~a~ncat << "EOF" > tmp~n~sEOF~nsed -e "~dr tmp" ~a > x~n\
 | 
			
		||||
     mv x ~a~n~n',[Dup,CN, Line1, File, File])
 | 
			
		||||
	  ;
 | 
			
		||||
	  close(S)
 | 
			
		||||
   ),
 | 
			
		||||
  fail.
 | 
			
		||||
add_comments :-
 | 
			
		||||
  listing( open_comment ).
 | 
			
		||||
 | 
			
		||||
check_comment( Comment, CN, _Line, _qFile ) :-
 | 
			
		||||
    string_codes( Comment, [_,_,_|C]),
 | 
			
		||||
    check_groups(0,_C,[]),
 | 
			
		||||
    check_quotes(0,C,[]),
 | 
			
		||||
    (
 | 
			
		||||
        append(C0,[0'@,0'},0' ,0'*,0'/,10], C) -> %'
 | 
			
		||||
	    append(C0,[0'*,0'/,10], CN)
 | 
			
		||||
	      ;
 | 
			
		||||
	      CN = C
 | 
			
		||||
    ),
 | 
			
		||||
    !.
 | 
			
		||||
check_comment( Comment, Comment,  Line, File ) :-
 | 
			
		||||
    format(user_error,'*** bad comment ~a ~d~n~n~s~n~', [File,Line,Comment]).
 | 
			
		||||
 | 
			
		||||
check_groups(0) --> [].
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
check_quotes( 0 ) --> [].
 | 
			
		||||
check_quotes( 0 ) -->
 | 
			
		||||
    "`", !,
 | 
			
		||||
    check_quotes( 1 ).
 | 
			
		||||
check_quotes( 1 ) -->
 | 
			
		||||
    "`", !,
 | 
			
		||||
    check_quotes( 0 ).
 | 
			
		||||
check_quotes( 1 ) -->
 | 
			
		||||
    "\"", !, { fail }.
 | 
			
		||||
check_quotes( 1 ) -->
 | 
			
		||||
    "'",  !, { fail }. %'
 | 
			
		||||
check_quotes( N ) -->
 | 
			
		||||
    [_],
 | 
			
		||||
    check_quotes( N ).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
%%%
 | 
			
		||||
%  ops_default sets operators back to YAP default.
 | 
			
		||||
%
 | 
			
		||||
ops_default :-
 | 
			
		||||
    abolish( default_ops/1 ),
 | 
			
		||||
    A = (_,_), functor(A,Comma,2),
 | 
			
		||||
    findall(op(X,Y,prolog:Z), ( current_op(X,Y,prolog:Z), Z\= Comma ), L),
 | 
			
		||||
    assert_static( default_ops(L) ).
 | 
			
		||||
 | 
			
		||||
:- initialization(ops_default, now).
 | 
			
		||||
 | 
			
		||||
ops_restore :-
 | 
			
		||||
    A = (_,_), functor(A,Comma,2),
 | 
			
		||||
    current_op(_X,Y,prolog:Z),
 | 
			
		||||
    Z\= Comma,
 | 
			
		||||
    op(0,Y,prolog:Z),
 | 
			
		||||
    fail.
 | 
			
		||||
ops_restore :-
 | 
			
		||||
    default_ops(L),
 | 
			
		||||
    maplist( call, L ).
 | 
			
		||||
 | 
			
		||||
do_user_c_dep(F1, F2) :-
 | 
			
		||||
    absolute_file_name(F1, A1),
 | 
			
		||||
    absolute_file_name(F2, A2),
 | 
			
		||||
    assert(c_dep(A1, A2)).
 | 
			
		||||
do_user_skip(F1) :-
 | 
			
		||||
    absolute_file_name(F1, A1),
 | 
			
		||||
    assert(doskip(A1)).
 | 
			
		||||
do_user_expand(F, F1) :-
 | 
			
		||||
    absolute_file_name(F1, A1),
 | 
			
		||||
    assert(doexpand(F, A1)).
 | 
			
		||||
 | 
			
		||||
user_deps( F, M ) :-
 | 
			
		||||
    c_dep(F, A2),
 | 
			
		||||
    c_file(A2 , M),
 | 
			
		||||
    fail.
 | 
			
		||||
user_deps( _F, _M ).
 | 
			
		||||
 | 
			
		||||
user_c_dep( 'packages/jpl/jpl.pl', 'packages/jpl/src/c/jpl.c' ).
 | 
			
		||||
user_c_dep( 'packages/real/real.pl', 'packages/real/real.c' ).
 | 
			
		||||
user_c_dep( 'packages/odbc/odbc.pl', 'packages/odbc/odbc.c' ).
 | 
			
		||||
user_c_dep( 'packages/clib/unix.pl', 'packages/clib/unix.c' ).
 | 
			
		||||
user_c_dep( 'packages/clib/cgi.pl', 'packages/clib/cgi.c' ).
 | 
			
		||||
user_c_dep( 'packages/clib/crypt.pl', 'packages/clib/crypt.c' ).
 | 
			
		||||
user_c_dep( 'packages/clib/filesex.pl', 'packages/clib/files.c' ).
 | 
			
		||||
user_c_dep( 'packages/clib/mime.pl', 'packages/clib/mime.c' ).
 | 
			
		||||
user_c_dep( 'packages/clib/socket.pl', 'packages/clib/socket.c' ).
 | 
			
		||||
user_c_dep( 'packages/clib/socket.pl', 'packages/clib/winpipe.c' ).
 | 
			
		||||
user_c_dep( 'packages/http/http_stream.pl', 'packages/http/cgi_stream.c' ).
 | 
			
		||||
user_c_dep( 'packages/http/http_stream.pl', 'packages/http/stream_range.c' ).
 | 
			
		||||
user_c_dep( 'packages/http/http_stream.pl', 'packages/http/http_chunked.c' ).
 | 
			
		||||
user_c_dep( 'packages/http/http_stream.pl', 'packages/http/http_error.c' ).
 | 
			
		||||
user_c_dep( 'packages/swi-minisat2/minisat.pl', 'packages/swi-minisat2/C/pl-minisat.C' ).
 | 
			
		||||
user_c_dep( 'packages/gecode/gecode.yap', 'packages/gecode/gecode4_yap.cc' ).
 | 
			
		||||
user_c_dep( 'packages/gecode/gecode.yap', 'packages/gecode/4.2.1/gecode_yap_cc_forward_auto_generated.icc' ).
 | 
			
		||||
user_c_dep( 'packages/gecode/gecode.yap', 'packages/gecode/4.2.1/gecode_yap_cc_init_auto_generated.icc' ).
 | 
			
		||||
user_c_dep( 'packages/gecode/gecode.yap', 'packages/gecode/4.2.1/gecode_yap_cc_impl_auto_generated.icc' ).
 | 
			
		||||
user_c_dep( 'packages/semweb/rdf_db.pl', 'packages/semweb/atom_map.c' ).
 | 
			
		||||
user_c_dep( 'packages/semweb/rdf_db.pl', 'packages/semweb/resource.c' ).
 | 
			
		||||
user_c_dep( 'packages/sgml/sgml.pl', 'packages/sgml/quote.c' ).
 | 
			
		||||
user_c_dep( 'swi/library/readutil.pl', 'packages/clib/readutil.c' ).
 | 
			
		||||
user_c_dep( 'packages/myddas/pl/myddas.ypp', 'packages/myddas/myddas_shared.c' ).
 | 
			
		||||
user_c_dep( 'packages/myddas/pl/myddas.ypp', 'packages/myddas/myddas_odbc.c' ).
 | 
			
		||||
user_c_dep( 'packages/myddas/pl/myddas.ypp', 'packages/myddas/myddas_mysql.c' ).
 | 
			
		||||
user_c_dep( 'packages/myddas/pl/myddas.ypp', 'packages/myddas/myddas_top_level.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/core/bpx.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/core/error.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/core/fputil.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/core/gamma.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/core/glue.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/core/idtable.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/core/idtable_preds.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/core/random.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/core/termpool.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/core/vector.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/core/xmalloc.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/up/em_aux.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/up/em_aux_ml.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/up/em_aux_vb.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/up/em_ml.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/up/em_preds.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/up/flags.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/up/graph.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/up/graph_aux.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/up/hindsight.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/up/util.c' ).
 | 
			
		||||
user_c_dep( 'packages/prism/src/prolog/prism.yap', 'packages/prism/src/c/up/viterbi.c' ).
 | 
			
		||||
 | 
			
		||||
doskip( D):- sub_atom( D, _, _, 0, '~' ).
 | 
			
		||||
doskip( D):- sub_atom( D, _, _, 0, '/.' ).
 | 
			
		||||
doskip( D):- sub_atom( D, _, _, 0, '/..' ).
 | 
			
		||||
doskip( D):- sub_atom( D, _, _, 0, '/.git' ).
 | 
			
		||||
doskip( D):- sub_atom( D, _, _, _, '/.#' ).
 | 
			
		||||
doskip( D):- sub_atom( D, _, _, 0, '#' ).
 | 
			
		||||
doskip( D):- user_skip( D ).
 | 
			
		||||
 | 
			
		||||
user_skip( 'packages/gecode/3.6.0').
 | 
			
		||||
user_skip( 'packages/gecode/3.7.0').
 | 
			
		||||
user_skip( 'packages/gecode/3.7.1').
 | 
			
		||||
user_skip( 'packages/gecode/3.7.2').
 | 
			
		||||
user_skip( 'packages/gecode/3.7.3').
 | 
			
		||||
user_skip( 'packages/gecode/4.0.0').
 | 
			
		||||
user_skip( 'packages/gecode/4.2.0').
 | 
			
		||||
user_skip( 'packages/gecode/4.2.1').
 | 
			
		||||
user_skip( 'packages/gecode/gecode3.yap' ).
 | 
			
		||||
user_skip( 'packages/gecode/gecode3_yap.cc' ).
 | 
			
		||||
user_skip( 'packages/gecode/gecode3_yap_hand_written.yap').
 | 
			
		||||
user_skip( 'packages/gecode/gecode3.yap-common.icc').
 | 
			
		||||
user_skip( 'packages/prism/src/prolog/core').
 | 
			
		||||
user_skip( 'packages/prism/src/prolog/up').
 | 
			
		||||
user_skip( 'packages/prism/src/prolog/mp').
 | 
			
		||||
user_skip( 'packages/prism/src/prolog/trans').
 | 
			
		||||
user_skip( 'packages/prism/src/prolog/bp').
 | 
			
		||||
user_skip( 'packages/prism/src/c').
 | 
			
		||||
 | 
			
		||||
user_expand( library(clpfd), 'library/clp/clpfd.pl' ).
 | 
			
		||||
							
								
								
									
										37
									
								
								misc/tests
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								misc/tests
									
									
									
									
									
								
							@@ -1,3 +1,34 @@
 | 
			
		||||
current_predicate	2
 | 
			
		||||
	X	Y	_
 | 
			
		||||
	goal_expansion	Y	goal_expansion(_)
 | 
			
		||||
 | 
			
		||||
:- op(test, fx, 1200).
 | 
			
		||||
 | 
			
		||||
test_mode.
 | 
			
		||||
 | 
			
		||||
test( ( G  :- Sols ) :-
 | 
			
		||||
      reset_sols,
 | 
			
		||||
      init_io( Streams ),
 | 
			
		||||
      catch( do_test(G, Sols), Done,  handler( Done ) ).
 | 
			
		||||
      close_io( Streams ).
 | 
			
		||||
 | 
			
		||||
do_test(G0, Sols)
 | 
			
		||||
      copy_term(G0, G),
 | 
			
		||||
      catch( ( G, answer(G, Sol) ) , Error, test_error(Error, Sol) ),
 | 
			
		||||
      next_solution( I, Sol, G0, Sol ),
 | 
			
		||||
      !.
 | 
			
		||||
do_test(G, Sols) :-
 | 
			
		||||
    counter(I),
 | 
			
		||||
    failure(G, Sols, I).
 | 
			
		||||
 | 
			
		||||
next_solution( I, Sol , G0, Sols ) :-
 | 
			
		||||
    inc(I),
 | 
			
		||||
    fetch(I, Sols, Pattern, Next),
 | 
			
		||||
    (
 | 
			
		||||
     Sol =@= Pattern
 | 
			
		||||
    ->
 | 
			
		||||
     success(I, G0)
 | 
			
		||||
    ;
 | 
			
		||||
     error(I, G0, Sol )
 | 
			
		||||
    ),
 | 
			
		||||
    ( var(Next) -> throw( done ) ).
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
@@ -53,7 +53,9 @@ if (READLINE_FOUND)
 | 
			
		||||
  # READLINE_readline_LIBRARY, where to find the READLINE library.
 | 
			
		||||
  # READLINE_ncurses_LIBRARY, where to find the ncurses library [might not be defined]
 | 
			
		||||
 | 
			
		||||
  set( CMAKE_REQUIRED_INCLUDES  ${READLINE_INCLUDE_DIR} ${CMAKE_REQUIRED_INCLUDES} )
 | 
			
		||||
  include_directories (BEFORE ${READLINE_INCLUDE_DIR})
 | 
			
		||||
 | 
			
		||||
  set(YAP_SYSTEM_OPTIONS "readline " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
 | 
			
		||||
  set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${READLINE_LIBRARIES} )
 | 
			
		||||
  check_include_files( "stdio.h;readline/readline.h" HAVE_READLINE_READLINE_H )
 | 
			
		||||
  check_include_files( "stdio.h;readline/history.h"  HAVE_READLINE_HISTORY_H )
 | 
			
		||||
@@ -81,15 +83,17 @@ endif (READLINE_FOUND)
 | 
			
		||||
set (POSITION_INDEPENDENT_CODE TRUE)
 | 
			
		||||
 | 
			
		||||
add_library (libYAPOs  OBJECT
 | 
			
		||||
  ${YAPOS_SOURCES} )
 | 
			
		||||
 | 
			
		||||
  ${YAPOS_SOURCES}
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
set_target_properties(libYAPOs
 | 
			
		||||
  PROPERTIES
 | 
			
		||||
 | 
			
		||||
  #  RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
 | 
			
		||||
  #  SOVERSION ${LIBYAPTAI_MAJOR_VERSION}.${LIBYAPTAI_MINOR_VERSION}
 | 
			
		||||
  POSITION_INDEPENDENT_CODE TRUE
 | 
			
		||||
  OUTPUT_NAME YAPOs
 | 
			
		||||
  depends dheap
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
configure_file ("${PROJECT_SOURCE_DIR}/os/YapIOConfig.h.cmake"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										25
									
								
								os/charsio.c
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								os/charsio.c
									
									
									
									
									
								
							@@ -131,8 +131,7 @@ Int Yap_peek(int sno) {
 | 
			
		||||
  /* buffer the character */
 | 
			
		||||
  if (s->encoding == LOCAL_encoding) {
 | 
			
		||||
    ungetwc(ch, s->file);
 | 
			
		||||
  } else if (s->encoding == ENC_OCTET ||
 | 
			
		||||
      s->encoding == ENC_ISO_LATIN1||
 | 
			
		||||
  } else if (s->encoding == ENC_OCTET || s->encoding == ENC_ISO_LATIN1 ||
 | 
			
		||||
             s->encoding == ENC_ISO_ASCII) {
 | 
			
		||||
    ungetc(ch, s->file);
 | 
			
		||||
  } else if (s->encoding == ENC_ISO_UTF8) {
 | 
			
		||||
@@ -512,7 +511,7 @@ static Int put_code(USES_REGS1) { /* '$put'(Stream,N)                      */
 | 
			
		||||
    return (FALSE);
 | 
			
		||||
  if (GLOBAL_Stream[sno].status & Binary_Stream_f) {
 | 
			
		||||
    UNLOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, ARG1, "put/2");
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, ARG1, "put/2");
 | 
			
		||||
    return (FALSE);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -552,7 +551,7 @@ static Int put_char_1(USES_REGS1) { /* '$put'(,N)                      */
 | 
			
		||||
  LOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
  if (GLOBAL_Stream[sno].status & Binary_Stream_f) {
 | 
			
		||||
    UNLOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, ARG1, "put/2");
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, ARG1, "put/2");
 | 
			
		||||
    return (FALSE);
 | 
			
		||||
  }
 | 
			
		||||
  GLOBAL_Stream[sno].stream_wputc(sno, ch);
 | 
			
		||||
@@ -590,7 +589,7 @@ static Int put_char(USES_REGS1) { /* '$put'(Stream,N)                      */
 | 
			
		||||
    return (FALSE);
 | 
			
		||||
  if (GLOBAL_Stream[sno].status & Binary_Stream_f) {
 | 
			
		||||
    UNLOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, ARG1, "put/2");
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, ARG1, "put/2");
 | 
			
		||||
    return (FALSE);
 | 
			
		||||
  }
 | 
			
		||||
  GLOBAL_Stream[sno].stream_wputc(sno, (int)IntegerOfTerm(Deref(ARG2)));
 | 
			
		||||
@@ -627,7 +626,7 @@ static Int tab_1(USES_REGS1) { /* nl                      */
 | 
			
		||||
  LOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
  if (GLOBAL_Stream[sno].status & Binary_Stream_f) {
 | 
			
		||||
    UNLOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, ARG1, "nl/0");
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, ARG1, "nl/0");
 | 
			
		||||
    return (FALSE);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -667,7 +666,7 @@ static Int tab(USES_REGS1) { /* nl(Stream)                      */
 | 
			
		||||
 | 
			
		||||
  if (GLOBAL_Stream[sno].status & Binary_Stream_f) {
 | 
			
		||||
    UNLOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, ARG1, "nl/0");
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, ARG1, "nl/0");
 | 
			
		||||
    return (FALSE);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -755,7 +754,7 @@ static Int put_byte(USES_REGS1) { /* '$put_byte'(Stream,N)                 */
 | 
			
		||||
      // && strictISOFlag()
 | 
			
		||||
      ) {
 | 
			
		||||
    UNLOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, ARG1, NULL);
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, ARG1, NULL);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
  GLOBAL_Stream[sno].stream_putc(sno, ch);
 | 
			
		||||
@@ -794,7 +793,7 @@ static Int put_byte_1(USES_REGS1) { /* '$put_byte'(Stream,N)                 */
 | 
			
		||||
      //&& strictISOFlag()
 | 
			
		||||
      ) {
 | 
			
		||||
    UNLOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, ARG1, "get0/2");
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, ARG1, "get0/2");
 | 
			
		||||
    return (FALSE);
 | 
			
		||||
  }
 | 
			
		||||
  GLOBAL_Stream[sno].stream_putc(sno, ch);
 | 
			
		||||
@@ -937,7 +936,7 @@ static Int peek_code(USES_REGS1) { /* at_end_of_stream */
 | 
			
		||||
    return FALSE;
 | 
			
		||||
  if (GLOBAL_Stream[sno].status & Binary_Stream_f) {
 | 
			
		||||
    UNLOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_INPUT_BINARY_STREAM, ARG1, "peek_code/2");
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_INPUT_TEXT_STREAM, ARG1, "peek_code/2");
 | 
			
		||||
    return FALSE;
 | 
			
		||||
  }
 | 
			
		||||
  if ((ch = Yap_peek(sno)) < 0) {
 | 
			
		||||
@@ -967,7 +966,7 @@ static Int peek_code_1(USES_REGS1) { /* at_end_of_stream */
 | 
			
		||||
  LOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
  if (GLOBAL_Stream[sno].status & Binary_Stream_f) {
 | 
			
		||||
    UNLOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_INPUT_BINARY_STREAM, ARG1, "peek_code/2");
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_INPUT_TEXT_STREAM, ARG1, "peek_code/2");
 | 
			
		||||
    return FALSE;
 | 
			
		||||
  }
 | 
			
		||||
  if ((ch = Yap_peek(sno)) < 0) {
 | 
			
		||||
@@ -996,7 +995,7 @@ static Int peek_byte(USES_REGS1) { /* at_end_of_stream */
 | 
			
		||||
    return (FALSE);
 | 
			
		||||
  if (!(GLOBAL_Stream[sno].status & Binary_Stream_f)) {
 | 
			
		||||
    UNLOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_INPUT_STREAM, ARG1, "peek_byte/2");
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_INPUT_BINARY_STREAM, ARG1, "peek_byte/2");
 | 
			
		||||
    return (FALSE);
 | 
			
		||||
  }
 | 
			
		||||
  if ((ch = dopeek_byte(sno)) < 0) {
 | 
			
		||||
@@ -1026,7 +1025,7 @@ static Int peek_byte_1(USES_REGS1) { /* at_end_of_stream */
 | 
			
		||||
  LOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
  if (!(GLOBAL_Stream[sno].status & Binary_Stream_f)) {
 | 
			
		||||
    UNLOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_INPUT_TEXT_STREAM, ARG1, "peek_byte/2");
 | 
			
		||||
    Yap_Error(PERMISSION_ERROR_INPUT_BINARY_STREAM, ARG1, "peek_byte/2");
 | 
			
		||||
    return (FALSE);
 | 
			
		||||
  }
 | 
			
		||||
  if ((ch = dopeek_byte(sno)) < 0) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1220,7 +1220,7 @@ static Int format(Term tout, Term tf, Term tas USES_REGS) {
 | 
			
		||||
    return false;
 | 
			
		||||
    UNLOCK(GLOBAL_Stream[output_stream].streamlock);
 | 
			
		||||
  } else {
 | 
			
		||||
    yhandle_t sls = Yap_CurrentSlot(PASS_REGS1);
 | 
			
		||||
    yhandle_t sls = Yap_CurrentSlot();
 | 
			
		||||
 | 
			
		||||
    out = doformat(tf, tas, output_stream PASS_REGS);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										30
									
								
								os/iopreds.c
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								os/iopreds.c
									
									
									
									
									
								
							@@ -647,19 +647,16 @@ int post_process_weof(StreamDesc *s) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * caled after EOF found a peek, it just calls console_post_process to conclude the job.
 | 
			
		||||
 * caled after EOF found a peek, it just calls console_post_process to conclude
 | 
			
		||||
 *the job.
 | 
			
		||||
 *
 | 
			
		||||
 * @param sno
 | 
			
		||||
 *
 | 
			
		||||
 * @return EOF
 | 
			
		||||
 */
 | 
			
		||||
int EOFPeek(int sno) {
 | 
			
		||||
  return EOFGetc( sno );
 | 
			
		||||
}
 | 
			
		||||
int EOFPeek(int sno) { return EOFGetc(sno); }
 | 
			
		||||
 | 
			
		||||
int EOFWPeek(int sno) {
 | 
			
		||||
  return EOFWGetc( sno );
 | 
			
		||||
}
 | 
			
		||||
int EOFWPeek(int sno) { return EOFWGetc(sno); }
 | 
			
		||||
 | 
			
		||||
/* standard routine, it should read from anything pointed by a FILE *.
 | 
			
		||||
 It could be made more efficient by doing our own buffering and avoiding
 | 
			
		||||
@@ -1383,10 +1380,8 @@ do_open(Term file_name, Term t2,
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  // BOM mess
 | 
			
		||||
  if ((encoding == ENC_OCTET ||
 | 
			
		||||
       encoding == ENC_ISO_ASCII ||
 | 
			
		||||
      encoding == ENC_ISO_LATIN1 ||
 | 
			
		||||
       encoding == ENC_ISO_UTF8 || bin))  {
 | 
			
		||||
  if ((encoding == ENC_OCTET || encoding == ENC_ISO_ASCII ||
 | 
			
		||||
       encoding == ENC_ISO_LATIN1 || encoding == ENC_ISO_UTF8 || bin)) {
 | 
			
		||||
    avoid_bom = true;
 | 
			
		||||
  }
 | 
			
		||||
  if (args[OPEN_BOM].used) {
 | 
			
		||||
@@ -1546,7 +1541,7 @@ static int CheckStream__(const char *file, const char *f, int line, Term arg,
 | 
			
		||||
    if (sname == AtomUser) {
 | 
			
		||||
      if (kind & Input_Stream_f) {
 | 
			
		||||
        if (kind & (Output_Stream_f | Append_Stream_f)) {
 | 
			
		||||
          PlIOError__(file, f, line, PERMISSION_ERROR_INPUT_STREAM, arg,
 | 
			
		||||
          PlIOError__(file, f, line, PERMISSION_ERROR_OUTPUT_STREAM, arg,
 | 
			
		||||
                      "ambiguous use of 'user' as a stream");
 | 
			
		||||
          return (-1);
 | 
			
		||||
        }
 | 
			
		||||
@@ -1581,12 +1576,12 @@ static int CheckStream__(const char *file, const char *f, int line, Term arg,
 | 
			
		||||
  if ((GLOBAL_Stream[sno].status & Input_Stream_f) &&
 | 
			
		||||
      !(kind & Input_Stream_f)) {
 | 
			
		||||
    UNLOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
    PlIOError__(file, f, line, PERMISSION_ERROR_INPUT_STREAM, arg, msg);
 | 
			
		||||
    PlIOError__(file, f, line, PERMISSION_ERROR_OUTPUT_STREAM, arg, msg);
 | 
			
		||||
  }
 | 
			
		||||
  if ((GLOBAL_Stream[sno].status & (Append_Stream_f | Output_Stream_f)) &&
 | 
			
		||||
      !(kind & Output_Stream_f)) {
 | 
			
		||||
    UNLOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
    PlIOError__(file, f, line, PERMISSION_ERROR_OUTPUT_STREAM, arg, msg);
 | 
			
		||||
    PlIOError__(file, f, line, PERMISSION_ERROR_INPUT_STREAM, arg, msg);
 | 
			
		||||
  }
 | 
			
		||||
  return (sno);
 | 
			
		||||
}
 | 
			
		||||
@@ -1602,7 +1597,12 @@ int Yap_CheckTextStream__(const char *file, const char *f, int line, Term arg,
 | 
			
		||||
  if ((sno = CheckStream__(file, f, line, arg, kind, msg)) < 0)
 | 
			
		||||
    return -1;
 | 
			
		||||
  if ((GLOBAL_Stream[sno].status & Binary_Stream_f)) {
 | 
			
		||||
    PlIOError__(file, f, line, PERMISSION_ERROR_INPUT_BINARY_STREAM, arg, msg);
 | 
			
		||||
    if (kind == Input_Stream_f)
 | 
			
		||||
      PlIOError__(file, f, line, PERMISSION_ERROR_INPUT_BINARY_STREAM, arg,
 | 
			
		||||
                  msg);
 | 
			
		||||
    else
 | 
			
		||||
      PlIOError__(file, f, line, PERMISSION_ERROR_OUTPUT_BINARY_STREAM, arg,
 | 
			
		||||
                  msg);
 | 
			
		||||
    UNLOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
    return -1;
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -400,6 +400,7 @@ static xarg *setReadEnv(Term opts, FEnv *fe, struct renv *re, int inp_stream) {
 | 
			
		||||
  if (args == NULL) {
 | 
			
		||||
    return NULL;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  re->bq = getBackQuotesFlag();
 | 
			
		||||
  if (args[READ_MODULE].used) {
 | 
			
		||||
    CurrentModule = args[READ_MODULE].tvalue;
 | 
			
		||||
@@ -456,7 +457,8 @@ static xarg *setReadEnv(Term opts, FEnv *fe, struct renv *re, int inp_stream) {
 | 
			
		||||
    re->prio = IntegerOfTerm(args[READ_PRIORITY].tvalue);
 | 
			
		||||
    if (re->prio > GLOBAL_MaxPriority) {
 | 
			
		||||
      Yap_Error(DOMAIN_ERROR_OPERATOR_PRIORITY, opts,
 | 
			
		||||
                "max priority in Prolog is %d, not %ld", GLOBAL_MaxPriority, re->prio);
 | 
			
		||||
                "max priority in Prolog is %d, not %ld", GLOBAL_MaxPriority,
 | 
			
		||||
                re->prio);
 | 
			
		||||
    }
 | 
			
		||||
  } else {
 | 
			
		||||
    re->prio = LOCAL_default_priority;
 | 
			
		||||
@@ -809,6 +811,16 @@ Term Yap_read_term(int inp_stream, Term opts, int nargs) {
 | 
			
		||||
      return fe.t;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  if (fe.t) {
 | 
			
		||||
    if (fe.reading_clause &&
 | 
			
		||||
        !complete_clause_processing(&fe, LOCAL_tokptr, fe.t))
 | 
			
		||||
      fe.t = 0;
 | 
			
		||||
    else if (!fe.reading_clause && !complete_processing(&fe, LOCAL_tokptr))
 | 
			
		||||
      fe.t = 0;
 | 
			
		||||
  }
 | 
			
		||||
#if EMACS
 | 
			
		||||
  first_char = tokstart->TokPos;
 | 
			
		||||
#endif /* EMACS */
 | 
			
		||||
  return fe.t;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -819,7 +831,7 @@ static Int
 | 
			
		||||
  if ((rc = Yap_read_term(LOCAL_c_input_stream, ARG2, 2)) == 0)
 | 
			
		||||
    return FALSE;
 | 
			
		||||
  Term tf = Yap_GetFromSlot(h);
 | 
			
		||||
  Yap_RecoverSlots(1, h PASS_REGS);
 | 
			
		||||
  Yap_RecoverSlots(1, h);
 | 
			
		||||
  return Yap_unify(tf, rc);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -837,7 +849,7 @@ static Int read_term(
 | 
			
		||||
  out = Yap_read_term(inp_stream, ARG3, 3);
 | 
			
		||||
  UNLOCK(GLOBAL_Stream[inp_stream].streamlock);
 | 
			
		||||
  Term tf = Yap_GetFromSlot(h);
 | 
			
		||||
  Yap_RecoverSlots(1, h PASS_REGS);
 | 
			
		||||
  Yap_RecoverSlots(1, h);
 | 
			
		||||
  return out != 0L && Yap_unify(tf, out);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -987,7 +999,7 @@ static Int read_clause2(USES_REGS1) {
 | 
			
		||||
  yhandle_t h = Yap_InitSlot(ARG1);
 | 
			
		||||
  rc = Yap_read_term(LOCAL_c_input_stream, Deref(ARG2), -2);
 | 
			
		||||
  Term tf = Yap_GetFromSlot(h);
 | 
			
		||||
  Yap_RecoverSlots(1, h PASS_REGS);
 | 
			
		||||
  Yap_RecoverSlots(1, h);
 | 
			
		||||
  return rc && Yap_unify(tf, rc);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1025,7 +1037,7 @@ static Int read_clause(
 | 
			
		||||
  out = Yap_read_term(inp_stream, t3, -3);
 | 
			
		||||
  UNLOCK(GLOBAL_Stream[inp_stream].streamlock);
 | 
			
		||||
  Term tf = Yap_GetFromSlot(h);
 | 
			
		||||
  Yap_RecoverSlots(1, h PASS_REGS);
 | 
			
		||||
  Yap_RecoverSlots(1, h);
 | 
			
		||||
  return out && Yap_unify(tf, out);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1181,7 +1193,7 @@ Term Yap_StringToTerm(const char *s, size_t len, encoding_t *encp, int prio,
 | 
			
		||||
    *bindings = Yap_GetFromSlot(sl);
 | 
			
		||||
  }
 | 
			
		||||
  if (bindings) {
 | 
			
		||||
    Yap_RecoverSlots(sl, 1 PASS_REGS);
 | 
			
		||||
    Yap_RecoverSlots(sl, 1);
 | 
			
		||||
  }
 | 
			
		||||
  return rval;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -241,7 +241,7 @@ read_stream_to_terms(USES_REGS1)
 | 
			
		||||
    RESET_VARIABLE(HR);
 | 
			
		||||
    RESET_VARIABLE(HR+1);
 | 
			
		||||
    hd = (CELL)HR;
 | 
			
		||||
    Yap_PutInSlot(news, (CELL)(HR+1) PASS_REGS);
 | 
			
		||||
    Yap_PutInSlot(news, (CELL)(HR+1));
 | 
			
		||||
    HR += 2;
 | 
			
		||||
    while ((hd=Yap_read_term(sno, TermNil, 2)) == 0L)
 | 
			
		||||
      ;
 | 
			
		||||
@@ -253,7 +253,7 @@ read_stream_to_terms(USES_REGS1)
 | 
			
		||||
    } else {
 | 
			
		||||
      CELL *newpt = (CELL*)Yap_GetFromSlot(news);
 | 
			
		||||
      *pt =AbsPair(newpt-1);
 | 
			
		||||
     Yap_PutInSlot(tails, (CELL)newpt PASS_REGS);
 | 
			
		||||
     Yap_PutInSlot(tails, (CELL)newpt);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  UNLOCK(GLOBAL_Stream[sno].streamlock);
 | 
			
		||||
 
 | 
			
		||||
@@ -718,8 +718,8 @@ void Yap_walltime_interval(Int *now,Int *interval)
 | 
			
		||||
  Yap_ReInitWTime (void)
 | 
			
		||||
  {
 | 
			
		||||
    Yap_InitWTime();
 | 
			
		||||
    if (Yap_global->LastWTimePtr_ != NULL)
 | 
			
		||||
      Yap_FreeCodeSpace(Yap_global->LastWTimePtr_);
 | 
			
		||||
    if (GLOBAL_LastWTimePtr != NULL)
 | 
			
		||||
      Yap_FreeCodeSpace(GLOBAL_LastWTimePtr);
 | 
			
		||||
    Yap_InitLastWTime();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								os/write.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								os/write.c
									
									
									
									
									
								
							@@ -102,7 +102,7 @@ static char SccsId[] = "%W% %G%";
 | 
			
		||||
int beam_write ( USES_REGS1 )
 | 
			
		||||
{
 | 
			
		||||
  Yap_StartSlots();
 | 
			
		||||
  Yap_plwrite (ARG1, GLOBAL_Stream+LOCAL_output_stream, 0, 0, 1200);
 | 
			
		||||
  Yap_plwrite (ARG1, GLOBAL_Stream+LOCAL_output_stream, 0, 0, GLOBAL_MaxPriority);
 | 
			
		||||
  Yap_CloseSlots();
 | 
			
		||||
  if (EX != 0L) {
 | 
			
		||||
    Term ball = Yap_PopTermFromDB(EX);
 | 
			
		||||
@@ -122,7 +122,7 @@ p_write ( USES_REGS1 )
 | 
			
		||||
  /* notice: we must have ASP well set when using portray, otherwise
 | 
			
		||||
     we cannot make recursive Prolog calls */
 | 
			
		||||
  yhandle_t mySlots = Yap_StartSlots();
 | 
			
		||||
  Yap_plwrite (ARG2, GLOBAL_Stream+LOCAL_output_stream, 0, flags, 1200);
 | 
			
		||||
  Yap_plwrite (ARG2, GLOBAL_Stream+LOCAL_output_stream, 0, flags, GLOBAL_MaxPriority);
 | 
			
		||||
  Yap_CloseSlots( mySlots );
 | 
			
		||||
  if (EX != 0L) {
 | 
			
		||||
    Term ball = Yap_PopTermFromDB(EX);
 | 
			
		||||
@@ -159,8 +159,7 @@ p_write2_prio ( USES_REGS1 )
 | 
			
		||||
  Int flags = IntegerOfTerm(Deref(ARG2));
 | 
			
		||||
  int stream_f;
 | 
			
		||||
 | 
			
		||||
  stream_f = Output_Stream_f;
 | 
			
		||||
  LOCAL_output_stream = CheckStream (ARG1, stream_f, "write/2");
 | 
			
		||||
  LOCAL_output_stream = CheckTextStream(ARG1, Output_Stream_f, "write/2");
 | 
			
		||||
  if (LOCAL_output_stream == -1) {
 | 
			
		||||
    LOCAL_output_stream = old_output_stream;
 | 
			
		||||
    return(FALSE);
 | 
			
		||||
@@ -185,7 +184,7 @@ static Int
 | 
			
		||||
p_write2 ( USES_REGS1 )
 | 
			
		||||
{				/* '$write'(+Stream,+Flags,?Term) */
 | 
			
		||||
  int old_output_stream = LOCAL_output_stream;
 | 
			
		||||
  LOCAL_output_stream = CheckStream (ARG1, Output_Stream_f, "write/2");
 | 
			
		||||
  LOCAL_output_stream = CheckTextStream(ARG1, Output_Stream_f, "write/2");
 | 
			
		||||
  if (LOCAL_output_stream == -1) {
 | 
			
		||||
    LOCAL_output_stream = old_output_stream;
 | 
			
		||||
    return(FALSE);
 | 
			
		||||
@@ -194,7 +193,7 @@ p_write2 ( USES_REGS1 )
 | 
			
		||||
  /* notice: we must have ASP well set when using portray, otherwise
 | 
			
		||||
     we cannot make recursive Prolog calls */
 | 
			
		||||
  yhandle_t myslots = Yap_StartSlots();
 | 
			
		||||
  Yap_plwrite (ARG3, GLOBAL_Stream+LOCAL_output_stream, 0, (int) IntOfTerm (Deref (ARG2)), 1200);
 | 
			
		||||
  Yap_plwrite (ARG3, GLOBAL_Stream+LOCAL_output_stream, 0, (int) IntOfTerm (Deref (ARG2)), GLOBAL_MaxPriority);
 | 
			
		||||
  Yap_CloseSlots(myslots);
 | 
			
		||||
  LOCAL_output_stream = old_output_stream;
 | 
			
		||||
  if (EX != 0L) {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										32
									
								
								os/yapio.h
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								os/yapio.h
									
									
									
									
									
								
							@@ -148,36 +148,8 @@ void Yap_init_socks(char *host, long interface_port);
 | 
			
		||||
extern int errno;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY EXTERN UInt inline HashFunction(const unsigned char *);
 | 
			
		||||
INLINE_ONLY EXTERN UInt inline WideHashFunction(wchar_t *);
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY EXTERN inline UInt HashFunction(const unsigned char *CHP) {
 | 
			
		||||
  /* djb2 */
 | 
			
		||||
  UInt hash = 5381;
 | 
			
		||||
  UInt c;
 | 
			
		||||
 | 
			
		||||
  while ((c = (UInt)(*CHP++)) != '\0') {
 | 
			
		||||
    /* hash = ((hash << 5) + hash) + c; hash * 33 + c */
 | 
			
		||||
    hash = hash * 33 ^ c;
 | 
			
		||||
  }
 | 
			
		||||
  return hash;
 | 
			
		||||
  /*
 | 
			
		||||
  UInt OUT=0, i = 1;
 | 
			
		||||
  while(*CHP != '\0') { OUT += (UInt)(*CHP++); }
 | 
			
		||||
  return OUT;
 | 
			
		||||
  */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY EXTERN UInt inline WideHashFunction(wchar_t *CHP) {
 | 
			
		||||
  UInt hash = 5381;
 | 
			
		||||
 | 
			
		||||
  UInt c;
 | 
			
		||||
 | 
			
		||||
  while ((c = *CHP++) != '\0') {
 | 
			
		||||
    hash = hash * 33 ^ c;
 | 
			
		||||
  }
 | 
			
		||||
  return hash;
 | 
			
		||||
}
 | 
			
		||||
uint64_t HashFunction(const unsigned char *);
 | 
			
		||||
uint64_t  WideHashFunction(wchar_t *);
 | 
			
		||||
 | 
			
		||||
INLINE_ONLY inline EXTERN Term MkCharTerm(Int c);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,7 @@
 | 
			
		||||
 | 
			
		||||
:- use_module(library(atts)).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
:- use_module(library(bhash)).
 | 
			
		||||
 | 
			
		||||
:- use_module(library(lists)).
 | 
			
		||||
@@ -33,7 +34,7 @@
 | 
			
		||||
 | 
			
		||||
:- attribute key/1, dist/2, evidence/1.
 | 
			
		||||
 | 
			
		||||
:- use_module('clpbn/ve',
 | 
			
		||||
:- use_module(clpbn/ve,
 | 
			
		||||
		[ve/3,
 | 
			
		||||
		 check_if_ve_done/1,
 | 
			
		||||
		 init_ve_solver/4,
 | 
			
		||||
@@ -198,7 +199,7 @@ clpbn_flag(parameter_softening,Before,After) :- !,
 | 
			
		||||
	retract(parameter_softening(Before)),
 | 
			
		||||
	assert(parameter_softening(After)).
 | 
			
		||||
 | 
			
		||||
clpbn_flag(use_factors,Before,After) :- !,
 | 
			
		||||
clpbn_flag(use_parfactors,Before,After) :- !,
 | 
			
		||||
	retract(use_parfactors(Before)),
 | 
			
		||||
	assert(use_parfactors(After)).
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -248,7 +248,7 @@ This option allows exporting the current model to the href{http://graphmod.ics.u
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
+ export_graphviz
 | 
			
		||||
This option allows exporting the factor graph's structure into a format that can be parsed by href{http://www.graphviz.org/}{Graphviz}.
 | 
			
		||||
This option allows exporting the factor graph's structure into a format that xocan be parsed by href{http://www.graphviz.org/}{Graphviz}.
 | 
			
		||||
  + Values: `true` or `false` (default).
 | 
			
		||||
  + Affects: `hve`, `bp`, and `cbp`.
 | 
			
		||||
 | 
			
		||||
@@ -362,7 +362,7 @@ The options that are available with the `set_pfl_flag/2` predicate can be used i
 | 
			
		||||
   ->
 | 
			
		||||
	% we're using factor language
 | 
			
		||||
	% set appropriate flag
 | 
			
		||||
	set_pfl_flag(use_factors,on)
 | 
			
		||||
	set_pfl_flag(use_parfactors,on)
 | 
			
		||||
   ;
 | 
			
		||||
	% we're within clp(bn), no need to do anything
 | 
			
		||||
	true
 | 
			
		||||
@@ -504,7 +504,11 @@ new_skolem(Sk, D) :-
 | 
			
		||||
	functor(Sk, N, A),
 | 
			
		||||
	functor(NSk, N, A),
 | 
			
		||||
	% [f,t] is special for evidence
 | 
			
		||||
	( D = [f,t] -> assert((evidence(NSk, 1) :- user:NSk)) ; true ),
 | 
			
		||||
	( D = [f,t] ->
 | 
			
		||||
      dynamic(N/A),
 | 
			
		||||
      assert((evidence(NSk, 1) :- user:NSk))
 | 
			
		||||
    ;
 | 
			
		||||
      true ),
 | 
			
		||||
	interface_predicate(NSk),
 | 
			
		||||
	assert(skolem(NSk, D)).
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -76,6 +76,7 @@ grounder_compute_reachable_atoms(A,ID,Success) :-
 | 
			
		||||
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
			
		||||
	( % go over all proofs for A in interpretation ID
 | 
			
		||||
      tabled_meta_interpreter(A,ID),
 | 
			
		||||
      writeln(A),
 | 
			
		||||
	 bb_put(dep_proven,true),
 | 
			
		||||
	  
 | 
			
		||||
	 fail; % go to next proof
 | 
			
		||||
@@ -100,6 +101,8 @@ grounder_compute_reachable_atoms(A,ID,Success) :-
 | 
			
		||||
%========================================================================
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
tabled_meta_interpreter(X,ID) :-
 | 
			
		||||
    writeln(ID:X), fail.
 | 
			
		||||
tabled_meta_interpreter((X,Y),ID) :-
 | 
			
		||||
	!,
 | 
			
		||||
	tabled_meta_interpreter(X,ID),
 | 
			
		||||
@@ -143,9 +146,9 @@ tabled_meta_interpreter(Atom,ID) :-
 | 
			
		||||
	% we can ignore probabilistic facts and only look for myclauses
 | 
			
		||||
	% since in ProbLog the requirement is that non-ground facts have to be 
 | 
			
		||||
	% ground at query time
 | 
			
		||||
 | 
			
		||||
	current_predicate(user:myclause/3),
 | 
			
		||||
	user:myclause(ID,Atom,Body),
 | 
			
		||||
    writeln(Atom:Body),
 | 
			
		||||
 | 
			
		||||
	tabled_meta_interpreter(Body,ID),
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -231,6 +231,7 @@
 | 
			
		||||
                   bb_put(logger_variables,[])
 | 
			
		||||
                  )).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
%========================================================================
 | 
			
		||||
%= Defines a new variable, possible types are: int, float and time
 | 
			
		||||
%=
 | 
			
		||||
 
 | 
			
		||||
@@ -53,7 +53,7 @@ myclause(calls(Person), (person(Person),alarm,hears_alarm(Person))).
 | 
			
		||||
 | 
			
		||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
			
		||||
%%%   Training examples    %
 | 
			
		||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
			
		||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%l
 | 
			
		||||
 | 
			
		||||
example(1).
 | 
			
		||||
example(2).
 | 
			
		||||
@@ -64,4 +64,3 @@ known(1,alarm,true).
 | 
			
		||||
%%%% Example 2
 | 
			
		||||
known(2,earthquake,false).
 | 
			
		||||
known(2,calls(mary),true).
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -689,10 +689,8 @@ create_test_query_cluster_list(L2) :-
 | 
			
		||||
	calc_all_md5(AllCluster,AllCluster2),
 | 
			
		||||
	findall(a(QueryID1,ClusterID1,Len),(bagof(a(QueryID,ClusterID),member(a(QueryID,ClusterID,_MD5),AllCluster2),L),nth1(1,L,a(QueryID1,ClusterID1)),length(L,Len)),L2),
 | 
			
		||||
	!,
 | 
			
		||||
 | 
			
		||||
	length(AllCluster,Len1),
 | 
			
		||||
	length(L2,Len2),
 | 
			
		||||
 | 
			
		||||
	(
 | 
			
		||||
	 Len1>0
 | 
			
		||||
	->
 | 
			
		||||
@@ -717,15 +715,12 @@ create_training_query_cluster_list(L2) :-
 | 
			
		||||
				      ), AllCluster),
 | 
			
		||||
 | 
			
		||||
	calc_all_md5(AllCluster,AllCluster2),
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	findall(a(QueryID1,ClusterID1,Len),
 | 
			
		||||
		(
 | 
			
		||||
		 bagof(a(QueryID,ClusterID),member(a(QueryID,ClusterID,_MD5),AllCluster2),L),
 | 
			
		||||
		 nth1(1,L,a(QueryID1,ClusterID1)),
 | 
			
		||||
		 length(L,Len)
 | 
			
		||||
		),L2),
 | 
			
		||||
 | 
			
		||||
	length(AllCluster,Len1),
 | 
			
		||||
	length(L2,Len2),
 | 
			
		||||
 | 
			
		||||
@@ -1186,6 +1181,3 @@ init_logger :-
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
%:- initialization(do_learning(100) ).
 | 
			
		||||
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -63,6 +63,7 @@ IF (CUDD_FOUND)
 | 
			
		||||
 | 
			
		||||
  add_subdirectory(simplecudd)
 | 
			
		||||
  add_subdirectory(simplecudd_lfi)
 | 
			
		||||
  set(YAP_SYSTEM_OPTIONS "cudd " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
 | 
			
		||||
 | 
			
		||||
  install(TARGETS  cudd
 | 
			
		||||
    LIBRARY DESTINATION ${dlls}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
/* Define to 1 if you have the <cuddInt.h> header file. */
 | 
			
		||||
#ifndef HAVE_CUDDINT_H
 | 
			
		||||
#define HAVE_CUDDINT_H 
 | 
			
		||||
/* #undef HAVE_CUDDINT_H */
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Define to 1 if you have the <cudd/cuddInt.h> header file. */
 | 
			
		||||
@@ -17,7 +17,7 @@
 | 
			
		||||
 | 
			
		||||
/*Define to 1 if you have the <cudd.h> header file. */
 | 
			
		||||
#ifndef HAVE_CUDD_H
 | 
			
		||||
#define HAVE_CUDD_H 
 | 
			
		||||
/* #undef HAVE_CUDD_H */
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Define to 1 if you have the <cudd/util.h> header file. */
 | 
			
		||||
 
 | 
			
		||||
@@ -254,7 +254,7 @@ int CharIn(const char c, const char *in) {
 | 
			
		||||
 | 
			
		||||
/* string handling */
 | 
			
		||||
 | 
			
		||||
int patternmatch(char *pattern, char *thestr) {
 | 
			
		||||
int patternmatch(const char *pattern, const char *thestr) {
 | 
			
		||||
  int i, j = -1, pl = strlen(pattern), sl = strlen(thestr);
 | 
			
		||||
  for(i = 0; i < pl; i++) {
 | 
			
		||||
    if (pattern[i] == '*') {
 | 
			
		||||
 
 | 
			
		||||
@@ -200,5 +200,5 @@ int IsRealNumber(char *c);
 | 
			
		||||
int IsNumber(const char *c);
 | 
			
		||||
char * freadstr(FILE *fd, const char *separators);
 | 
			
		||||
int CharIn(const char c, const char *in);
 | 
			
		||||
int patternmatch(char *pattern, char *thestr);
 | 
			
		||||
int patternmatch(const char *pattern, const char *thestr);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -241,7 +241,7 @@ double CalcExpectedCountsUp(extmanager * MyManager, DdNode *Current, char *query
 | 
			
		||||
double CalcExpectedCountsDown(extmanager * MyManager, DdNode *Current, char *query_id);
 | 
			
		||||
double CalcExpectedCounts(extmanager * MyManager, DdNode *Current, char *query_id, int calcdown_needed);
 | 
			
		||||
int patterncalculated(char *pattern, extmanager MyManager, int loc);
 | 
			
		||||
char * extractpattern(char *thestr);
 | 
			
		||||
char * extractpattern(const char *thestr);
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **arg) {
 | 
			
		||||
  extmanager MyManager;
 | 
			
		||||
@@ -476,7 +476,7 @@ int main(int argc, char **arg) {
 | 
			
		||||
      free(MyManager.varmap.dynvalue);
 | 
			
		||||
    }
 | 
			
		||||
    for (i = 0; i < MyManager.varmap.varcnt; i++)
 | 
			
		||||
      free(MyManager.varmap.vars[i]);
 | 
			
		||||
      free((const char *)MyManager.varmap.vars[i]);
 | 
			
		||||
    free(MyManager.varmap.vars);
 | 
			
		||||
  }
 | 
			
		||||
  if (params.error != NULL) free(params.error);
 | 
			
		||||
@@ -1168,7 +1168,7 @@ gradientpair CalcGradient(extmanager MyManager, DdNode *Current, int TargetVar,
 | 
			
		||||
  return tvalue;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char * extractpattern(char *thestr) {
 | 
			
		||||
char * extractpattern(const char *thestr) {
 | 
			
		||||
  char *p;
 | 
			
		||||
  int i = 0, sl = strlen(thestr);
 | 
			
		||||
  while((thestr[i] != '_') && (i < sl)) i++;
 | 
			
		||||
 
 | 
			
		||||
@@ -370,7 +370,7 @@ int CheckFileVersion(const char *version) {
 | 
			
		||||
  return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int simpleBDDtoDot(DdManager *manager, DdNode *bdd, char *filename) {
 | 
			
		||||
int simpleBDDtoDot(DdManager *manager, DdNode *bdd, const char *filename) {
 | 
			
		||||
  DdNode *f[1];
 | 
			
		||||
  int ret;
 | 
			
		||||
  FILE *fd;
 | 
			
		||||
@@ -385,8 +385,8 @@ int simpleBDDtoDot(DdManager *manager, DdNode *bdd, char *filename) {
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int simpleNamedBDDtoDot(DdManager *manager, const namedvars varmap, DdNode *bdd,
 | 
			
		||||
                        char *filename) {
 | 
			
		||||
int simpleNamedBDDtoDot(DdManager *manager, namedvars varmap, DdNode *bdd,
 | 
			
		||||
                        const char *filename) {
 | 
			
		||||
  DdNode *f[1];
 | 
			
		||||
  int ret;
 | 
			
		||||
  FILE *fd;
 | 
			
		||||
@@ -435,7 +435,7 @@ void SaveExpand(DdManager *manager, namedvars varmap, hisqueue *Nodes,
 | 
			
		||||
                DdNode *Current, FILE *outputfile) {
 | 
			
		||||
  DdNode *h, *l;
 | 
			
		||||
  hisnode *Found;
 | 
			
		||||
  char *curnode;
 | 
			
		||||
  const char *curnode;
 | 
			
		||||
  int inode;
 | 
			
		||||
  if (Current != HIGH(manager) && Current != LOW(manager)) {
 | 
			
		||||
    if ((Found = GetNode(Nodes, varmap.varstart, Current)) == NULL) {
 | 
			
		||||
@@ -917,7 +917,7 @@ namedvars InitNamedVars(int varcnt, int varstart) {
 | 
			
		||||
  int i;
 | 
			
		||||
  temp.varcnt = varcnt;
 | 
			
		||||
  temp.varstart = varstart;
 | 
			
		||||
  temp.vars = (char **)malloc(sizeof(char *) * varcnt);
 | 
			
		||||
  temp.vars = (const char **)malloc(sizeof(char *) * varcnt);
 | 
			
		||||
  temp.loaded = (int *)malloc(sizeof(int) * varcnt);
 | 
			
		||||
  temp.dvalue = (double *)malloc(sizeof(double) * varcnt);
 | 
			
		||||
  temp.ivalue = (int *)malloc(sizeof(int) * varcnt);
 | 
			
		||||
@@ -934,7 +934,7 @@ namedvars InitNamedVars(int varcnt, int varstart) {
 | 
			
		||||
 | 
			
		||||
void EnlargeNamedVars(namedvars *varmap, int newvarcnt) {
 | 
			
		||||
  int i;
 | 
			
		||||
  varmap->vars = (char **)realloc(varmap->vars, sizeof(char *) * newvarcnt);
 | 
			
		||||
  varmap->vars = (const char **)realloc(varmap->vars, sizeof(const char *) * newvarcnt);
 | 
			
		||||
  varmap->loaded = (int *)realloc(varmap->loaded, sizeof(int) * newvarcnt);
 | 
			
		||||
  varmap->dvalue =
 | 
			
		||||
      (double *)realloc(varmap->dvalue, sizeof(double) * newvarcnt);
 | 
			
		||||
@@ -954,7 +954,7 @@ void EnlargeNamedVars(namedvars *varmap, int newvarcnt) {
 | 
			
		||||
int AddNamedVarAt(namedvars varmap, const char *varname, int index) {
 | 
			
		||||
  if (varmap.varcnt > index) {
 | 
			
		||||
    varmap.vars[index] = (char *)malloc(sizeof(char) * (strlen(varname) + 1));
 | 
			
		||||
    strcpy(varmap.vars[index], varname);
 | 
			
		||||
    strcpy(varmap.vars[index], (char *)varname);
 | 
			
		||||
    return index;
 | 
			
		||||
  }
 | 
			
		||||
  return -1;
 | 
			
		||||
@@ -1010,7 +1010,7 @@ int GetNamedVarIndex(const namedvars varmap, const char *varname) {
 | 
			
		||||
  return -1 * varmap.varcnt;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char *GetNodeVarName(DdManager *manager, namedvars varmap, DdNode *node) {
 | 
			
		||||
const char *GetNodeVarName(DdManager *manager, namedvars varmap, DdNode *node) {
 | 
			
		||||
  if (node == NULL)
 | 
			
		||||
    return NULL;
 | 
			
		||||
  if (node == HIGH(manager))
 | 
			
		||||
@@ -1020,7 +1020,7 @@ char *GetNodeVarName(DdManager *manager, namedvars varmap, DdNode *node) {
 | 
			
		||||
  return varmap.vars[GetIndex(node) - varmap.varstart];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char *GetNodeVarNameDisp(DdManager *manager, namedvars varmap, DdNode *node) {
 | 
			
		||||
const char *GetNodeVarNameDisp(DdManager *manager, namedvars varmap, DdNode *node) {
 | 
			
		||||
  if (HIGH(manager) == node)
 | 
			
		||||
    return "TRUE";
 | 
			
		||||
  if (LOW(manager) == node)
 | 
			
		||||
 
 | 
			
		||||
@@ -249,7 +249,7 @@ typedef struct _bddfileheader {
 | 
			
		||||
typedef struct _namedvars {
 | 
			
		||||
  int varcnt;
 | 
			
		||||
  int varstart;
 | 
			
		||||
  char **vars;
 | 
			
		||||
  const char ** vars;
 | 
			
		||||
  int *loaded;
 | 
			
		||||
  double *dvalue;
 | 
			
		||||
  int *ivalue;
 | 
			
		||||
@@ -317,8 +317,8 @@ void SetNamedVarValuesAt(namedvars varmap, int index, double dvalue, int ivalue,
 | 
			
		||||
int SetNamedVarValues(namedvars varmap, const char *varname, double dvalue, int ivalue, void *dynvalue);
 | 
			
		||||
int GetNamedVarIndex(const namedvars varmap, const char *varname);
 | 
			
		||||
int RepairVarcnt(namedvars *varmap);
 | 
			
		||||
char* GetNodeVarName(DdManager *manager, namedvars varmap, DdNode *node);
 | 
			
		||||
char* GetNodeVarNameDisp(DdManager *manager, namedvars varmap, DdNode *node);
 | 
			
		||||
const char* GetNodeVarName(DdManager *manager, namedvars varmap, DdNode *node);
 | 
			
		||||
const char* GetNodeVarNameDisp(DdManager *manager, namedvars varmap, DdNode *node);
 | 
			
		||||
int all_loaded(namedvars varmap, int disp);
 | 
			
		||||
int all_loaded_for_deterministic_variables(namedvars varmap, int disp);
 | 
			
		||||
 | 
			
		||||
@@ -351,6 +351,6 @@ void ExpandNodes(hisqueue *Nodes, int index, int nodenum);
 | 
			
		||||
 | 
			
		||||
/* Export */
 | 
			
		||||
 | 
			
		||||
int simpleBDDtoDot(DdManager *manager, DdNode *bdd, char *filename);
 | 
			
		||||
int simpleNamedBDDtoDot(DdManager *manager, namedvars varmap, DdNode *bdd, char *filename);
 | 
			
		||||
int simpleBDDtoDot(DdManager *manager, DdNode *bdd, const char *filename);
 | 
			
		||||
int simpleNamedBDDtoDot(DdManager *manager, namedvars varmap, DdNode *bdd, const char *filename);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							@@ -22,7 +22,6 @@
 | 
			
		||||
 | 
			
		||||
:-set_clpbn_flag(bnt_model,propositional).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* start of list of parameters that can be set by the user with
 | 
			
		||||
set(Parameter,Value) */
 | 
			
		||||
setting(epsilon_parsing,0.00001).
 | 
			
		||||
 
 | 
			
		||||
@@ -56,6 +56,8 @@ if (Java_Development_FOUND)
 | 
			
		||||
  set_target_properties(jplYap PROPERTIES
 | 
			
		||||
    OUTPUT_NAME jpl )
 | 
			
		||||
 | 
			
		||||
    set(YAP_SYSTEM_OPTIONS "jpl " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
 | 
			
		||||
 | 
			
		||||
  install(TARGETS  jplYap
 | 
			
		||||
    LIBRARY DESTINATION ${dlls}
 | 
			
		||||
    )
 | 
			
		||||
 
 | 
			
		||||
@@ -81,14 +81,14 @@
 | 
			
		||||
	    jpl_set_element/2
 | 
			
		||||
	  ]).
 | 
			
		||||
 | 
			
		||||
:- expects_dialect(swi).
 | 
			
		||||
%:- expects_dialect(swi).
 | 
			
		||||
 | 
			
		||||
:- use_module(library(lists)).
 | 
			
		||||
:- use_module(library(apply)).
 | 
			
		||||
:- use_module(library(shlib)).
 | 
			
		||||
 | 
			
		||||
% suppress debugging this library
 | 
			
		||||
:- set_prolog_flag(generate_debug_info, false).
 | 
			
		||||
%:- set_prolog_flag(generate_debug_info, false).
 | 
			
		||||
 | 
			
		||||
%------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -81,8 +81,6 @@
 | 
			
		||||
	    jpl_set_element/2
 | 
			
		||||
	  ]).
 | 
			
		||||
 | 
			
		||||
:- expects_dialect(swi).
 | 
			
		||||
 | 
			
		||||
:- use_module(library(lists)).
 | 
			
		||||
:- use_module(library(apply)).
 | 
			
		||||
:- use_module(library(shlib)).
 | 
			
		||||
@@ -157,6 +155,8 @@ jpl_tidy_iref_type_cache( Iref) :-
 | 
			
		||||
%
 | 
			
		||||
%   finally, an attempt will be made to unify Result with the returned result
 | 
			
		||||
 | 
			
		||||
:- stop_low_level_trace.
 | 
			
		||||
 | 
			
		||||
jpl_call(X, Mspec, Params, R) :-
 | 
			
		||||
	(   jpl_object_to_type(X, Type)         % the usual case (goal fails safely if X is var or rubbish)
 | 
			
		||||
	->  Obj = X,
 | 
			
		||||
 
 | 
			
		||||
@@ -1,79 +0,0 @@
 | 
			
		||||
/* MYDDAS */
 | 
			
		||||
 | 
			
		||||
#ifdef USE_MYDDAS
 | 
			
		||||
 | 
			
		||||
/* myddas_initialization.c */
 | 
			
		||||
MYDDAS_GLOBAL          myddas_init_initialize_myddas(void);
 | 
			
		||||
MYDDAS_UTIL_CONNECTION myddas_init_initialize_connection(void *,void *,MYDDAS_API,MYDDAS_UTIL_CONNECTION);
 | 
			
		||||
MYDDAS_UTIL_PREDICATE  myddas_init_initialize_predicate(char *, int, char *,MYDDAS_UTIL_PREDICATE);
 | 
			
		||||
 | 
			
		||||
#ifdef MYDDAS_STATS
 | 
			
		||||
/* myddas_statistics.c */
 | 
			
		||||
MYDDAS_GLOBAL          myddas_stats_initialize_global_stats(MYDDAS_GLOBAL);
 | 
			
		||||
MYDDAS_STATS_STRUCT    myddas_stats_initialize_connection_stats(void);
 | 
			
		||||
void                   myddas_stats_delete_stats_list(MYDDAS_STATS_STRUCT);
 | 
			
		||||
#endif /* MYDDAS_STATS */
 | 
			
		||||
 | 
			
		||||
#ifdef MYDDAS_MYSQL
 | 
			
		||||
/* myddas_util.c */
 | 
			
		||||
void                   myddas_util_table_write(MYSQL_RES *);
 | 
			
		||||
#endif
 | 
			
		||||
MYDDAS_API             myddas_util_connection_type(void *);
 | 
			
		||||
MYDDAS_UTIL_CONNECTION myddas_util_add_connection(void *,void *,MYDDAS_API);
 | 
			
		||||
MYDDAS_UTIL_CONNECTION myddas_util_search_connection(void *);
 | 
			
		||||
void                   myddas_util_delete_connection(void *);
 | 
			
		||||
MYDDAS_UTIL_CONNECTION myddas_util_add_predicate(char * ,Int , char *,void *);
 | 
			
		||||
MYDDAS_UTIL_PREDICATE  myddas_util_search_predicate(char * ,Int , char *);
 | 
			
		||||
void                   myddas_util_delete_predicate(MYDDAS_UTIL_PREDICATE);
 | 
			
		||||
 | 
			
		||||
/* Get's the number of queries to save */
 | 
			
		||||
UInt                   myddas_util_get_total_multi_queries_number(MYDDAS_UTIL_CONNECTION);
 | 
			
		||||
void                   myddas_util_set_total_multi_queries_number(MYDDAS_UTIL_CONNECTION,UInt);
 | 
			
		||||
#ifdef MYDDAS_ODBC
 | 
			
		||||
/* Return enviromment identifier*/
 | 
			
		||||
SQLHENV                myddas_util_get_odbc_enviromment(SQLHDBC);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void *                 myddas_util_get_list_pred(MYDDAS_UTIL_CONNECTION);
 | 
			
		||||
void *                 myddas_util_get_pred_next(void *);
 | 
			
		||||
char *                 myddas_util_get_pred_module(void *);
 | 
			
		||||
char *                 myddas_util_get_pred_name(void *);
 | 
			
		||||
MyddasInt              myddas_util_get_pred_arity(void *);
 | 
			
		||||
//DELETE THIS WHEN DB_STATS  IS COMPLETED
 | 
			
		||||
MyddasInt              get_myddas_top(void);
 | 
			
		||||
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
void check_int(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* MYDDAS_MYSQL || MYDDAS_ODBC */
 | 
			
		||||
 | 
			
		||||
/* myddas_mysql.c */
 | 
			
		||||
#if defined MYDDAS_MYSQL
 | 
			
		||||
void    Yap_InitMYDDAS_MySQLPreds(void);
 | 
			
		||||
void    Yap_InitBackMYDDAS_MySQLPreds(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* myddas_odbc.c */
 | 
			
		||||
#if defined MYDDAS_ODBC
 | 
			
		||||
void    Yap_InitMYDDAS_ODBCPreds(void);
 | 
			
		||||
void    Yap_InitBackMYDDAS_ODBCPreds(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* myddas_odbc.c */
 | 
			
		||||
#if defined MYDDAS_SQLITE3
 | 
			
		||||
void    Yap_InitMYDDAS_SQLITE3Preds(void);
 | 
			
		||||
void    Yap_InitBackMYDDAS_SQLITE3Preds(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Myddas_shared.c */
 | 
			
		||||
#if defined USE_MYDDAS
 | 
			
		||||
void    Yap_MYDDAS_delete_all_myddas_structs(void);
 | 
			
		||||
void    Yap_InitMYDDAS_SharedPreds(void);
 | 
			
		||||
void    Yap_InitBackMYDDAS_SharedPreds(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* myddas_top_level.c */
 | 
			
		||||
#if defined MYDDAS_TOP_LEVEL && defined MYDDAS_MYSQL //&& defined HAVE_LIBREADLINE
 | 
			
		||||
void    Yap_InitMYDDAS_TopLevelPreds(void);
 | 
			
		||||
#endif
 | 
			
		||||
@@ -13,7 +13,7 @@ set( MYDDAS_SOURCES
 | 
			
		||||
  myddas_shared.c
 | 
			
		||||
  myddas_statistics.c
 | 
			
		||||
  myddas_top_level.c
 | 
			
		||||
  myddas_wkb2prolog.c )
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
set( MYDDAS_HEADERS
 | 
			
		||||
  myddas.h
 | 
			
		||||
@@ -21,8 +21,7 @@ set( MYDDAS_HEADERS
 | 
			
		||||
  myddas_statistics_structs.h
 | 
			
		||||
  myddas_structs.h
 | 
			
		||||
  myddas_top_level.c
 | 
			
		||||
  myddas_types.h
 | 
			
		||||
  myddas_wkb2prolog.c )
 | 
			
		||||
  myddas_types.h )
 | 
			
		||||
 | 
			
		||||
set( MYDDAS_UTIL_SOURCES
 | 
			
		||||
  myddas_util.c
 | 
			
		||||
 
 | 
			
		||||
@@ -4,8 +4,12 @@
 | 
			
		||||
 | 
			
		||||
/* myddas_initialization.c */
 | 
			
		||||
MYDDAS_GLOBAL myddas_init_initialize_myddas(void);
 | 
			
		||||
MYDDAS_UTIL_CONNECTION myddas_init_initialize_connection(void *,void *,MYDDAS_API,MYDDAS_UTIL_CONNECTION);
 | 
			
		||||
MYDDAS_UTIL_PREDICATE  myddas_init_initialize_predicate(const char *, int, const char *,MYDDAS_UTIL_PREDICATE);
 | 
			
		||||
MYDDAS_UTIL_CONNECTION
 | 
			
		||||
myddas_init_initialize_connection(void *, void *, MYDDAS_API,
 | 
			
		||||
                                  MYDDAS_UTIL_CONNECTION);
 | 
			
		||||
MYDDAS_UTIL_PREDICATE myddas_init_initialize_predicate(const char *, int,
 | 
			
		||||
                                                       const char *,
 | 
			
		||||
                                                       MYDDAS_UTIL_PREDICATE);
 | 
			
		||||
 | 
			
		||||
#ifdef MYDDAS_STATS
 | 
			
		||||
/* myddas_statistics.c */
 | 
			
		||||
@@ -18,21 +22,19 @@ void                   myddas_stats_delete_stats_list(MYDDAS_STATS_STRUCT);
 | 
			
		||||
/* myddas_util.c */
 | 
			
		||||
void myddas_util_table_write(MYSQL_RES *);
 | 
			
		||||
#endif
 | 
			
		||||
Short                  myddas_util_connection_type(void *);
 | 
			
		||||
MYDDAS_UTIL_CONNECTION myddas_util_search_connection(void *con);
 | 
			
		||||
MYDDAS_UTIL_CONNECTION myddas_util_add_connection(void *, void *, MYDDAS_API);
 | 
			
		||||
MYDDAS_UTIL_CONNECTION myddas_util_search_connection(void *);
 | 
			
		||||
void myddas_util_delete_connection(void *);
 | 
			
		||||
MYDDAS_UTIL_CONNECTION myddas_util_add_predicate(const char * ,Int , const char *,void *);
 | 
			
		||||
MYDDAS_UTIL_PREDICATE  myddas_util_search_predicate(const char * ,Int , const char *);
 | 
			
		||||
MYDDAS_UTIL_CONNECTION myddas_util_add_predicate(const char *, Int,
 | 
			
		||||
                                                 const char *, void *);
 | 
			
		||||
MYDDAS_UTIL_PREDICATE myddas_util_search_predicate(const char *, Int,
 | 
			
		||||
                                                   const char *);
 | 
			
		||||
void myddas_util_delete_predicate(MYDDAS_UTIL_PREDICATE);
 | 
			
		||||
 | 
			
		||||
/* Get's the number of queries to save */
 | 
			
		||||
UInt myddas_util_get_total_multi_queries_number(MYDDAS_UTIL_CONNECTION);
 | 
			
		||||
void myddas_util_set_total_multi_queries_number(MYDDAS_UTIL_CONNECTION, UInt);
 | 
			
		||||
#ifdef MYDDAS_ODBC
 | 
			
		||||
/* Return enviromment identifier*/
 | 
			
		||||
SQLHENV                myddas_util_get_odbc_enviromment(SQLHDBC);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void *myddas_util_get_list_pred(MYDDAS_UTIL_CONNECTION);
 | 
			
		||||
void *myddas_util_get_pred_next(void *);
 | 
			
		||||
@@ -74,6 +76,7 @@ void    Yap_InitBackMYDDAS_SharedPreds(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* myddas_top_level.c */
 | 
			
		||||
#if defined MYDDAS_TOP_LEVEL && defined MYDDAS_MYSQL //&& defined HAVE_LIBREADLINE
 | 
			
		||||
#if defined MYDDAS_TOP_LEVEL &&                                                \
 | 
			
		||||
    defined MYDDAS_MYSQL //&& defined HAVE_LIBREADLINE
 | 
			
		||||
void Yap_InitMYDDAS_TopLevelPreds(void);
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,8 @@ myddas_init_initialize_myddas(void){
 | 
			
		||||
  global->myddas_top_level_connection = NULL;
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef MYDDAS_STATS
 | 
			
		||||
  global->myddas_statistics = (MYDDAS_GLOBAL_STATS) malloc (sizeof(struct myddas_global_stats));
 | 
			
		||||
  global->myddas_statistics =
 | 
			
		||||
      (MYDDAS_GLOBAL_STATS)malloc(sizeof(struct myddas_global_stats));
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
  printf("MALLOC %p %s %d\n", global->myddas_statistics, __FILE__, __LINE__);
 | 
			
		||||
#endif
 | 
			
		||||
@@ -36,7 +37,8 @@ myddas_init_initialize_myddas(void){
 | 
			
		||||
/* We first malloc for this struct and the stats struct */
 | 
			
		||||
#ifdef MYDDAS_STATS
 | 
			
		||||
  global->malloc_called = 2;
 | 
			
		||||
  global->memory_allocated = sizeof(struct myddas_global) + sizeof(struct myddas_global_stats);
 | 
			
		||||
  global->memory_allocated =
 | 
			
		||||
      sizeof(struct myddas_global) + sizeof(struct myddas_global_stats);
 | 
			
		||||
#else
 | 
			
		||||
  global->malloc_called = 1;
 | 
			
		||||
  global->memory_allocated = sizeof(struct myddas_global);
 | 
			
		||||
@@ -50,15 +52,13 @@ myddas_init_initialize_myddas(void){
 | 
			
		||||
 | 
			
		||||
/* Inserts the new node on the front of the list */
 | 
			
		||||
MYDDAS_UTIL_CONNECTION
 | 
			
		||||
myddas_init_initialize_connection(void *conn,void *enviromment,
 | 
			
		||||
				  MYDDAS_API api,
 | 
			
		||||
myddas_init_initialize_connection(void *conn, void *enviromment, MYDDAS_API api,
 | 
			
		||||
                                  MYDDAS_UTIL_CONNECTION next) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  MYDDAS_UTIL_CONNECTION new = NULL;
 | 
			
		||||
  MYDDAS_MALLOC(new, struct myddas_list_connection);
 | 
			
		||||
 | 
			
		||||
  if (new == NULL)
 | 
			
		||||
    {
 | 
			
		||||
  if (new == NULL) {
 | 
			
		||||
    return NULL;
 | 
			
		||||
  }
 | 
			
		||||
  new->api = api;
 | 
			
		||||
@@ -88,13 +88,13 @@ myddas_init_initialize_connection(void *conn,void *enviromment,
 | 
			
		||||
 | 
			
		||||
MYDDAS_UTIL_PREDICATE
 | 
			
		||||
myddas_init_initialize_predicate(const char *pred_name, int pred_arity,
 | 
			
		||||
				 const char *pred_module, MYDDAS_UTIL_PREDICATE next){
 | 
			
		||||
                                 const char *pred_module,
 | 
			
		||||
                                 MYDDAS_UTIL_PREDICATE next) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  MYDDAS_UTIL_PREDICATE new = NULL;
 | 
			
		||||
  MYDDAS_MALLOC(new, struct myddas_list_preds);
 | 
			
		||||
 | 
			
		||||
  if (new == NULL)
 | 
			
		||||
    {
 | 
			
		||||
  if (new == NULL) {
 | 
			
		||||
    return NULL;
 | 
			
		||||
  }
 | 
			
		||||
  new->pred_name = pred_name;
 | 
			
		||||
 
 | 
			
		||||
@@ -706,9 +706,6 @@ void
 | 
			
		||||
init_myddas(void)
 | 
			
		||||
{
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
#if defined MYDDAS_MYSQL
 | 
			
		||||
  Yap_InitBackMYDDAS_MySQLPreds();
 | 
			
		||||
#endif
 | 
			
		||||
#if defined MYDDAS_ODBC
 | 
			
		||||
  Yap_InitBackMYDDAS_ODBCPreds();
 | 
			
		||||
#endif
 | 
			
		||||
@@ -733,21 +730,6 @@ init_myddas(void)
 | 
			
		||||
#if defined MYDDAS_TOP_LEVEL && defined MYDDAS_MYSQL // && defined HAVE_LIBREADLINE
 | 
			
		||||
  Yap_InitMYDDAS_TopLevelPreds();
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef MYDDAS_MYSQL_INIT
 | 
			
		||||
  if (yap_init->myddas) {
 | 
			
		||||
    Yap_PutValue(AtomMyddasGoal,MkIntegerTerm(yap_init->myddas));
 | 
			
		||||
 | 
			
		||||
    /* Mandatory Fields */
 | 
			
		||||
    Yap_PutValue(AtomMyddasUser,MkAtomTerm(Yap_LookupAtom(yap_init->myddas_user)));
 | 
			
		||||
    Yap_PutValue(AtomMyddasDB,MkAtomTerm(Yap_LookupAtom(yap_init->myddas_db)));
 | 
			
		||||
 | 
			
		||||
    /* Non-Mandatory Fields */
 | 
			
		||||
    if (yap_init->myddas_pass != NULL)
 | 
			
		||||
      Yap_PutValue(AtomMyddasPass,MkAtomTerm(Yap_LookupAtom(yap_init->myddas_pass)));
 | 
			
		||||
    if (yap_init->myddas_host != NULL)
 | 
			
		||||
      Yap_PutValue(AtomMyddasHost,MkAtomTerm(Yap_LookupAtom(yap_init->myddas_host)));
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
#if USE_MYDDAS
 | 
			
		||||
#define stringify(X) _stringify(X)
 | 
			
		||||
#define _stringify(X) #X
 | 
			
		||||
 
 | 
			
		||||
@@ -12,21 +12,13 @@
 | 
			
		||||
#include <mysql/mysql.h>
 | 
			
		||||
#endif /*MYDDAS_MYSQL*/
 | 
			
		||||
 | 
			
		||||
#include "myddas.h"
 | 
			
		||||
#include "myddas_util.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef MYDDAS_MYSQL
 | 
			
		||||
/* Auxilary function to table_write*/
 | 
			
		||||
static void
 | 
			
		||||
n_print(Int , char );
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Type: MYSQL->1 ODBC->2*/
 | 
			
		||||
Short
 | 
			
		||||
myddas_util_connection_type(void *con){
 | 
			
		||||
Short myddas_util_connection_type(void *con) {
 | 
			
		||||
 | 
			
		||||
  MYDDAS_UTIL_CONNECTION con_node =
 | 
			
		||||
    myddas_util_search_connection(con);
 | 
			
		||||
  MYDDAS_UTIL_CONNECTION con_node = myddas_util_search_connection(con);
 | 
			
		||||
 | 
			
		||||
  if (con_node == NULL)
 | 
			
		||||
    return 0;
 | 
			
		||||
@@ -38,17 +30,17 @@ myddas_util_connection_type(void *con){
 | 
			
		||||
  //  return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
MYDDAS_UTIL_PREDICATE
 | 
			
		||||
myddas_util_search_predicate(const char *pred_name, Int pred_arity,
 | 
			
		||||
                             const char *pred_module) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  MYDDAS_UTIL_PREDICATE pred = NULL;
 | 
			
		||||
  MYDDAS_UTIL_CONNECTION top = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
 | 
			
		||||
  MYDDAS_UTIL_CONNECTION top =
 | 
			
		||||
      Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
 | 
			
		||||
 | 
			
		||||
  for (;top!=NULL;top=top->next)
 | 
			
		||||
    {
 | 
			
		||||
      if ((pred=myddas_util_find_predicate(pred_name,pred_arity,pred_module,top->predicates)))
 | 
			
		||||
  for (; top != NULL; top = top->next) {
 | 
			
		||||
    if ((pred = myddas_util_find_predicate(pred_name, pred_arity, pred_module,
 | 
			
		||||
                                           top->predicates)))
 | 
			
		||||
      return pred;
 | 
			
		||||
  }
 | 
			
		||||
  return NULL;
 | 
			
		||||
@@ -60,15 +52,14 @@ MYDDAS_UTIL_CONNECTION
 | 
			
		||||
myddas_util_add_predicate(const char *pred_name, Int pred_arity,
 | 
			
		||||
                          const char *pred_module, void *con) {
 | 
			
		||||
 | 
			
		||||
  MYDDAS_UTIL_CONNECTION node_con = 
 | 
			
		||||
    myddas_util_search_connection(con);
 | 
			
		||||
  MYDDAS_UTIL_CONNECTION node_con = myddas_util_search_connection(con);
 | 
			
		||||
 | 
			
		||||
  MYDDAS_UTIL_PREDICATE new = 
 | 
			
		||||
    myddas_init_initialize_predicate(pred_name,pred_arity,pred_module,node_con->predicates);
 | 
			
		||||
  MYDDAS_UTIL_PREDICATE new = myddas_init_initialize_predicate(
 | 
			
		||||
      pred_name, pred_arity, pred_module, node_con->predicates);
 | 
			
		||||
 | 
			
		||||
  if (new == NULL)
 | 
			
		||||
    {
 | 
			
		||||
      myddas_util_error_message("Could not initialize predicate node",__LINE__,__FILE__);
 | 
			
		||||
  if (new == NULL) {
 | 
			
		||||
    myddas_util_error_message("Could not initialize predicate node", __LINE__,
 | 
			
		||||
                              __FILE__);
 | 
			
		||||
    return NULL;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -76,8 +67,7 @@ myddas_util_add_predicate(const char *pred_name, Int pred_arity,
 | 
			
		||||
  return node_con;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
myddas_util_delete_predicate(MYDDAS_UTIL_PREDICATE to_delete){
 | 
			
		||||
void myddas_util_delete_predicate(MYDDAS_UTIL_PREDICATE to_delete) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  if (to_delete->next != NULL)
 | 
			
		||||
    to_delete->next->previous = to_delete->previous;
 | 
			
		||||
@@ -85,7 +75,8 @@ myddas_util_delete_predicate(MYDDAS_UTIL_PREDICATE to_delete){
 | 
			
		||||
    to_delete->previous->next = to_delete->next;
 | 
			
		||||
  else // First predicate of the predicate list
 | 
			
		||||
  {
 | 
			
		||||
      MYDDAS_UTIL_CONNECTION con_node = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
 | 
			
		||||
    MYDDAS_UTIL_CONNECTION con_node =
 | 
			
		||||
        Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
 | 
			
		||||
    for (; con_node != NULL; con_node = con_node->next)
 | 
			
		||||
      if (con_node->predicates == to_delete)
 | 
			
		||||
        break;
 | 
			
		||||
@@ -94,15 +85,13 @@ myddas_util_delete_predicate(MYDDAS_UTIL_PREDICATE to_delete){
 | 
			
		||||
  MYDDAS_FREE(to_delete, struct myddas_list_preds);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void 
 | 
			
		||||
myddas_util_delete_connection(void *conn){
 | 
			
		||||
void myddas_util_delete_connection(void *conn) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  MYDDAS_UTIL_CONNECTION to_delete = myddas_util_search_connection(conn);
 | 
			
		||||
 | 
			
		||||
  if (to_delete == NULL)
 | 
			
		||||
    return;
 | 
			
		||||
  else
 | 
			
		||||
    {
 | 
			
		||||
  else {
 | 
			
		||||
    /* Removes the predicates list */
 | 
			
		||||
    myddas_util_delete_predicate_list(to_delete->predicates);
 | 
			
		||||
 | 
			
		||||
@@ -129,7 +118,8 @@ myddas_util_delete_connection(void *conn){
 | 
			
		||||
MYDDAS_UTIL_CONNECTION
 | 
			
		||||
myddas_util_search_connection(void *conn) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  MYDDAS_UTIL_CONNECTION list = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
 | 
			
		||||
  MYDDAS_UTIL_CONNECTION list =
 | 
			
		||||
      Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
 | 
			
		||||
 | 
			
		||||
#ifdef MYDDAS_STATS
 | 
			
		||||
  if (conn == 0) { /* We want all the statistics */
 | 
			
		||||
@@ -149,16 +139,17 @@ myddas_util_add_connection(void *conn, void *enviromment, MYDDAS_API api){
 | 
			
		||||
  MYDDAS_UTIL_CONNECTION node = NULL;
 | 
			
		||||
  MYDDAS_UTIL_CONNECTION temp = NULL;
 | 
			
		||||
 | 
			
		||||
  if ((node = myddas_util_search_connection(conn)) != NULL)
 | 
			
		||||
    {
 | 
			
		||||
  if ((node = myddas_util_search_connection(conn)) != NULL) {
 | 
			
		||||
    return node;
 | 
			
		||||
  }
 | 
			
		||||
  // put the new connection node on the top of the list
 | 
			
		||||
  temp = myddas_init_initialize_connection(conn,enviromment,api,Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections);
 | 
			
		||||
  if (temp == NULL)
 | 
			
		||||
    {
 | 
			
		||||
  temp = myddas_init_initialize_connection(
 | 
			
		||||
      conn, enviromment, api,
 | 
			
		||||
      Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections);
 | 
			
		||||
  if (temp == NULL) {
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
      myddas_util_error_message("Could not initialize connection node",__LINE__,__FILE__);
 | 
			
		||||
    myddas_util_error_message("Could not initialize connection node", __LINE__,
 | 
			
		||||
                              __FILE__);
 | 
			
		||||
#endif
 | 
			
		||||
    return NULL;
 | 
			
		||||
  }
 | 
			
		||||
@@ -166,40 +157,20 @@ myddas_util_add_connection(void *conn, void *enviromment, MYDDAS_API api){
 | 
			
		||||
  return Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef MYDDAS_ODBC
 | 
			
		||||
/* This function searches the MYDDAS list for odbc connections 
 | 
			
		||||
 If there isn't any, it returns NULL. This is a nice way to know 
 | 
			
		||||
 if there is any odbc connections left on the list*/
 | 
			
		||||
SQLHENV
 | 
			
		||||
myddas_util_get_odbc_enviromment(SQLHDBC connection){
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  MYDDAS_UTIL_CONNECTION top = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
 | 
			
		||||
  
 | 
			
		||||
  for (;top != NULL;top=top->next)
 | 
			
		||||
    if (top->connection == ((void *)connection))
 | 
			
		||||
      return top->odbc_enviromment;
 | 
			
		||||
  
 | 
			
		||||
  return NULL;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
UInt
 | 
			
		||||
myddas_util_get_total_multi_queries_number(MYDDAS_UTIL_CONNECTION con){
 | 
			
		||||
UInt myddas_util_get_total_multi_queries_number(MYDDAS_UTIL_CONNECTION con) {
 | 
			
		||||
  return con->total_number_queries;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
myddas_util_set_total_multi_queries_number(MYDDAS_UTIL_CONNECTION con,
 | 
			
		||||
void myddas_util_set_total_multi_queries_number(MYDDAS_UTIL_CONNECTION con,
 | 
			
		||||
                                                UInt number) {
 | 
			
		||||
  con->total_number_queries = number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef MYDDAS_MYSQL
 | 
			
		||||
/* Auxilary function to table_write*/
 | 
			
		||||
static void
 | 
			
		||||
n_print(Int n, char c)
 | 
			
		||||
{
 | 
			
		||||
  for(;n>0;n--) printf("%c",c);
 | 
			
		||||
static void n_print(Int n, char c) {
 | 
			
		||||
  for (; n > 0; n--)
 | 
			
		||||
    printf("%c", c);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@@ -213,24 +184,22 @@ void myddas_util_error_message(char *message ,Int line,char *file){
 | 
			
		||||
 | 
			
		||||
MYDDAS_UTIL_PREDICATE
 | 
			
		||||
myddas_util_find_predicate(const char *pred_name, Int pred_arity,
 | 
			
		||||
			   const char *pred_module, MYDDAS_UTIL_PREDICATE list){
 | 
			
		||||
                           const char *pred_module,
 | 
			
		||||
                           MYDDAS_UTIL_PREDICATE list) {
 | 
			
		||||
 | 
			
		||||
  for (; list != NULL; list = list->next)
 | 
			
		||||
    if (pred_arity == list->pred_arity && 
 | 
			
		||||
	!strcmp(pred_name,list->pred_name) && 
 | 
			
		||||
    if (pred_arity == list->pred_arity && !strcmp(pred_name, list->pred_name) &&
 | 
			
		||||
        !strcmp(pred_module, list->pred_module))
 | 
			
		||||
      return list;
 | 
			
		||||
 | 
			
		||||
  return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void 
 | 
			
		||||
myddas_util_delete_predicate_list(MYDDAS_UTIL_PREDICATE preds_list){
 | 
			
		||||
void myddas_util_delete_predicate_list(MYDDAS_UTIL_PREDICATE preds_list) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  MYDDAS_UTIL_PREDICATE to_delete = NULL;
 | 
			
		||||
 | 
			
		||||
  for (;preds_list != NULL;)
 | 
			
		||||
    {
 | 
			
		||||
  for (; preds_list != NULL;) {
 | 
			
		||||
    to_delete = preds_list;
 | 
			
		||||
    preds_list = preds_list->next;
 | 
			
		||||
 | 
			
		||||
@@ -239,110 +208,35 @@ myddas_util_delete_predicate_list(MYDDAS_UTIL_PREDICATE preds_list){
 | 
			
		||||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef MYDDAS_MYSQL
 | 
			
		||||
void
 | 
			
		||||
myddas_util_table_write(MYSQL_RES *res_set){
 | 
			
		||||
  
 | 
			
		||||
  MYSQL_ROW row;
 | 
			
		||||
  MYSQL_FIELD *fields;
 | 
			
		||||
  Int i,f;
 | 
			
		||||
 | 
			
		||||
  if (mysql_num_rows(res_set) == 0)
 | 
			
		||||
    {
 | 
			
		||||
      printf ("Empty Set\n");
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  f = mysql_num_fields(res_set);
 | 
			
		||||
 | 
			
		||||
  fields = mysql_fetch_field(res_set);
 | 
			
		||||
  for(i=0;i<f;i++) 
 | 
			
		||||
  {
 | 
			
		||||
    printf("+");
 | 
			
		||||
    if (strlen(fields[i].name)>fields[i].max_length) fields[i].max_length=strlen(fields[i].name);
 | 
			
		||||
    n_print(fields[i].max_length+2,'-');
 | 
			
		||||
  }
 | 
			
		||||
  printf("+\n");
 | 
			
		||||
  
 | 
			
		||||
  for(i=0;i<f;i++) 
 | 
			
		||||
    {
 | 
			
		||||
    printf("|");
 | 
			
		||||
    printf(" %s ",fields[i].name);
 | 
			
		||||
    n_print(fields[i].max_length - strlen(fields[i].name),' ');
 | 
			
		||||
    }
 | 
			
		||||
  printf("|\n");
 | 
			
		||||
  
 | 
			
		||||
  for(i=0;i<f;i++) 
 | 
			
		||||
  {
 | 
			
		||||
    printf("+");
 | 
			
		||||
    n_print(fields[i].max_length+2,'-');
 | 
			
		||||
  }
 | 
			
		||||
  printf("+\n");
 | 
			
		||||
  
 | 
			
		||||
  while ((row = mysql_fetch_row(res_set)) != NULL)
 | 
			
		||||
    {
 | 
			
		||||
      for(i=0;i<f;i++) 
 | 
			
		||||
	{
 | 
			
		||||
	  printf("|");
 | 
			
		||||
	  if (row[i] != NULL) 
 | 
			
		||||
	    {
 | 
			
		||||
	      printf(" %s ",row[i]);
 | 
			
		||||
	      n_print(fields[i].max_length - strlen(row[i]),' ');
 | 
			
		||||
	    }
 | 
			
		||||
	  else 
 | 
			
		||||
	    {
 | 
			
		||||
	      printf(" NULL ");
 | 
			
		||||
	      n_print(fields[i].max_length - 4,' ');
 | 
			
		||||
	    }
 | 
			
		||||
	}
 | 
			
		||||
      printf("|\n");
 | 
			
		||||
    }
 | 
			
		||||
  
 | 
			
		||||
  for(i=0;i<f;i++) 
 | 
			
		||||
    {
 | 
			
		||||
      printf("+");
 | 
			
		||||
      n_print(fields[i].max_length+2,'-');
 | 
			
		||||
    }
 | 
			
		||||
  printf("+\n");
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// DELETE THIS WHEN DB_STATS  IS COMPLETED
 | 
			
		||||
MyddasInt
 | 
			
		||||
get_myddas_top( void ){
 | 
			
		||||
MyddasInt get_myddas_top(void) {
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
  if (Yap_REGS.MYDDAS_GLOBAL_POINTER == NULL)
 | 
			
		||||
    return 0;
 | 
			
		||||
  return (Int)Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *
 | 
			
		||||
myddas_util_get_pred_next(void *pointer){
 | 
			
		||||
void *myddas_util_get_pred_next(void *pointer) {
 | 
			
		||||
  MYDDAS_UTIL_PREDICATE temp = (MYDDAS_UTIL_PREDICATE)pointer;
 | 
			
		||||
  return (void *)(temp->next);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MyddasInt 
 | 
			
		||||
myddas_util_get_pred_arity(void *pointer){
 | 
			
		||||
MyddasInt myddas_util_get_pred_arity(void *pointer) {
 | 
			
		||||
  MYDDAS_UTIL_PREDICATE temp = (MYDDAS_UTIL_PREDICATE)pointer;
 | 
			
		||||
  return temp->pred_arity;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *
 | 
			
		||||
myddas_util_get_pred_name(void *pointer){
 | 
			
		||||
const char *myddas_util_get_pred_name(void *pointer) {
 | 
			
		||||
  MYDDAS_UTIL_PREDICATE temp = (MYDDAS_UTIL_PREDICATE)pointer;
 | 
			
		||||
  return temp->pred_name;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *
 | 
			
		||||
myddas_util_get_pred_module(void *pointer){
 | 
			
		||||
const char *myddas_util_get_pred_module(void *pointer) {
 | 
			
		||||
  MYDDAS_UTIL_PREDICATE temp = (MYDDAS_UTIL_PREDICATE)pointer;
 | 
			
		||||
  return temp->pred_module;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *
 | 
			
		||||
myddas_util_get_list_pred(MYDDAS_UTIL_CONNECTION node){
 | 
			
		||||
void *myddas_util_get_list_pred(MYDDAS_UTIL_CONNECTION node) {
 | 
			
		||||
  return (void *)(node->predicates);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -351,9 +245,9 @@ void check_int( void ){
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
 | 
			
		||||
  MYDDAS_UTIL_PREDICATE pred = NULL;
 | 
			
		||||
  MYDDAS_UTIL_CONNECTION top = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
 | 
			
		||||
  for ( ; top!=NULL ; top=top->next)
 | 
			
		||||
    {
 | 
			
		||||
  MYDDAS_UTIL_CONNECTION top =
 | 
			
		||||
      Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
 | 
			
		||||
  for (; top != NULL; top = top->next) {
 | 
			
		||||
    printf("***************\n");
 | 
			
		||||
    printf("===== top =====\n");
 | 
			
		||||
    printf("======= %p =====\n", top);
 | 
			
		||||
@@ -362,12 +256,10 @@ void check_int( void ){
 | 
			
		||||
    printf("PRED: = %p =====\n", top->predicates);
 | 
			
		||||
    printf("======= %p =====\n", top->previous);
 | 
			
		||||
    printf("======= %p =====\n", top->next);
 | 
			
		||||
      if (top->predicates != NULL)
 | 
			
		||||
	{
 | 
			
		||||
    if (top->predicates != NULL) {
 | 
			
		||||
      printf("\t******\n");
 | 
			
		||||
      printf("\t===== PREDICATES =====\n");
 | 
			
		||||
	  for (pred = top->predicates ; pred != NULL ; pred = pred->next)
 | 
			
		||||
	    {
 | 
			
		||||
      for (pred = top->predicates; pred != NULL; pred = pred->next) {
 | 
			
		||||
        printf("\t--------------\n");
 | 
			
		||||
        printf("\t===== %p =====\n", pred);
 | 
			
		||||
        printf("\t===== %s =====\n", pred->pred_name);
 | 
			
		||||
@@ -377,7 +269,6 @@ void check_int( void ){
 | 
			
		||||
        printf("\t===== %p =====\n", pred->next);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
      
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return;
 | 
			
		||||
 
 | 
			
		||||
@@ -3,30 +3,12 @@
 | 
			
		||||
 | 
			
		||||
void myddas_util_error_message(char *message, Int line, char *file);
 | 
			
		||||
 | 
			
		||||
/* Search for the predicate in the given predicate list*/
 | 
			
		||||
MYDDAS_UTIL_CONNECTION myddas_util_search_connection(void *conn);
 | 
			
		||||
UInt myddas_util_get_total_multi_queries_number(MYDDAS_UTIL_CONNECTION con);
 | 
			
		||||
 | 
			
		||||
MYDDAS_UTIL_CONNECTION
 | 
			
		||||
myddas_init_initialize_connection(void *conn,void *enviromment,
 | 
			
		||||
				  MYDDAS_API api,
 | 
			
		||||
				  MYDDAS_UTIL_CONNECTION next);
 | 
			
		||||
void myddas_util_set_total_multi_queries_number(MYDDAS_UTIL_CONNECTION con,
 | 
			
		||||
                                                UInt number);
 | 
			
		||||
 | 
			
		||||
MYDDAS_UTIL_CONNECTION 
 | 
			
		||||
myddas_util_add_connection(void *conn, void *enviromment, MYDDAS_API api);
 | 
			
		||||
 | 
			
		||||
MYDDAS_UTIL_PREDICATE
 | 
			
		||||
myddas_init_initialize_predicate(const char *pred_name, int pred_arity,
 | 
			
		||||
				 const char *pred_module, MYDDAS_UTIL_PREDICATE next);
 | 
			
		||||
  
 | 
			
		||||
MYDDAS_UTIL_PREDICATE
 | 
			
		||||
myddas_util_find_predicate(const char *pred_name, Int pred_arity,
 | 
			
		||||
			   const char *pred_module, MYDDAS_UTIL_PREDICATE list);
 | 
			
		||||
 | 
			
		||||
UInt
 | 
			
		||||
myddas_util_get_total_multi_queries_number(MYDDAS_UTIL_CONNECTION con);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
myddas_util_set_total_multi_queries_number(MYDDAS_UTIL_CONNECTION con, UInt number);
 | 
			
		||||
//void myddas_util_table_write(MYSQL_RES *res_set);
 | 
			
		||||
 | 
			
		||||
void *myddas_util_get_pred_next(void *pointer);
 | 
			
		||||
 | 
			
		||||
@@ -34,8 +16,30 @@ MyddasInt myddas_util_get_pred_arity(void *pointer);
 | 
			
		||||
 | 
			
		||||
const char *myddas_util_get_pred_name(void *pointer);
 | 
			
		||||
 | 
			
		||||
void myddas_util_delete_predicate(MYDDAS_UTIL_PREDICATE to_delete);
 | 
			
		||||
 | 
			
		||||
const char *myddas_util_get_pred_module(void *pointer);
 | 
			
		||||
 | 
			
		||||
void *myddas_util_get_list_pred(MYDDAS_UTIL_CONNECTION node);
 | 
			
		||||
 | 
			
		||||
void myddas_util_delete_predicate_list(MYDDAS_UTIL_PREDICATE preds_list);
 | 
			
		||||
 | 
			
		||||
MYDDAS_UTIL_CONNECTION myddas_util_search_connection(void *con);
 | 
			
		||||
 | 
			
		||||
MYDDAS_UTIL_PREDICATE myddas_util_find_predicate(const char *pred_name,
 | 
			
		||||
                                                 Int pred_arity,
 | 
			
		||||
                                                 const char *pred_module,
 | 
			
		||||
                                                 MYDDAS_UTIL_PREDICATE list);
 | 
			
		||||
 | 
			
		||||
MYDDAS_UTIL_CONNECTION myddas_util_add_connection(void *conn, void *enviromment,
 | 
			
		||||
                                                  MYDDAS_API api);
 | 
			
		||||
void myddas_util_delete_connection(void *conn);
 | 
			
		||||
 | 
			
		||||
MYDDAS_UTIL_PREDICATE
 | 
			
		||||
myddas_init_initialize_predicate(const char *pred_name, int pred_arity,
 | 
			
		||||
                                 const char *pred_module,
 | 
			
		||||
                                 MYDDAS_UTIL_PREDICATE next);
 | 
			
		||||
 | 
			
		||||
MYDDAS_UTIL_CONNECTION
 | 
			
		||||
myddas_init_initialize_connection(void *conn, void *enviromment, MYDDAS_API api,
 | 
			
		||||
                                  MYDDAS_UTIL_CONNECTION next);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,21 @@
 | 
			
		||||
#include <string.h>
 | 
			
		||||
p#include <string.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include "Yap.h"
 | 
			
		||||
#include "cut_c.h"
 | 
			
		||||
 | 
			
		||||
MYDDAS_UTIL_CONNECTION
 | 
			
		||||
myddas_init_initialize_connection(void *conn, void *enviromment, MYDDAS_API api,
 | 
			
		||||
                                  MYDDAS_UTIL_CONNECTION next);
 | 
			
		||||
 | 
			
		||||
MYDDAS_UTIL_CONNECTION
 | 
			
		||||
myddas_util_add_connection(void *conn, void *enviromment, MYDDAS_API api);
 | 
			
		||||
 | 
			
		||||
MYDDAS_UTIL_PREDICATE
 | 
			
		||||
myddas_init_initialize_predicate(const char *pred_name, int pred_arity,
 | 
			
		||||
                                 const char *pred_module,
 | 
			
		||||
                                 MYDDAS_UTIL_PREDICATE next);
 | 
			
		||||
 | 
			
		||||
MYDDAS_UTIL_PREDICATE
 | 
			
		||||
myddas_util_find_predicate(const char *pred_name, Int pred_arity,
 | 
			
		||||
                           const char *pred_module, MYDDAS_UTIL_PREDICATE list);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,25 +0,0 @@
 | 
			
		||||
#ifndef MYDDAS_WKB_H_
 | 
			
		||||
#define MYDDAS_WKB_H_
 | 
			
		||||
 | 
			
		||||
typedef char byte;
 | 
			
		||||
 | 
			
		||||
typedef unsigned int uint32;
 | 
			
		||||
 | 
			
		||||
#define WKBXDR 0
 | 
			
		||||
#define WKBNDR 1
 | 
			
		||||
 | 
			
		||||
#define WKBMINTYPE 1
 | 
			
		||||
 | 
			
		||||
#define WKBPOINT 1
 | 
			
		||||
#define WKBLINESTRING 2
 | 
			
		||||
#define WKBPOLYGON 3
 | 
			
		||||
#define WKBMULTIPOINT 4
 | 
			
		||||
#define WKBMULTILINESTRING 5
 | 
			
		||||
#define WKBMULTIPOLYGON 6
 | 
			
		||||
#define WKBGEOMETRYCOLLECTION 7
 | 
			
		||||
 | 
			
		||||
#define WKBMAXTYPE 7
 | 
			
		||||
 | 
			
		||||
#define WKBGEOMETRY 0
 | 
			
		||||
 | 
			
		||||
#endif /* MYDDAS_WKB_H_ */
 | 
			
		||||
@@ -1,382 +0,0 @@
 | 
			
		||||
#if defined MYDDAS_MYSQL
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include "Yap.h"
 | 
			
		||||
#include <netinet/in.h>
 | 
			
		||||
#include "myddas_wkb.h"
 | 
			
		||||
#include "myddas_wkb2prolog.h"
 | 
			
		||||
 | 
			
		||||
static void readswap4(uint32 *buf);
 | 
			
		||||
static void readswap8(double *buf);
 | 
			
		||||
 | 
			
		||||
static byte get_hostbyteorder(void);
 | 
			
		||||
static byte get_inbyteorder(void);
 | 
			
		||||
static uint32 get_wkbType(void);
 | 
			
		||||
static Term get_point(char *functor USES_REGS);
 | 
			
		||||
static Term get_linestring(char *functor);
 | 
			
		||||
static Term get_polygon(char *functor);
 | 
			
		||||
static Term get_geometry(uint32 type);
 | 
			
		||||
 | 
			
		||||
static int swaporder;
 | 
			
		||||
static byte inbyteorder, hostbyteorder;
 | 
			
		||||
static byte *cursor;
 | 
			
		||||
 | 
			
		||||
Term wkb2prolog(char *wkb) {
 | 
			
		||||
  uint32 type;
 | 
			
		||||
 | 
			
		||||
  cursor = wkb;
 | 
			
		||||
 | 
			
		||||
  /*ignore the SRID 4 bytes*/
 | 
			
		||||
  cursor += 4;
 | 
			
		||||
 | 
			
		||||
  /*byteorder*/
 | 
			
		||||
  hostbyteorder = get_hostbyteorder();
 | 
			
		||||
  inbyteorder = get_inbyteorder();
 | 
			
		||||
 | 
			
		||||
  swaporder = 0;
 | 
			
		||||
  if ( hostbyteorder != inbyteorder )
 | 
			
		||||
    swaporder = 1;
 | 
			
		||||
 | 
			
		||||
  type = get_wkbType();
 | 
			
		||||
 | 
			
		||||
  return get_geometry(type);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static byte get_hostbyteorder(void){
 | 
			
		||||
  uint16_t host = 5;
 | 
			
		||||
  uint16_t net;
 | 
			
		||||
 | 
			
		||||
  net = htons(host);
 | 
			
		||||
  if ( net == host )
 | 
			
		||||
    return(WKBXDR);
 | 
			
		||||
  else
 | 
			
		||||
    return(WKBNDR);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static byte get_inbyteorder(void){
 | 
			
		||||
  byte b = cursor[0];
 | 
			
		||||
 | 
			
		||||
  if (b != WKBNDR && b != WKBXDR) {
 | 
			
		||||
    fprintf(stderr, "Unknown byteorder: %d\n",b);
 | 
			
		||||
    exit(0);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  cursor++;
 | 
			
		||||
 | 
			
		||||
  return(b);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint32 get_wkbType(void){
 | 
			
		||||
  uint32 u;
 | 
			
		||||
 | 
			
		||||
  /* read the type */
 | 
			
		||||
  readswap4(&u);
 | 
			
		||||
 | 
			
		||||
  if (u > WKBMAXTYPE || u < WKBMINTYPE) {
 | 
			
		||||
    fprintf(stderr, "Unknown type: %d\n",u);
 | 
			
		||||
    exit(0);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return(u);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void readswap4(uint32 *buf){
 | 
			
		||||
  ((byte *) buf)[0] = cursor[0];
 | 
			
		||||
  ((byte *) buf)[1] = cursor[1];
 | 
			
		||||
  ((byte *) buf)[2] = cursor[2];
 | 
			
		||||
  ((byte *) buf)[3] = cursor[3];
 | 
			
		||||
 | 
			
		||||
  if ( swaporder ) {
 | 
			
		||||
    if ( inbyteorder == WKBXDR ) {
 | 
			
		||||
      *buf = (uint32)ntohl((u_long)*buf);
 | 
			
		||||
    } else {
 | 
			
		||||
      byte u[4];
 | 
			
		||||
 | 
			
		||||
      u[0] = ((byte *) buf)[3];
 | 
			
		||||
      u[1] = ((byte *) buf)[2];
 | 
			
		||||
      u[2] = ((byte *) buf)[1];
 | 
			
		||||
      u[3] = ((byte *) buf)[0];
 | 
			
		||||
      ((byte *) buf)[0] = u[0];
 | 
			
		||||
      ((byte *) buf)[1] = u[1];
 | 
			
		||||
      ((byte *) buf)[2] = u[2];
 | 
			
		||||
      ((byte *) buf)[3] = u[3];
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  cursor += 4;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void readswap8(double *buf) {
 | 
			
		||||
  ((byte *) buf)[0] = cursor[0];
 | 
			
		||||
  ((byte *) buf)[1] = cursor[1];
 | 
			
		||||
  ((byte *) buf)[2] = cursor[2];
 | 
			
		||||
  ((byte *) buf)[3] = cursor[3];
 | 
			
		||||
  ((byte *) buf)[4] = cursor[4];
 | 
			
		||||
  ((byte *) buf)[5] = cursor[5];
 | 
			
		||||
  ((byte *) buf)[6] = cursor[6];
 | 
			
		||||
  ((byte *) buf)[7] = cursor[7];
 | 
			
		||||
 | 
			
		||||
  if ( swaporder ) {
 | 
			
		||||
    if ( inbyteorder == WKBXDR ) {
 | 
			
		||||
      u_long u[2];
 | 
			
		||||
 | 
			
		||||
      u[0] = ((u_long *) buf)[0];
 | 
			
		||||
      u[1] = ((u_long *) buf)[1];
 | 
			
		||||
      ((u_long *) buf)[1] = ntohl(u[0]);
 | 
			
		||||
      ((u_long *) buf)[0] = ntohl(u[1]);
 | 
			
		||||
    } else {
 | 
			
		||||
      byte u[8];
 | 
			
		||||
 | 
			
		||||
      u[0] = ((byte *) buf)[7];
 | 
			
		||||
      u[1] = ((byte *) buf)[6];
 | 
			
		||||
      u[2] = ((byte *) buf)[5];
 | 
			
		||||
      u[3] = ((byte *) buf)[4];
 | 
			
		||||
      u[4] = ((byte *) buf)[3];
 | 
			
		||||
      u[5] = ((byte *) buf)[2];
 | 
			
		||||
      u[6] = ((byte *) buf)[1];
 | 
			
		||||
      u[7] = ((byte *) buf)[0];
 | 
			
		||||
      ((byte *) buf)[0] = u[0];
 | 
			
		||||
      ((byte *) buf)[1] = u[1];
 | 
			
		||||
      ((byte *) buf)[2] = u[2];
 | 
			
		||||
      ((byte *) buf)[3] = u[3];
 | 
			
		||||
      ((byte *) buf)[4] = u[4];
 | 
			
		||||
      ((byte *) buf)[5] = u[5];
 | 
			
		||||
      ((byte *) buf)[6] = u[6];
 | 
			
		||||
      ((byte *) buf)[7] = u[7];
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  cursor += 8;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Term get_point(char *func USES_REGS){
 | 
			
		||||
  Term args[2];
 | 
			
		||||
  Functor functor;
 | 
			
		||||
  double d;
 | 
			
		||||
 | 
			
		||||
  if(func == NULL)
 | 
			
		||||
    /*functor "," => (_,_)*/
 | 
			
		||||
    functor = Yap_MkFunctor(Yap_LookupAtom(","), 2);
 | 
			
		||||
  else
 | 
			
		||||
    functor = Yap_MkFunctor(Yap_LookupAtom(func), 2);
 | 
			
		||||
 | 
			
		||||
  /* read the X */
 | 
			
		||||
  readswap8(&d);
 | 
			
		||||
  args[0] = MkFloatTerm(d);
 | 
			
		||||
 | 
			
		||||
  /* read the Y */
 | 
			
		||||
  readswap8(&d);
 | 
			
		||||
  args[1] = MkFloatTerm(d);
 | 
			
		||||
 | 
			
		||||
  return Yap_MkApplTerm(functor, 2, args);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Term get_linestring(char *func){
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
 | 
			
		||||
  Term *c_list;
 | 
			
		||||
  Term list;
 | 
			
		||||
  Functor functor;
 | 
			
		||||
  uint32 n;
 | 
			
		||||
  int i;
 | 
			
		||||
 | 
			
		||||
  /* read the number of vertices */
 | 
			
		||||
  readswap4(&n);
 | 
			
		||||
 | 
			
		||||
  /* space for arguments */
 | 
			
		||||
  c_list = (Term *) calloc(sizeof(Term),n);
 | 
			
		||||
 | 
			
		||||
  for ( i = 0; i < n; i++) {
 | 
			
		||||
    c_list[i] = get_point(NULL PASS_REGS);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  list = MkAtomTerm(Yap_LookupAtom("[]"));
 | 
			
		||||
  for (i = n - 1; i >= 0; i--) {
 | 
			
		||||
    list = MkPairTerm(c_list[i],list);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if(func == NULL)
 | 
			
		||||
    return list;
 | 
			
		||||
  else{
 | 
			
		||||
    functor = Yap_MkFunctor(Yap_LookupAtom(func), 1);
 | 
			
		||||
    return Yap_MkApplTerm(functor, 1, &list);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Term get_polygon(char *func){
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
 | 
			
		||||
  uint32 r;
 | 
			
		||||
  int i;
 | 
			
		||||
  Functor functor;
 | 
			
		||||
  Term *c_list;
 | 
			
		||||
  Term list;
 | 
			
		||||
 | 
			
		||||
  /* read the number of rings */
 | 
			
		||||
  readswap4(&r);
 | 
			
		||||
 | 
			
		||||
  /* space for rings */
 | 
			
		||||
  c_list = (Term *) calloc(sizeof(Term),r);
 | 
			
		||||
 | 
			
		||||
  for ( i = 0; i < r; i++ ) {
 | 
			
		||||
    c_list[i] = get_linestring(NULL);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  list = MkAtomTerm(Yap_LookupAtom("[]"));
 | 
			
		||||
  for (i = r - 1; i >= 0; i--) {
 | 
			
		||||
    list = MkPairTerm(c_list[i],list);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if(func == NULL)
 | 
			
		||||
    return list;
 | 
			
		||||
  else{
 | 
			
		||||
    functor = Yap_MkFunctor(Yap_LookupAtom("polygon"), 1);
 | 
			
		||||
    return Yap_MkApplTerm(functor, 1, &list);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Term get_geometry(uint32 type){
 | 
			
		||||
  CACHE_REGS
 | 
			
		||||
 | 
			
		||||
  switch(type) {
 | 
			
		||||
  case WKBPOINT:
 | 
			
		||||
    return get_point("point" PASS_REGS);
 | 
			
		||||
  case WKBLINESTRING:
 | 
			
		||||
    return get_linestring("linestring");
 | 
			
		||||
  case WKBPOLYGON:
 | 
			
		||||
    return get_polygon("polygon");
 | 
			
		||||
  case WKBMULTIPOINT:
 | 
			
		||||
    {
 | 
			
		||||
      uint32 n;
 | 
			
		||||
      int i;
 | 
			
		||||
      Functor functor;
 | 
			
		||||
      Term *c_list;
 | 
			
		||||
      Term list;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      /* read the number of points */
 | 
			
		||||
      readswap4(&n);
 | 
			
		||||
 | 
			
		||||
      /* space for points */
 | 
			
		||||
      c_list = (Term *) calloc(sizeof(Term),n);
 | 
			
		||||
 | 
			
		||||
      for ( i = 0; i < n; i++ ) {
 | 
			
		||||
	/* read (and ignore) the byteorder and type */
 | 
			
		||||
	get_inbyteorder();
 | 
			
		||||
	get_wkbType();
 | 
			
		||||
 | 
			
		||||
	c_list[i] = get_point(NULL PASS_REGS);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      list = MkAtomTerm(Yap_LookupAtom("[]"));
 | 
			
		||||
      for (i = n - 1; i >= 0; i--) {
 | 
			
		||||
	list = MkPairTerm(c_list[i],list);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      functor = Yap_MkFunctor(Yap_LookupAtom("multipoint"), 1);
 | 
			
		||||
 | 
			
		||||
      return Yap_MkApplTerm(functor, 1, &list);
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
  case WKBMULTILINESTRING:
 | 
			
		||||
    {
 | 
			
		||||
      uint32 n;
 | 
			
		||||
      int i;
 | 
			
		||||
      Functor functor;
 | 
			
		||||
      Term *c_list;
 | 
			
		||||
      Term list;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      /* read the number of polygons */
 | 
			
		||||
      readswap4(&n);
 | 
			
		||||
 | 
			
		||||
      /* space for polygons*/
 | 
			
		||||
      c_list = (Term *) calloc(sizeof(Term),n);
 | 
			
		||||
 | 
			
		||||
      for ( i = 0; i < n; i++ ) {
 | 
			
		||||
	/* read (and ignore) the byteorder and type */
 | 
			
		||||
	get_inbyteorder();
 | 
			
		||||
	get_wkbType();
 | 
			
		||||
 | 
			
		||||
	c_list[i] = get_linestring(NULL);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      list = MkAtomTerm(Yap_LookupAtom("[]"));
 | 
			
		||||
      for (i = n - 1; i >= 0; i--) {
 | 
			
		||||
	list = MkPairTerm(c_list[i],list);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      functor = Yap_MkFunctor(Yap_LookupAtom("multilinestring"), 1);
 | 
			
		||||
 | 
			
		||||
      return Yap_MkApplTerm(functor, 1, &list);
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
  case WKBMULTIPOLYGON:
 | 
			
		||||
    {
 | 
			
		||||
      uint32 n;
 | 
			
		||||
      int i;
 | 
			
		||||
      Functor functor;
 | 
			
		||||
      Term *c_list;
 | 
			
		||||
      Term list;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      /* read the number of polygons */
 | 
			
		||||
      readswap4(&n);
 | 
			
		||||
 | 
			
		||||
      /* space for polygons*/
 | 
			
		||||
      c_list = (Term *) calloc(sizeof(Term),n);
 | 
			
		||||
 | 
			
		||||
      for ( i = 0; i < n; i++ ) {
 | 
			
		||||
	/* read (and ignore) the byteorder and type */
 | 
			
		||||
	get_inbyteorder();
 | 
			
		||||
	get_wkbType();
 | 
			
		||||
 | 
			
		||||
	c_list[i] = get_polygon(NULL);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      list = MkAtomTerm(Yap_LookupAtom("[]"));
 | 
			
		||||
      for (i = n - 1; i >= 0; i--) {
 | 
			
		||||
	list = MkPairTerm(c_list[i],list);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      functor = Yap_MkFunctor(Yap_LookupAtom("multipolygon"), 1);
 | 
			
		||||
 | 
			
		||||
      return Yap_MkApplTerm(functor, 1, &list);
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
  case WKBGEOMETRYCOLLECTION:
 | 
			
		||||
    {
 | 
			
		||||
      uint32 n;
 | 
			
		||||
      int i;
 | 
			
		||||
      Functor functor;
 | 
			
		||||
      Term *c_list;
 | 
			
		||||
      Term list;
 | 
			
		||||
 | 
			
		||||
      /* read the number of geometries */
 | 
			
		||||
      readswap4(&n);
 | 
			
		||||
 | 
			
		||||
      /* space for geometries*/
 | 
			
		||||
      c_list = (Term *) calloc(sizeof(Term),n);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      for ( i = 0; i < n; i++ ) {
 | 
			
		||||
	get_inbyteorder();
 | 
			
		||||
	c_list[i] = get_geometry(get_wkbType());
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      list = MkAtomTerm(Yap_LookupAtom("[]"));
 | 
			
		||||
      for (i = n - 1; i >= 0; i--) {
 | 
			
		||||
	list = MkPairTerm(c_list[i],list);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      functor = Yap_MkFunctor(Yap_LookupAtom("geometrycollection"), 1);
 | 
			
		||||
 | 
			
		||||
      return Yap_MkApplTerm(functor, 1, &list);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return MkAtomTerm(Yap_LookupAtom("[]"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /*MYDDAS_MYSQL*/
 | 
			
		||||
@@ -1,6 +0,0 @@
 | 
			
		||||
#ifndef   	MYDDAS_WKB2PROLOG_H_
 | 
			
		||||
# define   	MYDDAS_WKB2PROLOG_H_
 | 
			
		||||
 | 
			
		||||
Term wkb2prolog(char *wkb) ;
 | 
			
		||||
 | 
			
		||||
#endif 	    /* !MYDDAS_WKB2PROLOG_H_ */
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user