Browse Source

Revert "add optional argument to ECheckType (closes #1935)"

This reverts commit 4b09d14680ca867ffe15809645e36848736d58b2.
Simon Krajewski 12 years ago
parent
commit
a271fc7b5c
7 changed files with 20 additions and 23 deletions
  1. 2 2
      ast.ml
  2. 4 4
      interp.ml
  3. 1 1
      matcher.ml
  4. 1 1
      optimizer.ml
  5. 9 9
      parser.ml
  6. 1 1
      std/haxe/macro/Expr.hx
  7. 2 5
      typer.ml

+ 2 - 2
ast.ml

@@ -314,7 +314,7 @@ and expr_def =
 	| EDisplay of expr * bool
 	| EDisplayNew of type_path
 	| ETernary of expr * expr * expr
-	| ECheckType of expr * complex_type * string option
+	| ECheckType of expr * complex_type
 	| EMeta of metadata_entry * expr
 
 and expr = expr_def * pos
@@ -677,7 +677,7 @@ let map_expr loop (e,p) =
 	| EDisplay (e,f) -> EDisplay (loop e,f)
 	| EDisplayNew t -> EDisplayNew (tpath t)
 	| ETernary (e1,e2,e3) -> ETernary (loop e1,loop e2,loop e3)
-	| ECheckType (e,t,so) -> ECheckType (loop e, ctype t,so)
+	| ECheckType (e,t) -> ECheckType (loop e, ctype t)
 	| EMeta (m,e) -> EMeta(m, loop e)
 	) in
 	(e,p)

+ 4 - 4
interp.ml

@@ -3749,8 +3749,8 @@ and encode_expr e =
 				26, [encode_path t]
 			| ETernary (econd,e1,e2) ->
 				27, [loop econd;loop e1;loop e2]
-			| ECheckType (e,t,so) ->
-				28, [loop e; encode_ctype t;null enc_string so]
+			| ECheckType (e,t) ->
+				28, [loop e; encode_ctype t]
 			| EMeta (m,e) ->
 				29, [encode_meta_entry m;loop e]
 		in
@@ -4012,8 +4012,8 @@ let rec decode_expr v =
 			EDisplayNew (decode_path t)
 		| 27, [e1;e2;e3] ->
 			ETernary (loop e1,loop e2,loop e3)
-		| 28, [e;t;so] ->
-			ECheckType (loop e, decode_ctype t, opt dec_string so)
+		| 28, [e;t] ->
+			ECheckType (loop e, decode_ctype t)
 		| 29, [m;e] ->
 			EMeta (decode_meta_entry m,loop e)
 		| 30, [e;f] ->

+ 1 - 1
matcher.ml

@@ -303,7 +303,7 @@ let to_pattern ctx e t =
 	let rec loop pctx e t =
 		let p = pos e in
 		match fst e with
-		| ECheckType(e, CTPath({tpackage=["haxe";"macro"]; tname="Expr"}), _) ->
+		| ECheckType(e, CTPath({tpackage=["haxe";"macro"]; tname="Expr"})) ->
 			let old = pctx.pc_reify in
 			pctx.pc_reify <- true;
 			let e = loop pctx e t in

+ 1 - 1
optimizer.ml

