fix setup_call_cleanup and friends.

This commit is contained in:
Vitor Santos Costa 2009-12-03 02:13:22 +00:00
parent 06d30b9fc9
commit d2da5bfe26
3 changed files with 8 additions and 7 deletions

View File

@ -1439,7 +1439,11 @@ static int is_cleanup_cp(choiceptr cp_b)
#else
pe = cp_b->cp_ap->u.p.p;
#endif /* YAPOR */
return (pe == PredSafeCallCleanup);
/*
it has to be a cleanup and it has to be a completed goal,
otherwise the throw will be caught anyway.
*/
return pe == PredSafeCallCleanup;
}
static Int

View File

@ -33,7 +33,6 @@
Bind(pt, MkAtomTerm(AtomCut));
Yap_WakeUp(pt);
}
pt1--;
} else if ((*pt & (LogUpdMask|IndexMask)) == (LogUpdMask|IndexMask)) {
LogUpdIndex *cl = ClauseFlagsToLogUpdIndex(pt);
int erase;

View File

@ -67,9 +67,7 @@ setup_call_cleanup(Setup, Goal, Cleanup) :-
setup_call_catcher_cleanup(Setup, Goal, Catcher, Cleanup) :-
yap_hacks:disable_interrupts,
'$do_setup'(Setup),
catch('$safe_call_cleanup'(Goal,Cleanup,Catcher,Exception),
Exception,
'$cleanup_exception'(Exception,Catcher,Cleanup)).
'$safe_call_cleanup'(Goal,Cleanup,Catcher,Exception).
% this is simple, do nothing
'$do_setup'(A:true) :- atom(A), !.
@ -96,9 +94,9 @@ setup_call_catcher_cleanup(Setup, Goal, Catcher, Cleanup) :-
'$safe_call_cleanup'(Goal, Cleanup, Catcher, Exception) :-
yap_hacks:current_choice_point(MyCP1),
'$freeze_goal'(Catcher, '$clean_call'(Exception, Cleanup)),
yap_hacks:trail_suspension_marker(Catcher),
'$freeze_goal'(Catcher, '$clean_call'(Active, Cleanup)),
(
yap_hacks:trail_suspension_marker(Catcher),
yap_hacks:enable_interrupts,
yap_hacks:current_choice_point(CP0),
'$execute'(Goal),