diff --git a/sledge/src/import/import.ml b/sledge/src/import/import.ml index eb618de8b..757ce898f 100644 --- a/sledge/src/import/import.ml +++ b/sledge/src/import/import.ml @@ -22,6 +22,7 @@ include ( (* prematurely deprecated, remove and use Stdlib instead *) and module Filename := Base.Filename and module Format := Base.Format + and module Marshal := Base.Marshal and module Scanf := Base.Scanf and type ('ok, 'err) result := ('ok, 'err) Base.result) [@warning "-3"] diff --git a/sledge/src/import/import.mli b/sledge/src/import/import.mli index 955dac69a..9364f64c9 100644 --- a/sledge/src/import/import.mli +++ b/sledge/src/import/import.mli @@ -22,6 +22,7 @@ include module type of ( (* prematurely deprecated, remove and use Stdlib instead *) and module Filename := Base.Filename and module Format := Base.Format + and module Marshal := Base.Marshal and module Scanf := Base.Scanf and type ('ok, 'err) result := ('ok, 'err) Base.result) [@warning "-3"] diff --git a/sledge/src/sledge.ml b/sledge/src/sledge.ml index 5d717ca6b..9b412739e 100644 --- a/sledge/src/sledge.ml +++ b/sledge/src/sledge.ml @@ -9,8 +9,17 @@ let main ~input ~output ~compile_only = try - let program = Frontend.translate input in - Trace.flush () ; + let program = + 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 | "-" -> Format.printf "%a@." Llair.pp program | filename ->