/* Part of SWI-Prolog Author: Jan Wielemaker E-mail: J.Wielemaker@vu.nl WWW: http://www.swi-prolog.org Copyright (c) 1985-2023, University of Amsterdam VU University Amsterdam CWI, Amsterdam SWI-Prolog Solutions b.v. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /*#define O_DEBUG 1*/ #include "pl-wic.h" #include "pl-comp.h" #include "pl-arith.h" #include "os/pl-utf8.h" #include "pl-dbref.h" #include "pl-dict.h" #include "pl-funct.h" #include "pl-proc.h" #include "pl-util.h" #include "pl-modul.h" #include "pl-srcfile.h" #include "pl-pro.h" #include "pl-fli.h" #include "pl-prims.h" #include "pl-write.h" #include "pl-read.h" #include "os/pl-ctype.h" #ifdef HAVE_SYS_PARAM_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef O_DEBUG #define Qgetc(s) Sgetc(s) #define TRACK_POS "" #else #define Qgetc(s) Snpgetc(s) /* ignore position recording */ #define TRACK_POS "r" #endif /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SWI-Prolog can compile Prolog source files into intermediate code files, which can be loaded very fast. They can be saved as stand alone executables using Unix #! magic number. A wic file consists of the magic code and a version check code. This is followed by the command line option defaults. Then an optional series of `include' statements follow. Finally the predicates and directives are described. Predicates are described close to the internal representation. Directives are stored as binary terms representing the query. The default options and include statements are written incrementally in each wic file. In the normal boot cycle first the boot file is determined. Then the option structure is filled with the default option found in this boot file. Next the command line arguments are scanned to obtain all options. Then stacks, built in's, etc. are initialised. The the boot file is read again, but now only scanning for directives and predicates. IF YOU CHANGE ANYTHING TO THIS FILE, SO THAT OLD WIC-FILES CAN NO LONGER BE READ, PLEASE DO NOT FORGET TO INCREMENT THE VERSION NUMBER! Below is an informal description of the format of a `.qlf' file: ::= % a {} 'T' ---------------------------------------------------------------- ::= 'F' % path of qlf file {'I' } 'Q' ::= ::= % size in bytes {} 'X' ::= 'M' % module name % file + time {'S' } {} 'X' | % not a module