exceptions
This commit is contained in:
parent
2dae2363a3
commit
06e5371afd
11
os/format.c
11
os/format.c
@ -892,7 +892,7 @@ static Int doformat(volatile Term otail, volatile Term oargs,
|
||||
ts = Yap_MkApplTerm(FunctorGFormatAt, 2, ta);
|
||||
res = Yap_execute_goal(ts, 0, CurrentModule, true);
|
||||
args = Yap_GetFromSlot(sl);
|
||||
if (EX)
|
||||
if (Yap_HasException())
|
||||
goto ex_handler;
|
||||
if (!res)
|
||||
return FALSE;
|
||||
@ -914,12 +914,9 @@ static Int doformat(volatile Term otail, volatile Term oargs,
|
||||
args = Yap_GetFromSlot(sl);
|
||||
Yap_CloseSlots(sl);
|
||||
}
|
||||
if (EX != 0L) {
|
||||
Term ball;
|
||||
if (Yap_HasException()) {
|
||||
|
||||
ex_handler:
|
||||
ball = Yap_PopTermFromDB(EX);
|
||||
EX = NULL;
|
||||
if (tnum <= 8)
|
||||
targs = NULL;
|
||||
if (IsAtomTerm(tail)) {
|
||||
@ -929,8 +926,8 @@ static Int doformat(volatile Term otail, volatile Term oargs,
|
||||
GLOBAL_Stream[sno].u.mem_string.error_handler = old_handler;
|
||||
}
|
||||
format_clean_up(sno, (char *)fstr, targs);
|
||||
Yap_JumpToEnv(ball);
|
||||
return FALSE;
|
||||
Yap_RaiseException();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'q':
|
||||
|
11
os/iopreds.c
11
os/iopreds.c
@ -1577,7 +1577,6 @@ int PlGetc(int sno) {
|
||||
return -1;
|
||||
} else {
|
||||
LOCK(GLOBAL_Stream[sno].streamlock);
|
||||
return sno;
|
||||
}
|
||||
} else if (IsApplTerm(arg) && FunctorOfTerm(arg) == FunctorStream) {
|
||||
arg = ArgOfTerm(1, arg);
|
||||
@ -1587,24 +1586,26 @@ int PlGetc(int sno) {
|
||||
}
|
||||
if (sno < 0) {
|
||||
Yap_Error(DOMAIN_ERROR_STREAM_OR_ALIAS, arg, msg);
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
if (GLOBAL_Stream[sno].status & Free_Stream_f) {
|
||||
PlIOError__(file, f, line, EXISTENCE_ERROR_STREAM, arg, msg);
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
LOCK(GLOBAL_Stream[sno].streamlock);
|
||||
if ((GLOBAL_Stream[sno].status & Input_Stream_f) &&
|
||||
!(kind & Input_Stream_f)) {
|
||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||
PlIOError__(file, f, line, PERMISSION_ERROR_OUTPUT_STREAM, arg, msg);
|
||||
return -1;
|
||||
}
|
||||
if ((GLOBAL_Stream[sno].status & (Append_Stream_f | Output_Stream_f)) &&
|
||||
!(kind & Output_Stream_f)) {
|
||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||
PlIOError__(file, f, line, PERMISSION_ERROR_INPUT_STREAM, arg, msg);
|
||||
return -1;
|
||||
}
|
||||
return (sno);
|
||||
return sno;
|
||||
}
|
||||
|
||||
int Yap_CheckStream__(const char *file, const char *f, int line, Term arg,
|
||||
@ -1618,13 +1619,13 @@ int PlGetc(int sno) {
|
||||
if ((sno = CheckStream__(file, f, line, arg, kind, msg)) < 0)
|
||||
return -1;
|
||||
if ((GLOBAL_Stream[sno].status & Binary_Stream_f)) {
|
||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||
if (kind == Input_Stream_f)
|
||||
PlIOError__(file, f, line, PERMISSION_ERROR_INPUT_BINARY_STREAM, arg,
|
||||
msg);
|
||||
else
|
||||
PlIOError__(file, f, line, PERMISSION_ERROR_OUTPUT_BINARY_STREAM, arg,
|
||||
msg);
|
||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||
return -1;
|
||||
}
|
||||
return sno;
|
||||
|
@ -145,12 +145,7 @@ int beam_write ( USES_REGS1 )
|
||||
Yap_StartSlots();
|
||||
Yap_plwrite (ARG1, GLOBAL_Stream+LOCAL_c_output_stream, 0, 0, GLOBAL_MaxPriority);
|
||||
Yap_CloseSlots();
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
EX = 0L;
|
||||
Yap_JumpToEnv(ball);
|
||||
return(FALSE);
|
||||
}
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
@ -324,13 +319,8 @@ write_term2 ( USES_REGS1 )
|
||||
write_term( output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
EX = NULL;
|
||||
Yap_JumpToEnv(ball);
|
||||
return(FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
@ -355,12 +345,7 @@ write_term3 ( USES_REGS1 )
|
||||
write_term( output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
EX = NULL;
|
||||
Yap_JumpToEnv(ball);
|
||||
return(FALSE);
|
||||
}
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -391,12 +376,7 @@ write2 ( USES_REGS1 )
|
||||
write_term( output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
EX = NULL;
|
||||
Yap_JumpToEnv(ball);
|
||||
return(FALSE);
|
||||
}
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -421,12 +401,7 @@ write1 ( USES_REGS1 )
|
||||
write_term( output_stream, ARG1, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
EX = NULL;
|
||||
Yap_JumpToEnv(ball);
|
||||
return(FALSE);
|
||||
}
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -453,12 +428,7 @@ write_canonical1 ( USES_REGS1 )
|
||||
write_term( output_stream, ARG1, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
EX = NULL;
|
||||
Yap_JumpToEnv(ball);
|
||||
return(FALSE);
|
||||
}
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -485,12 +455,7 @@ write_canonical ( USES_REGS1 )
|
||||
write_term( output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
EX = NULL;
|
||||
Yap_JumpToEnv(ball);
|
||||
return(FALSE);
|
||||
}
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -517,12 +482,7 @@ writeq1 ( USES_REGS1 )
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
EX = NULL;
|
||||
Yap_JumpToEnv(ball);
|
||||
return(FALSE);
|
||||
}
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -550,12 +510,7 @@ writeq ( USES_REGS1 )
|
||||
write_term( output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
EX = NULL;
|
||||
Yap_JumpToEnv(ball);
|
||||
return(FALSE);
|
||||
}
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -583,12 +538,7 @@ print1 ( USES_REGS1 )
|
||||
write_term( output_stream, ARG1, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
EX = NULL;
|
||||
Yap_JumpToEnv(ball);
|
||||
return(FALSE);
|
||||
}
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -616,13 +566,8 @@ print ( USES_REGS1 )
|
||||
write_term( output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
EX = NULL;
|
||||
Yap_JumpToEnv(ball);
|
||||
return(FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static Int
|
||||
@ -648,12 +593,7 @@ writeln1 ( USES_REGS1 )
|
||||
write_term( output_stream, ARG1, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
EX = NULL;
|
||||
Yap_JumpToEnv(ball);
|
||||
return(FALSE);
|
||||
}
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -681,12 +621,7 @@ writeln ( USES_REGS1 )
|
||||
write_term( output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
EX = NULL;
|
||||
Yap_JumpToEnv(ball);
|
||||
return(FALSE);
|
||||
}
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ INLINE_ONLY inline EXTERN Term MkCharTerm(Int c);
|
||||
INLINE_ONLY inline EXTERN Term MkCharTerm(Int c) {
|
||||
wchar_t cs[2];
|
||||
if (c < 0)
|
||||
return MkAtomTerm(AtomEof);
|
||||
return TermEof;
|
||||
cs[0] = c;
|
||||
cs[1] = '\0';
|
||||
return MkAtomTerm(Yap_LookupMaybeWideAtom(cs));
|
||||
|
Reference in New Issue
Block a user