YAP 7.1.0
boot2.yap
Go to the documentation of this file.
1/*************************************************************************
2* *
3* YAP Prolog *
4* *
5* Yap Prolog was developed at NCCUP - Universidade do Porto *
6* *
7* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2014 *
8* *
9**************************************************************************
10* *
11* File: boot.yap *
12* Last rev: 8/2/88 *
13* mods: *
14* commen ts: boot file for Prolog *
15* *
16*************************************************************************/
17
18/**
19 @file boot2.yap
20 @brief YAP bootstrap, now in full Prolog.
21
22
23 @addtogroup TopLevel Top-Level and Boot Predicates
24
25 @ingroup Builtins
26 @{
27
28
29*/
30
31
32
33:- meta_predicate(log_event(+,:)).
34
35:- dynamic prolog:'$user_defined_flag'/4.
36
37:- multifile prolog:debug_action_hook/1.
38
39:- multifile prolog:'$system_predicate'/2.
40
41:- '$opdec'(1150,fx,(mode),prolog).
42
43:- dynamic 'extensions_to_present_answer'/1.
44:- ['arrays.yap'].
45
46:- multifile user:portray_message/2.
47
48:- dynamic user:portray_message/2.
49
50/** @pred prolog:goal_expansion( :G,+ M,- NG)
51 @pred user:goalexpansion(+ G,+ M,- NG)
52
53The goal_expansion/3 hook is an user-defined
54procedure that is called after term expansion when compiling or
55asserting goals for each sub-goal in a clause. The first argument is
56bound to the goal and the second to the module under which the goal
57 _G_ will execute. If goal_expansion/3 succeeds the new
58sub-goal _NG_ will replace _G_ and will be processed in the same
59 way. If goal_expansion/3 fails the system will use the default
60expandion mechanism.
61
62This hook is called:
63- at compilation time;
64- when running a query in the top-level
65
66Older versions of YAP would call this procedure at every meta-call.
67
68
69*/
70:- multifile goal_expansion/3.
71
72:- dynamic goal_expansion/3.
73
74:- multifile user:goal_expansion/2.
75
76:- dynamic user:goal_expansion/2.
77
78:- multifile system:goal_expansion/2.
79
80:- dynamic system:goal_expansion/2.
81
82:- multifile goal_expansion/2.
83
84:- dynamic goal_expansion/2.
85
86:- use_module('messages.yap').
87
88:- ['undefined.yap'].
89
90:- use_module('hacks.yap').
91
92:- use_module('pathconf.yap').
93
94
95
96:- use_module('attributes.yap').
97:- use_module('corout.yap').
98:- use_module('dialect.yap').
99:- use_module('dbload.yap').
100:- use_module('ypp.yap').
101:- use_module('../os/chartypes.yap').
102:- use_module('../os/edio.yap').
103
104:- '$change_type_of_char'(36,7). % Make $ a symbol character
105
106:- set_prolog_flag(generate_debug_info,true).
107
108%
109% cleanup ensure loaded and recover some data-base space.
110%
111%:- ( recorded('$lf_loaded',_,R), erase(R), fail ; true ).
112%:- ( recorded('$module',_,R), erase(R), fail ; true ).
113
114:- set_value('$user_module',user), '$protect'.
115
116:- style_check([+discontiguous,+multiple,+single_var]).
117
118%
119% moved this to init_gc in sgc.c to separate the alpha
120%
121% :- yap_flag(gc,on).
122%
123% :- yap_flag(gc_trace,verbose`␈
124
125:- multifile
126 prolog:comment_hook/3.
127
128:- style_check.
129
130:- module(user).
131
132:- current_prolog_flag(android,true)->use_module(user:'android.yap') ; true.
133
134
135/** @pred term_expansion( _T_,- _X_)
136 user:term_expansion( _T_,- _X_)
137
138
139This user-defined predicate is called by `expand_term/3` to
140preprocess all terms read when consulting a file. If it succeeds:
141
142+
143If _X_ is of the form `:- G` or `?- G`, it is processed as
144a directive.
145+
146If _X_ is of the form `$source_location`( _File_, _Line_): _Clause_` it is processed as if from `File` and line `Line`.
147
148+
149If _X_ is a list, all terms of the list are asserted or processed
150as directives.
151+ The term _X_ is asserted instead of _T_.
152
153*/
154:- multifile term_expansion/2.
155
156:- dynamic term_expansion/2.
157
158:- multifile term_expansion/2.
159
160:- dynamic term_expansion/2.
161
162:- multifile system:swi_predicate_table/4.
163
164/** @pred user:message_hook(+ _Term_, + _Kind_, + _Lines_)
165
166
167Hook predicate that may be define in the module `user` to intercept
168messages from print_message/2. _Term_ and _Kind_ are the
169same as passed to print_message/2. _Lines_ is a list of
170format statements as described with print_message_lines/3.
171
172This predicate should be defined dynamic and multifile to allow other
173modules defining clauses for it too.
174
175
176*/
177:- multifile message_hook/3.
178
179:- dynamic message_hook/3.
180
181/** @pred exception(+ _Exception_, + _Context_, - _Action_)
182
183
184Dynamic predicate, normally not defined. Called by the Prolog system on run-time exceptions that can be repaired `just-in-time`. The values for _Exception_ are described below. See also catch/3 and throw/1.
185If this hook preodicate succeeds it must instantiate the _Action_ argument to the atom `fail` to make the operation fail silently, `retry` to tell Prolog to retry the operation or `error` to make the system generate an exception. The action `retry` only makes sense if this hook modified the environment such that the operation can now succeed without error.
186
187+ `undefined_predicate`
188 _Context_ is instantiated to a predicate-indicator ( _Module:Name/Arity_). If the predicate fails Prolog will generate an existence_error exception. The hook is intended to implement alternatives to the SWI built-in autoloader, such as autoloading code from a database. Do not use this hook to suppress existence errors on predicates. See also `unknown`.
189+ `undefined_global_variable`
190 _Context_ is instantiated to the name of the missing global variable. The hook must call nb_setval/2 or b_setval/2 before returning with the action retry.
191
192*/
193
194:- module(user).
195
196
197:- multifile exception/3.
198
199:- dynamic exception/3.
200
201
202:- set_prolog_flag(unknown,error).
203
204%% @}
205
use_module( +Files )
goal_expansion( :G,+ M,- NG)
term_expansion( T,- X)
exception(+ Exception, + Context, - Action)
message_hook(+ Term, + Kind, + Lines)
set_prolog_flag(+ Flag,+ Value)
set_value(+ A,+ C)