make Error Handler call throw in C, instead of doing messy

Prolog code.


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@335 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2002-01-29 05:37:31 +00:00
parent a60e61f507
commit 28128ed29c
6 changed files with 346 additions and 57 deletions

360
C/absmi.c

File diff suppressed because it is too large Load Diff

View File

@ -1749,24 +1749,10 @@ Error (yap_error_number type, Term where, char *format,...)
} }
nt[1] = MkAtomTerm(LookupAtom(p)); nt[1] = MkAtomTerm(LookupAtom(p));
if (serious) { if (serious) {
choiceptr newb;
PredEntry *p = PredThrow;
CreepFlag = CalculateStackGap();
ASP--;
newb = ((choiceptr)ASP)-1;
newb->cp_h = H;
newb->cp_tr = TR;
newb->cp_cp = CP;
newb->cp_ap = (yamop *)(p->CodeOfPred);
newb->cp_env = ENV;
newb->cp_b = B;
if (type == PURE_ABORT) if (type == PURE_ABORT)
ARG1 = newb->cp_a1 = MkAtomTerm(LookupAtom("abort")); JumpToEnv(MkAtomTerm(LookupAtom("abort")));
else else
ARG1 = newb->cp_a1 = MkApplTerm(fun, 2, nt); JumpToEnv(CopyTerm(MkApplTerm(fun, 2, nt)));
B = newb;
ASP = YENV = (CELL *)B;
P = (yamop *)FAILCODE; P = (yamop *)FAILCODE;
} }
PrologMode &= ~InErrorMode; PrologMode &= ~InErrorMode;

View File

@ -1250,9 +1250,8 @@ p_clean_ifcp(void) {
return(TRUE); return(TRUE);
} }
/* This does very nasty stuff!!!!! */ Int
static Int JumpToEnv(Term t) {
p_jump_env(void) {
yamop *min = (yamop *)(PredCatch->CodeOfPred); yamop *min = (yamop *)(PredCatch->CodeOfPred);
yamop *max = (yamop *)(PredThrow->CodeOfPred); yamop *max = (yamop *)(PredThrow->CodeOfPred);
CELL *cur = ENV, *env; CELL *cur = ENV, *env;
@ -1274,11 +1273,19 @@ p_jump_env(void) {
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 */
B->cp_a3 = Deref(ARG1); B->cp_a3 = t;
return(FALSE); return(FALSE);
} }
/* This does very nasty stuff!!!!! */
static Int
p_jump_env(void) {
return(JumpToEnv(Deref(ARG1)));
}
void void
InitExecFs(void) InitExecFs(void)
{ {

View File

@ -251,7 +251,7 @@ static void copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *
clean_tr(TR0); clean_tr(TR0);
} }
static Term Term
CopyTerm(Term inp) { CopyTerm(Term inp) {
Term t = Deref(inp); Term t = Deref(inp);

View File

@ -10,7 +10,7 @@
* File: Yap.proto * * File: Yap.proto *
* mods: * * mods: *
* comments: Function declarations for YAP * * comments: Function declarations for YAP *
* version: $Id: Yapproto.h,v 1.7 2002-01-07 06:28:03 vsc Exp $ * * version: $Id: Yapproto.h,v 1.8 2002-01-29 05:37:31 vsc Exp $ *
*************************************************************************/ *************************************************************************/
/* prototype file for Yap */ /* prototype file for Yap */
@ -149,6 +149,7 @@ Int STD_PROTO(EvFArt,(Term));
/* exec.c */ /* exec.c */
Term STD_PROTO(ExecuteCallMetaCall,(SMALLUNSGN mod)); Term STD_PROTO(ExecuteCallMetaCall,(SMALLUNSGN mod));
void STD_PROTO(InitExecFs,(void)); void STD_PROTO(InitExecFs,(void));
Int STD_PROTO(JumpToEnv,(Term));
int STD_PROTO(RunTopGoal,(Term)); int STD_PROTO(RunTopGoal,(Term));
Int STD_PROTO(execute_goal,(Term, int, SMALLUNSGN)); Int STD_PROTO(execute_goal,(Term, int, SMALLUNSGN));
int STD_PROTO(exec_absmi,(int)); int STD_PROTO(exec_absmi,(int));
@ -270,6 +271,7 @@ void STD_PROTO(InitUserCPreds,(void));
void STD_PROTO(InitUserBacks,(void)); void STD_PROTO(InitUserBacks,(void));
/* utilpreds.c */ /* utilpreds.c */
Term STD_PROTO(CopyTerm,(Term));
Int STD_PROTO(var_in_term, (Term, Term)); Int STD_PROTO(var_in_term, (Term, Term));
void STD_PROTO(InitUtilCPreds,(void)); void STD_PROTO(InitUtilCPreds,(void));

View File

@ -10,7 +10,7 @@
* File: Yap.h.m4 * * File: Yap.h.m4 *
* mods: * * mods: *
* comments: main header file for YAP * * comments: main header file for YAP *
* version: $Id: Yap.h.m4,v 1.18 2002-01-27 20:40:10 vsc Exp $ * * version: $Id: Yap.h.m4,v 1.19 2002-01-29 05:37:31 vsc Exp $ *
*************************************************************************/ *************************************************************************/
#include "config.h" #include "config.h"
@ -496,7 +496,7 @@ typedef enum {
#define ISO_CHARACTER_ESCAPES 1 #define ISO_CHARACTER_ESCAPES 1
#define SICSTUS_CHARACTER_ESCAPES 2 #define SICSTUS_CHARACTER_ESCAPES 2
#define NUMBER_OF_YAP_FLAGS HALT_AFTER_CONSULT_FLAG+1 #define NUMBER_OF_YAP_FLAGS FAST_BOOT_FLAG+1
/************************ prototypes **********************************/ /************************ prototypes **********************************/