From 5cd55b0e0e591f4221ab14184a74686eb67219df Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Tue, 27 Jul 2010 23:29:55 +0100 Subject: [PATCH] EX changes --- C/c_interface.c | 2 +- C/save.c | 11 +++++++---- C/write.c | 16 ++++++++-------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/C/c_interface.c b/C/c_interface.c index c865e71c1..8d0a12285 100755 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -2839,7 +2839,7 @@ YAP_ThreadSelf(void) #if THREADS return Yap_thread_self(); #else - return NULL; + return -2; #endif } diff --git a/C/save.c b/C/save.c index fce0999e4..31d273eaf 100755 --- a/C/save.c +++ b/C/save.c @@ -110,6 +110,7 @@ STATIC_PROTO(int get_coded, (int, OPCODE [])); STATIC_PROTO(void restore_codes, (void)); STATIC_PROTO(Term AdjustDBTerm, (Term, Term *)); STATIC_PROTO(void RestoreDB, (DBEntry *)); +STATIC_PROTO(void RestoreDBTerm, (DBTerm *, int)); STATIC_PROTO(void CleanClauses, (yamop *, yamop *,PredEntry *)); STATIC_PROTO(void rehash, (CELL *, int, int)); STATIC_PROTO(void CleanCode, (PredEntry *)); @@ -404,7 +405,7 @@ save_regs(int mode) return -1; if (putout(CreepFlag) < 0) return -1; - if (putout(EX) < 0) + if (putcellptr((CELL *)EX) < 0) return -1; #if defined(SBA) || defined(TABLING) if (putcellptr(H_FZ) < 0) @@ -841,7 +842,7 @@ get_regs(int flag) CreepFlag = get_cell(); if (Yap_ErrorMessage) return -1; - EX = get_cell(); + EX = (struct DB_TERM *)get_cellptr(); if (Yap_ErrorMessage) return -1; #if defined(SBA) || defined(TABLING) @@ -1046,8 +1047,10 @@ restore_regs(int flag) HB = PtoLocAdjust(HB); YENV = PtoLocAdjust(YENV); S = PtoGloAdjust(S); - if (EX) - EX = AbsAppl(PtoGloAdjust(RepAppl(EX))); + if (EX) { + EX = DBTermAdjust(EX); + RestoreDBTerm(EX, TRUE); + } WokenGoals = AbsAppl(PtoGloAdjust(RepAppl(WokenGoals))); } } diff --git a/C/write.c b/C/write.c index 92836ad16..cabb21864 100755 --- a/C/write.c +++ b/C/write.c @@ -656,7 +656,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str putAtom(Atom3Dots, wglb->Quote_illegal, wglb->writewch); return; } - if (EX != 0) + if (EX) return; t = Deref(t); if (IsVarTerm(t)) { @@ -668,17 +668,17 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str } else if (IsPairTerm(t)) { if (wglb->Use_portray) { Term targs[1]; - Term old_EX = 0L; + struct DB_TERM *old_EX = NULL; Int sl = 0; targs[0] = t; Yap_PutValue(AtomPortray, MkAtomTerm(AtomNil)); - if (EX != 0L) old_EX = EX; + if (EX) old_EX = EX; sl = Yap_InitSlot(t); Yap_execute_goal(Yap_MkApplTerm(FunctorPortray, 1, targs), 0, 1); t = Yap_GetFromSlot(sl); Yap_RecoverSlots(1); - if (old_EX != 0L) EX = old_EX; + if (old_EX != NULL) EX = old_EX; if (Yap_GetValue(AtomPortray) == MkAtomTerm(AtomTrue)) return; } @@ -760,18 +760,18 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str #endif if (wglb->Use_portray) { Term targs[1]; - Term old_EX = 0L; + struct DB_TERM *old_EX = NULL; Int sl = 0; targs[0] = t; Yap_PutValue(AtomPortray, MkAtomTerm(AtomNil)); - if (EX != 0L) old_EX = EX; + if (EX) old_EX = EX; sl = Yap_InitSlot(t); Yap_execute_goal(Yap_MkApplTerm(FunctorPortray, 1, targs),0, 1); t = Yap_GetFromSlot(sl); Yap_RecoverSlots(1); - if (old_EX != 0L) EX = old_EX; - if (Yap_GetValue(AtomPortray) == MkAtomTerm(AtomTrue) || EX != 0L) + if (old_EX) EX = old_EX; + if (Yap_GetValue(AtomPortray) == MkAtomTerm(AtomTrue) || EX) return; } if (!wglb->Ignore_ops &&