@@ -4,7 +4,7 @@ use hax_rust_engine::{
4
4
ocaml_engine:: { ExtendedToEngine , Response } ,
5
5
printer:: Allocator ,
6
6
} ;
7
- use hax_types:: engine_api:: File ;
7
+ use hax_types:: { cli_options :: Backend , engine_api:: File } ;
8
8
9
9
use pretty:: { DocAllocator , DocBuilder } ;
10
10
@@ -13,22 +13,7 @@ fn krate_name(items: &Vec<Item>) -> String {
13
13
head_item. ident . krate ( )
14
14
}
15
15
16
- fn main ( ) {
17
- let ExtendedToEngine :: Query ( input) = hax_rust_engine:: hax_io:: read ( ) else {
18
- panic ! ( )
19
- } ;
20
- let ( value, _map) = input. destruct ( ) ;
21
-
22
- let query = hax_rust_engine:: ocaml_engine:: Query {
23
- hax_version : value. hax_version ,
24
- impl_infos : value. impl_infos ,
25
- kind : hax_rust_engine:: ocaml_engine:: QueryKind :: ImportThir { input : value. input } ,
26
- } ;
27
-
28
- let Some ( Response :: ImportThir { output : items } ) = query. execute ( ) else {
29
- panic ! ( )
30
- } ;
31
-
16
+ fn lean_backend ( items : Vec < Item > ) {
32
17
let krate = krate_name ( & items) ;
33
18
34
19
// For now, the main function always calls the Lean backend
@@ -57,3 +42,39 @@ fn main() {
57
42
sourcemap : None ,
58
43
} ) ) ;
59
44
}
45
+
46
+ fn main ( ) {
47
+ let ExtendedToEngine :: Query ( input) = hax_rust_engine:: hax_io:: read ( ) else {
48
+ panic ! ( )
49
+ } ;
50
+ let ( value, _map) = input. destruct ( ) ;
51
+
52
+ let query = hax_rust_engine:: ocaml_engine:: Query {
53
+ hax_version : value. hax_version ,
54
+ impl_infos : value. impl_infos ,
55
+ kind : hax_rust_engine:: ocaml_engine:: QueryKind :: ImportThir { input : value. input } ,
56
+ } ;
57
+
58
+ let Some ( Response :: ImportThir { output : items } ) = query. execute ( ) else {
59
+ panic ! ( )
60
+ } ;
61
+
62
+ match & value. backend . backend {
63
+ Backend :: Fstar { .. }
64
+ | Backend :: Coq { .. }
65
+ | Backend :: Ssprove { .. }
66
+ | Backend :: Easycrypt { .. }
67
+ | Backend :: ProVerif { .. } => panic ! (
68
+ "The Rust engine cannot be called with backend {}." ,
69
+ value. backend. backend
70
+ ) ,
71
+ Backend :: Lean => lean_backend ( items) ,
72
+ Backend :: GenerateRustEngineNames => hax_rust_engine:: hax_io:: write (
73
+ & hax_types:: engine_api:: protocol:: FromEngine :: File ( File {
74
+ path : "generated.rs" . into ( ) ,
75
+ contents : hax_rust_engine:: names:: codegen:: export_def_ids_to_mod ( items) ,
76
+ sourcemap : None ,
77
+ } ) ,
78
+ ) ,
79
+ }
80
+ }
0 commit comments