197 |
197 |
198 fun set_default_type s thy ({size, iterations, ...} : test_params) = |
198 fun set_default_type s thy ({size, iterations, ...} : test_params) = |
199 {size = size, iterations = iterations, |
199 {size = size, iterations = iterations, |
200 default_type = SOME (Sign.read_typ thy s)}; |
200 default_type = SOME (Sign.read_typ thy s)}; |
201 |
201 |
202 (* data kind 'Pure/codegen' *) |
202 |
|
203 (* theory data *) |
203 |
204 |
204 structure CodeData = CodegenData; |
205 structure CodeData = CodegenData; |
205 |
206 |
206 structure CodegenData = TheoryDataFun |
207 structure CodegenData = TheoryDataFun |
207 (struct |
208 ( |
208 val name = "Pure/codegen"; |
|
209 type T = |
209 type T = |
210 {codegens : (string * term codegen) list, |
210 {codegens : (string * term codegen) list, |
211 tycodegens : (string * typ codegen) list, |
211 tycodegens : (string * typ codegen) list, |
212 consts : ((string * typ) * (term mixfix list * (string * string) list)) list, |
212 consts : ((string * typ) * (term mixfix list * (string * string) list)) list, |
213 types : (string * (typ mixfix list * (string * string) list)) list, |
213 types : (string * (typ mixfix list * (string * string) list)) list, |
235 types = AList.merge (op =) (K true) (types1, types2), |
235 types = AList.merge (op =) (K true) (types1, types2), |
236 attrs = AList.merge (op =) (K true) (attrs1, attrs2), |
236 attrs = AList.merge (op =) (K true) (attrs1, attrs2), |
237 preprocs = AList.merge (op =) (K true) (preprocs1, preprocs2), |
237 preprocs = AList.merge (op =) (K true) (preprocs1, preprocs2), |
238 modules = Symtab.merge (K true) (modules1, modules2), |
238 modules = Symtab.merge (K true) (modules1, modules2), |
239 test_params = merge_test_params test_params1 test_params2}; |
239 test_params = merge_test_params test_params1 test_params2}; |
240 |
240 ); |
241 fun print _ ({codegens, tycodegens, ...} : T) = |
241 |
|
242 fun print_codegens thy = |
|
243 let val {codegens, tycodegens, ...} = CodegenData.get thy in |
242 Pretty.writeln (Pretty.chunks |
244 Pretty.writeln (Pretty.chunks |
243 [Pretty.strs ("term code generators:" :: map fst codegens), |
245 [Pretty.strs ("term code generators:" :: map fst codegens), |
244 Pretty.strs ("type code generators:" :: map fst tycodegens)]); |
246 Pretty.strs ("type code generators:" :: map fst tycodegens)]) |
245 end); |
247 end; |
246 |
248 |
247 val _ = Context.add_setup CodegenData.init; |
|
248 val print_codegens = CodegenData.print; |
|
249 |
249 |
250 |
250 |
251 (**** access parameters for random testing ****) |
251 (**** access parameters for random testing ****) |
252 |
252 |
253 fun get_test_params thy = #test_params (CodegenData.get thy); |
253 fun get_test_params thy = #test_params (CodegenData.get thy); |