3 Part of CHR
(Constraint Handling Rules
)
6 E
-mail
: Tom
.Schrijvers
@cs.kuleuven
.be
7 WWW
: http
://www
.swi
-prolog
.org
8 Copyright
(C
): 2005-2006, K
.U
. Leuven
10 This program is free software
; you can redistribute it
and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation
; either version
2
13 of the License
, or (at your option
) any later version
.
15 This program is distributed
in the hope that it will be useful
,
16 but WITHOUT ANY WARRANTY
; without even the implied warranty of
17 MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE
. See the
18 GNU General Public License
for more details
.
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library
; if not, write to the Free Software
22 Foundation
, Inc
., 59 Temple Place
, Suite
330, Boston
, MA
02111-1307 USA
24 As a special exception
, if you
link this library with other files
,
25 compiled with a Free Software compiler
, to produce an executable
, this
26 library does
not by itself cause the resulting executable to be covered
27 by the GNU General Public License
. This exception does
not however
28 invalidate any other reasons why the executable file might be covered by
29 the GNU General Public License
.
31 :- module
(chr_compiler_options
,
38 %% :- use_module
(hprolog
, [nb_setval
/2,nb_getval/2]).
39 %% local_current_prolog_flag
(_
,_
) :- fail
.
43 local_current_prolog_flag
(X
,Y
) :- current_prolog_flag
(X
,Y
).
47 :- use_module
(chr_compiler_errors
).
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 handle_option
(Name
,Value
) :-
55 chr_error
(syntax
((:- chr_option
(Name
,Value
))),'First argument should be an atom, not a variable.\n',[]).
57 handle_option
(Name
,Value
) :-
59 chr_error
(syntax
((:- chr_option
(Name
,Value
))),'Second argument cannot be a variable.\n',[]).
61 handle_option
(Name
,Value
) :-
62 option_definition
(Name
,Value
,Flags
),
64 set_chr_pp_flags
(Flags
).
66 handle_option
(Name
,Value
) :-
67 \
+ option_definition
(Name
,_
,_
), !,
68 chr_error
(syntax
((:- chr_option
(Name
,Value
))),'Invalid option name ~w: consult the manual for valid options.\n',[Name
]).
70 handle_option
(Name
,Value
) :-
71 chr_error
(syntax
((:- chr_option
(Name
,Value
))),'Invalid option value ~w: consult the manual for valid option values.\n',[Value
]).
73 option_definition
(optimize
,experimental
,Flags
) :-
74 Flags
= [ functional_dependency_analysis
- on
,
75 check_unnecessary_active
- full
,
77 set_semantics_rule
- on
,
78 storage_analysis
- on
,
79 guard_via_reschedule
- on
,
80 guard_simplification
- on
,
81 check_impossible_rules
- on
,
82 occurrence_subsumption
- on
,
84 ai_observation_analysis
- on
,
86 reduced_indexing
- on
,
88 inline_insertremove
- on
90 option_definition
(optimize
,full
,Flags
) :-
91 Flags
= [ functional_dependency_analysis
- on
,
92 check_unnecessary_active
- full
,
94 set_semantics_rule
- on
,
95 storage_analysis
- on
,
96 guard_via_reschedule
- on
,
97 guard_simplification
- on
,
98 check_impossible_rules
- on
,
99 occurrence_subsumption
- on
,
101 ai_observation_analysis
- on
,
102 late_allocation
- on
,
103 reduced_indexing
- on
,
104 inline_insertremove
- on
107 option_definition
(optimize
,off
,Flags
) :-
108 Flags
= [ functional_dependency_analysis
- off
,
109 check_unnecessary_active
- off
,
111 set_semantics_rule
- off
,
112 storage_analysis
- off
,
113 guard_via_reschedule
- off
,
114 guard_simplification
- off
,
115 check_impossible_rules
- off
,
116 occurrence_subsumption
- off
,
118 ai_observation_analysis
- off
,
119 late_allocation
- off
,
120 reduced_indexing
- off
123 option_definition
(functional_dependency_analysis
,on
,Flags
) :-
124 Flags
= [ functional_dependency_analysis
- on
].
125 option_definition
(functional_dependency_analysis
,off
,Flags
) :-
126 Flags
= [ functional_dependency_analysis
- off
].
128 option_definition
(set_semantics_rule
,on
,Flags
) :-
129 Flags
= [ set_semantics_rule
- on
].
130 option_definition
(set_semantics_rule
,off
,Flags
) :-
131 Flags
= [ set_semantics_rule
- off
].
133 option_definition
(check_unnecessary_active
,full
,Flags
) :-
134 Flags
= [ check_unnecessary_active
- full
].
135 option_definition
(check_unnecessary_active
,simplification
,Flags
) :-
136 Flags
= [ check_unnecessary_active
- simplification
].
137 option_definition
(check_unnecessary_active
,off
,Flags
) :-
138 Flags
= [ check_unnecessary_active
- off
].
140 option_definition
(check_guard_bindings
,on
,Flags
) :-
141 Flags
= [ guard_locks
- on
].
142 option_definition
(check_guard_bindings
,off
,Flags
) :-
143 Flags
= [ guard_locks
- off
].
145 option_definition
(reduced_indexing
,on
,Flags
) :-
146 Flags
= [ reduced_indexing
- on
].
147 option_definition
(reduced_indexing
,off
,Flags
) :-
148 Flags
= [ reduced_indexing
- off
].
150 option_definition
(storage_analysis
,on
,Flags
) :-
151 Flags
= [ storage_analysis
- on
].
152 option_definition
(storage_analysis
,off
,Flags
) :-
153 Flags
= [ storage_analysis
- off
].
155 option_definition
(guard_simplification
,on
,Flags
) :-
156 Flags
= [ guard_simplification
- on
].
157 option_definition
(guard_simplification
,off
,Flags
) :-
158 Flags
= [ guard_simplification
- off
].
160 option_definition
(check_impossible_rules
,on
,Flags
) :-
161 Flags
= [ check_impossible_rules
- on
].
162 option_definition
(check_impossible_rules
,off
,Flags
) :-
163 Flags
= [ check_impossible_rules
- off
].
165 option_definition
(occurrence_subsumption
,on
,Flags
) :-
166 Flags
= [ occurrence_subsumption
- on
].
167 option_definition
(occurrence_subsumption
,off
,Flags
) :-
168 Flags
= [ occurrence_subsumption
- off
].
170 option_definition
(late_allocation
,on
,Flags
) :-
171 Flags
= [ late_allocation
- on
].
172 option_definition
(late_allocation
,off
,Flags
) :-
173 Flags
= [ late_allocation
- off
].
175 option_definition
(inline_insertremove
,on
,Flags
) :-
176 Flags
= [ inline_insertremove
- on
].
177 option_definition
(inline_insertremove
,off
,Flags
) :-
178 Flags
= [ inline_insertremove
- off
].
179 option_definition
(type_definition
,TypeDef
,[]) :-
182 chr_translate
:type_definition
(T
,D
)
184 option_definition
(type_declaration
,TypeDecl
,[]) :-
185 ( nonvar
(TypeDecl
) ->
186 functor
(TypeDecl
,F
,A
),
187 TypeDecl
=.. [_
|ArgTypes
],
188 chr_translate
:constraint_type
(F
/A
,ArgTypes
)
191 option_definition
(mode
,ModeDecl
,[]) :-
192 ( nonvar
(ModeDecl
) ->
193 functor
(ModeDecl
,F
,A
),
194 ModeDecl
=.. [_
|ArgModes
],
195 chr_translate
:constraint_mode
(F
/A
,ArgModes
)
197 option_definition
(store
,FA
-Store
,[]) :-
198 chr_translate
:store_type
(FA
,Store
).
200 option_definition
(debug
,off
,Flags
) :-
201 option_definition
(optimize
,full
,Flags2
),
202 Flags
= [ debugable
- off
| Flags2
].
203 option_definition
(debug
,on
,Flags
) :-
204 ( local_current_prolog_flag
(generate_debug_info
,false
) ->
205 % TODO
: should
not be allowed
when nodebug flag is set
in SWI
-Prolog
206 chr_warning
(any
,':- chr_option(debug,on) inconsistent with current_prolog_flag(generate_debug_info,off\n\tCHR option is ignored!\n)',[]),
209 Flags
= [ debugable
- on
]
212 option_definition
(store_counter
,off
,[]).
213 option_definition
(store_counter
,on
,[store_counter
-on
]).
215 option_definition
(observation
,off
,Flags
) :-
217 observation_analysis
- off
,
218 ai_observation_analysis
- off
,
219 late_allocation
- off
,
220 storage_analysis
- off
222 option_definition
(observation
,on
,Flags
) :-
224 observation_analysis
- on
,
225 ai_observation_analysis
- on
227 option_definition
(observation
,regular
,Flags
) :-
229 observation_analysis
- on
,
230 ai_observation_analysis
- off
232 option_definition
(observation
,ai
,Flags
) :-
234 observation_analysis
- off
,
235 ai_observation_analysis
- on
238 option_definition
(solver_events
,NMod
,Flags
) :-
239 Flags
= [solver_events
- NMod
].
241 option_definition
(toplevel_show_store
,on
,Flags
) :-
242 Flags
= [toplevel_show_store
- on
].
244 option_definition
(toplevel_show_store
,off
,Flags
) :-
245 Flags
= [toplevel_show_store
- off
].
247 option_definition
(term_indexing
,on
,Flags
) :-
248 Flags
= [term_indexing
- on
].
249 option_definition
(term_indexing
,off
,Flags
) :-
250 Flags
= [term_indexing
- off
].
252 option_definition
(verbosity
,on
,Flags
) :-
253 Flags
= [verbosity
- on
].
254 option_definition
(verbosity
,off
,Flags
) :-
255 Flags
= [verbosity
- off
].
258 chr_pp_flag_definition
(Name
,[DefaultValue
|_
]),
259 set_chr_pp_flag
(Name
,DefaultValue
),
263 set_chr_pp_flags
([]).
264 set_chr_pp_flags
([Name
-Value
|Flags
]) :-
265 set_chr_pp_flag
(Name
,Value
),
266 set_chr_pp_flags
(Flags
).
268 set_chr_pp_flag
(Name
,Value
) :-
269 atom_concat
('$chr_pp_',Name
,GlobalVar
),
270 nb_setval
(GlobalVar
,Value
).
272 chr_pp_flag_definition
(functional_dependency_analysis
,[off
,on
]).
273 chr_pp_flag_definition
(check_unnecessary_active
,[off
,full
,simplification
]).
274 chr_pp_flag_definition
(reorder_heads
,[off
,on
]).
275 chr_pp_flag_definition
(set_semantics_rule
,[off
,on
]).
276 chr_pp_flag_definition
(guard_via_reschedule
,[off
,on
]).
277 chr_pp_flag_definition
(guard_locks
,[on
,off
]).
278 chr_pp_flag_definition
(storage_analysis
,[off
,on
]).
279 chr_pp_flag_definition
(debugable
,[on
,off
]).
280 chr_pp_flag_definition
(reduced_indexing
,[off
,on
]).
281 chr_pp_flag_definition
(observation_analysis
,[off
,on
]).
282 chr_pp_flag_definition
(ai_observation_analysis
,[off
,on
]).
283 chr_pp_flag_definition
(late_allocation
,[off
,on
]).
284 chr_pp_flag_definition
(store_counter
,[off
,on
]).
285 chr_pp_flag_definition
(guard_simplification
,[off
,on
]).
286 chr_pp_flag_definition
(check_impossible_rules
,[off
,on
]).
287 chr_pp_flag_definition
(occurrence_subsumption
,[off
,on
]).
288 chr_pp_flag_definition
(observation
,[off
,on
]).
289 chr_pp_flag_definition
(show
,[off
,on
]).
290 chr_pp_flag_definition
(inline_insertremove
,[on
,off
]).
291 chr_pp_flag_definition
(solver_events
,[none
,_
]).
292 chr_pp_flag_definition
(toplevel_show_store
,[on
,off
]).
293 chr_pp_flag_definition
(term_indexing
,[off
,on
]).
294 chr_pp_flag_definition
(verbosity
,[on
,off
]).
296 chr_pp_flag
(Name
,Value
) :-
297 atom_concat
('$chr_pp_',Name
,GlobalVar
),
298 nb_getval
(GlobalVar
,V
),
300 chr_pp_flag_definition
(Name
,[Value
|_
])
304 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%