[sledge] Dump program to file between frontend and backend

Summary:
`sledge -c foo.bc` generates a binary file `foo.bc.llair` which can be
analyzed with `sledge foo.bc.llair`, and converted to textual form
with `sledge -c foo.bc.llair -o foo.llair`. Binary files are not
compatible between debug and release builds.

Reviewed By: mbouaziz

Differential Revision: D10389473

fbshipit-source-id: dfcabf33b
master
Josh Berdine 6 years ago committed by Facebook Github Bot
parent 080c843856
commit 889f7abc6f

@ -22,6 +22,7 @@ include (
(* prematurely deprecated, remove and use Stdlib instead *) (* prematurely deprecated, remove and use Stdlib instead *)
and module Filename := Base.Filename and module Filename := Base.Filename
and module Format := Base.Format and module Format := Base.Format
and module Marshal := Base.Marshal
and module Scanf := Base.Scanf and module Scanf := Base.Scanf
and type ('ok, 'err) result := ('ok, 'err) Base.result) and type ('ok, 'err) result := ('ok, 'err) Base.result)
[@warning "-3"] [@warning "-3"]

@ -22,6 +22,7 @@ include module type of (
(* prematurely deprecated, remove and use Stdlib instead *) (* prematurely deprecated, remove and use Stdlib instead *)
and module Filename := Base.Filename and module Filename := Base.Filename
and module Format := Base.Format and module Format := Base.Format
and module Marshal := Base.Marshal
and module Scanf := Base.Scanf and module Scanf := Base.Scanf
and type ('ok, 'err) result := ('ok, 'err) Base.result) and type ('ok, 'err) result := ('ok, 'err) Base.result)
[@warning "-3"] [@warning "-3"]

@ -9,8 +9,17 @@
let main ~input ~output ~compile_only = let main ~input ~output ~compile_only =
try try
let program = Frontend.translate input in let program =
Trace.flush () ; if String.is_suffix input ~suffix:".llair" then
In_channel.with_file input ~f:(fun ic ->
(Marshal.from_channel ic : Llair.t) )
else
let program = Frontend.translate input in
Trace.flush () ;
Out_channel.with_file (input ^ ".llair") ~f:(fun oc ->
Marshal.to_channel oc program [Marshal.Closures] ) ;
program
in
Option.iter output ~f:(function Option.iter output ~f:(function
| "-" -> Format.printf "%a@." Llair.pp program | "-" -> Format.printf "%a@." Llair.pp program
| filename -> | filename ->

Loading…
Cancel
Save