1 | (*open Misc.ArgExt replaced by next line*) |
---|
2 | let extra_doc s = "", Arg.Unit ignore, s |
---|
3 | |
---|
4 | (* |
---|
5 | let web_mode = ref false |
---|
6 | let is_web_mode () = !web_mode |
---|
7 | let set_web_mode () = web_mode := true |
---|
8 | *) |
---|
9 | |
---|
10 | (* |
---|
11 | let default_choice = "default" |
---|
12 | let option_settings_step = "during option settings" |
---|
13 | |
---|
14 | let language_from_string kind default s = |
---|
15 | try |
---|
16 | Languages.from_string s |
---|
17 | with Not_found -> |
---|
18 | if s = default_choice then |
---|
19 | default |
---|
20 | else |
---|
21 | Error.global_error option_settings_step |
---|
22 | (Printf.sprintf "`%s' is not a valid %s language." s kind) |
---|
23 | |
---|
24 | let source_language_of_string = language_from_string "source" Languages.Clight |
---|
25 | let source_language = ref (source_language_of_string default_choice) |
---|
26 | let set_source_language s = source_language := source_language_of_string s |
---|
27 | let get_source_language () = !source_language |
---|
28 | |
---|
29 | let target_language_of_string = language_from_string "target" Languages.ASM |
---|
30 | let target_language = ref (target_language_of_string default_choice) |
---|
31 | let set_target_language s = target_language := target_language_of_string s |
---|
32 | let get_target_language () = !target_language |
---|
33 | *) |
---|
34 | |
---|
35 | (* |
---|
36 | let input_files = ref [] |
---|
37 | let add_input_file f = input_files := f :: !input_files |
---|
38 | let input_files () = !input_files |
---|
39 | *) |
---|
40 | |
---|
41 | let output_files = ref None |
---|
42 | let set_output_files s = output_files := Some s |
---|
43 | let get_output_files () = !output_files |
---|
44 | |
---|
45 | let annotation_flag = ref false |
---|
46 | let request_annotation = (:=) annotation_flag |
---|
47 | let annotation_requested () = !annotation_flag |
---|
48 | |
---|
49 | (* |
---|
50 | let interpretation_flag = ref false |
---|
51 | let request_interpretation = (:=) interpretation_flag |
---|
52 | let interpretation_requested () = !interpretation_flag |
---|
53 | *) |
---|
54 | |
---|
55 | let interpretations_flag = ref false |
---|
56 | let request_interpretations = (:=) interpretations_flag |
---|
57 | let interpretations_requested () = !interpretations_flag |
---|
58 | |
---|
59 | (* |
---|
60 | let debug_flag = ref false |
---|
61 | let set_debug = (:=) debug_flag |
---|
62 | let is_debug_enabled () = !debug_flag |
---|
63 | *) |
---|
64 | |
---|
65 | (* |
---|
66 | let asm_pretty_flag = ref false |
---|
67 | let set_asm_pretty = (:=) asm_pretty_flag |
---|
68 | let is_asm_pretty () = !asm_pretty_flag |
---|
69 | *) |
---|
70 | |
---|
71 | let lustre_flag = ref false |
---|
72 | let set_lustre_file = (:=) lustre_flag |
---|
73 | let is_lustre_file () = !lustre_flag |
---|
74 | |
---|
75 | let remove_lustre_externals = ref false |
---|
76 | let set_remove_lustre_externals = (:=) remove_lustre_externals |
---|
77 | let is_remove_lustre_externals () = !remove_lustre_externals |
---|
78 | |
---|
79 | let lustre_test = ref None |
---|
80 | let set_lustre_test s = lustre_test := Some s |
---|
81 | let get_lustre_test () = !lustre_test |
---|
82 | |
---|
83 | let lustre_test_cases = ref 100 |
---|
84 | let set_lustre_test_cases = (:=) lustre_test_cases |
---|
85 | let get_lustre_test_cases () = !lustre_test_cases |
---|
86 | |
---|
87 | let lustre_test_cycles = ref 100 |
---|
88 | let set_lustre_test_cycles = (:=) lustre_test_cycles |
---|
89 | let get_lustre_test_cycles () = !lustre_test_cycles |
---|
90 | |
---|
91 | let lustre_test_min_int = ref (-1000) |
---|
92 | let set_lustre_test_min_int = (:=) lustre_test_min_int |
---|
93 | let get_lustre_test_min_int () = !lustre_test_min_int |
---|
94 | |
---|
95 | let lustre_test_max_int = ref 1000 |
---|
96 | let set_lustre_test_max_int = (:=) lustre_test_max_int |
---|
97 | let get_lustre_test_max_int () = !lustre_test_max_int |
---|
98 | |
---|
99 | (* |
---|
100 | let print_result_flag = ref false |
---|
101 | let set_print_result = (:=) print_result_flag |
---|
102 | let is_print_result_enabled () = !print_result_flag |
---|
103 | *) |
---|
104 | |
---|
105 | (* |
---|
106 | let dev_test = ref false |
---|
107 | let set_dev_test = (:=) dev_test |
---|
108 | let is_dev_test_enabled () = !dev_test |
---|
109 | *) |
---|
110 | |
---|
111 | let options = OptionsParsing.register [ |
---|
112 | (* |
---|
113 | "-s", Arg.String set_source_language, |
---|
114 | " Choose the source language between:"; |
---|
115 | extra_doc " Clight, Cminor"; |
---|
116 | extra_doc " [default is C]"; |
---|
117 | |
---|
118 | "-l", Arg.String set_target_language, |
---|
119 | " Choose the target language between:"; |
---|
120 | extra_doc " Clight, Cminor, RTLabs, RTL, ERTL, LTL, LIN, ASM"; |
---|
121 | extra_doc " [default is ASM]"; |
---|
122 | *) |
---|
123 | |
---|
124 | "-a", Arg.Set annotation_flag, |
---|
125 | " Add cost annotations on the source code."; |
---|
126 | |
---|
127 | (* |
---|
128 | "-i", Arg.Set interpretation_flag, |
---|
129 | " Interpret the compiled code."; |
---|
130 | *) |
---|
131 | |
---|
132 | "-is", Arg.Set interpretations_flag, |
---|
133 | " Outputs and interprets all the compilation passes,"; |
---|
134 | extra_doc " showing the execution traces"; |
---|
135 | |
---|
136 | (* |
---|
137 | "-d", Arg.Set debug_flag, |
---|
138 | " Debug mode."; |
---|
139 | extra_doc " Outputs all the passes up to the target language."; |
---|
140 | extra_doc " Combined with an interpret option, shows the trace"; |
---|
141 | extra_doc " of execution states."; |
---|
142 | *) |
---|
143 | |
---|
144 | "-o", Arg.String set_output_files, |
---|
145 | " Prefix of the output files."; |
---|
146 | |
---|
147 | (* |
---|
148 | "-asm-pretty", Arg.Set asm_pretty_flag, |
---|
149 | " Output a pretty-printed assembly file."; |
---|
150 | *) |
---|
151 | |
---|
152 | "-lustre", Arg.Set lustre_flag, |
---|
153 | " Input file is a Lustre file."; |
---|
154 | |
---|
155 | "-remove-lustre-externals", Arg.Set remove_lustre_externals, |
---|
156 | " Remove Lustre externals."; |
---|
157 | |
---|
158 | "-lustre-test", Arg.String set_lustre_test, |
---|
159 | " Input file is a Lustre file, testing requested."; |
---|
160 | |
---|
161 | "-lustre-test-cases", Arg.Int set_lustre_test_cases, |
---|
162 | " Set the number of test cases when testing a Lustre"; |
---|
163 | extra_doc " file."; |
---|
164 | extra_doc " [default is 100]"; |
---|
165 | |
---|
166 | "-lustre-test-cycles", Arg.Int set_lustre_test_cycles, |
---|
167 | " Set the number of cycles for each case when testing"; |
---|
168 | extra_doc " a Lustre file."; |
---|
169 | extra_doc " [default is 100]"; |
---|
170 | |
---|
171 | "-lustre-test-min-int", Arg.Int set_lustre_test_min_int, |
---|
172 | " Random int minimum value when testing a Lustre file."; |
---|
173 | extra_doc " [default is -1000]"; |
---|
174 | |
---|
175 | "-lustre-test-max-int", Arg.Int set_lustre_test_max_int, |
---|
176 | " Random int maximum value when testing a Lustre file."; |
---|
177 | extra_doc " [default is 1000]"; |
---|
178 | |
---|
179 | (* |
---|
180 | "-res", Arg.Set print_result_flag, |
---|
181 | " Print the result of interpretations."; |
---|
182 | *) |
---|
183 | |
---|
184 | (* |
---|
185 | "-dev", Arg.Set dev_test, |
---|
186 | " Playground for developers."; |
---|
187 | *) |
---|
188 | ] |
---|