fix throw
This commit is contained in:
parent
b02c775915
commit
f037b2478c
21
C/errors.c
21
C/errors.c
@ -305,12 +305,17 @@ static char tmpbuf[YAP_BUF_SIZE];
|
||||
#include "YapErrors.h"
|
||||
//
|
||||
void Yap_pushErrorContext(yap_error_descriptor_t *new_error) {
|
||||
memset(new_error, 0, sizeof(yap_error_descriptor_t));
|
||||
new_error->top_error = LOCAL_ActiveError;
|
||||
LOCAL_ActiveError = new_error;
|
||||
}
|
||||
|
||||
yap_error_descriptor_t *Yap_popErrorContext(void) {
|
||||
yap_error_descriptor_t *new_error = LOCAL_ActiveError;
|
||||
yap_error_descriptor_t *Yap_popErrorContext(bool pass) {
|
||||
if (pass && LOCAL_ActiveError->top_error->errorNo == YAP_NO_ERROR &&
|
||||
LOCAL_ActiveError->errorNo != YAP_NO_ERROR)
|
||||
memcpy(LOCAL_ActiveError->top_error, LOCAL_ActiveError,
|
||||
sizeof(yap_error_descriptor_t));
|
||||
yap_error_descriptor_t *new_error = LOCAL_ActiveError;
|
||||
LOCAL_ActiveError = LOCAL_ActiveError->top_error;
|
||||
return new_error;
|
||||
}
|
||||
@ -387,14 +392,14 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
}
|
||||
if (LOCAL_DoingUndefp && type == EVALUATION_ERROR_UNDEFINED) {
|
||||
P = FAILCODE;
|
||||
CalculateStackGap(PASS_REGS1);
|
||||
CalculateStackGap(PASS_REGS1);
|
||||
return P;
|
||||
}
|
||||
LOCAL_ActiveError->errorNo = type;
|
||||
LOCAL_ActiveError->errorAsText = Yap_errorName(type);
|
||||
LOCAL_ActiveError->errorClass = Yap_errorClass(type);
|
||||
LOCAL_ActiveError->classAsText =
|
||||
Yap_errorClassName(LOCAL_ActiveError->errorClass);
|
||||
Yap_errorClassName(LOCAL_ActiveError->errorClass);
|
||||
LOCAL_ActiveError->errorLine = lineno;
|
||||
LOCAL_ActiveError->errorFunction = function;
|
||||
LOCAL_ActiveError->errorFile = file;
|
||||
@ -574,7 +579,7 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
LOCAL_ErrorMessage = RepAtom(AtomOfTerm(nt[0]))->StrOfAE;
|
||||
} else {
|
||||
LOCAL_ErrorMessage =
|
||||
(char *)RepAtom(NameOfFunctor(FunctorOfTerm(nt[0])))->StrOfAE;
|
||||
(char *)RepAtom(NameOfFunctor(FunctorOfTerm(nt[0])))->StrOfAE;
|
||||
}
|
||||
nt[1] = TermNil;
|
||||
switch (type) {
|
||||
@ -593,15 +598,15 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
ts[2] = MkAtomTerm(Yap_LookupAtom(function));
|
||||
t3 = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("c"), 3), 3, ts);
|
||||
nt[1] =
|
||||
MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("c")), t3), nt[1]);
|
||||
MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("c")), t3), nt[1]);
|
||||
}
|
||||
if ((location = Yap_pc_location(P, B, ENV)) != TermNil) {
|
||||
nt[1] = MkPairTerm(
|
||||
MkPairTerm(MkAtomTerm(Yap_LookupAtom("p")), location), nt[1]);
|
||||
MkPairTerm(MkAtomTerm(Yap_LookupAtom("p")), location), nt[1]);
|
||||
}
|
||||
if ((location = Yap_env_location(CP, B, ENV, 0)) != TermNil) {
|
||||
nt[1] = MkPairTerm(
|
||||
MkPairTerm(MkAtomTerm(Yap_LookupAtom("e")), location), nt[1]);
|
||||
MkPairTerm(MkAtomTerm(Yap_LookupAtom("e")), location), nt[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ static void syntax_msg(const char *msg, ...) {
|
||||
va_list ap;
|
||||
if (!LOCAL_ErrorMessage ||
|
||||
(LOCAL_Error_TYPE == SYNTAX_ERROR &&
|
||||
LOCAL_tokptr->TokPos < LOCAL_ActiveError->prologParserPos )) {
|
||||
LOCAL_tokptr->TokPos < LOCAL_ActiveError->prologParserPos)) {
|
||||
if (!LOCAL_ErrorMessage) {
|
||||
LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE + 1);
|
||||
}
|
||||
@ -1013,8 +1013,8 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, encoding_t enc,
|
||||
}
|
||||
}
|
||||
if (LOCAL_tokptr->Tok <= Ord(String_tok)) {
|
||||
syntax_msg("line %d: expected operator, got \'%s\'", LOCAL_tokptr->TokLine,
|
||||
Yap_tokText(LOCAL_tokptr));
|
||||
syntax_msg("line %d: expected operator, got \'%s\'",
|
||||
LOCAL_tokptr->TokLine, Yap_tokText(LOCAL_tokptr));
|
||||
FAIL;
|
||||
}
|
||||
break;
|
||||
@ -1036,6 +1036,7 @@ Term Yap_Parse(UInt prio, encoding_t enc, Term cmod) {
|
||||
t = ParseTerm(prio, &FailBuff, enc, cmod PASS_REGS);
|
||||
#if DEBUG
|
||||
if (GLOBAL_Option['p' - 'a' + 1]) {
|
||||
Yap_DebugPlWrite(MkIntTerm(LOCAL_tokptr->TokLine));
|
||||
Yap_DebugPutc(stderr, '[');
|
||||
if (t == 0)
|
||||
Yap_DebugPlWrite(MkIntTerm(0));
|
||||
|
@ -440,7 +440,7 @@ static const char *find_directory(YAP_init_args *iap, const char *paths[],
|
||||
const char *inp;
|
||||
if (filename) {
|
||||
strcpy(out, filename);
|
||||
if (Yap_IsAbsolutePath(out, false)) {
|
||||
if (Yap_IsAbsolutePath(out, true)) {
|
||||
out = pop_output_text_stack(lvl, out);
|
||||
return out;
|
||||
}
|
||||
|
@ -50,7 +50,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/* The YAP main types */
|
||||
#include "YapTerm.h"
|
||||
|
||||
@ -75,17 +74,14 @@
|
||||
typedef bool YAP_Bool;
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
This term can never be constructed as a valid term, so it is
|
||||
used as a "BAD" term
|
||||
*/
|
||||
#define TermZERO ((Term)0)
|
||||
|
||||
|
||||
#include "YapConfig.h"
|
||||
|
||||
|
||||
typedef void *YAP_PredEntryPtr;
|
||||
|
||||
typedef size_t YAP_Arity;
|
||||
@ -129,7 +125,7 @@ typedef enum {
|
||||
YAP_SAVED_STATE = 0x0004,
|
||||
YAP_OBJ = 0x0008,
|
||||
YAP_PL = 0x0010,
|
||||
YAP_BOOT_PL = 0x0030,
|
||||
YAP_BOOT_PL = 0x0030,
|
||||
YAP_QLY = 0x0040,
|
||||
YAP_EXE = 0x0080,
|
||||
YAP_FOUND_BOOT_ERROR = 0x0100,
|
||||
@ -175,37 +171,36 @@ typedef enum {
|
||||
#define YAP_RECONSULT_MODE 1
|
||||
#define YAP_BOOT_MODE 2
|
||||
|
||||
|
||||
X_API YAP_file_type_t Yap_InitDefaults(void *init_args, char saved_state[],
|
||||
int Argc, char *Argv[]);
|
||||
X_API YAP_file_type_t Yap_InitDefaults(void *init_args, char saved_state[],
|
||||
int Argc, char *Argv[]);
|
||||
|
||||
typedef struct yap_boot_params {
|
||||
//> boot type as suggested by the user
|
||||
YAP_file_type_t boot_file_type;
|
||||
//> how files are organised: NULL is GNU/Linux way
|
||||
// const char *directory_structure;
|
||||
//> if NON-NULL, set value for Yap_ROOTDIR
|
||||
const char *RootDir;
|
||||
//> if NON-NULL, location of libYap, sets Yap_LIBDIR
|
||||
const char *LibDir;
|
||||
//> if NON-NULL, architecture independent files, sets Yap_SHAREDIR
|
||||
const char *SharedDir;
|
||||
//> if NON-NULL, include files, sets Yap_INCLUDEDIR
|
||||
const char *IncludeDir;
|
||||
//> if NON-NULL, Prolog DLL location, sets Yap_DLLDIR
|
||||
const char *DLLDir;
|
||||
//> if NON-NULL, Prolog library, sets Yap_DLLDIR
|
||||
const char *PlDir;
|
||||
//> boot type as suggested by the user
|
||||
YAP_file_type_t boot_file_type;
|
||||
//> how files are organised: NULL is GNU/Linux way
|
||||
// const char *directory_structure;
|
||||
//> if NON-NULL, set value for Yap_ROOTDIR
|
||||
const char *RootDir;
|
||||
//> if NON-NULL, location of libYap, sets Yap_LIBDIR
|
||||
const char *LibDir;
|
||||
//> if NON-NULL, architecture independent files, sets Yap_SHAREDIR
|
||||
const char *SharedDir;
|
||||
//> if NON-NULL, include files, sets Yap_INCLUDEDIR
|
||||
const char *IncludeDir;
|
||||
//> if NON-NULL, Prolog DLL location, sets Yap_DLLDIR
|
||||
const char *DLLDir;
|
||||
//> if NON-NULL, Prolog library, sets Yap_DLLDIR
|
||||
const char *PlDir;
|
||||
//> if NON-NULL, name for a Prolog file to use when booting
|
||||
const char *PrologBootFile;
|
||||
//> if NON-NULL, directory for a Prolog file to be when booting
|
||||
const char *PlBootDir;
|
||||
const char *BootPlDir;
|
||||
//> if NON-NULL, path where we can find the saved state
|
||||
const char *SavedState;
|
||||
//> bootstrapping mode: YAP is not properly installed
|
||||
bool install;
|
||||
//> generats a saved space at this path
|
||||
char *OutputSavedState;
|
||||
//> bootstrapping mode: YAP is not properly installed
|
||||
bool install;
|
||||
//> generats a saved space at this path
|
||||
char *OutputSavedState;
|
||||
//> if NON-0, minimal size for Heap or Code Area
|
||||
size_t HeapSize;
|
||||
//> if NON-0, maximal size for Heap or Code Area
|
||||
@ -266,15 +261,15 @@ typedef struct yap_boot_params {
|
||||
//> 0, maintain default, > 0 use fd-1, < 0 close
|
||||
int inp, out, err;
|
||||
#if __ANDROID__
|
||||
//> android asset support
|
||||
AAssetManager *assetManager;
|
||||
//> android asset support
|
||||
AAssetManager *assetManager;
|
||||
#endif
|
||||
/* support nf's ypp preprocessor code */
|
||||
#define YAP_MAX_YPP_DEFS 100
|
||||
char *def_var[YAP_MAX_YPP_DEFS];
|
||||
char *def_value[YAP_MAX_YPP_DEFS];
|
||||
int def_c;
|
||||
/* End preprocessor code */
|
||||
/* End preprocessor code */
|
||||
|
||||
#ifdef MYDDAS_MYSQL
|
||||
//> If any myddas option was given
|
||||
@ -332,7 +327,7 @@ typedef YAP_Bool (*YAP_Opaque_CallOnGCRelocate)(YAP_opaque_tag_t, void *,
|
||||
/// opaque variables can interact with the system
|
||||
typedef struct YAP_opaque_handler_struct {
|
||||
YAP_Opaque_CallOnCut cut_handler; //< called at cut, which may be a forward
|
||||
//cut or an exception.
|
||||
// cut or an exception.
|
||||
YAP_Opaque_CallOnFail
|
||||
fail_handler; //< called at exit, it can be used to cleanup resources
|
||||
YAP_Opaque_CallOnWrite write_handler; //< text representation
|
||||
|
@ -238,6 +238,6 @@ INLINE_ONLY extern inline Term Yap_ensure_atom__(const char *fu, const char *fi,
|
||||
extern const char *Yap_errorClassName(yap_error_class_number e);
|
||||
|
||||
extern void Yap_pushErrorContext(yap_error_descriptor_t * new_error);
|
||||
extern yap_error_descriptor_t *Yap_popErrorContext(void);
|
||||
extern yap_error_descriptor_t *Yap_popErrorContext(bool pass);
|
||||
|
||||
#endif
|
||||
|
19
os/charsio.c
19
os/charsio.c
@ -153,9 +153,6 @@ int Yap_peekWithSeek(int sno) {
|
||||
int Yap_popChar(int sno) {
|
||||
StreamDesc *s = GLOBAL_Stream + sno;
|
||||
s->buf.on = false;
|
||||
s->charcount = s->buf.pos;
|
||||
s->linecount = s->buf.line;
|
||||
s->linepos = s->buf.lpos;
|
||||
Yap_DefaultStreamOps(s);
|
||||
return s->buf.ch;
|
||||
}
|
||||
@ -174,16 +171,13 @@ int Yap_peekWide(int sno) {
|
||||
} else {
|
||||
s->buf.on = true;
|
||||
s->buf.ch = ch;
|
||||
s->buf.pos = s->charcount;
|
||||
s->buf.line = s->linecount;
|
||||
s->buf.lpos = s->linepos;
|
||||
s->charcount = pos;
|
||||
s->linecount = line;
|
||||
s->linepos = lpos;
|
||||
s->stream_wgetc = Yap_popChar;
|
||||
s->stream_getc = NULL;
|
||||
s->stream_peek= NULL;
|
||||
s->stream_wpeek= NULL;
|
||||
s->stream_peek = NULL;
|
||||
s->stream_wpeek = NULL;
|
||||
s->stream_getc = Yap_popChar;
|
||||
s->stream_wgetc = Yap_popChar;
|
||||
// Yap_SetCurInpPos(sno, pos);
|
||||
@ -205,17 +199,14 @@ int Yap_peekChar(int sno) {
|
||||
} else {
|
||||
s->buf.on = true;
|
||||
s->buf.ch = ch;
|
||||
s->buf.pos = s->charcount;
|
||||
s->buf.line = s->linecount;
|
||||
s->buf.lpos = s->linepos;
|
||||
s->charcount = pos;
|
||||
s->linecount = line;
|
||||
s->linepos = lpos;
|
||||
s->stream_getc = Yap_popChar;
|
||||
s->stream_wgetc = NULL;
|
||||
s->stream_peek= NULL;
|
||||
s->stream_wpeek= NULL;
|
||||
//Yap_SetCurInpPos(sno, pos);
|
||||
s->stream_peek = NULL;
|
||||
s->stream_wpeek = NULL;
|
||||
// Yap_SetCurInpPos(sno, pos);
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
|
@ -224,13 +224,11 @@
|
||||
|
||||
:- yap_flag(unknown,error).
|
||||
:- style_check(single_var).
|
||||
:- start_low_level_trace.
|
||||
:- initialization((
|
||||
bb_put(logger_filename,'out.dat'),
|
||||
bb_put(logger_delimiter,';'),
|
||||
bb_put(logger_variables,[])
|
||||
)).
|
||||
:- stopS_low_level_trace.
|
||||
|
||||
%========================================================================
|
||||
%= Defines a new variable, possible types are: int, float and time
|
||||
|
Reference in New Issue
Block a user