- ExecutionEngine.run_static_ctors ee;
-
- (* run_function_as_main *)
- let res = ExecutionEngine.run_function_as_main main [|"test"|] [||] ee in
- if 42 != res then bomb "main did not return 42";
-
- (* free_machine_code *)
- ExecutionEngine.free_machine_code main ee;
-
- (* find_function *)
- match ExecutionEngine.find_function "dne" ee with
- | Some _ -> raise (Failure "find_function 'dne' failed")
- | None ->
-
- match ExecutionEngine.find_function "plus" ee with
- | None -> raise (Failure "find_function 'plus' failed")
- | Some plus ->
-
- (* run_function *)
- let res = ExecutionEngine.run_function plus
- [| GenericValue.of_int i32_type 2;
- GenericValue.of_int i32_type 2 |]
- ee in
- if 4 != GenericValue.as_int res then bomb "plus did not work";
-
- (* remove_module_provider *)
- Llvm.dispose_module (ExecutionEngine.remove_module_provider mp2 ee);
-
+ run_static_ctors ee;
+
+ (* call plus *)
+ let cplusty = Foreign.funptr (int32_t @-> int32_t @-> returning int32_t) in
+ let cplus = get_pointer_to_global plus cplusty ee in
+ if 4l <> cplus 2l 2l then bomb "plus didn't work";
+
+ (* call getglobal *)
+ (* let cgetglobalty = Foreign.funptr (void @-> returning int32_t) in
+ let cgetglobal = get_pointer_to_global getglobal cgetglobalty ee in
+ if 42l <> cgetglobal () then bomb "getglobal didn't work"; *)
+
+ (* remove_module *)
+ remove_module m2 ee;
+ dispose_module m2;
+