Previous Up Next

6.4  Compiler Input

The compiler normally reads a file up to its end. The file end can also be simulated with a clause
end_of_file.
The file is normally read consecutively, however the compiler uses the normal ECLiPSe I/O streams, and so if during the compilation the stream pointer is modified (e.g. by seek/2 or read/2), the compiler continues at the specified place1.

There are several built-in predicates which invoke the compiler:
compile(File) This is the standard compiler predicate. The contents of the file is compiled according to the current state of the global flags.

compile(File, Module) This predicate is used to compile the contents of a file into a specified module, without having to use the module declaration in the file itself.

include(File) This predicate is similar to the compile predicate, except that it is treated as an in place inclusion of File by fcompile/1 (see section 6.10). Like compile, File can be a single file, or a list of files.

compile_stream(Stream) This predicate compiles a given stream up to its end or to the end_of_file clause. It can be used when the input file is already open, e.g. when the beginning of the file does not contain compiler input, or when the input has to be processed in a non-consecutive way.

compile_term(Clauses) This predicate is used to compile a given term, usually a list of clauses and directives. Unlike assert/1 it compiles a static procedure, and so it can be used to compile a procedure which is dynamically created and then used as a static one. For more information please refer to [10].

ensure_loaded(File) This predicate compiles the specified file if it has not been compiled yet or if it has been modified since the last compilation.

make This predicate recompiles all files that have been modified since their last compilation.

lib(File) This predicate is used to ensure that a specified library file is loaded. If this library is not yet compiled, the system will look in all directories in the library_path flag for a file with this name. When the file is found, it is compiled and the system remembers it.

current_compiled_file(File, Time, Module) This predicate returns on backtracking all files that have been compiled in this session, together with the module from where the compilation was done and the modification time stamp of the file at the time it was compiled.

compiled_file(File, Line) This predicate allows to access the compiled file during the compilation. If it is called during the compilation, it returns the name of the file being compiled and the current line in it2. If some I/O operations are performed on the compiler stream, it influences the compiler, e.g. some procedures can be omitted and some compiled several times. An example of its use is the library ifdef which implements a C-like conditional compilation.

assert(Clause) This predicate compiles the given clause of a dynamic predicate.

Previous Up Next