3 Part of CHR
(Constraint Handling Rules
)
6 E
-mail
: Tom
.Schrijvers
@cs.kuleuven
.ac
.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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 handle_option
(Var
,Value
) :-
44 format
('CHR compiler ERROR: ~w.\n',[option
(Var
,Value
)]),
45 format
(' `--> First argument should be an atom, not a variable.\n',[]),
48 handle_option
(Name
,Value
) :-
50 format
('CHR compiler ERROR: ~w.\n',[option
(Name
,Value
)]),
51 format
(' `--> Second argument should be a nonvariable.\n',[]),
54 handle_option
(Name
,Value
) :-
55 option_definition
(Name
,Value
,Flags
),
57 set_chr_pp_flags
(Flags
).
59 handle_option
(Name
,Value
) :-
60 \
+ option_definition
(Name
,_
,_
), !,
61 setof
(N
,_V
^ _F
^ (option_definition
(N
,_V
,_F
)),Ns
),
62 format
('CHR compiler WARNING: ~w.\n',[option
(Name
,Value
)]),
63 format
(' `--> Invalid option name ~w: should be one of ~w.\n',[Name
,Ns
]).
65 handle_option
(Name
,Value
) :-
66 findall
(V
,option_definition
(Name
,V
,_
),Vs
),
67 format
('CHR compiler ERROR: ~w.\n',[option
(Name
,Value
)]),
68 format
(' `--> Invalid value ~w: should be one of ~w.\n',[Value
,Vs
]),
71 option_definition
(optimize
,experimental
,Flags
) :-
72 Flags
= [ functional_dependency_analysis
- on
,
73 check_unnecessary_active
- off
,
75 set_semantics_rule
- off
,
76 storage_analysis
- on
,
77 guard_via_reschedule
- on
,
78 guard_simplification
- on
,
79 check_impossible_rules
- on
,
80 occurrence_subsumption
- on
,
82 ai_observation_analysis
- on
,
86 option_definition
(optimize
,full
,Flags
) :-
87 Flags
= [ functional_dependency_analysis
- on
,
88 check_unnecessary_active
- full
,
90 set_semantics_rule
- on
,
91 storage_analysis
- on
,
92 guard_via_reschedule
- on
,
93 guard_simplification
- on
,
94 check_impossible_rules
- on
,
95 occurrence_subsumption
- on
,
97 ai_observation_analysis
- on
,
102 option_definition
(optimize
,sicstus
,Flags
) :-
103 Flags
= [ functional_dependency_analysis
- off
,
104 check_unnecessary_active
- simplification
,
106 set_semantics_rule
- off
,
107 storage_analysis
- off
,
108 guard_via_reschedule
- off
,
109 guard_simplification
- off
,
110 check_impossible_rules
- off
,
111 occurrence_subsumption
- off
,
113 ai_observation_analysis
- off
,
114 late_allocation
- off
,
115 reduced_indexing
- off
118 option_definition
(optimize
,off
,Flags
) :-
119 Flags
= [ functional_dependency_analysis
- off
,
120 check_unnecessary_active
- off
,
122 set_semantics_rule
- off
,
123 storage_analysis
- off
,
124 guard_via_reschedule
- off
,
125 guard_simplification
- off
,
126 check_impossible_rules
- off
,
127 occurrence_subsumption
- off
,
129 ai_observation_analysis
- off
,
130 late_allocation
- off
,
131 reduced_indexing
- off
134 option_definition
(functional_dependency_analysis
,on
,Flags
) :-
135 Flags
= [ functional_dependency_analysis
- on
].
136 option_definition
(functional_dependency_analysis
,off
,Flags
) :-
137 Flags
= [ functional_dependency_analysis
- off
].
139 option_definition
(set_semantics_rule
,on
,Flags
) :-
140 Flags
= [ set_semantics_rule
- on
].
141 option_definition
(set_semantics_rule
,off
,Flags
) :-
142 Flags
= [ set_semantics_rule
- off
].
144 option_definition
(check_unnecessary_active
,full
,Flags
) :-
145 Flags
= [ check_unnecessary_active
- full
].
146 option_definition
(check_unnecessary_active
,simplification
,Flags
) :-
147 Flags
= [ check_unnecessary_active
- simplification
].
148 option_definition
(check_unnecessary_active
,off
,Flags
) :-
149 Flags
= [ check_unnecessary_active
- off
].
151 option_definition
(check_guard_bindings
,on
,Flags
) :-
152 Flags
= [ guard_locks
- on
].
153 option_definition
(check_guard_bindings
,off
,Flags
) :-
154 Flags
= [ guard_locks
- off
].
156 option_definition
(reduced_indexing
,on
,Flags
) :-
157 Flags
= [ reduced_indexing
- on
].
158 option_definition
(reduced_indexing
,off
,Flags
) :-
159 Flags
= [ reduced_indexing
- off
].
161 option_definition
(storage_analysis
,on
,Flags
) :-
162 Flags
= [ storage_analysis
- on
].
163 option_definition
(storage_analysis
,off
,Flags
) :-
164 Flags
= [ storage_analysis
- off
].
166 option_definition
(guard_simplification
,on
,Flags
) :-
167 Flags
= [ guard_simplification
- on
].
168 option_definition
(guard_simplification
,off
,Flags
) :-
169 Flags
= [ guard_simplification
- off
].
171 option_definition
(check_impossible_rules
,on
,Flags
) :-
172 Flags
= [ check_impossible_rules
- on
].
173 option_definition
(check_impossible_rules
,off
,Flags
) :-
174 Flags
= [ check_impossible_rules
- off
].
176 option_definition
(occurrence_subsumption
,on
,Flags
) :-
177 Flags
= [ occurrence_subsumption
- on
].
178 option_definition
(occurrence_subsumption
,off
,Flags
) :-
179 Flags
= [ occurrence_subsumption
- off
].
181 option_definition
(late_allocation
,on
,Flags
) :-
182 Flags
= [ late_allocation
- on
].
183 option_definition
(late_allocation
,off
,Flags
) :-
184 Flags
= [ late_allocation
- off
].
186 option_definition
(type_definition
,TypeDef
,[]) :-
189 chr_translate
:type_definition
(T
,D
)
191 option_definition
(type_declaration
,TypeDecl
,[]) :-
192 ( nonvar
(TypeDecl
) ->
193 functor
(TypeDecl
,F
,A
),
194 TypeDecl
=.. [_
|ArgTypes
],
195 chr_translate
:constraint_type
(F
/A
,ArgTypes
)
198 option_definition
(mode
,ModeDecl
,[]) :-
199 ( nonvar
(ModeDecl
) ->
200 functor
(ModeDecl
,F
,A
),
201 ModeDecl
=.. [_
|ArgModes
],
202 chr_translate
:constraint_mode
(F
/A
,ArgModes
)
204 option_definition
(store
,FA
-Store
,[]) :-
205 chr_translate
:store_type
(FA
,Store
).
207 option_definition
(debug
,off
,Flags
) :-
208 Flags
= [ debugable
- off
].
209 option_definition
(debug
,on
,Flags
) :-
210 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
].
242 chr_pp_flag_definition
(Name
,[DefaultValue
|_
]),
243 set_chr_pp_flag
(Name
,DefaultValue
),
247 set_chr_pp_flags
([]).
248 set_chr_pp_flags
([Name
-Value
|Flags
]) :-
249 set_chr_pp_flag
(Name
,Value
),
250 set_chr_pp_flags
(Flags
).
252 set_chr_pp_flag
(Name
,Value
) :-
253 atom_concat
('$chr_pp_',Name
,GlobalVar
),
254 nb_setval
(GlobalVar
,Value
).
256 chr_pp_flag_definition
(functional_dependency_analysis
,[off
,on
]).
257 chr_pp_flag_definition
(check_unnecessary_active
,[off
,full
,simplification
]).
258 chr_pp_flag_definition
(reorder_heads
,[off
,on
]).
259 chr_pp_flag_definition
(set_semantics_rule
,[off
,on
]).
260 chr_pp_flag_definition
(guard_via_reschedule
,[off
,on
]).
261 chr_pp_flag_definition
(guard_locks
,[on
,off
]).
262 chr_pp_flag_definition
(storage_analysis
,[off
,on
]).
263 chr_pp_flag_definition
(debugable
,[on
,off
]).
264 chr_pp_flag_definition
(reduced_indexing
,[off
,on
]).
265 chr_pp_flag_definition
(observation_analysis
,[off
,on
]).
266 chr_pp_flag_definition
(ai_observation_analysis
,[off
,on
]).
267 chr_pp_flag_definition
(late_allocation
,[off
,on
]).
268 chr_pp_flag_definition
(store_counter
,[off
,on
]).
269 chr_pp_flag_definition
(guard_simplification
,[off
,on
]).
270 chr_pp_flag_definition
(check_impossible_rules
,[off
,on
]).
271 chr_pp_flag_definition
(occurrence_subsumption
,[off
,on
]).
272 chr_pp_flag_definition
(observation
,[off
,on
]).
273 chr_pp_flag_definition
(show
,[off
,on
]).
274 chr_pp_flag_definition
(solver_events
,[none
,_
]).
276 chr_pp_flag
(Name
,Value
) :-
277 atom_concat
('$chr_pp_',Name
,GlobalVar
),
278 nb_getval
(GlobalVar
,V
),
280 chr_pp_flag_definition
(Name
,[Value
|_
])
284 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%