diff options
| author | Alasdair Armstrong | 2017-08-29 17:50:17 +0100 |
|---|---|---|
| committer | Alasdair Armstrong | 2017-08-29 17:55:06 +0100 |
| commit | 9cc9b5afff769b9185c6e6e4afad496d58d1a38d (patch) | |
| tree | fd7c5073728d3a69825b2028d0ebf8ecced771b3 /src/reporting_basic.ml | |
| parent | 4b1b3f0e45d114592102d02fb668b6e11b526dbf (diff) | |
More work on ocaml backend.
Works for basic examples with arbitrary register types, so for example we can compile:
val extern string -> unit effect pure print = "print_endline"
val unit -> string effect pure hello_world
function hello_world () = {
return "Hello, World!";
"Unreachable"
}
val unit -> unit effect {wreg, rreg} main
register string REG
function main () = {
REG := "Hello, Sail!";
print(REG);
REG := hello_world ();
print(REG);
return ()
}
into
open Sail_lib;;
let zhello_world () = with_return (fun r ->
begin r.return "Hello, World!"; "Unreachable" end);;
let zREG : (string) ref = ref (undefined_string ());;
let zmain () = with_return (fun r ->
begin
zREG := "Hello, Sail!";
print_endline !zREG;
zREG := zhello_world ();
print_endline !zREG;
r.return ()
end);;
let initialize_registers () = with_return (fun r -> zREG := undefined_string ());;
with the arbitrary register types and early returns being handled
appropriately, given a suitable implementation for Sail_lib
Diffstat (limited to 'src/reporting_basic.ml')
0 files changed, 0 insertions, 0 deletions
