Procházet zdrojové kódy

raise Sys_exit exception from Sys.exit call in interpreter to allow flushing context before actually terminating (was swallowing warnings in optimization unit tests)

Simon Krajewski před 11 roky
rodič
revize
8980bbc30d
2 změnil soubory, kde provedl 5 přidání a 1 odebrání
  1. 2 1
      interp.ml
  2. 3 0
      main.ml

+ 2 - 1
interp.ml

@@ -182,6 +182,7 @@ exception Continue
 exception Break of value
 exception Return of value
 exception Invalid_expr
+exception Sys_exit of int
 
 (* ---------------------------------------------------------------------- *)
 (* UTILS *)
@@ -1648,7 +1649,7 @@ let std_lib =
 		);
 		"sys_exit", Fun1 (fun code ->
 			if (get_ctx()).curapi.use_cache() then raise (Typecore.Fatal_error ("",Ast.null_pos));
-			exit (vint code);
+			raise (Sys_exit(vint code));
 		);
 		"sys_exists", Fun1 (fun file ->
 			VBool (Sys.file_exists (vstring file))

+ 3 - 0
main.ml

@@ -1541,6 +1541,9 @@ with
 				raise (Completion c)
 			| _ ->
 				error ctx ("Could not load module " ^ (Ast.s_type_path (p,c))) Ast.null_pos)
+	| Interp.Sys_exit i ->
+		ctx.flush();
+		exit i
 	| e when (try Sys.getenv "OCAMLRUNPARAM" <> "b" || !global_cache <> None with _ -> true) && not (is_debug_run()) ->
 		error ctx (Printexc.to_string e) Ast.null_pos