diff --git a/C/yap-args.c b/C/yap-args.c index 3a9b753a4..74c3c6160 100755 --- a/C/yap-args.c +++ b/C/yap-args.c @@ -147,8 +147,8 @@ static void init_globals(YAP_init_args *yap_init) { const char *Yap_BINDIR, *Yap_ROOTDIR, *Yap_SHAREDIR, *Yap_LIBDIR, *Yap_DLLDIR, - *Yap_PLDIR, *Yap_BOOTPLDIR, *Yap_BOOTSTRAPPLDIR, *Yap_COMMONSDIR, - *Yap_STARTUP, *Yap_OUTPUT_STARTUP, *Yap_BOOTFILE, *Yap_INCLUDEDIR; + *Yap_PLDIR, *Yap_BOOTSTRAP, *Yap_COMMONSDIR, + *Yap_STARTUP, *Yap_INPUT_STARTUP, *Yap_OUTPUT_STARTUP, *Yap_BOOTFILE, *Yap_INCLUDEDIR; /* do initial boot by consulting the file boot.yap */ static void consult(const char *b_file USES_REGS) { @@ -188,7 +188,7 @@ static void consult(const char *b_file USES_REGS) { fprintf(stderr, "[ SYNTAX ERROR: while parsing stream %s at line %ld ]\n", b_file, GLOBAL_Stream[c_stream].linecount); } else if (IsVarTerm(t) || t == TermNil) { - fprintf(stderr, "[ line %d: term cannot be compiled ]", + fprintf(stderr, "[ line: " Int_FORMAT ": term cannot be compiled ]", GLOBAL_Stream[c_stream].linecount); } else if (IsApplTerm(t) && (FunctorOfTerm(t) == functor_query || FunctorOfTerm(t) == functor_command1)) { @@ -337,13 +337,13 @@ static const char * join(const char *s, ...) { #endif false ); /// BOOTPLDIR: where we can find Prolog bootstrap files - Yap_BOOTPLDIR = sel(true, - iap->BOOTPLDIR != NULL, iap->BOOTPLDIR, + Yap_BOOTSTRAP = sel(true, + iap->BOOTSTRAP != NULL, iap->BOOTSTRAP, true, #if __ANDROID__ "/assets/Yap/pl", #else - join(getenv("DESTDIR"),YAP_PLDIR "/pl", NULL), + join(getenv("DESTDIR"),YAP_BOOTSTRAP, NULL), #endif false ); /// BOOTFILE: where we can find the core Prolog bootstrap file @@ -357,24 +357,24 @@ static const char * join(const char *s, ...) { #endif false ); /// STARTUP: where we can find the core Prolog bootstrap file - Yap_STARTUP = sel(false, - iap->STARTUP != NULL, iap->STARTUP, - true, + Yap_OUTPUT_STARTUP = sel(false, + iap->OUTPUT_STARTUP != NULL, iap->OUTPUT_STARTUP, + true, #if __ANDROID__ - NULL, + NULL, #else - join(getenv("DESTDIR"),YAP_STARTUP,NULL), + join(getenv("DESTDIR"),YAP_OUTPUT_STARTUP,NULL), #endif - false ); - Yap_OUTPUT_STARTUP = sel(false, - iap->OUTPUT_STARTUP != NULL, iap->OUTPUT_STARTUP, - true, + false ); + Yap_INPUT_STARTUP = sel(false, + iap->INPUT_STARTUP != NULL, iap->INPUT_STARTUP, + true, #if __ANDROID__ - NULL, + NULL, #else - join(getenv("DESTDIR"),YAP_STARTUP,NULL), + join(getenv("DESTDIR"),YAP_INPUT_STARTUP,NULL), #endif - false ); + false ); if (Yap_ROOTDIR) setAtomicGlobalPrologFlag(HOME_FLAG, MkAtomTerm(Yap_LookupAtom(Yap_ROOTDIR))); @@ -490,7 +490,7 @@ X_API YAP_file_type_t Yap_InitDefaults(void *x, char *saved_state, int argc, iap->assetManager = NULL; #else iap->boot_file_type = YAP_QLY; - iap->STARTUP = saved_state; + iap->INPUT_STARTUP = saved_state; #endif iap->Argc = argc; iap->Argv = argv; @@ -526,9 +526,9 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[], case 'B': iap->boot_file_type = YAP_BOOT_PL; if (p[1]) - iap->BOOTFILE = p + 1; + iap->BOOTSTRAP = p + 1; else if (argv[1] && *argv[1] != '-') { - iap->BOOTFILE = *++argv; + iap->BOOTSTRAP = *++argv; argc--; } iap->install = true; @@ -912,7 +912,7 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[], } } else { - iap->STARTUP = p; + iap->INPUT_STARTUP = p; } } return iap->boot_file_type; @@ -1057,9 +1057,9 @@ X_API YAP_file_type_t YAP_Init(YAP_init_args *yap_init) { Yap_ExecutionMode = yap_init->ExecutionMode; Yap_set_locations(yap_init); - if (!do_bootstrap && Yap_STARTUP && yap_init->boot_file_type != YAP_BOOT_PL && - Yap_SavedInfo(Yap_STARTUP, &minfo.Trail, &minfo.Stack, &minfo.Heap) && - Yap_Restore(Yap_STARTUP)) { + if (!do_bootstrap && Yap_INPUT_STARTUP && yap_init->boot_file_type != YAP_BOOT_PL && + Yap_SavedInfo(Yap_INPUT_STARTUP, &minfo.Trail, &minfo.Stack, &minfo.Heap) && + Yap_Restore(Yap_INPUT_STARTUP)) { setBooleanGlobalPrologFlag(SAVED_PROGRAM_FLAG, true); CurrentModule = LOCAL_SourceModule = USER_MODULE; init_globals(yap_init); @@ -1071,8 +1071,8 @@ X_API YAP_file_type_t YAP_Init(YAP_init_args *yap_init) { init_globals(yap_init); start_modules(); - consult(Yap_BOOTFILE PASS_REGS); - if (yap_init->install && Yap_OUTPUT_STARTUP == NULL) { + consult(Yap_BOOTSTRAP PASS_REGS); + if (yap_init->install && Yap_OUTPUT_STARTUP) { Term t = MkAtomTerm(Yap_LookupAtom(Yap_OUTPUT_STARTUP)); Term g = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("qsave_program"), 1), 1, &t); diff --git a/CXX/yapq.hh b/CXX/yapq.hh index 688333cfb..cb2a2a3c1 100644 --- a/CXX/yapq.hh +++ b/CXX/yapq.hh @@ -189,9 +189,9 @@ struct X_API YAPEngineArgs : YAP_init_args { public: YAPEngineArgs() { - const std::string *s = new std::string("startup.yss"); + // const std::string *s = new std::string("startup.yss"); Embedded = true; - Yap_InitDefaults(this, (char *)s->c_str(), 0, nullptr); + Yap_InitDefaults(this, nullptr, 0, nullptr); #if YAP_PYTHON Embedded = true; python_in_python = Py_IsInitialized(); @@ -233,26 +233,34 @@ public: inline const char *getSHAREDIR() { return SHAREDIR; }; - inline void setRESTORE(const char *fl) { - STARTUP = (const char *)malloc(strlen(fl) + 1); - strcpy((char *)STARTUP, fl); - }; + inline void setINPUT_RESTORE(const char *fl) { + STARTUP = (const char *)malloc(strlen(fl) + 1); + strcpy((char *)INPUT_STARTUP, fl); + }; - inline const char *getSTARTUP() { return STARTUP; }; + inline const char *getINPUT_STARTUP() { return INPUT_STARTUP; }; - inline void setBOOTFILE(const char *fl) { + + inline void setOUTPUT_RESTORE(const char *fl) { + STARTUP = (const char *)malloc(strlen(fl) + 1); + strcpy((char *)OUTPUT_STARTUP, fl); + }; + + inline const char *getINPUT_STARTUP() { return OUTPUT_STARTUP; }; + + inline void setBOOTFILE(const char *fl) { BOOTFILE = (const char *)malloc(strlen(fl) + 1); strcpy((char *)BOOTFILE, fl); }; inline const char *getBOOTFILE() { return BOOTFILE; }; - inline void setPrologBOOTPLDIR(const char *fl) { - BOOTPLDIR = (const char *)malloc(strlen(fl) + 1); - strcpy((char *)BOOTPLDIR, fl); + inline void setPrologBOOTSTRAP(const char *fl) { + BOOTSTRAP = (const char *)malloc(strlen(fl) + 1); + strcpy((char *)BOOTSTRAP, fl); }; - inline const char *getBOOTPLDIR() { return BOOTPLDIR; }; + inline const char *getBOOTSTRAP() { return BOOTSTRAP; }; inline void setPrologGoal(const char *fl) { PrologGoal = fl; }; diff --git a/H/Yap.h b/H/Yap.h index e6c591cf2..630dd4b26 100755 --- a/H/Yap.h +++ b/H/Yap.h @@ -151,7 +151,9 @@ typedef void *(*fptr_t)(void); main exports in YapInterface.h *************************************************************************************************/ -extern const char *Yap_BINDIR, *Yap_ROOTDIR, *Yap_SHAREDIR, *Yap_LIBDIR, *Yap_DLLDIR, *Yap_PLDIR, *Yap_COMMONSDIR, *Yap_STARTUP, *Yap_BOOTFILE, *Yap_INCLUDEDIR; +extern const char *Yap_BINDIR, *Yap_ROOTDIR, *Yap_SHAREDIR, *Yap_LIBDIR, *Yap_DLLDIR, + *Yap_PLDIR, *Yap_COMMONSDIR, *Yap_STARTUP,*Yap_INPUT_STARTUP,*Yap_OUTPUT_STARTUP, + *Yap_BOOTFILE, *Yap_INCLUDEDIR; /* Basic exports */ diff --git a/H/YapGFlagInfo.h b/H/YapGFlagInfo.h index dd2bf501d..60697fba0 100644 --- a/H/YapGFlagInfo.h +++ b/H/YapGFlagInfo.h @@ -32,6 +32,7 @@ Set or read system properties for _Param_: @enum GlobalFlags Global Flags Dupported ny YAP * */ + YAP_FLAG(ADDRESS_BITS_FLAG, "address_bits", false, nat, BITNESS, NULL), /**< `address_bits` Number of address bits in the machine, either 64 or 32 bits */ @@ -358,7 +359,7 @@ call_count_data/3 built-in. YAP_FLAG(REPORT_ERROR_FLAG, "report_error", true, booleanFlag, "true", NULL), YAP_FLAG(RESOURCE_DATABASE_FLAG, "resource_database", false, isatom, - "pl/boot.yap", NULL), + YAP_BOOTSTRAP, NULL), /**<`resource_database` Name of the resource file (saved-state or Prolog file) used to construct the YAP diff --git a/cmake/Sources.cmake b/cmake/Sources.cmake index 8346ffc9d..54e4c975e 100644 --- a/cmake/Sources.cmake +++ b/cmake/Sources.cmake @@ -198,7 +198,8 @@ set (INCLUDE_HEADERS ${CMAKE_SOURCE_DIR}/include/GitSHA1.h ${CMAKE_SOURCE_DIR}/include/SWI-Prolog.h ${CMAKE_SOURCE_DIR}/include/VFS.h - ${CMAKE_SOURCE_DIR}/include/YapDefs.h + ${CMAKE_SOURCE_DIR}/include/YapBlobs.h + ${CMAKE_SOURCE_DIR}/include/YapDefs.h ${CMAKE_SOURCE_DIR}/include/YapError.h ${CMAKE_SOURCE_DIR}/include/YapErrors.h ${CMAKE_SOURCE_DIR}/include/YapFormat.h @@ -206,7 +207,6 @@ set (INCLUDE_HEADERS ${CMAKE_SOURCE_DIR}/include/YapRegs.h ${CMAKE_SOURCE_DIR}/include/YapStreams.h ${CMAKE_SOURCE_DIR}/include/YapTerm.h - ${CMAKE_SOURCE_DIR}/include/blobs.h ${CMAKE_SOURCE_DIR}/include/c_interface.h ${CMAKE_SOURCE_DIR}/include/clause_list.h ${CMAKE_SOURCE_DIR}/include/pl-types.h diff --git a/config.h.cmake b/config.h.cmake index bd11ba4c9..5aa2d6e13 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -1956,17 +1956,6 @@ significant byte first (like Motorola and SPARC, unlike Intel). */ #cmakedefine YAP_IS_MOVABLE "${YAP_IS_MOVABLE}" #endif -/* saved state file */ -#ifndef YAP_STARTUP -#define YAP_STARTUP "${YAP_STARTUP}" -#endif - -/* saved state file */ -#ifndef YAP_BOOTFILE -#define YAP_BOOTFILE "${YAP_BOOTFILE}" -#endif - -/* date of compilation */ #ifndef YAP_TIMESTAMP #define YAP_TIMESTAMP ${YAP_TIMESTAMP} #endif @@ -2013,6 +2002,7 @@ significant byte first (like Motorola and SPARC, unlike Intel). */ #define YAP_DLLDIR "${YAP_LIBDIR}/Yap" #endif + /* name of YAP JIT library */ #ifndef YAP_YAPJITLIB #define YAP_YAPJITLIB "${YAP_YAPJITLIB}" @@ -2033,6 +2023,27 @@ significant byte first (like Motorola and SPARC, unlike Intel). */ #endif +/* run-time boot */ +#ifndef YAP_BOOTFILE +#define YAP_BOOTFILE "${YAP_PLDIR}/pl/boot.yap" +#endif + +/* init-time boot */ +#ifndef YAP_BOOTSTRAP +#define YAP_BOOTSTRAP "${CMAKE_SOURCE_DIR}/pl/boot.yap" +#endif + + + +/* run-time boot */ +#ifndef YAP_INPUT_STARTUP +#define YAP_INPUT_STARTUP "${YAP_DLLDIR}/${YAP_STARTUP}" +#endif + +/* init-time boot */ +##ifndef YAP_OUTPUT_STARTUP +##define YAP_OUTPUT_STARTUP "${CMAKE_BINARY_DIR}/${YAP_STARTUP}" +##endif /* HP-UX old socket stuff */ #ifndef _XOPEN_SOURCE diff --git a/include/YapDefs.h b/include/YapDefs.h index cec7d1587..a0bd4bd5f 100755 --- a/include/YapDefs.h +++ b/include/YapDefs.h @@ -195,13 +195,12 @@ typedef struct yap_boot_params { const char *PLDIR; //> if NON-NULL, Prolog library, sets Yap_COMMONSDIR const char *COMMONSDIR; - //> if NON-NULL, name for a Prolog file to use when booting + //> if NON-NULL, name for a Prolog file to use when booting at run-time const char *BOOTFILE; - //> if NON-NULL, directory for a Prolog file to be when booting - const char *BOOTPLDIR; - const char *BOOTPLFILE; + //> if NON-NULL, name for a Prolog file to use when booting at compile-time + const char *BOOTSTRAP; //> if NON-NULL, path where we can find the saved state - const char *STARTUP; + const char *INPUT_STARTUP; //> bootstrapping mode: YAP is not properly installed bool install; //> generats a saved space at this path diff --git a/os/files.c b/os/files.c index 532184985..9bca964bf 100644 --- a/os/files.c +++ b/os/files.c @@ -429,11 +429,7 @@ static Int access_file(USES_REGS1) { return FALSE; } } else { -<<<<<<< HEAD - return true; -======= return false; ->>>>>>> f798372fb1dc4ff03c592d2ae8e0245a842305b8 } } #if HAVE_ACCESS diff --git a/packages/python/yap_kernel/yap_ipython/prolog/jupyter.yap b/packages/python/yap_kernel/yap_ipython/prolog/jupyter.yap index 711f34fa6..a4299aa12 100644 --- a/packages/python/yap_kernel/yap_ipython/prolog/jupyter.yap +++ b/packages/python/yap_kernel/yap_ipython/prolog/jupyter.yap @@ -183,14 +183,21 @@ ready(Self, Line ) :- errors( Self, Text ) :- setup_call_cleanup( open_events( Self, Text, Stream), - clauses(Self, Stream), + goals(Self, Stream), close_events( Self ) ). clauses(Self, Stream) :- repeat, read_clause(Stream, Cl, [term_position(_Pos), syntax_errors(fail)] ), - command( Self, Cl ), +% command( Self, Cl ), + Cl == end_of_file, + !. + +goals(Self, Stream) :- + repeat, + read_term(Stream, Cl, [term_position(_Pos), syntax_errors(fail)] ), +% command( Self, Cl ), Cl == end_of_file, !. diff --git a/packages/python/yap_kernel/yap_ipython/yapi.py b/packages/python/yap_kernel/yap_ipython/yapi.py index 779359a3f..6ac67e5e9 100644 --- a/packages/python/yap_kernel/yap_ipython/yapi.py +++ b/packages/python/yap_kernel/yap_ipython/yapi.py @@ -113,6 +113,7 @@ class YAPInputSplitter(InputSplitter): return False self.errors = [] self.yapeng.mgoal(errors(self, line),"user") + print(self.errors) return self.errors != [] diff --git a/pl/CMakeLists.txt b/pl/CMakeLists.txt index 21be2b004..d206f9908 100644 --- a/pl/CMakeLists.txt +++ b/pl/CMakeLists.txt @@ -71,7 +71,7 @@ elseif(CMAKE_CROSSCOMPILING) ) else () add_custom_target(STARTUP ALL - DEPENDS ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP} + DEPENDS ${CMAKE_BUILD_DIR}/${YAP_STARTUPFILE} ) add_custom_command(OUTPUT ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP} COMMAND yap-bin -B${CMAKE_SOURCE_DIR}/pl/boot.yap --output-saved-state=${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}