瀏覽代碼

small toplevel collector cleanup (is going to help with #6341)

Simon Krajewski 8 年之前
父節點
當前提交
a7d5cead5c
共有 1 個文件被更改,包括 13 次插入12 次删除
  1. 13 12
      src/display/display.ml

+ 13 - 12
src/display/display.ml

@@ -786,19 +786,20 @@ module ToplevelCollector = struct
 
 
 	let run ctx only_types =
 	let run ctx only_types =
 		let acc = DynArray.create () in
 		let acc = DynArray.create () in
+		let add x = DynArray.add acc x in
 
 
 		if not only_types then begin
 		if not only_types then begin
 			(* locals *)
 			(* locals *)
 			PMap.iter (fun _ v ->
 			PMap.iter (fun _ v ->
 				if not (is_gen_local v) then
 				if not (is_gen_local v) then
-					DynArray.add acc (ITLocal v)
+					add (ITLocal v)
 			) ctx.locals;
 			) ctx.locals;
 
 
 			(* member vars *)
 			(* member vars *)
 			if ctx.curfun <> FunStatic then begin
 			if ctx.curfun <> FunStatic then begin
 				let rec loop c =
 				let rec loop c =
 					List.iter (fun cf ->
 					List.iter (fun cf ->
-						DynArray.add acc (ITMember(ctx.curclass,cf))
+						add (ITMember(ctx.curclass,cf))
 					) c.cl_ordered_fields;
 					) c.cl_ordered_fields;
 					match c.cl_super with
 					match c.cl_super with
 						| None ->
 						| None ->
@@ -812,7 +813,7 @@ module ToplevelCollector = struct
 
 
 			(* statics *)
 			(* statics *)
 			List.iter (fun cf ->
 			List.iter (fun cf ->
-				DynArray.add acc (ITStatic(ctx.curclass,cf))
+				add (ITStatic(ctx.curclass,cf))
 			) ctx.curclass.cl_ordered_statics;
 			) ctx.curclass.cl_ordered_statics;
 
 
 			(* enum constructors *)
 			(* enum constructors *)
@@ -820,7 +821,7 @@ module ToplevelCollector = struct
 				match t with
 				match t with
 				| TAbstractDecl ({a_impl = Some c} as a) when Meta.has Meta.Enum a.a_meta ->
 				| TAbstractDecl ({a_impl = Some c} as a) when Meta.has Meta.Enum a.a_meta ->
 					List.iter (fun cf ->
 					List.iter (fun cf ->
-						if (Meta.has Meta.Enum cf.cf_meta) then DynArray.add acc (ITEnumAbstract(a,cf));
+						if (Meta.has Meta.Enum cf.cf_meta) then add (ITEnumAbstract(a,cf));
 					) c.cl_ordered_statics
 					) c.cl_ordered_statics
 				| TClassDecl _ | TAbstractDecl _ ->
 				| TClassDecl _ | TAbstractDecl _ ->
 					()
 					()
@@ -831,7 +832,7 @@ module ToplevelCollector = struct
 					end
 					end
 				| TEnumDecl e ->
 				| TEnumDecl e ->
 					PMap.iter (fun _ ef ->
 					PMap.iter (fun _ ef ->
-						DynArray.add acc (ITEnum(e,ef))
+						add (ITEnum(e,ef))
 					) e.e_constrs;
 					) e.e_constrs;
 			in
 			in
 			List.iter enum_ctors ctx.m.curmod.m_types;
 			List.iter enum_ctors ctx.m.curmod.m_types;
@@ -846,15 +847,15 @@ module ToplevelCollector = struct
 						| TAbstractDecl {a_impl = Some c} -> (PMap.find s c.cl_statics).cf_type
 						| TAbstractDecl {a_impl = Some c} -> (PMap.find s c.cl_statics).cf_type
 						| _ -> raise Not_found
 						| _ -> raise Not_found
 					in
 					in
-					DynArray.add acc (ITGlobal(mt,s,t))
+					add (ITGlobal(mt,s,t))
 				with Not_found ->
 				with Not_found ->
 					()
 					()
 			) ctx.m.module_globals;
 			) ctx.m.module_globals;
 
 
 			(* literals *)
 			(* literals *)
-			DynArray.add acc (ITLiteral "null");
-			DynArray.add acc (ITLiteral "true");
-			DynArray.add acc (ITLiteral "false");
+			add (ITLiteral "null");
+			add (ITLiteral "true");
+			add (ITLiteral "false");
 		end;
 		end;
 
 
 		let module_types = ref [] in
 		let module_types = ref [] in
@@ -906,16 +907,16 @@ module ToplevelCollector = struct
 		explore_class_paths ctx class_paths false add_package (fun _ -> ()) add_type;
 		explore_class_paths ctx class_paths false add_package (fun _ -> ()) add_type;
 
 
 		List.iter (fun pack ->
 		List.iter (fun pack ->
-			DynArray.add acc (ITPackage pack)
+			add (ITPackage pack)
 		) !packages;
 		) !packages;
 
 
 		List.iter (fun mt ->
 		List.iter (fun mt ->
-			DynArray.add acc (ITType mt)
+			add (ITType mt)
 		) !module_types;
 		) !module_types;
 
 
 		(* type params *)
 		(* type params *)
 		List.iter (fun (_,t) ->
 		List.iter (fun (_,t) ->
-			DynArray.add acc (ITType (module_type_of_type t))
+			add (ITType (module_type_of_type t))
 		) ctx.type_params;
 		) ctx.type_params;
 
 
 		DynArray.to_list acc
 		DynArray.to_list acc