From ab33864f0ce1f3c0fef96eb48e716751725b4d8a Mon Sep 17 00:00:00 2001 From: pmoura Date: Sun, 7 Jan 2007 11:27:09 +0000 Subject: [PATCH] Another attemp to get call_cleanup/2-3 right. Third is the charm (I hope...). git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1769 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- pl/corout.yap | 4 ++++ pl/utils.yap | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pl/corout.yap b/pl/corout.yap index 8370c40bb..a81f00829 100644 --- a/pl/corout.yap +++ b/pl/corout.yap @@ -522,6 +522,10 @@ frozen(V, LG) :- '$purge_done_goals'(G0, GF). '$purge_done_goals'(['$redo_freeze'(Done, _, _)|G0], GF) :- nonvar(Done), !, '$purge_done_goals'(G0, GF). +'$purge_done_goals'(['$redo_freeze'(Done, _, CallCleanup)|G0], GF) :- + nonvar(CallCleanup), + CallCleanup = _:'$clean_call'(_), !, + '$purge_done_goals'(G0, GF). '$purge_done_goals'(['$redo_eq'(Done, _, _, _)|G0], GF) :- nonvar(Done), !, '$purge_done_goals'(G0, GF). '$purge_done_goals'(['$redo_ground'(Done, _, _)|G0], GF) :- nonvar(Done), !, diff --git a/pl/utils.yap b/pl/utils.yap index 0170030b2..d0be525b2 100644 --- a/pl/utils.yap +++ b/pl/utils.yap @@ -189,8 +189,7 @@ call_cleanup(Goal, Cleanup) :- call_cleanup(Goal, Catcher, Cleanup) :- catch('$call_cleanup'(Goal,Cleanup,Result), Exception, - '$cleanup_exception'(Exception,Catcher,Cleanup)), - Result = exit. + '$cleanup_exception'(Exception,Catcher,Cleanup)). '$cleanup_exception'(Exception, exception(Exception), Cleanup) :- call(Cleanup). @@ -205,7 +204,8 @@ call_cleanup(Goal, Catcher, Cleanup) :- Result = exit, ! ; true ) - ; Result = fail + ; Result = fail, + fail ). '$clean_call'(Cleanup) :-