diff options
Diffstat (limited to 'compiler/Main.ml')
-rw-r--r-- | compiler/Main.ml | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/compiler/Main.ml b/compiler/Main.ml index 41addc81..88c32ca9 100644 --- a/compiler/Main.ml +++ b/compiler/Main.ml @@ -267,16 +267,31 @@ let () = definitions"; fail ()); - (* Apply the pre-passes *) - let m = Aeneas.PrePasses.apply_passes m in + (try + (* Apply the pre-passes *) + let m = Aeneas.PrePasses.apply_passes m in - (* Some options for the execution *) + (* Test the unit functions with the concrete interpreter *) + if !test_unit_functions then Test.test_unit_functions m; - (* Test the unit functions with the concrete interpreter *) - if !test_unit_functions then Test.test_unit_functions m; - - (* Translate the functions *) - Aeneas.Translate.translate_crate filename dest_dir m; + (* Translate the functions *) + Aeneas.Translate.translate_crate filename dest_dir m + with Errors.CFailure msg -> + (* In theory it shouldn't happen, but there may be uncaught errors - + note that we let the Failure errors go through *) + (* The error should have been saved *) + let meta = + match !Errors.error_list with + | (m, _) :: _ -> m + | _ -> (* Want to be safe here *) None + in + let msg = + match meta with + | None -> msg + | Some m -> Errors.format_error_message m msg + in + log#serror msg; + exit 1); (* Print total elapsed time *) log#linfo |