more simplifications on the catch and throw mechanism after

having failed the ISO testset.


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@341 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2002-01-30 03:49:50 +00:00
parent af7cb4cd93
commit f9ff6498d8
4 changed files with 25 additions and 21 deletions

View File

@ -1252,24 +1252,28 @@ p_clean_ifcp(void) {
Int Int
JumpToEnv(Term t) { JumpToEnv(Term t) {
yamop *min = (yamop *)(PredCatch->CodeOfPred); yamop *pos = (yamop *)(PredDollarCatch->LastClause);
yamop *max = (yamop *)(PredThrow->CodeOfPred); CELL *env;
CELL *cur = ENV, *env;
yamop *cpe = (yamop *)(cur[E_CP]);
while (cpe < min || cpe > max) { do {
cur = (CELL *)cur[E_E]; /* find the first choicepoint that may be a catch */
cpe = (yamop *)(cur[E_CP]); while (B->cp_ap != pos) {
}
CP = cpe;
env = (CELL *)cur[E_E];
YENV = ENV = (CELL *)(env[E_E]);
while (B->cp_b < (choiceptr)env) {
B = B->cp_b; B = B->cp_b;
} }
B->cp_cp = (yamop *)(env[E_CP]); /* is it a continuation? */
env = B->cp_env;
while (env > ENV)
ENV = (CELL *)ENV[E_E];
/* yes, we found it ! */
if (env == ENV) break;
/* oops, try next */
B = B->cp_b;
} while (TRUE);
/* step one environment above */
B->cp_cp = (yamop *)env[E_CP];
B->cp_ap = (yamop *)(PredHandleThrow->LastClause); B->cp_ap = (yamop *)(PredHandleThrow->LastClause);
B->cp_env = ENV; B->cp_env = (CELL *)env[E_E];
/* cannot recover Heap because of copy term :-( */
B->cp_h = H; B->cp_h = H;
/* I could backtrack here, but it is easier to leave the unwinding /* I could backtrack here, but it is easier to leave the unwinding
to the emulator */ to the emulator */

View File

@ -1012,7 +1012,7 @@ InitCodes(void)
CurrentModule = 0; CurrentModule = 0;
heap_regs->dead_clauses = NULL; heap_regs->dead_clauses = NULL;
heap_regs->pred_meta_call = RepPredProp(PredPropByFunc(MkFunctor(heap_regs->atom_meta_call,4),0)); heap_regs->pred_meta_call = RepPredProp(PredPropByFunc(MkFunctor(heap_regs->atom_meta_call,4),0));
heap_regs->pred_catch = RepPredProp(PredPropByFunc(MkFunctor(LookupAtom("catch"),3),0)); heap_regs->pred_dollar_catch = RepPredProp(PredPropByFunc(MkFunctor(LookupAtom("$catch"),3),0));
heap_regs->pred_throw = RepPredProp(PredPropByFunc(FunctorThrow,0)); heap_regs->pred_throw = RepPredProp(PredPropByFunc(FunctorThrow,0));
heap_regs->pred_handle_throw = RepPredProp(PredPropByFunc(MkFunctor(LookupAtom("$handle_throw"),3),0)); heap_regs->pred_handle_throw = RepPredProp(PredPropByFunc(MkFunctor(LookupAtom("$handle_throw"),3),0));
ReleaseAtom(AtomOfTerm(heap_regs->term_refound_var)); ReleaseAtom(AtomOfTerm(heap_regs->term_refound_var));

View File

@ -1122,8 +1122,8 @@ restore_codes(void)
(PredEntry *)AddrAdjust((ADDR)heap_regs->pred_goal_expansion); (PredEntry *)AddrAdjust((ADDR)heap_regs->pred_goal_expansion);
heap_regs->pred_meta_call = heap_regs->pred_meta_call =
(PredEntry *)AddrAdjust((ADDR)heap_regs->pred_meta_call); (PredEntry *)AddrAdjust((ADDR)heap_regs->pred_meta_call);
heap_regs->pred_catch = heap_regs->pred_dollar_catch =
(PredEntry *)AddrAdjust((ADDR)heap_regs->pred_catch); (PredEntry *)AddrAdjust((ADDR)heap_regs->pred_dollar_catch);
heap_regs->pred_throw = heap_regs->pred_throw =
(PredEntry *)AddrAdjust((ADDR)heap_regs->pred_throw); (PredEntry *)AddrAdjust((ADDR)heap_regs->pred_throw);
heap_regs->pred_handle_throw = heap_regs->pred_handle_throw =

View File

@ -10,7 +10,7 @@
* File: Heap.h * * File: Heap.h *
* mods: * * mods: *
* comments: Heap Init Structure * * comments: Heap Init Structure *
* version: $Id: Heap.h,v 1.22 2002-01-28 04:30:40 vsc Exp $ * * version: $Id: Heap.h,v 1.23 2002-01-30 03:49:50 vsc Exp $ *
*************************************************************************/ *************************************************************************/
/* information that can be stored in Code Space */ /* information that can be stored in Code Space */
@ -270,7 +270,7 @@ typedef struct various_codes {
void *last_wtime; void *last_wtime;
PredEntry *pred_goal_expansion; PredEntry *pred_goal_expansion;
PredEntry *pred_meta_call; PredEntry *pred_meta_call;
PredEntry *pred_catch; PredEntry *pred_dollar_catch;
PredEntry *pred_throw; PredEntry *pred_throw;
PredEntry *pred_handle_throw; PredEntry *pred_handle_throw;
UInt n_of_file_aliases; UInt n_of_file_aliases;
@ -461,7 +461,7 @@ typedef struct various_codes {
#define TermReFoundVar heap_regs->term_refound_var #define TermReFoundVar heap_regs->term_refound_var
#define PredGoalExpansion heap_regs->pred_goal_expansion #define PredGoalExpansion heap_regs->pred_goal_expansion
#define PredMetaCall heap_regs->pred_meta_call #define PredMetaCall heap_regs->pred_meta_call
#define PredCatch heap_regs->pred_catch #define PredDollarCatch heap_regs->pred_dollar_catch
#define PredThrow heap_regs->pred_throw #define PredThrow heap_regs->pred_throw
#define PredHandleThrow heap_regs->pred_handle_throw #define PredHandleThrow heap_regs->pred_handle_throw
#define NOfFileAliases heap_regs->n_of_file_aliases #define NOfFileAliases heap_regs->n_of_file_aliases