fixes
This commit is contained in:
parent
fadf853e96
commit
34c6ace8be
21
C/errors.c
21
C/errors.c
@ -305,12 +305,17 @@ static char tmpbuf[YAP_BUF_SIZE];
|
|||||||
#include "YapErrors.h"
|
#include "YapErrors.h"
|
||||||
//
|
//
|
||||||
void Yap_pushErrorContext(yap_error_descriptor_t *new_error) {
|
void Yap_pushErrorContext(yap_error_descriptor_t *new_error) {
|
||||||
|
memset(new_error, 0, sizeof(yap_error_descriptor_t));
|
||||||
new_error->top_error = LOCAL_ActiveError;
|
new_error->top_error = LOCAL_ActiveError;
|
||||||
LOCAL_ActiveError = new_error;
|
LOCAL_ActiveError = new_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
yap_error_descriptor_t *Yap_popErrorContext(void) {
|
yap_error_descriptor_t *Yap_popErrorContext(bool pass) {
|
||||||
yap_error_descriptor_t *new_error = LOCAL_ActiveError;
|
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;
|
LOCAL_ActiveError = LOCAL_ActiveError->top_error;
|
||||||
return new_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) {
|
if (LOCAL_DoingUndefp && type == EVALUATION_ERROR_UNDEFINED) {
|
||||||
P = FAILCODE;
|
P = FAILCODE;
|
||||||
CalculateStackGap(PASS_REGS1);
|
CalculateStackGap(PASS_REGS1);
|
||||||
return P;
|
return P;
|
||||||
}
|
}
|
||||||
LOCAL_ActiveError->errorNo = type;
|
LOCAL_ActiveError->errorNo = type;
|
||||||
LOCAL_ActiveError->errorAsText = Yap_errorName(type);
|
LOCAL_ActiveError->errorAsText = Yap_errorName(type);
|
||||||
LOCAL_ActiveError->errorClass = Yap_errorClass(type);
|
LOCAL_ActiveError->errorClass = Yap_errorClass(type);
|
||||||
LOCAL_ActiveError->classAsText =
|
LOCAL_ActiveError->classAsText =
|
||||||
Yap_errorClassName(LOCAL_ActiveError->errorClass);
|
Yap_errorClassName(LOCAL_ActiveError->errorClass);
|
||||||
LOCAL_ActiveError->errorLine = lineno;
|
LOCAL_ActiveError->errorLine = lineno;
|
||||||
LOCAL_ActiveError->errorFunction = function;
|
LOCAL_ActiveError->errorFunction = function;
|
||||||
LOCAL_ActiveError->errorFile = file;
|
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;
|
LOCAL_ErrorMessage = RepAtom(AtomOfTerm(nt[0]))->StrOfAE;
|
||||||
} else {
|
} else {
|
||||||
LOCAL_ErrorMessage =
|
LOCAL_ErrorMessage =
|
||||||
(char *)RepAtom(NameOfFunctor(FunctorOfTerm(nt[0])))->StrOfAE;
|
(char *)RepAtom(NameOfFunctor(FunctorOfTerm(nt[0])))->StrOfAE;
|
||||||
}
|
}
|
||||||
nt[1] = TermNil;
|
nt[1] = TermNil;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -593,15 +598,15 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
|||||||
ts[2] = MkAtomTerm(Yap_LookupAtom(function));
|
ts[2] = MkAtomTerm(Yap_LookupAtom(function));
|
||||||
t3 = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("c"), 3), 3, ts);
|
t3 = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("c"), 3), 3, ts);
|
||||||
nt[1] =
|
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) {
|
if ((location = Yap_pc_location(P, B, ENV)) != TermNil) {
|
||||||
nt[1] = MkPairTerm(
|
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) {
|
if ((location = Yap_env_location(CP, B, ENV, 0)) != TermNil) {
|
||||||
nt[1] = MkPairTerm(
|
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;
|
va_list ap;
|
||||||
if (!LOCAL_ErrorMessage ||
|
if (!LOCAL_ErrorMessage ||
|
||||||
(LOCAL_Error_TYPE == SYNTAX_ERROR &&
|
(LOCAL_Error_TYPE == SYNTAX_ERROR &&
|
||||||
LOCAL_tokptr->TokPos < LOCAL_ActiveError->prologParserPos )) {
|
LOCAL_tokptr->TokPos < LOCAL_ActiveError->prologParserPos)) {
|
||||||
if (!LOCAL_ErrorMessage) {
|
if (!LOCAL_ErrorMessage) {
|
||||||
LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE + 1);
|
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)) {
|
if (LOCAL_tokptr->Tok <= Ord(String_tok)) {
|
||||||
syntax_msg("line %d: expected operator, got \'%s\'", LOCAL_tokptr->TokLine,
|
syntax_msg("line %d: expected operator, got \'%s\'",
|
||||||
Yap_tokText(LOCAL_tokptr));
|
LOCAL_tokptr->TokLine, Yap_tokText(LOCAL_tokptr));
|
||||||
FAIL;
|
FAIL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1036,6 +1036,7 @@ Term Yap_Parse(UInt prio, encoding_t enc, Term cmod) {
|
|||||||
t = ParseTerm(prio, &FailBuff, enc, cmod PASS_REGS);
|
t = ParseTerm(prio, &FailBuff, enc, cmod PASS_REGS);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (GLOBAL_Option['p' - 'a' + 1]) {
|
if (GLOBAL_Option['p' - 'a' + 1]) {
|
||||||
|
Yap_DebugPlWrite(MkIntTerm(LOCAL_tokptr->TokLine));
|
||||||
Yap_DebugPutc(stderr, '[');
|
Yap_DebugPutc(stderr, '[');
|
||||||
if (t == 0)
|
if (t == 0)
|
||||||
Yap_DebugPlWrite(MkIntTerm(0));
|
Yap_DebugPlWrite(MkIntTerm(0));
|
||||||
|
@ -440,7 +440,7 @@ static const char *find_directory(YAP_init_args *iap, const char *paths[],
|
|||||||
const char *inp;
|
const char *inp;
|
||||||
if (filename) {
|
if (filename) {
|
||||||
strcpy(out, filename);
|
strcpy(out, filename);
|
||||||
if (Yap_IsAbsolutePath(out, false)) {
|
if (Yap_IsAbsolutePath(out, true)) {
|
||||||
out = pop_output_text_stack(lvl, out);
|
out = pop_output_text_stack(lvl, out);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
/* The YAP main types */
|
/* The YAP main types */
|
||||||
#include "YapTerm.h"
|
#include "YapTerm.h"
|
||||||
|
|
||||||
@ -75,17 +74,14 @@
|
|||||||
typedef bool YAP_Bool;
|
typedef bool YAP_Bool;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This term can never be constructed as a valid term, so it is
|
This term can never be constructed as a valid term, so it is
|
||||||
used as a "BAD" term
|
used as a "BAD" term
|
||||||
*/
|
*/
|
||||||
#define TermZERO ((Term)0)
|
#define TermZERO ((Term)0)
|
||||||
|
|
||||||
|
|
||||||
#include "YapConfig.h"
|
#include "YapConfig.h"
|
||||||
|
|
||||||
|
|
||||||
typedef void *YAP_PredEntryPtr;
|
typedef void *YAP_PredEntryPtr;
|
||||||
|
|
||||||
typedef size_t YAP_Arity;
|
typedef size_t YAP_Arity;
|
||||||
@ -129,7 +125,7 @@ typedef enum {
|
|||||||
YAP_SAVED_STATE = 0x0004,
|
YAP_SAVED_STATE = 0x0004,
|
||||||
YAP_OBJ = 0x0008,
|
YAP_OBJ = 0x0008,
|
||||||
YAP_PL = 0x0010,
|
YAP_PL = 0x0010,
|
||||||
YAP_BOOT_PL = 0x0030,
|
YAP_BOOT_PL = 0x0030,
|
||||||
YAP_QLY = 0x0040,
|
YAP_QLY = 0x0040,
|
||||||
YAP_EXE = 0x0080,
|
YAP_EXE = 0x0080,
|
||||||
YAP_FOUND_BOOT_ERROR = 0x0100,
|
YAP_FOUND_BOOT_ERROR = 0x0100,
|
||||||
@ -175,37 +171,36 @@ typedef enum {
|
|||||||
#define YAP_RECONSULT_MODE 1
|
#define YAP_RECONSULT_MODE 1
|
||||||
#define YAP_BOOT_MODE 2
|
#define YAP_BOOT_MODE 2
|
||||||
|
|
||||||
|
X_API YAP_file_type_t Yap_InitDefaults(void *init_args, char saved_state[],
|
||||||
X_API YAP_file_type_t Yap_InitDefaults(void *init_args, char saved_state[],
|
int Argc, char *Argv[]);
|
||||||
int Argc, char *Argv[]);
|
|
||||||
|
|
||||||
typedef struct yap_boot_params {
|
typedef struct yap_boot_params {
|
||||||
//> boot type as suggested by the user
|
//> boot type as suggested by the user
|
||||||
YAP_file_type_t boot_file_type;
|
YAP_file_type_t boot_file_type;
|
||||||
//> how files are organised: NULL is GNU/Linux way
|
//> how files are organised: NULL is GNU/Linux way
|
||||||
// const char *directory_structure;
|
// const char *directory_structure;
|
||||||
//> if NON-NULL, set value for Yap_ROOTDIR
|
//> if NON-NULL, set value for Yap_ROOTDIR
|
||||||
const char *RootDir;
|
const char *RootDir;
|
||||||
//> if NON-NULL, location of libYap, sets Yap_LIBDIR
|
//> if NON-NULL, location of libYap, sets Yap_LIBDIR
|
||||||
const char *LibDir;
|
const char *LibDir;
|
||||||
//> if NON-NULL, architecture independent files, sets Yap_SHAREDIR
|
//> if NON-NULL, architecture independent files, sets Yap_SHAREDIR
|
||||||
const char *SharedDir;
|
const char *SharedDir;
|
||||||
//> if NON-NULL, include files, sets Yap_INCLUDEDIR
|
//> if NON-NULL, include files, sets Yap_INCLUDEDIR
|
||||||
const char *IncludeDir;
|
const char *IncludeDir;
|
||||||
//> if NON-NULL, Prolog DLL location, sets Yap_DLLDIR
|
//> if NON-NULL, Prolog DLL location, sets Yap_DLLDIR
|
||||||
const char *DLLDir;
|
const char *DLLDir;
|
||||||
//> if NON-NULL, Prolog library, sets Yap_DLLDIR
|
//> if NON-NULL, Prolog library, sets Yap_DLLDIR
|
||||||
const char *PlDir;
|
const char *PlDir;
|
||||||
//> if NON-NULL, name for a Prolog file to use when booting
|
//> if NON-NULL, name for a Prolog file to use when booting
|
||||||
const char *PrologBootFile;
|
const char *PrologBootFile;
|
||||||
//> if NON-NULL, directory for a Prolog file to be when booting
|
//> 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
|
//> if NON-NULL, path where we can find the saved state
|
||||||
const char *SavedState;
|
const char *SavedState;
|
||||||
//> bootstrapping mode: YAP is not properly installed
|
//> bootstrapping mode: YAP is not properly installed
|
||||||
bool install;
|
bool install;
|
||||||
//> generats a saved space at this path
|
//> generats a saved space at this path
|
||||||
char *OutputSavedState;
|
char *OutputSavedState;
|
||||||
//> if NON-0, minimal size for Heap or Code Area
|
//> if NON-0, minimal size for Heap or Code Area
|
||||||
size_t HeapSize;
|
size_t HeapSize;
|
||||||
//> if NON-0, maximal size for Heap or Code Area
|
//> 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
|
//> 0, maintain default, > 0 use fd-1, < 0 close
|
||||||
int inp, out, err;
|
int inp, out, err;
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
//> android asset support
|
//> android asset support
|
||||||
AAssetManager *assetManager;
|
AAssetManager *assetManager;
|
||||||
#endif
|
#endif
|
||||||
/* support nf's ypp preprocessor code */
|
/* support nf's ypp preprocessor code */
|
||||||
#define YAP_MAX_YPP_DEFS 100
|
#define YAP_MAX_YPP_DEFS 100
|
||||||
char *def_var[YAP_MAX_YPP_DEFS];
|
char *def_var[YAP_MAX_YPP_DEFS];
|
||||||
char *def_value[YAP_MAX_YPP_DEFS];
|
char *def_value[YAP_MAX_YPP_DEFS];
|
||||||
int def_c;
|
int def_c;
|
||||||
/* End preprocessor code */
|
/* End preprocessor code */
|
||||||
|
|
||||||
#ifdef MYDDAS_MYSQL
|
#ifdef MYDDAS_MYSQL
|
||||||
//> If any myddas option was given
|
//> 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
|
/// opaque variables can interact with the system
|
||||||
typedef struct YAP_opaque_handler_struct {
|
typedef struct YAP_opaque_handler_struct {
|
||||||
YAP_Opaque_CallOnCut cut_handler; //< called at cut, which may be a forward
|
YAP_Opaque_CallOnCut cut_handler; //< called at cut, which may be a forward
|
||||||
//cut or an exception.
|
// cut or an exception.
|
||||||
YAP_Opaque_CallOnFail
|
YAP_Opaque_CallOnFail
|
||||||
fail_handler; //< called at exit, it can be used to cleanup resources
|
fail_handler; //< called at exit, it can be used to cleanup resources
|
||||||
YAP_Opaque_CallOnWrite write_handler; //< text representation
|
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 const char *Yap_errorClassName(yap_error_class_number e);
|
||||||
|
|
||||||
extern void Yap_pushErrorContext(yap_error_descriptor_t * new_error);
|
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
|
#endif
|
||||||
|
19
os/charsio.c
19
os/charsio.c
@ -153,9 +153,6 @@ int Yap_peekWithSeek(int sno) {
|
|||||||
int Yap_popChar(int sno) {
|
int Yap_popChar(int sno) {
|
||||||
StreamDesc *s = GLOBAL_Stream + sno;
|
StreamDesc *s = GLOBAL_Stream + sno;
|
||||||
s->buf.on = false;
|
s->buf.on = false;
|
||||||
s->charcount = s->buf.pos;
|
|
||||||
s->linecount = s->buf.line;
|
|
||||||
s->linepos = s->buf.lpos;
|
|
||||||
Yap_DefaultStreamOps(s);
|
Yap_DefaultStreamOps(s);
|
||||||
return s->buf.ch;
|
return s->buf.ch;
|
||||||
}
|
}
|
||||||
@ -174,16 +171,13 @@ int Yap_peekWide(int sno) {
|
|||||||
} else {
|
} else {
|
||||||
s->buf.on = true;
|
s->buf.on = true;
|
||||||
s->buf.ch = ch;
|
s->buf.ch = ch;
|
||||||
s->buf.pos = s->charcount;
|
|
||||||
s->buf.line = s->linecount;
|
|
||||||
s->buf.lpos = s->linepos;
|
|
||||||
s->charcount = pos;
|
s->charcount = pos;
|
||||||
s->linecount = line;
|
s->linecount = line;
|
||||||
s->linepos = lpos;
|
s->linepos = lpos;
|
||||||
s->stream_wgetc = Yap_popChar;
|
s->stream_wgetc = Yap_popChar;
|
||||||
s->stream_getc = NULL;
|
s->stream_getc = NULL;
|
||||||
s->stream_peek= NULL;
|
s->stream_peek = NULL;
|
||||||
s->stream_wpeek= NULL;
|
s->stream_wpeek = NULL;
|
||||||
s->stream_getc = Yap_popChar;
|
s->stream_getc = Yap_popChar;
|
||||||
s->stream_wgetc = Yap_popChar;
|
s->stream_wgetc = Yap_popChar;
|
||||||
// Yap_SetCurInpPos(sno, pos);
|
// Yap_SetCurInpPos(sno, pos);
|
||||||
@ -205,17 +199,14 @@ int Yap_peekChar(int sno) {
|
|||||||
} else {
|
} else {
|
||||||
s->buf.on = true;
|
s->buf.on = true;
|
||||||
s->buf.ch = ch;
|
s->buf.ch = ch;
|
||||||
s->buf.pos = s->charcount;
|
|
||||||
s->buf.line = s->linecount;
|
|
||||||
s->buf.lpos = s->linepos;
|
|
||||||
s->charcount = pos;
|
s->charcount = pos;
|
||||||
s->linecount = line;
|
s->linecount = line;
|
||||||
s->linepos = lpos;
|
s->linepos = lpos;
|
||||||
s->stream_getc = Yap_popChar;
|
s->stream_getc = Yap_popChar;
|
||||||
s->stream_wgetc = NULL;
|
s->stream_wgetc = NULL;
|
||||||
s->stream_peek= NULL;
|
s->stream_peek = NULL;
|
||||||
s->stream_wpeek= NULL;
|
s->stream_wpeek = NULL;
|
||||||
//Yap_SetCurInpPos(sno, pos);
|
// Yap_SetCurInpPos(sno, pos);
|
||||||
}
|
}
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
@ -224,13 +224,11 @@
|
|||||||
|
|
||||||
:- yap_flag(unknown,error).
|
:- yap_flag(unknown,error).
|
||||||
:- style_check(single_var).
|
:- style_check(single_var).
|
||||||
:- start_low_level_trace.
|
|
||||||
:- initialization((
|
:- initialization((
|
||||||
bb_put(logger_filename,'out.dat'),
|
bb_put(logger_filename,'out.dat'),
|
||||||
bb_put(logger_delimiter,';'),
|
bb_put(logger_delimiter,';'),
|
||||||
bb_put(logger_variables,[])
|
bb_put(logger_variables,[])
|
||||||
)).
|
)).
|
||||||
:- stopS_low_level_trace.
|
|
||||||
|
|
||||||
%========================================================================
|
%========================================================================
|
||||||
%= Defines a new variable, possible types are: int, float and time
|
%= Defines a new variable, possible types are: int, float and time
|
||||||
|
@ -8,7 +8,6 @@ set(PL_BOOT_SOURCES
|
|||||||
boot.yap
|
boot.yap
|
||||||
bootlists.yap
|
bootlists.yap
|
||||||
bootutils.yap
|
bootutils.yap
|
||||||
builtins.yap
|
|
||||||
callcount.yap
|
callcount.yap
|
||||||
checker.yap
|
checker.yap
|
||||||
consult.yap
|
consult.yap
|
||||||
@ -27,7 +26,7 @@ set(PL_BOOT_SOURCES
|
|||||||
grammar.yap
|
grammar.yap
|
||||||
ground.yap
|
ground.yap
|
||||||
hacks.yap
|
hacks.yap
|
||||||
imports.yap
|
init.yap
|
||||||
listing.yap
|
listing.yap
|
||||||
load_foreign.yap
|
load_foreign.yap
|
||||||
messages.yap
|
messages.yap
|
||||||
@ -52,7 +51,6 @@ set(PL_BOOT_SOURCES
|
|||||||
swi.yap
|
swi.yap
|
||||||
tabling.yap
|
tabling.yap
|
||||||
threads.yap
|
threads.yap
|
||||||
top.yap
|
|
||||||
udi.yap
|
udi.yap
|
||||||
undefined.yap
|
undefined.yap
|
||||||
utils.yap
|
utils.yap
|
||||||
@ -61,29 +59,39 @@ set(PL_BOOT_SOURCES
|
|||||||
|
|
||||||
add_to_group(PL_BOOT_SOURCES pl_boot_library)
|
add_to_group(PL_BOOT_SOURCES pl_boot_library)
|
||||||
|
|
||||||
|
if (ANDROID)
|
||||||
|
add_custom_target(STARTUP
|
||||||
|
DEPENDS ${PL_BOOT_SOURCES}
|
||||||
|
)
|
||||||
|
file (INSTALL ${PL_BOOT_SOURCES} DESTINATION ${libpl}/pl)
|
||||||
|
elif(CMAKE_CROSSCOMPILING)
|
||||||
|
add_custom_target(STARTUP ALL SOURCES
|
||||||
|
DEPENDS ${PL_BOOT_SOURCES}
|
||||||
|
)
|
||||||
|
else ()
|
||||||
|
add_custom_target(STARTUP ALL
|
||||||
|
DEPENDS ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
||||||
|
)
|
||||||
|
add_custom_command(OUTPUT ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
||||||
|
COMMAND yap-bin -B${CMAKE_SOURCE_DIR}/pl --output-saved-state=${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
||||||
|
VERBATIM
|
||||||
|
DEPENDS ${PL_BOOT_SOURCES} yap-bin
|
||||||
|
)
|
||||||
|
|
||||||
|
# install(CODE "execute_process(COMMAND ./yap -B
|
||||||
|
# WORKING_DIRECTORY ${CMAKE_TOP_BINARY_DIR})"
|
||||||
|
# DEPENDS Py4YAP ${PL_BOOT_SOURCES} yap-bin )
|
||||||
|
|
||||||
|
|
||||||
|
install(FILES ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
||||||
|
DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
install(FILES ${PL_BOOT_SOURCES}
|
install(FILES ${PL_BOOT_SOURCES}
|
||||||
DESTINATION ${libpl}/pl
|
DESTINATION ${libpl}/pl
|
||||||
)
|
)
|
||||||
install(FILES ../library/ypp.yap
|
install(FILES ../library/ypp.yap
|
||||||
DESTINATION ${libpl}/library)
|
DESTINATION ${libpl}/library
|
||||||
# )
|
)
|
||||||
# if (ANDROID OR CMAKE_CROSSCOMPILING)
|
|
||||||
# add_custom_target(STARTUP
|
|
||||||
# )
|
|
||||||
# else()
|
|
||||||
add_custom_target(STARTUP ALL
|
|
||||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/startup.yss)
|
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/startup.yss
|
|
||||||
COMMAND yap-bin -B${CMAKE_CURRENT_SOURCE_DIR} --output-saved-state=${CMAKE_CURRENT_BINARY_DIR}/startup.yss
|
|
||||||
DEPENDS ${PL_BOOT_SOURCES} yap-bin
|
|
||||||
)
|
|
||||||
#else ()
|
|
||||||
#add_custom_target(STARTUP ALL
|
|
||||||
# DEPENDS ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
|
||||||
# )
|
|
||||||
|
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/startup.yss DESTINATION ${dlls} )
|
|
||||||
|
|
||||||
|
|
||||||
#endif()
|
|
||||||
|
@ -513,7 +513,7 @@ path(Path) :-
|
|||||||
'$in_path'(X) :-
|
'$in_path'(X) :-
|
||||||
recorded('$path',Path,_),
|
recorded('$path',Path,_),
|
||||||
atom_codes(Path,S),
|
atom_codes(Path,S),
|
||||||
( S = "" -> X = '.' ;
|
( S = [] -> X = '.' ;
|
||||||
atom_codes(X,S) ).
|
atom_codes(X,S) ).
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
16
pl/boot.yap
16
pl/boot.yap
@ -120,6 +120,7 @@ print_message(L,E) :-
|
|||||||
).
|
).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'$undefp0'([M|G], _Action) :-
|
'$undefp0'([M|G], _Action) :-
|
||||||
stream_property( loop_stream, file_name(F)),
|
stream_property( loop_stream, file_name(F)),
|
||||||
stream_property( loop_stream, line_number(L)),
|
stream_property( loop_stream, line_number(L)),
|
||||||
@ -165,6 +166,9 @@ print_message(L,E) :-
|
|||||||
% This is the YAP init file
|
% This is the YAP init file
|
||||||
% should be consulted first step after booting
|
% should be consulted first step after booting
|
||||||
|
|
||||||
|
|
||||||
|
:- yap_flag(prolog:unknown, error).
|
||||||
|
|
||||||
:- c_compile('top.yap').
|
:- c_compile('top.yap').
|
||||||
|
|
||||||
% These are pseudo declarations
|
% These are pseudo declarations
|
||||||
@ -200,14 +204,17 @@ print_message(L,E) :-
|
|||||||
|
|
||||||
'$command'(C,VL,Pos,Con) :-
|
'$command'(C,VL,Pos,Con) :-
|
||||||
current_prolog_flag(strict_iso, true), !, /* strict_iso on */
|
current_prolog_flag(strict_iso, true), !, /* strict_iso on */
|
||||||
'$execute_command'(C,VL,Pos,Con,_Source).
|
'$yap_strip_module'(C, EM, EG),
|
||||||
|
'$execute_command'(EM,EG,VL,Pos,Con,_Source).
|
||||||
'$command'(C,VL,Pos,Con) :-
|
'$command'(C,VL,Pos,Con) :-
|
||||||
( (Con = top ; var(C) ; C = [_|_]) ->
|
( (Con = top ; var(C) ; C = [_|_]) ->
|
||||||
'$execute_command'(C,VL,Pos,Con,C), ! ;
|
'$yap_strip_module'(C, EM, EG),
|
||||||
|
'$execute_command'(EG,EM,VL,Pos,Con,C), ! ;
|
||||||
% do term expansion
|
% do term expansion
|
||||||
'$expand_term'(C, EC),
|
'$expand_term'(C, EC),
|
||||||
|
'$yap_strip_module'(EC, EM, EG),
|
||||||
% execute a list of commands
|
% execute a list of commands
|
||||||
'$execute_commands'(EC,VL,Pos,Con,_Source),
|
'$execute_commands'(EG,EM,VL,Pos,Con,_Source),
|
||||||
% succeed only if the *original* was at end of file.
|
% succeed only if the *original* was at end of file.
|
||||||
C == end_of_file
|
C == end_of_file
|
||||||
).
|
).
|
||||||
@ -217,8 +224,6 @@ print_message(L,E) :-
|
|||||||
|
|
||||||
:- '$init_prolog'.
|
:- '$init_prolog'.
|
||||||
|
|
||||||
:- '$all_current_modules'(M), yap_flag(M:unknown, error) ; true.
|
|
||||||
|
|
||||||
:- compile_expressions.
|
:- compile_expressions.
|
||||||
|
|
||||||
|
|
||||||
@ -453,4 +458,3 @@ If this hook predicate succeeds it must instantiate the _Action_ argument to th
|
|||||||
:- ensure_loaded('../pl/pathconf.yap').
|
:- ensure_loaded('../pl/pathconf.yap').
|
||||||
|
|
||||||
:- yap_flag(user:unknown,error).
|
:- yap_flag(user:unknown,error).
|
||||||
|
|
||||||
|
@ -1403,16 +1403,17 @@ Similar to initialization/1, but allows for specifying when
|
|||||||
Do not execute _Goal_ while loading the program, but only when restoring a state (not implemented yet).
|
Do not execute _Goal_ while loading the program, but only when restoring a state (not implemented yet).
|
||||||
|
|
||||||
*/
|
*/
|
||||||
initialization(G0,OPT) :-
|
initialization(G,OPT) :-
|
||||||
expand_goal(G0, G),
|
|
||||||
catch('$initialization'(G, OPT), Error, '$LoopError'( Error, consult ) ),
|
catch('$initialization'(G, OPT), Error, '$LoopError'( Error, consult ) ),
|
||||||
fail.
|
fail.
|
||||||
initialization(_G,_OPT).
|
initialization(_G,_OPT).
|
||||||
|
|
||||||
'$initialization'(G,OPT) :-
|
'$initialization'(G0,OPT) :-
|
||||||
must_be_of_type(callable, G, initialization(G,OPT)),
|
must_be_of_type(callable, G0, initialization(G0,OPT)),
|
||||||
must_be_of_type(oneof([after_load, now, restore]),
|
must_be_of_type(oneof([after_load, now, restore]),
|
||||||
OPT, initialization(G,OPT)),
|
OPT, initialization(G0,OPT)),
|
||||||
|
'$yap_strip_module'(G0,M,G1),
|
||||||
|
'$expand_term'((M:G1), G),
|
||||||
(
|
(
|
||||||
OPT == now
|
OPT == now
|
||||||
->
|
->
|
||||||
@ -1426,7 +1427,7 @@ initialization(_G,_OPT).
|
|||||||
->
|
->
|
||||||
recordz('$call_at_restore', G, _ )
|
recordz('$call_at_restore', G, _ )
|
||||||
).
|
).
|
||||||
:- .
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@}
|
@}
|
||||||
|
@ -222,8 +222,8 @@ beautify_hidden_goal('$system_catch'(G,Mod,Exc,Handler),prolog) -->
|
|||||||
[catch(Mod:G, Exc, Handler)].
|
[catch(Mod:G, Exc, Handler)].
|
||||||
beautify_hidden_goal('$catch'(G,Exc,Handler),prolog) -->
|
beautify_hidden_goal('$catch'(G,Exc,Handler),prolog) -->
|
||||||
[catch(G, Exc, Handler)].
|
[catch(G, Exc, Handler)].
|
||||||
beautify_hidden_goal('$execute_command'(Query,V,P,Option,Source),prolog) -->
|
beautify_hidden_goal('$execute_command'(Query,M,V,P,Option,Source),prolog) -->
|
||||||
[toplevel_query(Query, V, P, Option, Source)].
|
[toplevel_query(M:Query, V, P, Option, Source)].
|
||||||
beautify_hidden_goal('$process_directive'(Gs,_Mode,_VL),prolog) -->
|
beautify_hidden_goal('$process_directive'(Gs,_Mode,_VL),prolog) -->
|
||||||
[(:- Gs)].
|
[(:- Gs)].
|
||||||
beautify_hidden_goal('$loop'(Stream,Option),prolog) -->
|
beautify_hidden_goal('$loop'(Stream,Option),prolog) -->
|
||||||
|
58
pl/top.yap
58
pl/top.yap
@ -117,7 +117,7 @@ live :- '$live'.
|
|||||||
throw(E).
|
throw(E).
|
||||||
|
|
||||||
|
|
||||||
/** @pred stream_property( _Stream_, _Prop_)
|
/** @pred stream_property( Stream, Prop )
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ current_prolog_flag(break_level, BreakLevel),
|
|||||||
eraseall('$$set'),
|
eraseall('$$set'),
|
||||||
eraseall('$$one'),
|
eraseall('$$one'),
|
||||||
eraseall('$reconsulted'), fail.
|
eraseall('$reconsulted'), fail.
|
||||||
'$erase_sets' :- \+ recorded('$path',_,_), recorda('$path',"",_).
|
'$erase_sets' :- \+ recorded('$path',_,_), recorda('$path',[],_).
|
||||||
'$erase_sets'.
|
'$erase_sets'.
|
||||||
|
|
||||||
'$start_corouts' :-
|
'$start_corouts' :-
|
||||||
@ -176,59 +176,59 @@ current_prolog_flag(break_level, BreakLevel),
|
|||||||
%
|
%
|
||||||
% Hack in case expand_term has created a list of commands.
|
% Hack in case expand_term has created a list of commands.
|
||||||
%
|
%
|
||||||
'$execute_commands'(V,_,_,_,Source) :- var(V), !,
|
'$execute_commands'(V,_,_,_,_,Source) :- var(V), !,
|
||||||
'$do_error'(instantiation_error,meta_call(Source)).
|
'$do_error'(instantiation_error,meta_call(Source)).
|
||||||
'$execute_commands'([],_,_,_,_) :- !.
|
'$execute_commands'([],_,_,_,_,_) :- !.
|
||||||
'$execute_commands'([C|Cs],VL,Pos,Con,Source) :-
|
'$execute_commands'([C|Cs],M,VL,Pos,Con,Source) :-
|
||||||
!,
|
!,
|
||||||
(
|
(
|
||||||
'$system_catch'('$execute_command'(C,VL,Pos,Con,Source),prolog,Error,'$LoopError'(Error, Con)),
|
'$system_catch'('$execute_command'(C,M,VL,Pos,Con,Source),prolog,Error,'$LoopError'(Error, Con)),
|
||||||
fail
|
fail
|
||||||
;
|
;
|
||||||
'$execute_commands'(Cs,VL,Pos,Con,Source)
|
'$execute_commands'(Cs,M,VL,Pos,Con,Source)
|
||||||
).
|
).
|
||||||
'$execute_commands'(C,VL,Pos,Con,Source) :-
|
'$execute_commands'(C,M,VL,Pos,Con,Source) :-
|
||||||
'$execute_command'(C,VL,Pos,Con,Source).
|
'$execute_command'(C,M,VL,Pos,Con,Source).
|
||||||
|
|
||||||
%
|
%
|
||||||
%
|
%
|
||||||
%
|
%
|
||||||
|
|
||||||
'$execute_command'(C,_,_,top,Source) :-
|
'$execute_command'(C,_,_,_,_,Source) :-
|
||||||
var(C),
|
var(C),
|
||||||
!,
|
!,
|
||||||
'$do_error'(instantiation_error,meta_call(Source)).
|
'$do_error'(instantiation_error,meta_call(Source)).
|
||||||
'$execute_command'(C,_,_,top,Source) :-
|
'$execute_command'(C,_,_,_,_top,Source) :-
|
||||||
number(C),
|
number(C),
|
||||||
!,
|
!,
|
||||||
'$do_error'(type_error(callable,C),meta_call(Source)).
|
'$do_error'(type_error(callable,C),meta_call(Source)).
|
||||||
'$execute_command'(R,_,_,top,Source) :-
|
'$execute_command'(R,_,_,_,_top,Source) :-
|
||||||
db_reference(R),
|
db_reference(R),
|
||||||
!,
|
!,
|
||||||
'$do_error'(type_error(callable,R),meta_call(Source)).
|
'$do_error'(type_error(callable,R),meta_call(Source)).
|
||||||
'$execute_command'(end_of_file,_,_,_,_) :- !.
|
'$execute_command'(end_of_file,_,_,_,_,_) :- !.
|
||||||
'$execute_command'(Command,_,_,_,_) :-
|
'$execute_command'(Command,_,_,_,_,_) :-
|
||||||
'__NB_getval__'('$if_skip_mode', skip, fail),
|
'__NB_getval__'('$if_skip_mode', skip, fail),
|
||||||
\+ '$if_directive'(Command),
|
\+ '$if_directive'(Command),
|
||||||
!.
|
!.
|
||||||
'$execute_command'((:-G),VL,Pos,Option,_) :-
|
'$execute_command'((:-G),M,VL,Pos,Option,_) :-
|
||||||
Option \= top,
|
Option \= top,
|
||||||
!, % allow user expansion
|
!, % allow user expansion
|
||||||
'$expand_term'((:- G), O),
|
'$expand_term'((:- M:G), O),
|
||||||
|
'$yap_strip_module'(O, NM, NO),
|
||||||
(
|
(
|
||||||
O = (:- G1)
|
NO = (:- G1)
|
||||||
->
|
->
|
||||||
'$yap_strip_module'(G1, M, NG),
|
'$process_directive'(G1, Option, NM, VL, Pos)
|
||||||
'$process_directive'(NG, Option, M, VL, Pos)
|
|
||||||
;
|
;
|
||||||
'$execute_commands'(G1,VL,Pos,Option,O)
|
'$execute_commands'(G1,NM,VL,Pos,Option,O)
|
||||||
).
|
).
|
||||||
'$execute_command'((?-G), VL, Pos, Option, Source) :-
|
'$execute_command'((?-G), M, VL, Pos, Option, Source) :-
|
||||||
Option \= top,
|
Option \= top,
|
||||||
!,
|
!,
|
||||||
'$execute_command'(G, VL, Pos, top, Source).
|
'$execute_command'(G, M, VL, Pos, top, Source).
|
||||||
'$execute_command'(G, VL, Pos, Option, Source) :-
|
'$execute_command'(G, M, VL, Pos, Option, Source) :-
|
||||||
'$continue_with_command'(Option, VL, Pos, G, Source).
|
'$continue_with_command'(Option, VL, Pos, M:G, Source).
|
||||||
|
|
||||||
'$expand_term'(T,O) :-
|
'$expand_term'(T,O) :-
|
||||||
catch( '$expand_term0'(T,O), _,( '$disable_debugging', fail) ),
|
catch( '$expand_term0'(T,O), _,( '$disable_debugging', fail) ),
|
||||||
@ -241,9 +241,7 @@ current_prolog_flag(break_level, BreakLevel),
|
|||||||
'$expand_term0'(T,T).
|
'$expand_term0'(T,T).
|
||||||
|
|
||||||
'$expand_term1'(T,O) :-
|
'$expand_term1'(T,O) :-
|
||||||
'$yap_strip_module'(T1, M, G2),
|
'$expand_meta_call'(T, [], O),
|
||||||
'$is_metapredicate'(G2,M),
|
|
||||||
'$expand_meta_call'(M:G2, [], O),
|
|
||||||
!.
|
!.
|
||||||
'$expand_term1'(O,O).
|
'$expand_term1'(O,O).
|
||||||
|
|
||||||
@ -680,8 +678,10 @@ write_query_answer( Bindings ) :-
|
|||||||
|
|
||||||
'$call'(M:_,_,G0,_) :- var(M), !,
|
'$call'(M:_,_,G0,_) :- var(M), !,
|
||||||
'$do_error'(instantiation_error,call(G0)).
|
'$do_error'(instantiation_error,call(G0)).
|
||||||
'$call'(M:G,CP,G0,_) :- !,
|
'$call'(M:G,CP,G0,_M0) :- !,
|
||||||
'$call'(G,CP,G0,M).
|
'$expand_meta_call'(M:G, [], NG),
|
||||||
|
'$yap_strip_module'(NG,NM,NC),
|
||||||
|
'$call'(NC,CP,G0,NM).
|
||||||
'$call'((X,Y),CP,G0,M) :- !,
|
'$call'((X,Y),CP,G0,M) :- !,
|
||||||
'$call'(X,CP,G0,M),
|
'$call'(X,CP,G0,M),
|
||||||
'$call'(Y,CP,G0,M).
|
'$call'(Y,CP,G0,M).
|
||||||
|
Reference in New Issue
Block a user