source: driver/compiler.ml @ 2779

Last change on this file since 2779 was 2778, checked in by sacerdot, 8 years ago

Code to pretty-print the IntelHex? output.
At the moment the glue code between the trusted and untrusted code
pass through Matita's base 1 integers. Thus the computation is just too
slow.

File size: 1.7 KB
Line 
1open Extracted.Errors
2open ClightPrinter
3
4let rec run g s =
5  (match Extracted.RTLabs_semantics.rTLabs_is_final s with
6  | Extracted.Types.None ->
7    (match Extracted.RTLabs_semantics.eval_statement g s with
8    | Extracted.IOMonad.Value x -> run g (Extracted.Types.snd x)
9    | Extracted.IOMonad.Wrong m -> failwith (Error.errormsg m)
10    | _ -> failwith "oh dear")
11  | Extracted.Types.Some r -> r)
12
13let convBool = function
14| Extracted.Bool.True -> true
15| Extracted.Bool.False -> false
16
17let bv_to_int v =
18  let rec aux i v =
19    match v with
20    | Extracted.Vector.VEmpty -> i
21    | Extracted.Vector.VCons (_,b,t) -> aux (2*i + (if convBool b then 1 else 0)) t
22  in aux 0 v
23;;
24
25let cl = ClightParser.process Sys.argv.(1) in
26let OK output = Extracted.Compiler.compile cl in
27let labelled = output.Extracted.Compiler.c_labelled_clight in
28let l_costmap = output.Extracted.Compiler.c_clight_cost_map in
29let style =
30  match try Sys.argv.(2) with _ -> "instrumented" with
31  | "plain" -> Cost_plain
32  | "numbered" -> Cost_numbered l_costmap
33  | "instrumented" -> Cost_instrumented l_costmap
34  | x -> failwith ("I have no idea what " ^ x ^ " means")
35in
36print_endline (ClightPrinter.print_program style labelled);
37print_newline ();
38print_endline (ASMPrinter.print_program (Extracted.ASM.oc (Extracted.Compiler.c_labelled_object_code output)));
39(*
40let OK mid = Extracted.Compiler.front_end cl in
41let rtlabs = Extracted.Types.snd mid in
42let g = Extracted.RTLabs_semantics.make_global0 rtlabs in
43let OK s0 = Extracted.RTLabs_semantics.make_initial_state0 rtlabs in
44let r = run g s0 in
45exit (bv_to_int r)
46
47val compile :
48  Csyntax.clight_program -> ((object_code, costlabel_map1) Types.prod,
49  (Csyntax.clight_program, Label.clight_cost_map) Types.dPair) Types.prod
50  Errors.res
51*)
Note: See TracBrowser for help on using the repository browser.