@@ -236,7 +236,7 @@ let env () : env =
236
236
let current_mod (env : env ) = " $$" ^ string_of_int env.current_mod
237
237
let of_mod_opt (env : env ) = function
238
238
| None -> current_mod env
239
- | Some x -> x.it
239
+ | Some x -> " $ " ^ x.it
240
240
241
241
let current_inst (env : env ) = " $" ^ string_of_int env.current_inst
242
242
let of_inst_opt (env : env ) = function
@@ -614,24 +614,18 @@ let rec of_result res =
614
614
| EitherResult ress ->
615
615
" [" ^ String. concat " , " (List. map of_result ress) ^ " ]"
616
616
617
- let of_module bs =
618
- " module(" ^ of_bytes bs ^ " )"
619
-
620
617
let rec of_definition def =
621
618
match def.it with
622
- | Textual (m , _ ) -> of_module (Encode. encode m)
623
- | Encoded (_ , bs ) -> of_module bs.it
619
+ | Textual (m , _ ) -> of_bytes (Encode. encode m)
620
+ | Encoded (_ , bs ) -> of_bytes bs.it
624
621
| Quoted (_ , s ) ->
625
622
try of_definition (snd (Parse.Module. parse_string ~offset: s.at s.it))
626
- with Parse. Syntax _ | Custom. Syntax _ -> of_module " <malformed quote>"
627
-
628
- let of_instance env x_opt =
629
- " instance(" ^ of_mod_opt env x_opt ^ " )"
623
+ with Parse. Syntax _ | Custom. Syntax _ -> of_bytes " <malformed quote>"
630
624
631
625
let of_wrapper env x_opt name wrap_action wrap_assertion at =
632
626
let x = of_inst_opt env x_opt in
633
627
let bs = wrap name wrap_action wrap_assertion at in
634
- " call(instance(" ^ of_module bs ^ " , " ^
628
+ " call(instance(module( " ^ of_bytes bs ^ " ) , " ^
635
629
" exports(" ^ x ^ " )), " ^ " \" run\" , [])"
636
630
637
631
let of_action env act =
@@ -680,9 +674,9 @@ let of_assertion env ass =
680
674
| AssertInvalidCustom (def , _ ) ->
681
675
" assert_invalid_custom(" ^ of_definition def ^ " );"
682
676
| AssertUnlinkable (x_opt , _ ) ->
683
- " assert_unlinkable(" ^ of_instance env x_opt ^ " );"
677
+ " assert_unlinkable(" ^ of_mod_opt env x_opt ^ " );"
684
678
| AssertUninstantiable (x_opt , _ ) ->
685
- " assert_uninstantiable(" ^ of_instance env x_opt ^ " );"
679
+ " assert_uninstantiable(" ^ of_mod_opt env x_opt ^ " );"
686
680
| AssertReturn (act , ress ) ->
687
681
of_assertion' env act " assert_return" (List. map of_result ress)
688
682
(Some (assert_return ress))
@@ -705,7 +699,7 @@ let of_command env cmd =
705
699
| Quoted (_ , s ) ->
706
700
unquote (snd (Parse.Module. parse_string ~offset: s.at s.it))
707
701
in bind_mod env x_opt (unquote def);
708
- " let " ^ current_mod env ^ " = " ^ of_definition def ^ " ;\n " ^
702
+ " let " ^ current_mod env ^ " = module( " ^ of_definition def ^ " ) ;\n " ^
709
703
(if x_opt = None then " " else
710
704
" let " ^ of_mod_opt env x_opt ^ " = " ^ current_mod env ^ " ;\n " )
711
705
| Instance (x1_opt , x2_opt ) ->
0 commit comments