3 let web_mode = ref false
4 let is_web_mode () = !web_mode
5 let set_web_mode () = web_mode := true
7 let default_choice = "default"
8 let option_settings_step = "during option settings"
10 let language_from_string kind default s =
12 Languages.from_string s
14 if s = default_choice then
17 Error.global_error option_settings_step
18 (Printf.sprintf "`%s' is not a valid %s language." s kind)
20 let source_language_of_string = language_from_string "source" Languages.Clight
21 let source_language = ref (source_language_of_string default_choice)
22 let set_source_language s = source_language := source_language_of_string s
23 let get_source_language () = !source_language
25 let target_language_of_string = language_from_string "target" Languages.ASM
26 let target_language = ref (target_language_of_string default_choice)
27 let set_target_language s = target_language := target_language_of_string s
28 let get_target_language () = !target_language
30 let input_files = ref []
31 let add_input_file f = input_files := f :: !input_files
32 let input_files () = !input_files
34 let output_files = ref None
35 let set_output_files s = output_files := Some s
36 let get_output_files () = !output_files
38 let annotation_flag = ref false
39 let request_annotation = (:=) annotation_flag
40 let annotation_requested () = !annotation_flag
42 let interpretation_flag = ref false
43 let request_interpretation = (:=) interpretation_flag
44 let interpretation_requested () = !interpretation_flag
46 let interpretations_flag = ref false
47 let request_interpretations = (:=) interpretations_flag
48 let interpretations_requested () = !interpretations_flag
50 let debug_flag = ref false
51 let set_debug = (:=) debug_flag
52 let is_debug_enabled () = !debug_flag
54 let asm_pretty_flag = ref false
55 let set_asm_pretty = (:=) asm_pretty_flag
56 let is_asm_pretty () = !asm_pretty_flag
58 let lustre_flag = ref false
59 let set_lustre_file = (:=) lustre_flag
60 let is_lustre_file () = !lustre_flag
62 let remove_lustre_externals = ref false
63 let set_remove_lustre_externals = (:=) remove_lustre_externals
64 let is_remove_lustre_externals () = !remove_lustre_externals
66 let lustre_test = ref None
67 let set_lustre_test s = lustre_test := Some s
68 let get_lustre_test () = !lustre_test
70 let lustre_test_cases = ref 100
71 let set_lustre_test_cases = (:=) lustre_test_cases
72 let get_lustre_test_cases () = !lustre_test_cases
74 let lustre_test_cycles = ref 100
75 let set_lustre_test_cycles = (:=) lustre_test_cycles
76 let get_lustre_test_cycles () = !lustre_test_cycles
78 let lustre_test_min_int = ref (-1000)
79 let set_lustre_test_min_int = (:=) lustre_test_min_int
80 let get_lustre_test_min_int () = !lustre_test_min_int
82 let lustre_test_max_int = ref 1000
83 let set_lustre_test_max_int = (:=) lustre_test_max_int
84 let get_lustre_test_max_int () = !lustre_test_max_int
87 let print_result_flag = ref false
88 let set_print_result = (:=) print_result_flag
89 let is_print_result_enabled () = !print_result_flag
92 let dev_test = ref false
93 let set_dev_test = (:=) dev_test
94 let is_dev_test_enabled () = !dev_test
96 let options = OptionsParsing.register [
98 "-s", Arg.String set_source_language,
99 " Choose the source language between:";
100 extra_doc " Clight, Cminor";
101 extra_doc " [default is C]";
104 "-l", Arg.String set_target_language,
105 " Choose the target language between:";
106 extra_doc " Clight, Cminor, RTLabs, RTL, ERTL, LTL, LIN, ASM";
107 extra_doc " [default is ASM]";
109 "-a", Arg.Set annotation_flag,
110 " Add cost annotations on the source code.";
112 "-i", Arg.Set interpretation_flag,
113 " Interpret the compiled code.";
115 "-is", Arg.Set interpretations_flag,
116 " Interpret all the compilation passes.";
118 "-d", Arg.Set debug_flag,
120 extra_doc " Outputs all the passes up to the target language.";
121 extra_doc " Combined with an interpret option, shows the trace";
122 extra_doc " of execution states.";
124 "-o", Arg.String set_output_files,
125 " Prefix of the output files.";
127 "-asm-pretty", Arg.Set asm_pretty_flag,
128 " Output a pretty-printed assembly file.";
130 "-lustre", Arg.Set lustre_flag,
131 " Input file is a Lustre file.";
133 "-remove-lustre-externals", Arg.Set remove_lustre_externals,
134 " Remove Lustre externals.";
136 "-lustre-test", Arg.String set_lustre_test,
137 " Input file is a Lustre file, testing requested.";
139 "-lustre-test-cases", Arg.Int set_lustre_test_cases,
140 " Set the number of test cases when testing a Lustre";
142 extra_doc " [default is 100]";
144 "-lustre-test-cycles", Arg.Int set_lustre_test_cycles,
145 " Set the number of cycles for each case when testing";
146 extra_doc " a Lustre file.";
147 extra_doc " [default is 100]";
149 "-lustre-test-min-int", Arg.Int set_lustre_test_min_int,
150 " Random int minimum value when testing a Lustre file.";
151 extra_doc " [default is -1000]";
153 "-lustre-test-max-int", Arg.Int set_lustre_test_max_int,
154 " Random int maximum value when testing a Lustre file.";
155 extra_doc " [default is 1000]";
158 "-res", Arg.Set print_result_flag,
159 " Print the result of interpretations.";
162 "-dev", Arg.Set dev_test,
163 " Playground for developers.";