make sure we separate betwen async exceptions and synchroneous.
This commit is contained in:
parent
c6f41e2970
commit
8db05c883b
@ -1861,7 +1861,6 @@ Yap_absmi(int inp)
|
|||||||
#else
|
#else
|
||||||
B = B->cp_b;
|
B = B->cp_b;
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
goto fail;
|
|
||||||
ENDBOp();
|
ENDBOp();
|
||||||
|
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
|
@ -480,6 +480,7 @@ X_API int STD_PROTO(YAP_RecoverSlots,(int));
|
|||||||
X_API Int STD_PROTO(YAP_ArgsToSlots,(int));
|
X_API Int STD_PROTO(YAP_ArgsToSlots,(int));
|
||||||
X_API void STD_PROTO(YAP_SlotsToArgs,(int, Int));
|
X_API void STD_PROTO(YAP_SlotsToArgs,(int, Int));
|
||||||
X_API void STD_PROTO(YAP_Throw,(Term));
|
X_API void STD_PROTO(YAP_Throw,(Term));
|
||||||
|
X_API void STD_PROTO(YAP_AsyncThrow,(Term));
|
||||||
X_API void STD_PROTO(YAP_Halt,(int));
|
X_API void STD_PROTO(YAP_Halt,(int));
|
||||||
X_API Term *STD_PROTO(YAP_TopOfLocalStack,(void));
|
X_API Term *STD_PROTO(YAP_TopOfLocalStack,(void));
|
||||||
X_API void *STD_PROTO(YAP_Predicate,(Atom,UInt,Term));
|
X_API void *STD_PROTO(YAP_Predicate,(Atom,UInt,Term));
|
||||||
@ -2833,6 +2834,16 @@ YAP_Throw(Term t)
|
|||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
X_API void
|
||||||
|
YAP_AsyncThrow(Term t)
|
||||||
|
{
|
||||||
|
BACKUP_MACHINE_REGS();
|
||||||
|
Yap_PrologMode |= AsyncIntMode;
|
||||||
|
Yap_JumpToEnv(t);
|
||||||
|
Yap_PrologMode &= ~AsyncIntMode;
|
||||||
|
RECOVER_MACHINE_REGS();
|
||||||
|
}
|
||||||
|
|
||||||
X_API void
|
X_API void
|
||||||
YAP_Halt(int i)
|
YAP_Halt(int i)
|
||||||
{
|
{
|
||||||
|
@ -455,6 +455,8 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
|||||||
where = TermNil;
|
where = TermNil;
|
||||||
Yap_PrologMode &= ~AbortMode;
|
Yap_PrologMode &= ~AbortMode;
|
||||||
Yap_PrologMode |= InErrorMode;
|
Yap_PrologMode |= InErrorMode;
|
||||||
|
/* make sure failure will be seen at next port */
|
||||||
|
if (Yap_PrologMode & AsyncIntMode)
|
||||||
Yap_signal(YAP_FAIL_SIGNAL);
|
Yap_signal(YAP_FAIL_SIGNAL);
|
||||||
P = FAILCODE;
|
P = FAILCODE;
|
||||||
} else {
|
} else {
|
||||||
|
5
C/exec.c
5
C/exec.c
@ -1511,7 +1511,10 @@ JumpToEnv(Term t) {
|
|||||||
EX = BallTerm;
|
EX = BallTerm;
|
||||||
BallTerm = NULL;
|
BallTerm = NULL;
|
||||||
P = (yamop *)FAILCODE;
|
P = (yamop *)FAILCODE;
|
||||||
|
/* make sure failure will be seen at next port */
|
||||||
|
if (Yap_PrologMode & AsyncIntMode) {
|
||||||
Yap_signal(YAP_FAIL_SIGNAL);
|
Yap_signal(YAP_FAIL_SIGNAL);
|
||||||
|
}
|
||||||
HB = B->cp_h;
|
HB = B->cp_h;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1553,7 +1556,9 @@ JumpToEnv(Term t) {
|
|||||||
/* 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 */
|
||||||
|
if (Yap_PrologMode & AsyncIntMode) {
|
||||||
Yap_signal(YAP_FAIL_SIGNAL);
|
Yap_signal(YAP_FAIL_SIGNAL);
|
||||||
|
}
|
||||||
P = (yamop *)FAILCODE;
|
P = (yamop *)FAILCODE;
|
||||||
HB = B->cp_h;
|
HB = B->cp_h;
|
||||||
/* try to recover space */
|
/* try to recover space */
|
||||||
|
11
C/sysbits.c
11
C/sysbits.c
@ -1545,6 +1545,7 @@ void (*handler)(int);
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
InteractSIGINT(int ch) {
|
InteractSIGINT(int ch) {
|
||||||
|
Yap_PrologMode |= AsyncIntMode;
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'a':
|
case 'a':
|
||||||
/* abort computation */
|
/* abort computation */
|
||||||
@ -1554,40 +1555,49 @@ InteractSIGINT(int ch) {
|
|||||||
Yap_Error(PURE_ABORT, TermNil, "abort from console");
|
Yap_Error(PURE_ABORT, TermNil, "abort from console");
|
||||||
/* in case someone mangles the P register */
|
/* in case someone mangles the P register */
|
||||||
}
|
}
|
||||||
|
Yap_PrologMode &= ~AsyncIntMode;
|
||||||
return -1;
|
return -1;
|
||||||
case 'b':
|
case 'b':
|
||||||
/* continue */
|
/* continue */
|
||||||
Yap_signal (YAP_BREAK_SIGNAL);
|
Yap_signal (YAP_BREAK_SIGNAL);
|
||||||
|
Yap_PrologMode &= ~AsyncIntMode;
|
||||||
return 1;
|
return 1;
|
||||||
case 'c':
|
case 'c':
|
||||||
/* continue */
|
/* continue */
|
||||||
return 1;
|
return 1;
|
||||||
case 'd':
|
case 'd':
|
||||||
Yap_signal (YAP_DEBUG_SIGNAL);
|
Yap_signal (YAP_DEBUG_SIGNAL);
|
||||||
|
Yap_PrologMode &= ~AsyncIntMode;
|
||||||
/* enter debug mode */
|
/* enter debug mode */
|
||||||
return 1;
|
return 1;
|
||||||
case 'e':
|
case 'e':
|
||||||
/* exit */
|
/* exit */
|
||||||
|
Yap_PrologMode &= ~AsyncIntMode;
|
||||||
Yap_exit(0);
|
Yap_exit(0);
|
||||||
return -1;
|
return -1;
|
||||||
case 'g':
|
case 'g':
|
||||||
/* exit */
|
/* exit */
|
||||||
Yap_signal (YAP_STACK_DUMP_SIGNAL);
|
Yap_signal (YAP_STACK_DUMP_SIGNAL);
|
||||||
|
Yap_PrologMode &= ~AsyncIntMode;
|
||||||
return -1;
|
return -1;
|
||||||
case 't':
|
case 't':
|
||||||
/* start tracing */
|
/* start tracing */
|
||||||
Yap_signal (YAP_TRACE_SIGNAL);
|
Yap_signal (YAP_TRACE_SIGNAL);
|
||||||
|
Yap_PrologMode &= ~AsyncIntMode;
|
||||||
return 1;
|
return 1;
|
||||||
#ifdef LOW_LEVEL_TRACER
|
#ifdef LOW_LEVEL_TRACER
|
||||||
case 'T':
|
case 'T':
|
||||||
toggle_low_level_trace();
|
toggle_low_level_trace();
|
||||||
|
Yap_PrologMode &= ~AsyncIntMode;
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
case 's':
|
case 's':
|
||||||
/* show some statistics */
|
/* show some statistics */
|
||||||
Yap_signal (YAP_STATISTICS_SIGNAL);
|
Yap_signal (YAP_STATISTICS_SIGNAL);
|
||||||
|
Yap_PrologMode &= ~AsyncIntMode;
|
||||||
return 1;
|
return 1;
|
||||||
case EOF:
|
case EOF:
|
||||||
|
Yap_PrologMode &= ~AsyncIntMode;
|
||||||
return(0);
|
return(0);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
@ -1598,6 +1608,7 @@ InteractSIGINT(int ch) {
|
|||||||
fprintf(Yap_stderr, " a for abort\n c for continue\n d for debug\n");
|
fprintf(Yap_stderr, " a for abort\n c for continue\n d for debug\n");
|
||||||
fprintf(Yap_stderr, " e for exit\n g for stack dump\n s for statistics\n t for trace\n");
|
fprintf(Yap_stderr, " e for exit\n g for stack dump\n s for statistics\n t for trace\n");
|
||||||
fprintf(Yap_stderr, " b for break\n");
|
fprintf(Yap_stderr, " b for break\n");
|
||||||
|
Yap_PrologMode &= ~AsyncIntMode;
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
H/Yap.h
1
H/Yap.h
@ -1187,6 +1187,7 @@ typedef enum
|
|||||||
UserCCallMode = 0x4000, /* In User C-call Code */
|
UserCCallMode = 0x4000, /* In User C-call Code */
|
||||||
MallocMode = 0x8000, /* Doing malloc, realloc, free */
|
MallocMode = 0x8000, /* Doing malloc, realloc, free */
|
||||||
SystemMode = 0x10000, /* in system mode */
|
SystemMode = 0x10000, /* in system mode */
|
||||||
|
AsyncIntMode = 0x20000 /* YAP has just been interrupted from the outside */
|
||||||
} prolog_exec_mode;
|
} prolog_exec_mode;
|
||||||
|
|
||||||
extern Int Yap_PrologMode;
|
extern Int Yap_PrologMode;
|
||||||
|
@ -435,6 +435,9 @@ extern X_API void PROTO(YAP_SlotsToArgs,(int, YAP_Int));
|
|||||||
/* void YAP_Throw() */
|
/* void YAP_Throw() */
|
||||||
extern X_API void PROTO(YAP_Throw,(YAP_Term));
|
extern X_API void PROTO(YAP_Throw,(YAP_Term));
|
||||||
|
|
||||||
|
/* void YAP_AsyncThrow() */
|
||||||
|
extern X_API void PROTO(YAP_AsyncThrow,(YAP_Term));
|
||||||
|
|
||||||
/* int YAP_LookupModule() */
|
/* int YAP_LookupModule() */
|
||||||
#define YAP_LookupModule(T) (T)
|
#define YAP_LookupModule(T) (T)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user