瀏覽代碼

[js] only lookup js.Boot.HaxeError when TThrow is detected

Dan Korostelev 10 年之前
父節點
當前提交
b703429a3d
共有 1 個文件被更改,包括 2 次插入4 次删除
  1. 2 4
      filters.ml

+ 2 - 4
filters.ml

@@ -140,19 +140,17 @@ let rec add_final_return e =
 		| _ -> e
 		| _ -> e
 
 
 let rec wrap_js_exceptions com e =
 let rec wrap_js_exceptions com e =
-	let terr = List.find (fun mt -> match mt with TClassDecl {cl_path = ["js";"_Boot"],"HaxeError"} -> true | _ -> false) com.types in
-	let cerr = match terr with TClassDecl c -> c | _ -> assert false in
-
 	let rec is_error t =
 	let rec is_error t =
 		match follow t with
 		match follow t with
 		| TInst ({cl_path = (["js"],"Error")},_) -> true
 		| TInst ({cl_path = (["js"],"Error")},_) -> true
 		| TInst ({cl_super = Some (csup,tl)}, _) -> is_error (TInst (csup,tl))
 		| TInst ({cl_super = Some (csup,tl)}, _) -> is_error (TInst (csup,tl))
 		| _ -> false
 		| _ -> false
 	in
 	in
-
 	let rec loop e =
 	let rec loop e =
 		match e.eexpr with
 		match e.eexpr with
 		| TThrow eerr when not (is_error eerr.etype) ->
 		| TThrow eerr when not (is_error eerr.etype) ->
+			let terr = List.find (fun mt -> match mt with TClassDecl {cl_path = ["js";"_Boot"],"HaxeError"} -> true | _ -> false) com.types in
+			let cerr = match terr with TClassDecl c -> c | _ -> assert false in
 			let ewrap = { eerr with eexpr = TNew (cerr,[],[eerr]) } in
 			let ewrap = { eerr with eexpr = TNew (cerr,[],[eerr]) } in
 			{ e with eexpr = TThrow ewrap }
 			{ e with eexpr = TThrow ewrap }
 		| _ ->
 		| _ ->