@@ -1221,7 +1221,7 @@ let optimize_completion_expr e =
 					let p = snd e in
 					(try
 						(match PMap.find n locals.r with
-						| Some t , _ -> (ECheckType ((EConst (Ident "null"),p),t,None),p)
+						| Some t , _ -> (ECheckType ((EConst (Ident "null"),p),t),p)
 						| _, Some (id,e,lc) ->
 							let name = (try
 								PMap.find id (!tmp_hlocals)

+ 9 - 9
parser.ml

@@ -398,8 +398,8 @@ let reify in_macro =
 			expr "EDisplayNew" [to_tpath t p]
 		| ETernary (e1,e2,e3) ->
 			expr "ETernary" [loop e1;loop e2;loop e3]
-		| ECheckType (e1,ct,so) ->
-			expr "ECheckType" [loop e1; to_ctype ct p;to_opt to_string so p]
+		| ECheckType (e1,ct) ->
+			expr "ECheckType" [loop e1; to_ctype ct p]
 		| EMeta ((m,ml,p),e1) ->
 			match m, ml with
 			| Meta.Dollar ("" | "e"), _ ->
@@ -411,9 +411,9 @@ let reify in_macro =
 			(* TODO: can $v and $i be implemented better? *)
 			| Meta.Dollar "v", _ ->
 				begin match fst e1 with
-				| EParenthesis (ECheckType (e2, CTPath{tname="String";tpackage=[]},_),_) -> expr "EConst" [mk_enum "Constant" "CString" [e2] (pos e2)]
-				| EParenthesis (ECheckType (e2, CTPath{tname="Int";tpackage=[]},_),_) -> expr "EConst" [mk_enum "Constant" "CInt" [e2] (pos e2)]
-				| EParenthesis (ECheckType (e2, CTPath{tname="Float";tpackage=[]},_),_) -> expr "EConst" [mk_enum "Constant" "CFloat" [e2] (pos e2)]
+				| EParenthesis (ECheckType (e2, CTPath{tname="String";tpackage=[]}),_) -> expr "EConst" [mk_enum "Constant" "CString" [e2] (pos e2)]
+				| EParenthesis (ECheckType (e2, CTPath{tname="Int";tpackage=[]}),_) -> expr "EConst" [mk_enum "Constant" "CInt" [e2] (pos e2)]
+				| EParenthesis (ECheckType (e2, CTPath{tname="Float";tpackage=[]}),_) -> expr "EConst" [mk_enum "Constant" "CFloat" [e2] (pos e2)]
 				| _ -> (ECall ((EField ((EField ((EField ((EConst (Ident "haxe"),p),"macro"),p),"Context"),p),"makeExpr"),p),[e; to_pos (pos e)]),p)
 				end
 			| Meta.Dollar "i", _ ->
@@ -1076,18 +1076,18 @@ and inline_function = parser
 and reify_expr e =
 	let to_expr,_,_ = reify !in_macro in
 	let e = to_expr e in
-	(ECheckType (e,(CTPath { tpackage = ["haxe";"macro"]; tname = "Expr"; tsub = None; tparams = [] }),None),pos e)
+	(ECheckType (e,(CTPath { tpackage = ["haxe";"macro"]; tname = "Expr"; tsub = None; tparams = [] })),pos e)
 
 and parse_macro_expr p = parser
 	| [< '(DblDot,_); t = parse_complex_type >] ->
 		let _, to_type, _  = reify !in_macro in
 		let t = to_type t p in
-		(ECheckType (t,(CTPath { tpackage = ["haxe";"macro"]; tname = "Expr"; tsub = Some "ComplexType"; tparams = [] }),None),p)
+		(ECheckType (t,(CTPath { tpackage = ["haxe";"macro"]; tname = "Expr"; tsub = Some "ComplexType"; tparams = [] })),p)
 	| [< '(Kwd Var,p1); vl = psep Comma parse_var_decl >] ->
 		reify_expr (EVars vl,p1)
 	| [< d = parse_class None [] [] false >] ->
 		let _,_,to_type = reify !in_macro in
-		(ECheckType (to_type d,(CTPath { tpackage = ["haxe";"macro"]; tname = "Expr"; tsub = Some "TypeDefinition"; tparams = [] }),None),p)
+		(ECheckType (to_type d,(CTPath { tpackage = ["haxe";"macro"]; tname = "Expr"; tsub = Some "TypeDefinition"; tparams = [] })),p)
 	| [< e = secure_expr >] ->
 		reify_expr e
 
@@ -1126,7 +1126,7 @@ and expr = parser
 		| [< >] -> serror())
 	| [< '(POpen,p1); e = expr; s >] -> (match s with parser
 		| [< '(PClose,p2); s >] -> expr_next (EParenthesis e, punion p1 p2) s
-		| [< '(DblDot,_); t = parse_complex_type; '(PClose,p2); s >] -> expr_next (EParenthesis (ECheckType(e,t,None),punion p1 p2), punion p1 p2) s)
+		| [< '(DblDot,_); t = parse_complex_type; '(PClose,p2); s >] -> expr_next (EParenthesis (ECheckType(e,t),punion p1 p2), punion p1 p2) s)
 	| [< '(BkOpen,p1); l = parse_array_decl; '(BkClose,p2); s >] -> expr_next (EArrayDecl l, punion p1 p2) s
 	| [< inl, p1 = inline_function; name = popt dollar_ident; pl = parse_constraint_params; '(POpen,_); al = psep Comma parse_fun_param; '(PClose,_); t = parse_type_opt; s >] ->
 		let make e =

+ 1 - 1
std/haxe/macro/Expr.hx

@@ -129,7 +129,7 @@ enum ExprDef {
 	EDisplay( e : Expr, isCall : Bool );
 	EDisplayNew( t : TypePath );
 	ETernary( econd : Expr, eif : Expr, eelse : Expr );
-	ECheckType( e : Expr, t : ComplexType, ?message : Null<String> );
+	ECheckType( e : Expr, t : ComplexType );
 	EMeta( s : MetadataEntry, e : Expr );
 }
 

+ 2 - 5
typer.ml

@@ -3004,14 +3004,11 @@ and type_expr ctx (e,p) (with_type:with_type) =
 			raise (DisplayTypes (ct :: List.map (fun f -> f.cf_type) f.cf_overloads))
 		| _ ->
 			error "Not a class" p)
-	| ECheckType (e,t,so) ->
+	| ECheckType (e,t) ->
 		let t = Typeload.load_complex_type ctx p t in
 		let e = type_expr ctx e (WithType t) in
 		let e = Codegen.Abstract.check_cast ctx t e p in
-		begin match so with
-			| None -> unify ctx e.etype t e.epos
-			| Some s -> try unify_raise ctx e.etype t e.epos with Error(Unify _,p) -> error s p
-		end;
+		unify ctx e.etype t e.epos;
 		if e.etype == t then e else mk (TCast (e,None)) t p
 	| EMeta (m,e) ->
 		let old = ctx.meta in