Nicolas Cannasse %!s(int64=14) %!d(string=hai) anos
pai
achega
960211fd63
Modificáronse 3 ficheiros con 10 adicións e 1 borrados
  1. 5 1
      parser.ml
  2. 4 0
      std/Std.hx
  3. 1 0
      typeload.ml

+ 5 - 1
parser.ml

@@ -25,6 +25,7 @@ type error_msg =
 	| Unclosed_macro
 	| Unclosed_macro
 	| Unimplemented
 	| Unimplemented
 	| Missing_type
 	| Missing_type
+	| Custom of string
 
 
 exception Error of error_msg * pos
 exception Error of error_msg * pos
 exception TypePath of string list * string option
 exception TypePath of string list * string option
@@ -37,6 +38,7 @@ let error_msg = function
 	| Unclosed_macro -> "Unclosed macro"
 	| Unclosed_macro -> "Unclosed macro"
 	| Unimplemented -> "Not implemented for current platform"
 	| Unimplemented -> "Not implemented for current platform"
 	| Missing_type -> "Missing type declaration"
 	| Missing_type -> "Missing type declaration"
+	| Custom s -> s
 
 
 let error m p = raise (Error (m,p))
 let error m p = raise (Error (m,p))
 let display_error : (error_msg -> pos -> unit) ref = ref (fun _ _ -> assert false)
 let display_error : (error_msg -> pos -> unit) ref = ref (fun _ _ -> assert false)
@@ -743,7 +745,9 @@ let parse ctx code =
 		| Macro "if" ->
 		| Macro "if" ->
 			process_token (enter_macro (snd tk))
 			process_token (enter_macro (snd tk))
 		| Macro "error" ->
 		| Macro "error" ->
-			error Unimplemented (snd tk)
+			(match Lexer.token code with
+			| (Const (String s),p) -> error (Custom s) p
+			| _ -> error Unimplemented (snd tk))
 		| Macro "line" ->
 		| Macro "line" ->
 			let line = (match next_token() with
 			let line = (match next_token() with
 				| (Const (Int s),_) -> int_of_string s
 				| (Const (Int s),_) -> int_of_string s

+ 4 - 0
std/Std.hx

@@ -23,6 +23,10 @@
  * DAMAGE.
  * DAMAGE.
  */
  */
 
 
+#if !core_api
+#error "Please don't add haxe/std to your classpath, instead set HAXE_LIBRARY_PATH env var"
+#end
+
 /**
 /**
 	The Std class provides standard methods for manipulating basic types.
 	The Std class provides standard methods for manipulating basic types.
 **/
 **/

+ 1 - 0
typeload.ml

@@ -540,6 +540,7 @@ let init_core_api ctx c =
 	let ctx2 = (match ctx.g.core_api with
 	let ctx2 = (match ctx.g.core_api with
 		| None ->
 		| None ->
 			let com2 = Common.clone ctx.com in
 			let com2 = Common.clone ctx.com in
+			Common.define com2 "core_api";
 			com2.class_path <- ctx.com.std_path;
 			com2.class_path <- ctx.com.std_path;
 			let ctx2 = ctx.g.do_create com2 in
 			let ctx2 = ctx.g.do_create com2 in
 			ctx.g.core_api <- Some ctx2;
 			ctx.g.core_api <- Some ctx2;