瀏覽代碼

add Context.fatalError (closes #1936)

Simon Krajewski 12 年之前
父節點
當前提交
68fb859011
共有 2 個文件被更改,包括 14 次插入0 次删除
  1. 6 0
      interp.ml
  2. 8 0
      std/haxe/macro/Context.hx

+ 6 - 0
interp.ml

@@ -2050,6 +2050,12 @@ let macro_lib =
 				raise Abort
 				raise Abort
 			| _ -> error()
 			| _ -> error()
 		);
 		);
+		"fatal_error", Fun2 (fun msg p ->
+			match msg, p with
+			| VString s, VAbstract (APos p) ->
+				raise (Typecore.Fatal_error (s,p))
+			| _ -> error()
+		);		
 		"warning", Fun2 (fun msg p ->
 		"warning", Fun2 (fun msg p ->
 			match msg, p with
 			match msg, p with
 			| VString s, VAbstract (APos p) ->
 			| VString s, VAbstract (APos p) ->

+ 8 - 0
std/haxe/macro/Context.hx

@@ -45,6 +45,14 @@ class Context {
 	public static function error( msg : String, pos : Position ) : Dynamic {
 	public static function error( msg : String, pos : Position ) : Dynamic {
 		return load("error",2)(untyped msg.__s, pos);
 		return load("error",2)(untyped msg.__s, pos);
 	}
 	}
+	
+	/**
+		Displays a compilation error `msg` at the given `Position` `pos`
+		and aborts the compilation.
+	**/
+	public static function fatalError( msg : String, pos : Position ) : Dynamic {
+		return load("fatal_error",2)(untyped msg.__s, pos);
+	}
 
 
 	/**
 	/**
 		Displays a compilation warning `msg` at the given `Position` `pos`.
 		Displays a compilation warning `msg` at the given `Position` `pos`.