2002-06-04 19:21:55 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* *
|
|
|
|
* YAP Prolog *
|
|
|
|
* *
|
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
2004-03-19 11:35:42 +00:00
|
|
|
* File: rheap.h *
|
2002-06-04 19:21:55 +01:00
|
|
|
* comments: walk through heap code *
|
|
|
|
* *
|
2008-04-04 10:10:02 +01:00
|
|
|
* Last rev: $Date: 2008-04-04 09:10:02 $,$Author: vsc $ *
|
2004-03-31 02:03:10 +01:00
|
|
|
* $Log: not supported by cvs2svn $
|
2008-04-04 10:10:02 +01:00
|
|
|
* Revision 1.92 2008/04/03 11:34:47 vsc
|
|
|
|
* fix restorebb in cases entry key is not an atom (obs from Nicos
|
|
|
|
* Angelopoulos)
|
|
|
|
*
|
2008-04-03 12:34:47 +01:00
|
|
|
* Revision 1.91 2008/04/01 15:31:43 vsc
|
|
|
|
* more saved state fixes
|
|
|
|
*
|
2008-04-01 16:31:43 +01:00
|
|
|
* Revision 1.90 2008/04/01 14:09:43 vsc
|
|
|
|
* improve restore
|
|
|
|
*
|
2008-04-01 15:09:43 +01:00
|
|
|
* Revision 1.89 2008/04/01 09:41:05 vsc
|
|
|
|
* more fixes to restore
|
|
|
|
*
|
2008-04-01 10:41:05 +01:00
|
|
|
* Revision 1.88 2008/04/01 08:42:46 vsc
|
|
|
|
* fix restore and small VISTA thingies
|
|
|
|
*
|
2008-04-01 09:42:46 +01:00
|
|
|
* Revision 1.87 2008/03/25 22:03:14 vsc
|
|
|
|
* fix some icc warnings
|
|
|
|
*
|
2008-03-25 22:03:14 +00:00
|
|
|
* Revision 1.86 2008/03/25 16:45:53 vsc
|
|
|
|
* make or-parallelism compile again
|
|
|
|
*
|
2008-03-25 16:45:53 +00:00
|
|
|
* Revision 1.85 2008/02/12 17:03:52 vsc
|
|
|
|
* SWI-portability changes
|
|
|
|
*
|
2008-02-12 17:03:59 +00:00
|
|
|
* Revision 1.84 2008/02/07 21:39:51 vsc
|
|
|
|
* fix case where predicate is for an integer (DBEntry).
|
|
|
|
*
|
2008-02-07 21:39:51 +00:00
|
|
|
* Revision 1.83 2008/01/23 17:57:55 vsc
|
|
|
|
* valgrind it!
|
|
|
|
* enable atom garbage collection.
|
|
|
|
*
|
2008-01-23 17:57:56 +00:00
|
|
|
* Revision 1.82 2007/12/05 12:17:23 vsc
|
|
|
|
* improve JT
|
|
|
|
* fix graph compatibility with SICStus
|
|
|
|
* re-export declaration.
|
|
|
|
*
|
2007-12-05 12:17:25 +00:00
|
|
|
* Revision 1.81 2007/11/26 23:43:09 vsc
|
|
|
|
* fixes to support threads and assert correctly, even if inefficiently.
|
|
|
|
*
|
2007-11-26 23:43:10 +00:00
|
|
|
* Revision 1.80 2007/11/07 09:35:53 vsc
|
|
|
|
* small fix
|
|
|
|
*
|
2007-11-07 09:35:53 +00:00
|
|
|
* Revision 1.79 2007/11/07 09:25:27 vsc
|
|
|
|
* speedup meta-calls
|
|
|
|
*
|
2007-11-07 09:25:27 +00:00
|
|
|
* Revision 1.78 2007/11/06 17:02:12 vsc
|
|
|
|
* compile ground terms away.
|
|
|
|
*
|
2007-11-06 17:02:13 +00:00
|
|
|
* Revision 1.77 2007/10/10 09:44:24 vsc
|
|
|
|
* some more fixes to make YAP swi compatible
|
|
|
|
* fix absolute_file_name (again)
|
|
|
|
* fix setarg
|
|
|
|
*
|
2007-10-10 10:44:28 +01:00
|
|
|
* Revision 1.76 2007/09/28 23:18:17 vsc
|
|
|
|
* handle learning from interpretations.
|
|
|
|
*
|
2007-09-29 00:18:17 +01:00
|
|
|
* Revision 1.75 2007/04/10 22:13:21 vsc
|
|
|
|
* fix max modules limitation
|
|
|
|
*
|
2007-04-10 23:13:21 +01:00
|
|
|
* Revision 1.74 2007/03/22 11:12:21 vsc
|
|
|
|
* make sure that YAP_Restart does not restart a failed goal.
|
|
|
|
*
|
2007-03-22 11:12:22 +00:00
|
|
|
* Revision 1.73 2007/02/18 00:26:36 vsc
|
|
|
|
* fix atom garbage collector (although it is still off by default)
|
|
|
|
* make valgrind feel better
|
|
|
|
*
|
2007-02-18 00:26:36 +00:00
|
|
|
* Revision 1.72 2007/01/08 08:27:19 vsc
|
|
|
|
* fix restore (Trevor)
|
|
|
|
* make indexing a bit faster on IDB
|
|
|
|
*
|
2007-01-08 08:27:19 +00:00
|
|
|
* Revision 1.71 2006/11/27 17:42:03 vsc
|
|
|
|
* support for UNICODE, and other bug fixes.
|
|
|
|
*
|
2006-11-27 17:42:03 +00:00
|
|
|
* Revision 1.70 2006/08/25 19:50:35 vsc
|
|
|
|
* global data structures
|
|
|
|
*
|
2006-08-25 20:50:35 +01:00
|
|
|
* Revision 1.69 2006/08/22 16:12:46 vsc
|
|
|
|
* global variables
|
|
|
|
*
|
2006-08-22 17:12:46 +01:00
|
|
|
* Revision 1.68 2006/08/02 18:18:30 vsc
|
|
|
|
* preliminary support for readutil library (SWI compatible).
|
|
|
|
*
|
2006-08-02 19:18:31 +01:00
|
|
|
* Revision 1.67 2006/05/17 18:38:11 vsc
|
|
|
|
* make system library use true file name
|
|
|
|
*
|
2006-05-17 19:38:11 +01:00
|
|
|
* Revision 1.66 2006/04/28 15:48:33 vsc
|
|
|
|
* do locking on streams
|
|
|
|
*
|
2006-04-28 16:48:33 +01:00
|
|
|
* Revision 1.65 2006/04/28 13:23:23 vsc
|
|
|
|
* fix number of overflow bugs affecting threaded version
|
|
|
|
* make current_op faster.
|
|
|
|
*
|
2006-04-28 14:23:23 +01:00
|
|
|
* Revision 1.64 2006/03/22 20:07:28 vsc
|
|
|
|
* take better care of zombies
|
|
|
|
*
|
2006-03-22 20:07:28 +00:00
|
|
|
* Revision 1.63 2006/03/06 14:04:56 vsc
|
|
|
|
* fixes to garbage collector
|
|
|
|
* fixes to debugger
|
|
|
|
*
|
2006-03-06 14:04:57 +00:00
|
|
|
* Revision 1.62 2006/02/24 14:03:42 vsc
|
|
|
|
* fix refs to old LogUpd implementation (pre 5).
|
|
|
|
*
|
2006-02-24 14:03:42 +00:00
|
|
|
* Revision 1.61 2006/01/02 02:16:18 vsc
|
|
|
|
* support new interface between YAP and GMP, so that we don't rely on our own
|
|
|
|
* allocation routines.
|
|
|
|
* Several big fixes.
|
|
|
|
*
|
2006-01-02 02:16:19 +00:00
|
|
|
* Revision 1.60 2005/12/17 03:25:39 vsc
|
|
|
|
* major changes to support online event-based profiling
|
|
|
|
* improve error discovery and restart on scanner.
|
|
|
|
*
|
2005-12-17 03:25:39 +00:00
|
|
|
* Revision 1.59 2005/12/05 17:16:11 vsc
|
|
|
|
* write_depth/3
|
|
|
|
* overflow handlings and garbage collection
|
|
|
|
* Several ipdates to CLPBN
|
|
|
|
* dif/2 could be broken in the presence of attributed variables.
|
|
|
|
*
|
2005-12-05 17:16:12 +00:00
|
|
|
* Revision 1.58 2005/11/23 03:01:33 vsc
|
|
|
|
* fix several bugs in save/restore.b
|
|
|
|
*
|
2005-11-23 03:01:33 +00:00
|
|
|
* Revision 1.57 2005/10/28 17:38:50 vsc
|
|
|
|
* sveral updates
|
|
|
|
*
|
2005-10-28 18:38:50 +01:00
|
|
|
* Revision 1.56 2005/10/21 16:09:03 vsc
|
|
|
|
* SWI compatible module only operators
|
|
|
|
*
|
2005-10-21 17:09:03 +01:00
|
|
|
* Revision 1.55 2005/10/19 19:00:48 vsc
|
|
|
|
* extend arrays with nb_terms so that we can implement nb_ builtins
|
|
|
|
* correctly.
|
|
|
|
*
|
2005-10-19 20:00:48 +01:00
|
|
|
* Revision 1.54 2005/09/09 17:24:39 vsc
|
|
|
|
* a new and hopefully much better implementation of atts.
|
|
|
|
*
|
2005-09-09 18:24:39 +01:00
|
|
|
* Revision 1.53 2005/08/01 15:40:38 ricroc
|
|
|
|
* TABLING NEW: better support for incomplete tabling
|
|
|
|
*
|
2005-08-01 16:40:39 +01:00
|
|
|
* Revision 1.52 2005/07/06 19:34:11 ricroc
|
|
|
|
* TABLING: answers for completed calls can now be obtained by loading (new option) or executing (default) them from the trie data structure.
|
|
|
|
*
|
2005-07-06 20:34:12 +01:00
|
|
|
* Revision 1.51 2005/07/06 15:10:15 vsc
|
|
|
|
* improvements to compiler: merged instructions and fixes for ->
|
|
|
|
*
|
2005-07-06 16:10:18 +01:00
|
|
|
* Revision 1.50 2005/06/01 13:53:46 vsc
|
|
|
|
* improve bb routines to use the DB efficiently
|
|
|
|
* change interface between DB and BB.
|
|
|
|
*
|
2005-06-01 14:53:46 +01:00
|
|
|
* Revision 1.49 2005/05/30 03:26:37 vsc
|
|
|
|
* add some atom gc fixes
|
|
|
|
*
|
2005-05-30 04:26:37 +01:00
|
|
|
* Revision 1.48 2005/01/04 02:50:21 vsc
|
|
|
|
* - allow MegaClauses with blobs
|
|
|
|
* - change Diffs to be thread specific
|
|
|
|
* - include Christian's updates
|
|
|
|
*
|
2005-01-04 02:50:23 +00:00
|
|
|
* Revision 1.47 2004/12/02 06:06:47 vsc
|
|
|
|
* fix threads so that they at least start
|
|
|
|
* allow error handling to work with threads
|
|
|
|
* replace heap_base by Yap_heap_base, according to Yap's convention for globals.
|
|
|
|
*
|
2004-12-02 06:06:47 +00:00
|
|
|
* Revision 1.46 2004/11/23 21:16:21 vsc
|
|
|
|
* A few extra fixes for saved states.
|
|
|
|
*
|
2004-11-23 21:16:21 +00:00
|
|
|
* Revision 1.45 2004/10/26 20:16:18 vsc
|
|
|
|
* More bug fixes for overflow handling
|
|
|
|
*
|
2004-10-26 21:16:18 +01:00
|
|
|
* Revision 1.44 2004/10/06 16:55:47 vsc
|
|
|
|
* change configure to support big mem configs
|
|
|
|
* get rid of extra globals
|
|
|
|
* fix trouble with multifile preds
|
|
|
|
*
|
2004-10-06 17:55:48 +01:00
|
|
|
* Revision 1.43 2004/09/27 20:45:04 vsc
|
|
|
|
* Mega clauses
|
|
|
|
* Fixes to sizeof(expand_clauses) which was being overestimated
|
|
|
|
* Fixes to profiling+indexing
|
|
|
|
* Fixes to reallocation of memory after restoring
|
|
|
|
* Make sure all clauses, even for C, end in _Ystop
|
|
|
|
* Don't reuse space for Streams
|
|
|
|
* Fix Stream_F on StreaNo+1
|
|
|
|
*
|
2004-09-27 21:45:04 +01:00
|
|
|
* Revision 1.42 2004/06/05 03:37:00 vsc
|
|
|
|
* coroutining is now a part of attvars.
|
|
|
|
* some more fixes.
|
|
|
|
*
|
2004-06-05 04:37:01 +01:00
|
|
|
* Revision 1.41 2004/04/29 03:45:50 vsc
|
|
|
|
* fix garbage collection in execute_tail
|
|
|
|
*
|
2004-04-29 04:45:50 +01:00
|
|
|
* Revision 1.40 2004/03/31 01:03:10 vsc
|
|
|
|
* support expand group of clauses
|
|
|
|
*
|
2004-03-31 02:03:10 +01:00
|
|
|
* Revision 1.39 2004/03/19 11:35:42 vsc
|
|
|
|
* trim_trail for default machine
|
|
|
|
* be more aggressive about try-retry-trust chains.
|
|
|
|
* - handle cases where block starts with a wait
|
|
|
|
* - don't use _killed instructions, just let the thing rot by itself.
|
|
|
|
* *
|
2004-03-19 11:35:42 +00:00
|
|
|
* *
|
2002-06-04 19:21:55 +01:00
|
|
|
*************************************************************************/
|
|
|
|
#ifdef SCCS
|
|
|
|
static char SccsId[] = "@(#)rheap.c 1.3 3/15/90";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define Atomics 0
|
|
|
|
#define Funcs 1
|
|
|
|
|
|
|
|
/* Now, everything on its place so you must adjust the pointers */
|
|
|
|
|
2004-09-27 21:45:04 +01:00
|
|
|
static void
|
|
|
|
do_clean_susp_clauses(yamop *ipc) {
|
|
|
|
COUNT i;
|
|
|
|
yamop **st = (yamop **)NEXTOP(ipc,sp);
|
|
|
|
|
|
|
|
ipc->opc = Yap_opcode(_expand_clauses);
|
|
|
|
ipc->u.sp.p = PtoPredAdjust(ipc->u.sp.p);
|
|
|
|
if (ipc->u.sp.sprev) {
|
|
|
|
ipc->u.sp.sprev = PtoOpAdjust(ipc->u.sp.sprev);
|
|
|
|
}
|
|
|
|
if (ipc->u.sp.snext) {
|
|
|
|
ipc->u.sp.snext = PtoOpAdjust(ipc->u.sp.snext);
|
|
|
|
}
|
|
|
|
for (i = 0; i < ipc->u.sp.s1; i++, st++) {
|
|
|
|
if (*st) {
|
|
|
|
*st = PtoOpAdjust(*st);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-22 20:07:28 +00:00
|
|
|
#include "rclause.h"
|
|
|
|
|
|
|
|
/* adjusts terms stored in the data base, when they have no variables */
|
|
|
|
static Term
|
|
|
|
AdjustDBTerm(Term trm, Term *p_base)
|
|
|
|
{
|
|
|
|
if (IsAtomTerm(trm))
|
|
|
|
return AtomTermAdjust(trm);
|
|
|
|
if (IsPairTerm(trm)) {
|
|
|
|
Term *p;
|
2008-04-03 12:34:47 +01:00
|
|
|
Term out;
|
2006-03-22 20:07:28 +00:00
|
|
|
|
|
|
|
p = PtoHeapCellAdjust(RepPair(trm));
|
2008-04-03 12:34:47 +01:00
|
|
|
out = AbsPair(p);
|
|
|
|
loop:
|
2006-03-22 20:07:28 +00:00
|
|
|
if (p >= p_base) {
|
|
|
|
p[0] = AdjustDBTerm(p[0], p);
|
2008-04-03 12:34:47 +01:00
|
|
|
if (IsPairTerm(p[1])) {
|
|
|
|
/* avoid term recursion with very deep lists */
|
|
|
|
Term *newp = PtoHeapCellAdjust(RepPair(p[1]));
|
|
|
|
p[1] = AbsPair(newp);
|
|
|
|
p_base = p;
|
|
|
|
p = newp;
|
|
|
|
goto loop;
|
|
|
|
} else {
|
|
|
|
p[1] = AdjustDBTerm(p[1], p);
|
|
|
|
}
|
2006-03-22 20:07:28 +00:00
|
|
|
}
|
2008-04-03 12:34:47 +01:00
|
|
|
return out;
|
2006-03-22 20:07:28 +00:00
|
|
|
}
|
|
|
|
if (IsApplTerm(trm)) {
|
|
|
|
Term *p;
|
|
|
|
Functor f;
|
|
|
|
Term *p0 = p = PtoHeapCellAdjust(RepAppl(trm));
|
|
|
|
/* if it is before the current position, then we are looking
|
|
|
|
at old code */
|
|
|
|
if (p >= p_base) {
|
|
|
|
f = (Functor)p[0];
|
|
|
|
if (!IsExtensionFunctor(f)) {
|
|
|
|
UInt Arity, i;
|
|
|
|
|
|
|
|
f = FuncAdjust(f);
|
|
|
|
*p++ = (Term)f;
|
|
|
|
Arity = ArityOfFunctor(f);
|
|
|
|
for (i = 0; i < Arity; ++i) {
|
|
|
|
*p = AdjustDBTerm(*p, p0);
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return AbsAppl(p0);
|
|
|
|
}
|
|
|
|
return trm;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-11-06 17:02:13 +00:00
|
|
|
RestoreDBTerm(DBTerm *dbr, int attachments)
|
2006-03-22 20:07:28 +00:00
|
|
|
{
|
2007-11-06 17:02:13 +00:00
|
|
|
if (attachments) {
|
2006-03-22 20:07:28 +00:00
|
|
|
#ifdef COROUTINING
|
2007-11-06 17:02:13 +00:00
|
|
|
if (dbr->ag.attachments)
|
|
|
|
dbr->ag.attachments = AdjustDBTerm(dbr->ag.attachments, dbr->Contents);
|
2006-03-22 20:07:28 +00:00
|
|
|
#endif
|
2007-11-06 17:02:13 +00:00
|
|
|
} else {
|
2008-04-01 09:42:46 +01:00
|
|
|
if (dbr->ag.NextDBT)
|
|
|
|
dbr->ag.NextDBT = DBTermAdjust(dbr->ag.NextDBT);
|
2007-11-06 17:02:13 +00:00
|
|
|
}
|
2006-03-22 20:07:28 +00:00
|
|
|
if (dbr->DBRefs != NULL) {
|
|
|
|
DBRef *cp;
|
|
|
|
DBRef tm;
|
|
|
|
|
|
|
|
dbr->DBRefs = DBRefPAdjust(dbr->DBRefs);
|
|
|
|
cp = dbr->DBRefs;
|
|
|
|
while ((tm = *--cp) != 0)
|
|
|
|
*cp = DBRefAdjust(tm);
|
|
|
|
}
|
|
|
|
dbr->Entry = AdjustDBTerm(dbr->Entry, dbr->Contents);
|
|
|
|
}
|
|
|
|
|
2007-11-06 17:02:13 +00:00
|
|
|
/* Restoring the heap */
|
|
|
|
|
2006-03-22 20:07:28 +00:00
|
|
|
/* Restores a prolog clause, in its compiled form */
|
|
|
|
static void
|
|
|
|
RestoreStaticClause(StaticClause *cl)
|
|
|
|
/*
|
|
|
|
* Cl points to the start of the code, IsolFlag tells if we have a single
|
|
|
|
* clause for this predicate or not
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
if (cl->ClFlags & FactMask) {
|
|
|
|
cl->usc.ClPred = PtoPredAdjust(cl->usc.ClPred);
|
|
|
|
} else {
|
|
|
|
cl->usc.ClSource = DBTermAdjust(cl->usc.ClSource);
|
|
|
|
}
|
|
|
|
if (cl->ClNext) {
|
|
|
|
cl->ClNext = PtoStCAdjust(cl->ClNext);
|
|
|
|
}
|
|
|
|
restore_opcodes(cl->ClCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restores a prolog clause, in its compiled form */
|
|
|
|
static void
|
|
|
|
RestoreMegaClause(MegaClause *cl)
|
|
|
|
/*
|
|
|
|
* Cl points to the start of the code, IsolFlag tells if we have a single
|
|
|
|
* clause for this predicate or not
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
cl->ClPred = PtoPredAdjust(cl->ClPred);
|
|
|
|
if (cl->ClNext) {
|
|
|
|
cl->ClNext = (MegaClause *)AddrAdjust((ADDR)(cl->ClNext));
|
|
|
|
}
|
|
|
|
restore_opcodes(cl->ClCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restores a prolog clause, in its compiled form */
|
|
|
|
static void
|
|
|
|
RestoreDynamicClause(DynamicClause *cl, PredEntry *pp)
|
|
|
|
/*
|
|
|
|
* Cl points to the start of the code, IsolFlag tells if we have a single
|
|
|
|
* clause for this predicate or not
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
if (cl->ClPrevious != NULL) {
|
|
|
|
cl->ClPrevious = PtoOpAdjust(cl->ClPrevious);
|
|
|
|
}
|
|
|
|
INIT_LOCK(cl->ClLock);
|
|
|
|
restore_opcodes(cl->ClCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restores a prolog clause, in its compiled form */
|
|
|
|
static void
|
|
|
|
RestoreLUClause(LogUpdClause *cl, PredEntry *pp)
|
|
|
|
/*
|
|
|
|
* Cl points to the start of the code, IsolFlag tells if we have a single
|
|
|
|
* clause for this predicate or not
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
INIT_LOCK(cl->ClLock);
|
|
|
|
if (cl->ClFlags & LogUpdRuleMask) {
|
|
|
|
cl->ClExt = PtoOpAdjust(cl->ClExt);
|
|
|
|
}
|
|
|
|
if (cl->ClSource) {
|
|
|
|
cl->ClSource = DBTermAdjust(cl->ClSource);
|
2007-11-06 17:02:13 +00:00
|
|
|
RestoreDBTerm(cl->ClSource, TRUE);
|
2006-03-22 20:07:28 +00:00
|
|
|
}
|
|
|
|
if (cl->ClPrev) {
|
|
|
|
cl->ClPrev = PtoLUCAdjust(cl->ClPrev);
|
|
|
|
}
|
|
|
|
if (cl->ClNext) {
|
|
|
|
cl->ClNext = PtoLUCAdjust(cl->ClNext);
|
|
|
|
}
|
|
|
|
cl->ClPred = PtoPredAdjust(cl->ClPred);
|
|
|
|
restore_opcodes(cl->ClCode);
|
|
|
|
}
|
|
|
|
|
2007-11-06 17:02:13 +00:00
|
|
|
static void
|
|
|
|
RestoreDBTermEntry(struct dbterm_list *dbl) {
|
|
|
|
DBTerm *dbt;
|
|
|
|
|
2008-04-01 09:42:46 +01:00
|
|
|
if (dbl->dbterms)
|
|
|
|
dbt = dbl->dbterms = DBTermAdjust(dbl->dbterms);
|
|
|
|
else
|
|
|
|
return;
|
2007-11-06 17:02:13 +00:00
|
|
|
dbl->clause_code = PtoOpAdjust(dbl->clause_code);
|
2008-04-01 09:42:46 +01:00
|
|
|
if (dbl->next_dbl)
|
|
|
|
dbl->next_dbl = PtoDBTLAdjust(dbl->next_dbl);
|
2007-11-06 17:02:13 +00:00
|
|
|
dbl->p = PredEntryAdjust(dbl->p);
|
|
|
|
while (dbt) {
|
|
|
|
RestoreDBTerm(dbt, FALSE);
|
|
|
|
dbt = dbt->ag.NextDBT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-22 20:07:28 +00:00
|
|
|
static void
|
|
|
|
CleanLUIndex(LogUpdIndex *idx)
|
|
|
|
{
|
|
|
|
INIT_LOCK(idx->ClLock);
|
|
|
|
idx->ClPred = PtoPredAdjust(idx->ClPred);
|
|
|
|
if (idx->ParentIndex)
|
|
|
|
idx->ParentIndex = LUIndexAdjust(idx->ParentIndex);
|
2008-01-23 17:57:56 +00:00
|
|
|
if (idx->PrevSiblingIndex) {
|
|
|
|
idx->PrevSiblingIndex = LUIndexAdjust(idx->PrevSiblingIndex);
|
|
|
|
}
|
2006-03-22 20:07:28 +00:00
|
|
|
if (idx->SiblingIndex) {
|
|
|
|
idx->SiblingIndex = LUIndexAdjust(idx->SiblingIndex);
|
|
|
|
CleanLUIndex(idx->SiblingIndex);
|
|
|
|
}
|
|
|
|
if (idx->ChildIndex) {
|
|
|
|
idx->ChildIndex = LUIndexAdjust(idx->ChildIndex);
|
|
|
|
CleanLUIndex(idx->ChildIndex);
|
|
|
|
}
|
2008-04-01 09:42:46 +01:00
|
|
|
if (!(idx->ClFlags & SwitchTableMask)) {
|
2006-03-22 20:07:28 +00:00
|
|
|
restore_opcodes(idx->ClCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CleanSIndex(StaticIndex *idx)
|
|
|
|
{
|
|
|
|
idx->ClPred = PtoPredAdjust(idx->ClPred);
|
|
|
|
if (idx->SiblingIndex) {
|
|
|
|
idx->SiblingIndex = SIndexAdjust(idx->SiblingIndex);
|
|
|
|
CleanSIndex(idx->SiblingIndex);
|
|
|
|
}
|
|
|
|
if (idx->ChildIndex) {
|
|
|
|
idx->ChildIndex = SIndexAdjust(idx->ChildIndex);
|
|
|
|
CleanSIndex(idx->ChildIndex);
|
|
|
|
}
|
2008-04-01 09:42:46 +01:00
|
|
|
if (!(idx->ClFlags & SwitchTableMask)) {
|
2006-03-22 20:07:28 +00:00
|
|
|
restore_opcodes(idx->ClCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-04 19:21:55 +01:00
|
|
|
/* restore the failcodes */
|
|
|
|
static void
|
|
|
|
restore_codes(void)
|
|
|
|
{
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->heap_top = AddrAdjust(OldHeapTop);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef YAPOR
|
2005-07-06 20:34:12 +01:00
|
|
|
Yap_heap_regs->seq_def = TRUE;
|
|
|
|
Yap_heap_regs->getwork_code.opc = Yap_opcode(_getwork);
|
|
|
|
INIT_YAMOP_LTT(&(Yap_heap_regs->getwork_code), 0);
|
|
|
|
Yap_heap_regs->getwork_seq_code.opc = Yap_opcode(_getwork_seq);
|
|
|
|
INIT_YAMOP_LTT(&(Yap_heap_regs->getwork_seq_code), 0);
|
|
|
|
Yap_heap_regs->getwork_first_time_code.opc = Yap_opcode(_getwork_first_time);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif /* YAPOR */
|
|
|
|
#ifdef TABLING
|
2005-08-01 16:40:39 +01:00
|
|
|
Yap_heap_regs->table_load_answer_code.opc = Yap_opcode(_table_load_answer);
|
|
|
|
Yap_heap_regs->table_try_answer_code.opc = Yap_opcode(_table_try_answer);
|
2005-07-06 20:34:12 +01:00
|
|
|
Yap_heap_regs->table_answer_resolution_code.opc = Yap_opcode(_table_answer_resolution);
|
|
|
|
Yap_heap_regs->table_completion_code.opc = Yap_opcode(_table_completion);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef YAPOR
|
2005-08-01 16:40:39 +01:00
|
|
|
INIT_YAMOP_LTT(&(Yap_heap_regs->table_load_answer_code), 0);
|
|
|
|
INIT_YAMOP_LTT(&(Yap_heap_regs->table_try_answer_code), 0);
|
2005-07-06 20:34:12 +01:00
|
|
|
INIT_YAMOP_LTT(&(Yap_heap_regs->table_completion_code), 0);
|
|
|
|
INIT_YAMOP_LTT(&(Yap_heap_regs->table_answer_resolution_code), 0);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif /* YAPOR */
|
|
|
|
#endif /* TABLING */
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->expand_op_code = Yap_opcode(_expand_index);
|
|
|
|
if (Yap_heap_regs->expand_clauses_first)
|
|
|
|
Yap_heap_regs->expand_clauses_first = PtoOpAdjust(Yap_heap_regs->expand_clauses_first);
|
|
|
|
if (Yap_heap_regs->expand_clauses_last)
|
|
|
|
Yap_heap_regs->expand_clauses_last = PtoOpAdjust(Yap_heap_regs->expand_clauses_last);
|
2004-09-27 21:45:04 +01:00
|
|
|
{
|
2004-12-02 06:06:47 +00:00
|
|
|
yamop *ptr = Yap_heap_regs->expand_clauses_first;
|
2004-09-27 21:45:04 +01:00
|
|
|
while (ptr) {
|
|
|
|
do_clean_susp_clauses(ptr);
|
|
|
|
ptr = ptr->u.sp.snext;
|
|
|
|
}
|
|
|
|
}
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->failcode->opc = Yap_opcode(_op_fail);
|
|
|
|
Yap_heap_regs->failcode_1 = Yap_opcode(_op_fail);
|
|
|
|
Yap_heap_regs->failcode_2 = Yap_opcode(_op_fail);
|
|
|
|
Yap_heap_regs->failcode_3 = Yap_opcode(_op_fail);
|
|
|
|
Yap_heap_regs->failcode_4 = Yap_opcode(_op_fail);
|
|
|
|
Yap_heap_regs->failcode_5 = Yap_opcode(_op_fail);
|
|
|
|
Yap_heap_regs->failcode_6 = Yap_opcode(_op_fail);
|
2002-06-04 19:21:55 +01:00
|
|
|
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->env_for_trustfail_code.op = Yap_opcode(_call);
|
|
|
|
Yap_heap_regs->trustfailcode->opc = Yap_opcode(_trust_fail);
|
2002-06-04 19:21:55 +01:00
|
|
|
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->env_for_yes_code.op = Yap_opcode(_call);
|
2008-03-25 16:45:53 +00:00
|
|
|
Yap_heap_regs->yescode.opc = Yap_opcode(_Ystop);
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->undef_op = Yap_opcode(_undef_p);
|
|
|
|
Yap_heap_regs->index_op = Yap_opcode(_index_pred);
|
2007-11-26 23:43:10 +00:00
|
|
|
Yap_heap_regs->lockpred_op = Yap_opcode(_lock_pred);
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->fail_op = Yap_opcode(_op_fail);
|
2008-03-25 16:45:53 +00:00
|
|
|
Yap_heap_regs->nocode.opc = Yap_opcode(_Nstop);
|
|
|
|
Yap_heap_regs->rtrycode.opc = Yap_opcode(_retry_and_mark);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef YAPOR
|
2004-12-02 06:06:47 +00:00
|
|
|
INIT_YAMOP_LTT(&(Yap_heap_regs->nocode), 1);
|
|
|
|
INIT_YAMOP_LTT(&(Yap_heap_regs->rtrycode), 1);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif /* YAPOR */
|
2004-12-02 06:06:47 +00:00
|
|
|
if (((yamop *)(&Yap_heap_regs->rtrycode))->u.ld.d != NIL)
|
|
|
|
((yamop *)(&Yap_heap_regs->rtrycode))->u.ld.d =
|
|
|
|
PtoOpAdjust(((yamop *)(&Yap_heap_regs->rtrycode))->u.ld.d);
|
2002-06-04 19:21:55 +01:00
|
|
|
{
|
|
|
|
int arity;
|
2004-12-02 06:06:47 +00:00
|
|
|
arity = Yap_heap_regs->clausecode->arity;
|
|
|
|
if (Yap_heap_regs->clausecode->clause != NIL)
|
|
|
|
Yap_heap_regs->clausecode->clause =
|
|
|
|
PtoOpAdjust(Yap_heap_regs->clausecode->clause);
|
2002-06-04 19:21:55 +01:00
|
|
|
if (arity) {
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->clausecode->func =
|
|
|
|
FuncAdjust(Yap_heap_regs->clausecode->func);
|
2002-06-04 19:21:55 +01:00
|
|
|
} else {
|
|
|
|
/* an atom */
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->clausecode->func =
|
|
|
|
(Functor)AtomAdjust((Atom)(Yap_heap_regs->clausecode->func));
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
}
|
2008-03-25 16:45:53 +00:00
|
|
|
#if !defined(THREADS) && !defined(YAPOR)
|
2002-06-04 19:21:55 +01:00
|
|
|
/* restore consult stack. It consists of heap pointers, so it
|
|
|
|
is easy to fix.
|
|
|
|
*/
|
2006-04-28 16:48:33 +01:00
|
|
|
Yap_heap_regs->wl.consultlow =
|
|
|
|
ConsultObjAdjust(Yap_heap_regs->wl.consultlow);
|
|
|
|
Yap_heap_regs->wl.consultbase =
|
|
|
|
ConsultObjAdjust(Yap_heap_regs->wl.consultbase);
|
|
|
|
Yap_heap_regs->wl.consultsp =
|
|
|
|
ConsultObjAdjust(Yap_heap_regs->wl.consultsp);
|
2002-06-04 19:21:55 +01:00
|
|
|
{
|
|
|
|
/* we assume all pointers have the same size */
|
2006-04-28 16:48:33 +01:00
|
|
|
register consult_obj *pt = Yap_heap_regs->wl.consultsp;
|
2002-06-04 19:21:55 +01:00
|
|
|
while (pt <
|
2006-04-28 16:48:33 +01:00
|
|
|
Yap_heap_regs->wl.consultlow+Yap_heap_regs->wl.consultcapacity) {
|
2002-06-04 19:21:55 +01:00
|
|
|
pt->p = PropAdjust(pt->p);
|
|
|
|
pt ++;
|
|
|
|
}
|
|
|
|
}
|
2006-04-28 16:48:33 +01:00
|
|
|
#endif
|
2002-06-04 19:21:55 +01:00
|
|
|
#if USE_THREADED_CODE
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->op_rtable = (opentry *)
|
|
|
|
CodeAddrAdjust((CODEADDR)(Yap_heap_regs->op_rtable));
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
if (Yap_heap_regs->atprompt != NIL) {
|
|
|
|
Yap_heap_regs->atprompt =
|
|
|
|
AtomAdjust(Yap_heap_regs->atprompt);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
2007-04-10 23:13:21 +01:00
|
|
|
if (Yap_heap_regs->current_modules) {
|
|
|
|
Yap_heap_regs->current_modules = (struct mod_entry *)
|
|
|
|
AddrAdjust((ADDR)Yap_heap_regs->current_modules);
|
|
|
|
}
|
2006-03-22 20:07:28 +00:00
|
|
|
if (Yap_heap_regs->char_conversion_table) {
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->char_conversion_table = (char *)
|
|
|
|
AddrAdjust((ADDR)Yap_heap_regs->char_conversion_table);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
2006-03-22 20:07:28 +00:00
|
|
|
if (Yap_heap_regs->char_conversion_table2) {
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->char_conversion_table2 = (char *)
|
|
|
|
AddrAdjust((ADDR)Yap_heap_regs->char_conversion_table2);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
2006-04-28 14:23:23 +01:00
|
|
|
if (Yap_heap_regs->op_list) {
|
|
|
|
Yap_heap_regs->op_list = (struct operator_entry *)
|
|
|
|
AddrAdjust((ADDR)Yap_heap_regs->op_list);
|
|
|
|
}
|
2006-03-22 20:07:28 +00:00
|
|
|
if (Yap_heap_regs->dead_static_clauses) {
|
|
|
|
StaticClause *sc = PtoStCAdjust(Yap_heap_regs->dead_static_clauses);
|
|
|
|
Yap_heap_regs->dead_static_clauses = sc;
|
|
|
|
while (sc) {
|
|
|
|
RestoreStaticClause(sc);
|
|
|
|
sc = sc->ClNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Yap_heap_regs->dead_mega_clauses) {
|
|
|
|
MegaClause *mc = (MegaClause *)AddrAdjust((ADDR)(Yap_heap_regs->dead_mega_clauses));
|
|
|
|
Yap_heap_regs->dead_mega_clauses = mc;
|
|
|
|
while (mc) {
|
|
|
|
RestoreMegaClause(mc);
|
|
|
|
mc = mc->ClNext;
|
|
|
|
}
|
|
|
|
}
|
2007-11-06 17:02:13 +00:00
|
|
|
if (Yap_heap_regs->dbterms_list) {
|
|
|
|
struct dbterm_list *dbl = PtoDBTLAdjust(Yap_heap_regs->dbterms_list);
|
|
|
|
Yap_heap_regs->dbterms_list = dbl;
|
|
|
|
while (dbl) {
|
|
|
|
RestoreDBTermEntry(dbl);
|
|
|
|
dbl = dbl->next_dbl;
|
|
|
|
}
|
|
|
|
}
|
2006-03-22 20:07:28 +00:00
|
|
|
if (Yap_heap_regs->dead_static_indices) {
|
|
|
|
StaticIndex *si = (StaticIndex *)AddrAdjust((ADDR)(Yap_heap_regs->dead_static_indices));
|
|
|
|
Yap_heap_regs->dead_static_indices = si;
|
|
|
|
while (si) {
|
|
|
|
CleanSIndex(si);
|
|
|
|
si = si->SiblingIndex;
|
|
|
|
}
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->retry_recorded_k_code =
|
|
|
|
PtoOpAdjust(Yap_heap_regs->retry_recorded_k_code);
|
|
|
|
Yap_heap_regs->retry_c_recordedp_code =
|
|
|
|
PtoOpAdjust(Yap_heap_regs->retry_c_recordedp_code);
|
|
|
|
if (Yap_heap_regs->IntKeys != NULL) {
|
|
|
|
Yap_heap_regs->IntKeys = (Prop *)AddrAdjust((ADDR)(Yap_heap_regs->IntKeys));
|
2002-06-04 19:21:55 +01:00
|
|
|
{
|
|
|
|
UInt i;
|
2004-12-02 06:06:47 +00:00
|
|
|
for (i = 0; i < Yap_heap_regs->int_keys_size; i++) {
|
|
|
|
if (Yap_heap_regs->IntKeys[i] != NIL) {
|
|
|
|
Prop p0 = Yap_heap_regs->IntKeys[i] = PropAdjust(Yap_heap_regs->IntKeys[i]);
|
2008-04-03 12:34:47 +01:00
|
|
|
RestoreEntries(RepProp(p0), TRUE);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-12-02 06:06:47 +00:00
|
|
|
if (Yap_heap_regs->IntLUKeys != NULL) {
|
|
|
|
Yap_heap_regs->IntLUKeys = (Prop *)AddrAdjust((ADDR)(Yap_heap_regs->IntLUKeys));
|
2004-02-06 10:19:49 +00:00
|
|
|
{
|
|
|
|
Int i;
|
|
|
|
for (i = 0; i < INT_KEYS_SIZE; i++) {
|
|
|
|
Prop p0 = INT_LU_KEYS[i];
|
|
|
|
if (p0) {
|
|
|
|
p0 = PropAdjust(p0);
|
|
|
|
INT_LU_KEYS[i] = p0;
|
|
|
|
while (p0) {
|
|
|
|
PredEntry *pe = RepPredProp(p0);
|
|
|
|
pe->NextOfPE =
|
|
|
|
PropAdjust(pe->NextOfPE);
|
|
|
|
CleanCode(pe);
|
|
|
|
p0 = RepProp(pe->NextOfPE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-12-02 06:06:47 +00:00
|
|
|
if (Yap_heap_regs->IntBBKeys != NULL) {
|
|
|
|
Yap_heap_regs->IntBBKeys = (Prop *)AddrAdjust((ADDR)(Yap_heap_regs->IntBBKeys));
|
2002-06-04 19:21:55 +01:00
|
|
|
{
|
|
|
|
UInt i;
|
2004-12-02 06:06:47 +00:00
|
|
|
for (i = 0; i < Yap_heap_regs->int_bb_keys_size; i++) {
|
|
|
|
if (Yap_heap_regs->IntBBKeys[i] != NIL) {
|
|
|
|
Prop p0 = Yap_heap_regs->IntBBKeys[i] = PropAdjust(Yap_heap_regs->IntBBKeys[i]);
|
2008-04-03 12:34:47 +01:00
|
|
|
RestoreEntries(RepProp(p0), TRUE);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->atom_abol = AtomAdjust(Yap_heap_regs->atom_abol);
|
|
|
|
Yap_heap_regs->atom_append = AtomAdjust(Yap_heap_regs->atom_append);
|
|
|
|
Yap_heap_regs->atom_array = AtomAdjust(Yap_heap_regs->atom_array);
|
|
|
|
Yap_heap_regs->atom_assert = AtomAdjust(Yap_heap_regs->atom_assert);
|
|
|
|
Yap_heap_regs->atom_alarm = AtomAdjust(Yap_heap_regs->atom_alarm);
|
2005-09-09 18:24:39 +01:00
|
|
|
#ifdef COROUTINING
|
|
|
|
Yap_heap_regs->atom_att = AtomAdjust(Yap_heap_regs->atom_att);
|
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->atom_b = AtomAdjust(Yap_heap_regs->atom_b);
|
|
|
|
Yap_heap_regs->atom_break = AtomAdjust(Yap_heap_regs->atom_break);
|
|
|
|
Yap_heap_regs->atom_call = AtomAdjust(Yap_heap_regs->atom_call);
|
|
|
|
Yap_heap_regs->atom_catch = AtomAdjust(Yap_heap_regs->atom_catch);
|
|
|
|
Yap_heap_regs->atom_comma = AtomAdjust(Yap_heap_regs->atom_comma);
|
|
|
|
Yap_heap_regs->atom_cpu_time = AtomAdjust(Yap_heap_regs->atom_cpu_time);
|
|
|
|
Yap_heap_regs->atom_csult = AtomAdjust(Yap_heap_regs->atom_csult);
|
|
|
|
Yap_heap_regs->atom_cut = AtomAdjust(Yap_heap_regs->atom_cut);
|
|
|
|
Yap_heap_regs->atom_cut_by = AtomAdjust(Yap_heap_regs->atom_cut_by);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef EUROTRA
|
|
|
|
#ifdef SFUNC
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->atom_dollar_undef = AtomAdjust(Yap_heap_regs->atom_dollar_undef);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->atom_dbref = AtomAdjust(Yap_heap_regs->atom_dbref);
|
|
|
|
Yap_heap_regs->atom_e = AtomAdjust(Yap_heap_regs->atom_e);
|
|
|
|
Yap_heap_regs->atom_e_q = AtomAdjust(Yap_heap_regs->atom_e_q);
|
|
|
|
Yap_heap_regs->atom_eof = AtomAdjust(Yap_heap_regs->atom_eof);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef EUROTRA
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->atom_f_b = AtomAdjust(Yap_heap_regs->atom_f_b);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->atom_fail = AtomAdjust(Yap_heap_regs->atom_fail);
|
|
|
|
Yap_heap_regs->atom_false = AtomAdjust(Yap_heap_regs->atom_false);
|
|
|
|
Yap_heap_regs->atom_fast = AtomAdjust(Yap_heap_regs->atom_fast);
|
|
|
|
Yap_heap_regs->atom_g_t = AtomAdjust(Yap_heap_regs->atom_g_t);
|
|
|
|
Yap_heap_regs->atom_gc = AtomAdjust(Yap_heap_regs->atom_gc);
|
|
|
|
Yap_heap_regs->atom_gc_margin = AtomAdjust(Yap_heap_regs->atom_gc_margin);
|
|
|
|
Yap_heap_regs->atom_gc_trace = AtomAdjust(Yap_heap_regs->atom_gc_trace);
|
|
|
|
Yap_heap_regs->atom_gc_verbose = AtomAdjust(Yap_heap_regs->atom_gc_verbose);
|
|
|
|
Yap_heap_regs->atom_gc_very_verbose = AtomAdjust(Yap_heap_regs->atom_gc_very_verbose);
|
|
|
|
Yap_heap_regs->atom_global = AtomAdjust(Yap_heap_regs->atom_global);
|
|
|
|
Yap_heap_regs->atom_heap_used = AtomAdjust(Yap_heap_regs->atom_heap_used);
|
|
|
|
Yap_heap_regs->atom_inf = AtomAdjust(Yap_heap_regs->atom_inf);
|
|
|
|
Yap_heap_regs->atom_l_t = AtomAdjust(Yap_heap_regs->atom_l_t);
|
|
|
|
Yap_heap_regs->atom_local = AtomAdjust(Yap_heap_regs->atom_local);
|
|
|
|
Yap_heap_regs->atom_meta_call = AtomAdjust(Yap_heap_regs->atom_meta_call);
|
|
|
|
Yap_heap_regs->atom_minus = AtomAdjust(Yap_heap_regs->atom_minus);
|
|
|
|
Yap_heap_regs->atom_multi_file = AtomAdjust(Yap_heap_regs->atom_multi_file);
|
|
|
|
Yap_heap_regs->atom_nan = AtomAdjust(Yap_heap_regs->atom_nan);
|
|
|
|
Yap_heap_regs->atom_otherwise = AtomAdjust(Yap_heap_regs->atom_otherwise);
|
|
|
|
Yap_heap_regs->atom_pi = AtomAdjust(Yap_heap_regs->atom_pi);
|
|
|
|
Yap_heap_regs->atom_plus = AtomAdjust(Yap_heap_regs->atom_plus);
|
|
|
|
Yap_heap_regs->atom_portray = AtomAdjust(Yap_heap_regs->atom_portray);
|
|
|
|
Yap_heap_regs->atom_profile = AtomAdjust(Yap_heap_regs->atom_profile);
|
|
|
|
Yap_heap_regs->atom_random = AtomAdjust(Yap_heap_regs->atom_random);
|
|
|
|
Yap_heap_regs->atom_read = AtomAdjust(Yap_heap_regs->atom_read);
|
|
|
|
Yap_heap_regs->atom_repeat = AtomAdjust(Yap_heap_regs->atom_repeat);
|
|
|
|
Yap_heap_regs->atom_restore_regs = AtomAdjust(Yap_heap_regs->atom_restore_regs);
|
2002-06-04 19:21:55 +01:00
|
|
|
#if HAVE_SIGACTION
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->atom_sig_pending = AtomAdjust(Yap_heap_regs->atom_sig_pending);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->atom_stack_free = AtomAdjust(Yap_heap_regs->atom_stack_free);
|
|
|
|
Yap_heap_regs->atom_true = AtomAdjust(Yap_heap_regs->atom_true);
|
|
|
|
Yap_heap_regs->atom_user = AtomAdjust(Yap_heap_regs->atom_user);
|
|
|
|
Yap_heap_regs->atom_usr_err = AtomAdjust(Yap_heap_regs->atom_usr_err);
|
|
|
|
Yap_heap_regs->atom_usr_in = AtomAdjust(Yap_heap_regs->atom_usr_in);
|
|
|
|
Yap_heap_regs->atom_usr_out = AtomAdjust(Yap_heap_regs->atom_usr_out);
|
|
|
|
Yap_heap_regs->atom_version_number = AtomAdjust(Yap_heap_regs->atom_version_number);
|
|
|
|
Yap_heap_regs->atom_write = AtomAdjust(Yap_heap_regs->atom_write);
|
2006-01-02 02:16:19 +00:00
|
|
|
Yap_heap_regs->float_format = AtomAdjust(Yap_heap_regs->float_format);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef USE_SOCKET
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->functor_af_inet = FuncAdjust(Yap_heap_regs->functor_af_inet);
|
|
|
|
Yap_heap_regs->functor_af_local = FuncAdjust(Yap_heap_regs->functor_af_local);
|
|
|
|
Yap_heap_regs->functor_af_unix = FuncAdjust(Yap_heap_regs->functor_af_unix);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->functor_alt_not = FuncAdjust(Yap_heap_regs->functor_alt_not);
|
|
|
|
Yap_heap_regs->functor_arrow = FuncAdjust(Yap_heap_regs->functor_arrow);
|
|
|
|
Yap_heap_regs->functor_assert = FuncAdjust(Yap_heap_regs->functor_assert);
|
2005-10-28 18:38:50 +01:00
|
|
|
Yap_heap_regs->functor_at_found_one = FuncAdjust(Yap_heap_regs->functor_at_found_one);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef COROUTINING
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->functor_att_goal = FuncAdjust(Yap_heap_regs->functor_att_goal);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->functor_braces = FuncAdjust(Yap_heap_regs->functor_braces);
|
|
|
|
Yap_heap_regs->functor_call = FuncAdjust(Yap_heap_regs->functor_call);
|
|
|
|
Yap_heap_regs->functor_cut_by = FuncAdjust(Yap_heap_regs->functor_cut_by);
|
|
|
|
Yap_heap_regs->functor_comma = FuncAdjust(Yap_heap_regs->functor_comma);
|
|
|
|
Yap_heap_regs->functor_creep = FuncAdjust(Yap_heap_regs->functor_creep);
|
|
|
|
Yap_heap_regs->functor_csult = FuncAdjust(Yap_heap_regs->functor_csult);
|
|
|
|
Yap_heap_regs->functor_eq = FuncAdjust(Yap_heap_regs->functor_eq);
|
|
|
|
Yap_heap_regs->functor_execute_in_mod = FuncAdjust(Yap_heap_regs->functor_execute_in_mod);
|
2007-11-07 09:25:27 +00:00
|
|
|
Yap_heap_regs->functor_execute2_in_mod = FuncAdjust(Yap_heap_regs->functor_execute2_in_mod);
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->functor_execute_within = FuncAdjust(Yap_heap_regs->functor_execute_within);
|
|
|
|
Yap_heap_regs->functor_g_atom = FuncAdjust(Yap_heap_regs->functor_g_atom);
|
|
|
|
Yap_heap_regs->functor_g_atomic = FuncAdjust(Yap_heap_regs->functor_g_atomic);
|
|
|
|
Yap_heap_regs->functor_g_compound = FuncAdjust(Yap_heap_regs->functor_g_compound);
|
|
|
|
Yap_heap_regs->functor_g_float = FuncAdjust(Yap_heap_regs->functor_g_float);
|
2005-10-28 18:38:50 +01:00
|
|
|
Yap_heap_regs->functor_g_format_at = FuncAdjust(Yap_heap_regs->functor_g_format_at);
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->functor_g_integer = FuncAdjust(Yap_heap_regs->functor_g_integer);
|
|
|
|
Yap_heap_regs->functor_g_number = FuncAdjust(Yap_heap_regs->functor_g_number);
|
|
|
|
Yap_heap_regs->functor_g_primitive = FuncAdjust(Yap_heap_regs->functor_g_primitive);
|
|
|
|
Yap_heap_regs->functor_g_var = FuncAdjust(Yap_heap_regs->functor_g_var);
|
|
|
|
Yap_heap_regs->functor_last_execute_within = FuncAdjust(Yap_heap_regs->functor_last_execute_within);
|
|
|
|
Yap_heap_regs->functor_list = FuncAdjust(Yap_heap_regs->functor_list);
|
|
|
|
Yap_heap_regs->functor_mega_clause = FuncAdjust(Yap_heap_regs->functor_mega_clause);
|
|
|
|
Yap_heap_regs->functor_module = FuncAdjust(Yap_heap_regs->functor_module);
|
|
|
|
Yap_heap_regs->functor_multi_file_clause = FuncAdjust(Yap_heap_regs->functor_multi_file_clause);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->functor_mutable = FuncAdjust(Yap_heap_regs->functor_mutable);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2006-08-22 17:12:46 +01:00
|
|
|
Yap_heap_regs->functor_nb_queue = FuncAdjust(Yap_heap_regs->functor_nb_queue);
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->functor_not = FuncAdjust(Yap_heap_regs->functor_not);
|
|
|
|
Yap_heap_regs->functor_or = FuncAdjust(Yap_heap_regs->functor_or);
|
|
|
|
Yap_heap_regs->functor_portray = FuncAdjust(Yap_heap_regs->functor_portray);
|
|
|
|
Yap_heap_regs->functor_query = FuncAdjust(Yap_heap_regs->functor_query);
|
|
|
|
Yap_heap_regs->functor_static_clause = FuncAdjust(Yap_heap_regs->functor_static_clause);
|
|
|
|
Yap_heap_regs->functor_stream = FuncAdjust(Yap_heap_regs->functor_stream);
|
|
|
|
Yap_heap_regs->functor_stream_pos = FuncAdjust(Yap_heap_regs->functor_stream_pos);
|
|
|
|
Yap_heap_regs->functor_stream_eOS = FuncAdjust(Yap_heap_regs->functor_stream_eOS);
|
|
|
|
Yap_heap_regs->functor_change_module = FuncAdjust(Yap_heap_regs->functor_change_module);
|
|
|
|
Yap_heap_regs->functor_current_module = FuncAdjust(Yap_heap_regs->functor_current_module);
|
|
|
|
Yap_heap_regs->functor_u_minus = FuncAdjust(Yap_heap_regs->functor_u_minus);
|
|
|
|
Yap_heap_regs->functor_u_plus = FuncAdjust(Yap_heap_regs->functor_u_plus);
|
|
|
|
Yap_heap_regs->functor_v_bar = FuncAdjust(Yap_heap_regs->functor_v_bar);
|
|
|
|
Yap_heap_regs->functor_var = FuncAdjust(Yap_heap_regs->functor_var);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef EUROTRA
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->term_dollar_u = AtomTermAdjust(Yap_heap_regs->term_dollar_u);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->term_prolog = AtomTermAdjust(Yap_heap_regs->term_prolog);
|
|
|
|
Yap_heap_regs->term_refound_var = AtomTermAdjust(Yap_heap_regs->term_refound_var);
|
|
|
|
Yap_heap_regs->user_module = AtomTermAdjust(Yap_heap_regs->user_module);
|
|
|
|
Yap_heap_regs->idb_module = AtomTermAdjust(Yap_heap_regs->idb_module);
|
|
|
|
Yap_heap_regs->attributes_module = AtomTermAdjust(Yap_heap_regs->attributes_module);
|
|
|
|
Yap_heap_regs->charsio_module = AtomTermAdjust(Yap_heap_regs->charsio_module);
|
|
|
|
Yap_heap_regs->terms_module = AtomTermAdjust(Yap_heap_regs->terms_module);
|
2006-05-17 19:38:11 +01:00
|
|
|
Yap_heap_regs->system_module = AtomTermAdjust(Yap_heap_regs->system_module);
|
2006-08-02 19:18:31 +01:00
|
|
|
Yap_heap_regs->readutil_module = AtomTermAdjust(Yap_heap_regs->readutil_module);
|
2008-04-01 09:42:46 +01:00
|
|
|
Yap_heap_regs->hacks_module = AtomTermAdjust(Yap_heap_regs->hacks_module);
|
2006-08-25 20:50:35 +01:00
|
|
|
Yap_heap_regs->globals_module = AtomTermAdjust(Yap_heap_regs->globals_module);
|
2008-02-12 17:03:59 +00:00
|
|
|
Yap_heap_regs->arg_module = AtomTermAdjust(Yap_heap_regs->arg_module);
|
2007-10-10 10:44:28 +01:00
|
|
|
Yap_heap_regs->swi_module = AtomTermAdjust(Yap_heap_regs->swi_module);
|
2007-12-05 12:17:25 +00:00
|
|
|
Yap_heap_regs->global_hold_entry = HoldEntryAdjust(Yap_heap_regs->global_hold_entry);
|
2008-04-01 16:31:43 +01:00
|
|
|
if (Yap_heap_regs->yap_streams != NULL) {
|
|
|
|
int sno;
|
|
|
|
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->yap_streams =
|
|
|
|
(struct stream_desc *)AddrAdjust((ADDR)Yap_heap_regs->yap_streams);
|
2008-04-01 16:31:43 +01:00
|
|
|
for (sno = 0; sno < MaxStreams; ++sno) {
|
|
|
|
if (Stream[sno].status & Free_Stream_f)
|
|
|
|
continue;
|
|
|
|
if (Stream[sno].status & (Socket_Stream_f|Pipe_Stream_f|InMemory_Stream_f))
|
|
|
|
continue;
|
|
|
|
Stream[sno].u.file.user_name = AtomTermAdjust(Stream[sno].u.file.user_name);
|
|
|
|
Stream[sno].u.file.name = AtomAdjust(Stream[sno].u.file.name);
|
|
|
|
}
|
2002-11-11 17:38:10 +00:00
|
|
|
}
|
2004-12-02 06:06:47 +00:00
|
|
|
if (Yap_heap_regs->file_aliases != NULL) {
|
2008-04-01 16:31:43 +01:00
|
|
|
int i;
|
|
|
|
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->file_aliases =
|
|
|
|
(struct AliasDescS *)AddrAdjust((ADDR)Yap_heap_regs->file_aliases);
|
2008-04-01 16:31:43 +01:00
|
|
|
for (i = 0; i < NOfFileAliases; i++)
|
|
|
|
FileAliases[i].name = AtomAdjust(FileAliases[i].name);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
2008-04-01 10:41:05 +01:00
|
|
|
if (Yap_heap_regs->yap_lib_dir) {
|
|
|
|
Yap_heap_regs->yap_lib_dir =
|
|
|
|
(char *)AddrAdjust((ADDR)Yap_heap_regs->yap_lib_dir);
|
|
|
|
}
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->pred_goal_expansion =
|
2007-11-06 17:02:13 +00:00
|
|
|
PredEntryAdjust(Yap_heap_regs->pred_goal_expansion);
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->pred_meta_call =
|
2007-11-06 17:02:13 +00:00
|
|
|
PredEntryAdjust(Yap_heap_regs->pred_meta_call);
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->pred_dollar_catch =
|
2007-11-06 17:02:13 +00:00
|
|
|
PredEntryAdjust(Yap_heap_regs->pred_dollar_catch);
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->pred_recorded_with_key =
|
2007-11-06 17:02:13 +00:00
|
|
|
PredEntryAdjust(Yap_heap_regs->pred_recorded_with_key);
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->pred_log_upd_clause =
|
2007-11-06 17:02:13 +00:00
|
|
|
PredEntryAdjust(Yap_heap_regs->pred_log_upd_clause);
|
2008-01-23 17:57:56 +00:00
|
|
|
Yap_heap_regs->pred_log_upd_clause_erase =
|
|
|
|
PredEntryAdjust(Yap_heap_regs->pred_log_upd_clause_erase);
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->pred_log_upd_clause0 =
|
2007-11-06 17:02:13 +00:00
|
|
|
PredEntryAdjust(Yap_heap_regs->pred_log_upd_clause0);
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->pred_static_clause =
|
2007-11-06 17:02:13 +00:00
|
|
|
PredEntryAdjust(Yap_heap_regs->pred_static_clause);
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->pred_throw =
|
2007-11-06 17:02:13 +00:00
|
|
|
PredEntryAdjust(Yap_heap_regs->pred_throw);
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->pred_handle_throw =
|
2007-11-06 17:02:13 +00:00
|
|
|
PredEntryAdjust(Yap_heap_regs->pred_handle_throw);
|
2008-03-25 22:03:14 +00:00
|
|
|
#ifdef DEBUG
|
2005-11-23 03:01:33 +00:00
|
|
|
if (Yap_heap_regs->db_erased_list) {
|
|
|
|
Yap_heap_regs->db_erased_list =
|
|
|
|
PtoLUCAdjust(Yap_heap_regs->db_erased_list);
|
|
|
|
}
|
|
|
|
if (Yap_heap_regs->db_erased_ilist) {
|
|
|
|
Yap_heap_regs->db_erased_ilist =
|
|
|
|
LUIndexAdjust(Yap_heap_regs->db_erased_ilist);
|
|
|
|
}
|
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
if (Yap_heap_regs->undef_code != NULL)
|
|
|
|
Yap_heap_regs->undef_code = (PredEntry *)PtoHeapCellAdjust((CELL *)(Yap_heap_regs->undef_code));
|
|
|
|
if (Yap_heap_regs->creep_code != NULL)
|
|
|
|
Yap_heap_regs->creep_code = (PredEntry *)PtoHeapCellAdjust((CELL *)(Yap_heap_regs->creep_code));
|
|
|
|
if (Yap_heap_regs->spy_code != NULL)
|
|
|
|
Yap_heap_regs->spy_code = (PredEntry *)PtoHeapCellAdjust((CELL *)(Yap_heap_regs->spy_code));
|
2008-03-25 16:45:53 +00:00
|
|
|
#if !defined(THREADS) && !defined(YAPOR)
|
2005-11-23 03:01:33 +00:00
|
|
|
if (Yap_heap_regs->wl.scratchpad.ptr) {
|
|
|
|
Yap_heap_regs->wl.scratchpad.ptr =
|
|
|
|
(char *)AddrAdjust((ADDR)Yap_heap_regs->wl.scratchpad.ptr);
|
|
|
|
}
|
2006-03-06 14:04:57 +00:00
|
|
|
Yap_heap_regs->wl.gc_generation =
|
|
|
|
AbsAppl(PtoGloAdjust(RepAppl(Yap_heap_regs->wl.gc_generation)));
|
|
|
|
Yap_heap_regs->wl.gc_phase =
|
|
|
|
AbsAppl(PtoGloAdjust(RepAppl(Yap_heap_regs->wl.gc_phase)));
|
|
|
|
/* current phase is an integer */
|
2005-11-23 03:01:33 +00:00
|
|
|
#endif
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef COROUTINING
|
2004-12-02 06:06:47 +00:00
|
|
|
if (Yap_heap_regs->wake_up_code != NULL)
|
|
|
|
Yap_heap_regs->wake_up_code = (PredEntry *)PtoHeapCellAdjust((CELL *)(Yap_heap_regs->wake_up_code));
|
2008-03-25 16:45:53 +00:00
|
|
|
#if !defined(THREADS) && !defined(YAPOR)
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->wl.atts_mutable_list =
|
|
|
|
AbsAppl(PtoGloAdjust(RepAppl(Yap_heap_regs->wl.atts_mutable_list)));
|
2005-10-28 18:38:50 +01:00
|
|
|
if (Yap_heap_regs->wl.dynamic_arrays) {
|
|
|
|
Yap_heap_regs->wl.dynamic_arrays =
|
|
|
|
PtoArrayEAdjust(Yap_heap_regs->wl.dynamic_arrays);
|
|
|
|
}
|
|
|
|
if (Yap_heap_regs->wl.static_arrays) {
|
|
|
|
Yap_heap_regs->wl.static_arrays =
|
|
|
|
PtoArraySAdjust(Yap_heap_regs->wl.static_arrays);
|
|
|
|
}
|
2006-08-22 17:12:46 +01:00
|
|
|
if (Yap_heap_regs->wl.global_variables) {
|
|
|
|
Yap_heap_regs->wl.global_variables =
|
|
|
|
PtoGlobalEAdjust(Yap_heap_regs->wl.global_variables);
|
|
|
|
}
|
|
|
|
if (Yap_heap_regs->wl.global_arena) {
|
|
|
|
if (IsAtomTerm(Yap_heap_regs->wl.global_arena)) {
|
|
|
|
Yap_heap_regs->wl.global_arena =
|
|
|
|
AtomTermAdjust(Yap_heap_regs->wl.global_arena);
|
|
|
|
} else {
|
|
|
|
Yap_heap_regs->wl.global_arena =
|
|
|
|
AbsAppl(PtoGloAdjust(RepAppl(Yap_heap_regs->wl.global_arena)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Yap_heap_regs->wl.global_delay_arena) {
|
|
|
|
Yap_heap_regs->wl.global_delay_arena =
|
|
|
|
GlobalAdjust(Yap_heap_regs->wl.global_delay_arena);
|
|
|
|
}
|
2007-03-22 11:12:22 +00:00
|
|
|
Yap_heap_regs->wl.allow_restart = FALSE;
|
2004-01-23 02:23:51 +00:00
|
|
|
#endif
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
if (Yap_heap_regs->last_wtime != NULL)
|
|
|
|
Yap_heap_regs->last_wtime = (void *)PtoHeapCellAdjust((CELL *)(Yap_heap_regs->last_wtime));
|
|
|
|
Yap_heap_regs->db_erased_marker =
|
|
|
|
DBRefAdjust(Yap_heap_regs->db_erased_marker);
|
2006-02-24 14:03:42 +00:00
|
|
|
Yap_heap_regs->logdb_erased_marker =
|
|
|
|
PtoLUCAdjust(Yap_heap_regs->logdb_erased_marker);
|
|
|
|
Yap_heap_regs->logdb_erased_marker->Id = FunctorDBRef;
|
|
|
|
Yap_heap_regs->logdb_erased_marker->ClCode->opc = Yap_opcode(_op_fail);
|
|
|
|
Yap_heap_regs->logdb_erased_marker->ClPred =
|
|
|
|
PtoPredAdjust(Yap_heap_regs->logdb_erased_marker->ClPred);
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->hash_chain =
|
|
|
|
(AtomHashEntry *)PtoHeapCellAdjust((CELL *)(Yap_heap_regs->hash_chain));
|
2006-11-27 17:42:03 +00:00
|
|
|
Yap_heap_regs->wide_hash_chain =
|
|
|
|
(AtomHashEntry *)PtoHeapCellAdjust((CELL *)(Yap_heap_regs->wide_hash_chain));
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
RestoreDBEntry(DBRef dbr)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_RESTORE
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, "Restoring at %x", dbr);
|
2002-06-04 19:21:55 +01:00
|
|
|
if (dbr->Flags & DBAtomic)
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, " an atomic term\n");
|
2002-06-04 19:21:55 +01:00
|
|
|
else if (dbr->Flags & DBNoVars)
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, " with no vars\n");
|
2002-06-04 19:21:55 +01:00
|
|
|
else if (dbr->Flags & DBComplex)
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, " complex term\n");
|
2002-06-04 19:21:55 +01:00
|
|
|
else if (dbr->Flags & DBIsRef)
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, " a ref\n");
|
2002-06-04 19:21:55 +01:00
|
|
|
else
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, " a var\n");
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2007-11-06 17:02:13 +00:00
|
|
|
RestoreDBTerm(&(dbr->DBT), TRUE);
|
2005-10-19 20:00:48 +01:00
|
|
|
if (dbr->Parent) {
|
|
|
|
dbr->Parent = (DBProp)AddrAdjust((ADDR)(dbr->Parent));
|
|
|
|
}
|
2003-02-12 13:20:52 +00:00
|
|
|
if (dbr->Code != NULL)
|
|
|
|
dbr->Code = PtoOpAdjust(dbr->Code);
|
2002-06-04 19:21:55 +01:00
|
|
|
if (dbr->Prev != NULL)
|
|
|
|
dbr->Prev = DBRefAdjust(dbr->Prev);
|
|
|
|
if (dbr->Next != NULL)
|
|
|
|
dbr->Next = DBRefAdjust(dbr->Next);
|
|
|
|
#ifdef DEBUG_RESTORE2
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, "Recomputing masks\n");
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
|
|
|
recompute_mask(dbr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restores a DB structure, as it was saved in the heap */
|
|
|
|
static void
|
|
|
|
RestoreDB(DBEntry *pp)
|
|
|
|
{
|
|
|
|
register DBRef dbr;
|
|
|
|
|
|
|
|
if (pp->First != NULL)
|
|
|
|
pp->First = DBRefAdjust(pp->First);
|
|
|
|
if (pp->Last != NULL)
|
|
|
|
pp->Last = DBRefAdjust(pp->Last);
|
|
|
|
if (pp->ArityOfDB)
|
|
|
|
pp->FunctorOfDB = FuncAdjust(pp->FunctorOfDB);
|
|
|
|
else
|
|
|
|
pp->FunctorOfDB = (Functor) AtomAdjust((Atom)(pp->FunctorOfDB));
|
2006-02-24 14:03:42 +00:00
|
|
|
if (pp->F0 != NULL)
|
|
|
|
pp->F0 = DBRefAdjust(pp->F0);
|
|
|
|
if (pp->L0 != NULL)
|
|
|
|
pp->L0 = DBRefAdjust(pp->L0);
|
|
|
|
/* immediate update semantics */
|
|
|
|
dbr = pp->F0;
|
|
|
|
/* While we have something in the data base, even if erased, restore it */
|
|
|
|
while (dbr) {
|
|
|
|
RestoreDBEntry(dbr);
|
|
|
|
if (dbr->n != NULL)
|
|
|
|
dbr->n = DBRefAdjust(dbr->n);
|
|
|
|
if (dbr->p != NULL)
|
|
|
|
dbr->p = DBRefAdjust(dbr->p);
|
|
|
|
dbr = dbr->n;
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restores a group of clauses for the same predicate, starting with First
|
|
|
|
* and ending with Last, First may be equal to Last
|
|
|
|
*/
|
|
|
|
static void
|
2003-04-30 18:46:05 +01:00
|
|
|
CleanClauses(yamop *First, yamop *Last, PredEntry *pp)
|
2002-06-04 19:21:55 +01:00
|
|
|
{
|
2003-08-27 14:37:10 +01:00
|
|
|
if (pp->PredFlags & LogUpdatePredFlag) {
|
|
|
|
LogUpdClause *cl = ClauseCodeToLogUpdClause(First);
|
|
|
|
|
|
|
|
while (cl != NULL) {
|
2004-02-06 02:26:23 +00:00
|
|
|
RestoreLUClause(cl, pp);
|
2003-08-27 14:37:10 +01:00
|
|
|
cl = cl->ClNext;
|
|
|
|
}
|
2004-09-27 21:45:04 +01:00
|
|
|
} else if (pp->PredFlags & MegaClausePredFlag) {
|
|
|
|
MegaClause *cl = ClauseCodeToMegaClause(First);
|
|
|
|
|
2006-03-22 20:07:28 +00:00
|
|
|
RestoreMegaClause(cl);
|
2003-11-26 18:36:35 +00:00
|
|
|
} else if (pp->PredFlags & DynamicPredFlag) {
|
|
|
|
yamop *cl = First;
|
|
|
|
|
|
|
|
do {
|
2004-02-06 02:26:23 +00:00
|
|
|
RestoreDynamicClause(ClauseCodeToDynamicClause(cl), pp);
|
2003-11-26 18:36:35 +00:00
|
|
|
if (cl == Last) return;
|
|
|
|
cl = NextDynamicClause(cl);
|
|
|
|
} while (TRUE);
|
2003-08-27 14:37:10 +01:00
|
|
|
} else {
|
2004-02-06 02:26:23 +00:00
|
|
|
StaticClause *cl = ClauseCodeToStaticClause(First);
|
2003-08-27 14:37:10 +01:00
|
|
|
|
|
|
|
do {
|
2006-03-22 20:07:28 +00:00
|
|
|
RestoreStaticClause(cl);
|
2004-02-06 02:26:23 +00:00
|
|
|
if (cl->ClCode == Last) return;
|
|
|
|
cl = cl->ClNext;
|
2003-08-27 14:37:10 +01:00
|
|
|
} while (TRUE);
|
|
|
|
}
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-06 02:26:23 +00:00
|
|
|
|
2005-06-01 14:53:46 +01:00
|
|
|
/* Restores a DB structure, as it was saved in the heap */
|
|
|
|
static void
|
2008-04-03 12:34:47 +01:00
|
|
|
RestoreBB(BlackBoardEntry *pp, int int_key)
|
2005-06-01 14:53:46 +01:00
|
|
|
{
|
|
|
|
Term t = pp->Element;
|
|
|
|
if (t) {
|
2007-02-18 00:26:36 +00:00
|
|
|
if (!IsVarTerm(t)) {
|
|
|
|
if (IsAtomicTerm(t)) {
|
|
|
|
if (IsAtomTerm(t)) {
|
|
|
|
pp->Element = AtomTermAdjust(t);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
RestoreLUClause((LogUpdClause *)DBRefOfTerm(t),NULL);
|
|
|
|
}
|
2005-06-01 14:53:46 +01:00
|
|
|
}
|
|
|
|
}
|
2008-04-03 12:34:47 +01:00
|
|
|
if (!int_key) {
|
|
|
|
pp->KeyOfBB = AtomAdjust(pp->KeyOfBB);
|
|
|
|
}
|
2005-06-01 14:53:46 +01:00
|
|
|
}
|
|
|
|
|
2002-06-04 19:21:55 +01:00
|
|
|
static void
|
|
|
|
restore_static_array(StaticArrayEntry *ae)
|
|
|
|
{
|
|
|
|
Int sz = -ae->ArrayEArity;
|
|
|
|
switch (ae->ArrayType) {
|
|
|
|
case array_of_ints:
|
|
|
|
case array_of_doubles:
|
|
|
|
case array_of_chars:
|
|
|
|
case array_of_uchars:
|
|
|
|
return;
|
|
|
|
case array_of_ptrs:
|
|
|
|
{
|
|
|
|
AtomEntry **base = (AtomEntry **)AddrAdjust((ADDR)(ae->ValueOfVE.ptrs));
|
|
|
|
Int i;
|
|
|
|
ae->ValueOfVE.ptrs = base;
|
|
|
|
if (ae != NULL) {
|
|
|
|
for (i=0; i<sz; i++) {
|
|
|
|
AtomEntry *reg = *base;
|
|
|
|
if (reg == NULL) {
|
|
|
|
base++;
|
|
|
|
} else if (IsOldCode((CELL)reg)) {
|
|
|
|
*base++ = AtomEntryAdjust(reg);
|
|
|
|
} else if (IsOldLocalInTR((CELL)reg)) {
|
|
|
|
*base++ = (AtomEntry *)LocalAddrAdjust((ADDR)reg);
|
|
|
|
} else if (IsOldGlobal((CELL)reg)) {
|
|
|
|
*base++ = (AtomEntry *)GlobalAddrAdjust((ADDR)reg);
|
|
|
|
} else if (IsOldTrail((CELL)reg)) {
|
|
|
|
*base++ = (AtomEntry *)TrailAddrAdjust((ADDR)reg);
|
|
|
|
} else {
|
|
|
|
/* oops */
|
|
|
|
base++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case array_of_atoms:
|
|
|
|
{
|
|
|
|
Term *base = (Term *)AddrAdjust((ADDR)(ae->ValueOfVE.atoms));
|
|
|
|
Int i;
|
|
|
|
ae->ValueOfVE.atoms = base;
|
|
|
|
if (ae != 0L) {
|
|
|
|
for (i=0; i<sz; i++) {
|
|
|
|
Term reg = *base;
|
|
|
|
if (reg == 0L) {
|
|
|
|
base++;
|
|
|
|
} else {
|
|
|
|
*base++ = AtomTermAdjust(reg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case array_of_dbrefs:
|
|
|
|
{
|
|
|
|
Term *base = (Term *)AddrAdjust((ADDR)(ae->ValueOfVE.dbrefs));
|
|
|
|
Int i;
|
|
|
|
|
|
|
|
ae->ValueOfVE.dbrefs = base;
|
|
|
|
if (ae != 0L) {
|
|
|
|
for (i=0; i<sz; i++) {
|
|
|
|
Term reg = *base;
|
|
|
|
if (reg == 0L) {
|
|
|
|
base++;
|
|
|
|
} else {
|
|
|
|
*base++ = AbsAppl(PtoHeapCellAdjust(RepAppl(reg)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
2005-10-19 20:00:48 +01:00
|
|
|
case array_of_nb_terms:
|
|
|
|
{
|
|
|
|
live_term *base = (live_term *)AddrAdjust((ADDR)(ae->ValueOfVE.lterms));
|
|
|
|
Int i;
|
|
|
|
|
|
|
|
ae->ValueOfVE.lterms = base;
|
|
|
|
if (ae != 0L) {
|
|
|
|
for (i=0; i < sz; i++,base++) {
|
|
|
|
Term reg = base->tlive;
|
|
|
|
if (IsVarTerm(reg)) {
|
|
|
|
CELL *var = (CELL *)reg;
|
|
|
|
|
|
|
|
if (IsOldGlobalPtr(var)) {
|
|
|
|
base->tlive = (CELL)PtoGloAdjust(var);
|
|
|
|
} else {
|
|
|
|
base->tlive = (CELL)PtoHeapCellAdjust(var);
|
|
|
|
}
|
|
|
|
} else if (IsAtomTerm(reg)) {
|
|
|
|
base->tlive = AtomTermAdjust(reg);
|
|
|
|
} else if (IsApplTerm(reg)) {
|
|
|
|
CELL *db = RepAppl(reg);
|
|
|
|
db = PtoGloAdjust(db);
|
|
|
|
base->tlive = AbsAppl(db);
|
|
|
|
} else if (IsApplTerm(reg)) {
|
|
|
|
CELL *db = RepPair(reg);
|
|
|
|
db = PtoGloAdjust(db);
|
|
|
|
base->tlive = AbsPair(db);
|
|
|
|
}
|
|
|
|
|
|
|
|
reg = base->tstore;
|
|
|
|
if (IsVarTerm(reg)) {
|
|
|
|
base->tstore = (Term)GlobalAddrAdjust((ADDR)reg);
|
|
|
|
} else if (IsAtomTerm(reg)) {
|
|
|
|
base->tstore = AtomTermAdjust(reg);
|
|
|
|
} else {
|
|
|
|
DBTerm *db = (DBTerm *)RepAppl(reg);
|
|
|
|
db = DBTermAdjust(db);
|
2007-11-06 17:02:13 +00:00
|
|
|
RestoreDBTerm(db, TRUE);
|
2005-10-19 20:00:48 +01:00
|
|
|
base->tstore = AbsAppl((CELL *)db);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-06-04 19:21:55 +01:00
|
|
|
case array_of_terms:
|
|
|
|
{
|
2003-08-27 14:37:10 +01:00
|
|
|
DBTerm **base = (DBTerm **)AddrAdjust((ADDR)(ae->ValueOfVE.terms));
|
2002-06-04 19:21:55 +01:00
|
|
|
Int i;
|
|
|
|
|
|
|
|
ae->ValueOfVE.terms = base;
|
|
|
|
if (ae != 0L) {
|
|
|
|
for (i=0; i<sz; i++) {
|
2003-08-27 14:37:10 +01:00
|
|
|
DBTerm *reg = *base;
|
2002-06-04 19:21:55 +01:00
|
|
|
if (reg == NULL) {
|
|
|
|
base++;
|
|
|
|
} else {
|
2004-02-06 02:26:23 +00:00
|
|
|
*base++ = reg = DBTermAdjust(reg);
|
2007-11-06 17:02:13 +00:00
|
|
|
RestoreDBTerm(reg, TRUE);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clean all the code for a particular predicate, this can get a bit tricky,
|
|
|
|
* because of the indexing code
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
CleanCode(PredEntry *pp)
|
|
|
|
{
|
|
|
|
CELL flag;
|
|
|
|
|
|
|
|
|
|
|
|
/* Init takes care of the first 2 cases */
|
2004-02-12 17:09:17 +00:00
|
|
|
if (pp->ModuleOfPred) {
|
|
|
|
pp->ModuleOfPred = AtomTermAdjust(pp->ModuleOfPred);
|
|
|
|
}
|
2005-05-30 04:26:37 +01:00
|
|
|
if (pp->ArityOfPE) {
|
|
|
|
if (pp->ModuleOfPred == IDB_MODULE) {
|
2008-02-07 21:39:51 +00:00
|
|
|
if (pp->PredFlags & NumberDBPredFlag) {
|
|
|
|
/* it's an integer, do nothing */
|
|
|
|
} else if (pp->PredFlags & AtomDBPredFlag) {
|
2005-05-30 04:26:37 +01:00
|
|
|
pp->FunctorOfPred = (Functor)AtomAdjust((Atom)(pp->FunctorOfPred));
|
|
|
|
} else {
|
|
|
|
pp->FunctorOfPred = FuncAdjust(pp->FunctorOfPred);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pp->FunctorOfPred = FuncAdjust(pp->FunctorOfPred);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pp->FunctorOfPred = (Functor)AtomAdjust((Atom)(pp->FunctorOfPred));
|
|
|
|
}
|
2004-02-06 10:19:49 +00:00
|
|
|
if (!(pp->PredFlags & NumberDBPredFlag)) {
|
2008-04-04 10:10:02 +01:00
|
|
|
if (pp->PredFlags & MultiFileFlag) {
|
|
|
|
if (pp->src.file_srcs)
|
|
|
|
pp->src.file_srcs = MFileAdjust(pp->src.file_srcs);
|
|
|
|
} else {
|
|
|
|
if (pp->src.OwnerFile)
|
|
|
|
pp->src.OwnerFile = AtomAdjust(pp->src.OwnerFile);
|
|
|
|
}
|
2004-02-06 10:19:49 +00:00
|
|
|
}
|
2002-11-18 18:18:05 +00:00
|
|
|
pp->OpcodeOfPred = Yap_opcode(Yap_op_from_opcode(pp->OpcodeOfPred));
|
2002-12-27 16:53:09 +00:00
|
|
|
if (pp->PredFlags & (AsmPredFlag|CPredFlag)) {
|
2002-06-04 19:21:55 +01:00
|
|
|
/* assembly */
|
2002-12-27 16:53:09 +00:00
|
|
|
if (pp->CodeOfPred) {
|
|
|
|
pp->CodeOfPred = PtoOpAdjust(pp->CodeOfPred);
|
2003-04-30 18:46:05 +01:00
|
|
|
CleanClauses(pp->CodeOfPred, pp->CodeOfPred, pp);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
} else {
|
2002-12-27 16:53:09 +00:00
|
|
|
yamop *FirstC, *LastC;
|
|
|
|
/* Prolog code */
|
|
|
|
if (pp->cs.p_code.FirstClause)
|
|
|
|
pp->cs.p_code.FirstClause = PtoOpAdjust(pp->cs.p_code.FirstClause);
|
|
|
|
if (pp->cs.p_code.LastClause)
|
|
|
|
pp->cs.p_code.LastClause = PtoOpAdjust(pp->cs.p_code.LastClause);
|
|
|
|
pp->CodeOfPred =PtoOpAdjust(pp->CodeOfPred);
|
|
|
|
pp->cs.p_code.TrueCodeOfPred = PtoOpAdjust(pp->cs.p_code.TrueCodeOfPred);
|
2003-08-27 14:37:10 +01:00
|
|
|
pp->cs.p_code.ExpandCode = Yap_opcode(_expand_index);
|
2002-06-04 19:21:55 +01:00
|
|
|
if (pp->NextPredOfModule)
|
|
|
|
pp->NextPredOfModule = PtoPredAdjust(pp->NextPredOfModule);
|
|
|
|
flag = pp->PredFlags;
|
2002-12-27 16:53:09 +00:00
|
|
|
FirstC = pp->cs.p_code.FirstClause;
|
|
|
|
LastC = pp->cs.p_code.LastClause;
|
2002-06-04 19:21:55 +01:00
|
|
|
/* We just have a fail here */
|
2004-02-06 10:19:49 +00:00
|
|
|
if (FirstC == NULL && LastC == NULL) {
|
2002-06-04 19:21:55 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#ifdef DEBUG_RESTORE2
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, "at %ux Correcting clauses from %p to %p\n", *(OPCODE *) FirstC, FirstC, LastC);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2003-04-30 18:46:05 +01:00
|
|
|
CleanClauses(FirstC, LastC, pp);
|
2004-02-06 02:26:23 +00:00
|
|
|
if (flag & IndexedPredFlag) {
|
|
|
|
#ifdef DEBUG_RESTORE2
|
|
|
|
fprintf(stderr, "Correcting indexed code\n");
|
|
|
|
#endif
|
|
|
|
if (flag & LogUpdatePredFlag) {
|
|
|
|
CleanLUIndex(ClauseCodeToLogUpdIndex(pp->cs.p_code.TrueCodeOfPred));
|
|
|
|
} else {
|
|
|
|
CleanSIndex(ClauseCodeToStaticIndex(pp->cs.p_code.TrueCodeOfPred));
|
|
|
|
}
|
|
|
|
} else if (flag & DynamicPredFlag) {
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef DEBUG_RESTORE2
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, "Correcting dynamic code\n");
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-02-06 02:26:23 +00:00
|
|
|
RestoreDynamicClause(ClauseCodeToDynamicClause(pp->cs.p_code.TrueCodeOfPred),pp);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* we are pointing at ourselves */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restores all of the entries, for a particular atom, we only have problems
|
|
|
|
* if we find code or data bases
|
|
|
|
*/
|
|
|
|
static void
|
2008-04-03 12:34:47 +01:00
|
|
|
RestoreEntries(PropEntry *pp, int int_key)
|
2002-06-04 19:21:55 +01:00
|
|
|
{
|
|
|
|
while (!EndOfPAEntr(pp)) {
|
|
|
|
switch(pp->KindOfPE) {
|
|
|
|
case FunctorProperty:
|
|
|
|
{
|
|
|
|
FunctorEntry *fe = (FunctorEntry *)pp;
|
|
|
|
Prop p0;
|
|
|
|
fe->NextOfPE =
|
|
|
|
PropAdjust(fe->NextOfPE);
|
|
|
|
fe->NameOfFE =
|
|
|
|
AtomAdjust(fe->NameOfFE);
|
|
|
|
p0 = fe->PropsOfFE =
|
|
|
|
PropAdjust(fe->PropsOfFE);
|
2007-09-29 00:18:17 +01:00
|
|
|
if (!EndOfPAEntr(p0)) {
|
|
|
|
/* at most one property */
|
2002-06-04 19:21:55 +01:00
|
|
|
CleanCode(RepPredProp(p0));
|
2007-09-29 00:18:17 +01:00
|
|
|
RepPredProp(p0)->NextOfPE =
|
2002-06-04 19:21:55 +01:00
|
|
|
PropAdjust(RepPredProp(p0)->NextOfPE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ValProperty:
|
|
|
|
{
|
|
|
|
ValEntry *ve = (ValEntry *)pp;
|
|
|
|
Term tv = ve->ValueOfVE;
|
|
|
|
ve->NextOfPE =
|
|
|
|
PropAdjust(ve->NextOfPE);
|
|
|
|
if (IsAtomTerm(tv))
|
|
|
|
ve->ValueOfVE = AtomTermAdjust(tv);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ArrayProperty:
|
|
|
|
{
|
|
|
|
ArrayEntry *ae = (ArrayEntry *)pp;
|
|
|
|
ae->NextOfPE =
|
|
|
|
PropAdjust(ae->NextOfPE);
|
|
|
|
if (ae->ArrayEArity < 0) {
|
2005-10-28 18:38:50 +01:00
|
|
|
/* static array entry */
|
|
|
|
StaticArrayEntry *sae = (StaticArrayEntry *)ae;
|
|
|
|
if (sae->NextAE)
|
|
|
|
sae->NextAE = PtoArraySAdjust(sae->NextAE);
|
|
|
|
restore_static_array(sae);
|
2002-06-04 19:21:55 +01:00
|
|
|
} else {
|
2005-10-28 18:38:50 +01:00
|
|
|
if (ae->NextAE)
|
|
|
|
ae->NextAE = PtoArrayEAdjust(ae->NextAE);
|
2002-06-04 19:21:55 +01:00
|
|
|
if (IsVarTerm(ae->ValueOfVE))
|
|
|
|
RESET_VARIABLE(&(ae->ValueOfVE));
|
|
|
|
else {
|
|
|
|
CELL *ptr = RepAppl(ae->ValueOfVE);
|
|
|
|
/* in fact it should just be a pointer to the global,
|
|
|
|
but we'll be conservative.
|
|
|
|
Notice that the variable should have been reset in restore_program mode.
|
|
|
|
*/
|
|
|
|
if (IsOldGlobalPtr(ptr)) {
|
|
|
|
ae->ValueOfVE = AbsAppl(PtoGloAdjust(ptr));
|
|
|
|
} else if (IsOldCodeCellPtr(ptr)) {
|
|
|
|
ae->ValueOfVE = AbsAppl(PtoHeapCellAdjust(ptr));
|
|
|
|
} else if (IsOldLocalInTRPtr(ptr)) {
|
|
|
|
ae->ValueOfVE = AbsAppl(PtoLocAdjust(ptr));
|
|
|
|
} else if (IsOldTrailPtr(ptr)) {
|
|
|
|
ae->ValueOfVE = AbsAppl(CellPtoTRAdjust(ptr));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PEProp:
|
|
|
|
{
|
|
|
|
PredEntry *pe = (PredEntry *) pp;
|
|
|
|
pe->NextOfPE =
|
|
|
|
PropAdjust(pe->NextOfPE);
|
|
|
|
CleanCode(pe);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DBProperty:
|
|
|
|
case CodeDBProperty:
|
|
|
|
#ifdef DEBUG_RESTORE2
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, "Correcting data base clause at %p\n", pp);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
DBEntry *de = (DBEntry *) pp;
|
|
|
|
de->NextOfPE =
|
2007-02-18 00:26:36 +00:00
|
|
|
PropAdjust(de->NextOfPE);
|
|
|
|
RestoreDB(de);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BBProperty:
|
|
|
|
{
|
|
|
|
BlackBoardEntry *bb = (BlackBoardEntry *) pp;
|
|
|
|
bb->NextOfPE =
|
|
|
|
PropAdjust(bb->NextOfPE);
|
2008-04-03 12:34:47 +01:00
|
|
|
RestoreBB(bb, int_key);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
break;
|
2007-01-08 08:27:19 +00:00
|
|
|
case GlobalProperty:
|
|
|
|
{
|
|
|
|
GlobalEntry *gb = (GlobalEntry *) pp;
|
|
|
|
Term gbt = gb->global;
|
|
|
|
|
|
|
|
gb->NextOfPE =
|
|
|
|
PropAdjust(gb->NextOfPE);
|
|
|
|
gb->AtomOfGE =
|
|
|
|
AtomEntryAdjust(gb->AtomOfGE);
|
2008-04-01 10:41:05 +01:00
|
|
|
if (gb->NextGE) {
|
|
|
|
gb->NextGE =
|
|
|
|
GlobalEntryAdjust(gb->NextGE);
|
|
|
|
}
|
2007-01-08 08:27:19 +00:00
|
|
|
if (IsVarTerm(gbt)) {
|
|
|
|
CELL *gbp = VarOfTerm(gbt);
|
|
|
|
if (IsOldGlobalPtr(gbp))
|
|
|
|
gbp = PtoGloAdjust(gbp);
|
|
|
|
else
|
|
|
|
gbp = CellPtoHeapAdjust(gbp);
|
|
|
|
gb->global = (CELL)gbp;
|
|
|
|
} else if (IsPairTerm(gbt)) {
|
|
|
|
gb->global = AbsPair(PtoGloAdjust(RepPair(gbt)));
|
|
|
|
} else if (IsApplTerm(gbt)) {
|
|
|
|
CELL *gbp = RepAppl(gbt);
|
|
|
|
if (IsOldGlobalPtr(gbp))
|
|
|
|
gbp = PtoGloAdjust(gbp);
|
|
|
|
else
|
|
|
|
gbp = CellPtoHeapAdjust(gbp);
|
|
|
|
gb->global = AbsAppl(gbp);
|
|
|
|
} else if (IsAtomTerm(gbt)) {
|
|
|
|
gb->global = AtomTermAdjust(gbt);
|
|
|
|
} /* numbers need no adjusting */
|
|
|
|
}
|
|
|
|
break;
|
2002-06-04 19:21:55 +01:00
|
|
|
case OpProperty:
|
2005-10-21 17:09:03 +01:00
|
|
|
{
|
|
|
|
OpEntry *opp = (OpEntry *)pp;
|
|
|
|
if (opp->OpModule) {
|
|
|
|
opp->OpModule = AtomTermAdjust(opp->OpModule);
|
|
|
|
}
|
|
|
|
}
|
2002-06-04 19:21:55 +01:00
|
|
|
case ModProperty:
|
2007-04-10 23:13:21 +01:00
|
|
|
{
|
|
|
|
ModEntry *me = (ModEntry *)pp;
|
|
|
|
me->NextOfPE =
|
|
|
|
PropAdjust(me->NextOfPE);
|
|
|
|
me->PredForME =
|
|
|
|
PtoPredAdjust(me->PredForME);
|
|
|
|
me->AtomOfME =
|
|
|
|
AtomAdjust(me->AtomOfME);
|
|
|
|
me->NextME = (struct mod_entry *)
|
|
|
|
AddrAdjust((ADDR)me->NextME);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ExpProperty:
|
2002-06-04 19:21:55 +01:00
|
|
|
pp->NextOfPE =
|
|
|
|
PropAdjust(pp->NextOfPE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* OOPS */
|
2002-11-18 18:18:05 +00:00
|
|
|
Yap_Error(SYSTEM_ERROR, TermNil,
|
2002-06-04 19:21:55 +01:00
|
|
|
"Invalid Atom Property %d at %p", pp->KindOfPE, pp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pp = RepProp(pp->NextOfPE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|