Sfoglia il codice sorgente

don't set error flag when custom interp error

Nicolas Cannasse 14 anni fa
parent
commit
dd3f201a80
2 ha cambiato i file con 6 aggiunte e 2 eliminazioni
  1. 3 2
      interp.ml
  2. 3 0
      typer.ml

+ 3 - 2
interp.ml

@@ -86,6 +86,7 @@ type cmp =
 
 type extern_api = {
 	pos : Ast.pos;
+	on_error : string -> Ast.pos -> bool -> unit;
 	define : string -> unit;
 	defined : string -> bool;
 	get_type : string -> Type.t option;
@@ -1690,12 +1691,12 @@ let macro_lib =
 		"curpos", Fun0 (fun() -> VAbstract (APos (get_ctx()).curapi.pos));
 		"error", Fun2 (fun msg p ->
 			match msg, p with
-			| VString s, VAbstract (APos p) -> (get_ctx()).com.Common.error s p; raise Abort
+			| VString s, VAbstract (APos p) -> (get_ctx()).curapi.on_error s p false; raise Abort
 			| _ -> error()
 		);
 		"warning", Fun2 (fun msg p ->
 			match msg, p with
-			| VString s, VAbstract (APos p) -> (get_ctx()).com.Common.warning s p; VNull;
+			| VString s, VAbstract (APos p) -> (get_ctx()).curapi.on_error s p true; VNull;
 			| _ -> error()
 		);
 		"class_path", Fun0 (fun() ->

+ 3 - 0
typer.ml

@@ -2108,6 +2108,9 @@ let make_macro_api ctx p =
 	in
 	{
 		Interp.pos = p;
+		Interp.on_error = (fun msg p warn ->
+			(if warn then ctx.com.warning else ctx.com.error) msg p
+		);
 		Interp.defined = Common.defined ctx.com;
 		Interp.define = Common.define ctx.com;
 		Interp.get_type = (fun s ->