Browse Source

Float/Int/Void cleanup

Simon Krajewski 12 years ago
parent
commit
8ea59bf552
3 changed files with 6 additions and 25 deletions
  1. 4 9
      optimizer.ml
  2. 0 6
      type.ml
  3. 2 10
      typer.ml

+ 4 - 9
optimizer.ml

@@ -194,7 +194,7 @@ let rec type_inline ctx cf f ethis params tret config p force =
 	let in_local_fun = ref false in
 	let cancel_inlining = ref false in
 	let has_return_value = ref false in
-	let ret_val = (match follow f.tf_type with TEnum ({ e_path = ([],"Void") },[]) | TAbstract ({ a_path = ([],"Void") },[]) -> false | _ -> true) in
+	let ret_val = (match follow f.tf_type with TAbstract ({ a_path = ([],"Void") },[]) -> false | _ -> true) in
 	let rec map term e =
 		let po = e.epos in
 		let e = { e with epos = p } in
@@ -382,7 +382,7 @@ let rec type_inline ctx cf f ethis params tret config p force =
 				(match follow e.etype with
 				| TMono _ ->
 					(match follow tret with
-					| TEnum ({ e_path = [],"Void" },_) | TAbstract ({ a_path = [],"Void" },_) -> e
+					| TAbstract ({ a_path = [],"Void" },_) -> e
 					| _ -> raise (Unify_error []))
 				| _ -> try
 					type_eq EqStrict etype tret;
@@ -515,7 +515,7 @@ let rec optimize_for_loop ctx i e1 e2 p =
 			force locals to be of Int type (to prevent Int/UInt issues)
 		*)
 		let i2 = match i2.etype with
-			| TInst({ cl_path = ([],"Int") }, []) | TAbstract ({ a_path = ([],"Int") }, []) -> i2
+			| TAbstract ({ a_path = ([],"Int") }, []) -> i2
 			| _ -> { i2 with eexpr = TCast(i2, None); etype = t_int }
 		in
 		(match max with
@@ -608,9 +608,6 @@ let rec need_parent e =
 let rec add_final_return e t =
 	let def_return p =
 		let c = (match follow t with
-			| TInst ({ cl_path = [],"Int" },_) -> TInt 0l
-			| TInst ({ cl_path = [],"Float" },_) -> TFloat "0."
-			| TEnum ({ e_path = [],"Bool" },_) -> TBool false
 			| TAbstract ({ a_path = [],"Int" },_) -> TInt 0l
 			| TAbstract ({ a_path = [],"Float" },_) -> TFloat "0."
 			| TAbstract ({ a_path = [],"Bool" },_) -> TBool false
@@ -706,7 +703,7 @@ let sanitize_expr com e =
 		{ e with eexpr = TFor (v,e1,e2) }
 	| TFunction f ->
 		let f = (match follow f.tf_type with
-			| TEnum ({ e_path = [],"Void" },[]) | TAbstract ({ a_path = [],"Void" },[]) -> f
+			| TAbstract ({ a_path = [],"Void" },[]) -> f
 			| t ->
 				if com.config.pf_add_final_return then { f with tf_expr = add_final_return f.tf_expr t } else f
 		) in
@@ -781,13 +778,11 @@ let rec reduce_loop ctx e =
 	let is_float t =
 		match follow t with
 		| TAbstract({ a_path = [],"Float" },_) -> true
-		| TInst ({ cl_path = ([],"Float") },_) -> true
 		| _ -> false
 	in
 	let is_numeric t =
 		match follow t with
 		| TAbstract({ a_path = [],("Float"|"Int") },_) -> true
-		| TInst ({ cl_path = ([],("Float" | "Int")) },_) -> true
 		| _ -> false
 	in
 	let e = Type.map_expr (reduce_loop ctx) e in

+ 0 - 6
type.ml

@@ -444,8 +444,6 @@ and s_fun ctx t void =
 	match t with
 	| TFun _ ->
 		"(" ^ s_type ctx t ^ ")"
-	| TEnum ({ e_path = ([],"Void") },[]) when void ->
-		"(" ^ s_type ctx t ^ ")"
 	| TAbstract ({ a_path = ([],"Void") },[]) when void ->
 		"(" ^ s_type ctx t ^ ")"
 	| TMono r ->
@@ -620,10 +618,6 @@ let rec is_nullable ?(no_lazy=false) = function
 
 	| TInst ({ cl_kind = KTypeParameter },_) -> false
 *)
-	| TInst ({ cl_path = (["haxe"],"Int32") },[])
-	| TInst ({ cl_path = ([],"Int") },[])
-	| TInst ({ cl_path = ([],"Float") },[])
-	| TEnum ({ e_path = ([],"Bool") },[]) -> false
 	| TAbstract (a,_) -> not (Meta.has Meta.NotNull a.a_meta)
 	| _ ->
 		true

+ 2 - 10
typer.ml

@@ -83,8 +83,6 @@ type type_class =
 
 let rec classify t =
 	match follow t with
-	| TInst ({ cl_path = ([],"Int") },[]) -> KInt
-	| TInst ({ cl_path = ([],"Float") },[]) -> KFloat
 	| TInst ({ cl_path = ([],"String") },[]) -> KString
 	| TAbstract({a_impl = Some _} as a,_) -> KAbstract a
 	| TAbstract ({ a_path = [],"Int" },[]) -> KInt
@@ -4105,15 +4103,9 @@ let rec create com =
 			| "Bool" -> ctx.t.tbool <- TAbstract (a,[])
 			| _ -> ());
 		| TEnumDecl e ->
-			(match snd e.e_path with
-			| "Void" -> ctx.t.tvoid <- TEnum (e,[])
-			| "Bool" -> ctx.t.tbool <- TEnum (e,[])
-			| _ -> ())
+			()
 		| TClassDecl c ->
-			(match snd c.cl_path with
-			| "Float" -> ctx.t.tfloat <- TInst (c,[])
-			| "Int" -> ctx.t.tint <- TInst (c,[])
-			| _ -> ())
+			()
 		| TTypeDecl td ->
 			(match snd td.t_path with
 			| "Null" ->