Nicolas Cannasse 13 rokov pred
rodič
commit
5140df2c17
4 zmenil súbory, kde vykonal 10 pridanie a 7 odobranie
  1. 2 2
      main.ml
  2. 4 1
      type.ml
  3. 1 1
      typeload.ml
  4. 3 3
      typer.ml

+ 2 - 2
main.ml

@@ -417,7 +417,7 @@ and wait_loop boot_com host port =
 				let m = Hashtbl.find cache.c_modules (m.m_path,m.m_extra.m_sign) in
 				if m.m_extra.m_kind <> MFake && m.m_extra.m_file <> Common.get_full_path (Typeload.resolve_module_file com2 m.m_path (ref[]) p) then raise Not_found;
 				if file_time m.m_extra.m_file <> m.m_extra.m_time then raise Not_found;
-				PMap.iter (fun m2 _ -> if not (check m2) then begin dep := Some m2; raise Not_found end) m.m_extra.m_deps;
+				PMap.iter (fun _ m2 -> if not (check m2) then begin dep := Some m2; raise Not_found end) m.m_extra.m_deps;
 				true
 			with Not_found ->
 				Hashtbl.add added m.m_id false;
@@ -436,7 +436,7 @@ and wait_loop boot_com host port =
 				| _ ->
 					if verbose then print_endline ("Reusing  cached module " ^ Ast.s_type_path m.m_path);
 					Typeload.add_module ctx m p;
-					PMap.iter (fun m2 _ -> add_modules m0 m2) m.m_extra.m_deps);
+					PMap.iter (fun _ m2 -> add_modules m0 m2) m.m_extra.m_deps);
 			end
 		in
 		try

+ 4 - 1
type.ml

@@ -235,7 +235,7 @@ and module_def_extra = {
 	m_file : string;
 	m_sign : string;
 	m_time : float;
-	mutable m_deps : (module_def,unit) PMap.t;
+	mutable m_deps : (int,module_def) PMap.t;
 	mutable m_processed : int;
 	mutable m_kind : module_kind;
 }
@@ -315,6 +315,9 @@ let null_class =
 	c.cl_private <- true;
 	c
 
+let add_dependency m mdep =
+	m.m_extra.m_deps <- PMap.add mdep.m_id mdep m.m_extra.m_deps
+
 let arg_name (a,_) = a.v_name
 
 let t_infos t : tinfos =

+ 1 - 1
typeload.ml

@@ -1458,5 +1458,5 @@ let load_module ctx m p =
 			) in
 			type_module ctx m file decls p
 	) in
-	ctx.current.m_extra.m_deps <- PMap.add m2 () ctx.current.m_extra.m_deps;
+	add_dependency ctx.current m2;
 	m2

+ 3 - 3
typer.ml

@@ -2375,7 +2375,7 @@ let make_macro_api ctx p =
 			let m, tdef, pos = (try Interp.decode_type_def v with Interp.Invalid_expr -> Interp.exc (Interp.VString "Invalid type definition")) in
 			let mdep = Typeload.type_module ctx m ctx.current.m_extra.m_file [tdef,pos] pos in
 			mdep.m_extra.m_kind <- MFake;
-			ctx.current.m_extra.m_deps <- PMap.add mdep () ctx.current.m_extra.m_deps;
+			add_dependency ctx.current mdep;
 		);
 		Interp.module_dependency = (fun mpath file ->
 			let m = typing_timer ctx (fun() -> Typeload.load_module ctx (parse_path mpath) p) in
@@ -2397,7 +2397,7 @@ let make_macro_api ctx p =
 				Hashtbl.add fake_modules file mdep;
 				mdep
 			) in
-			m.m_extra.m_deps <- PMap.add mdep () m.m_extra.m_deps;
+			add_dependency m mdep;
 			Hashtbl.replace ctx.g.modules mdep.m_path mdep
 		);
 	}
@@ -2453,7 +2453,7 @@ let load_macro ctx cpath f p =
 	let m = (try Hashtbl.find ctx.g.types_module cpath with Not_found -> cpath) in
 	let mloaded = Typeload.load_module ctx2 m p in
 	ctx2.local_types <- mloaded.m_types;
-	ctx.current.m_extra.m_deps <- PMap.add mloaded () ctx.current.m_extra.m_deps;
+	add_dependency ctx.current mloaded;
 	let meth = (match Typeload.load_instance ctx2 { tpackage = fst cpath; tname = snd cpath; tparams = []; tsub = None } p true with
 		| TInst (c,_) -> (try PMap.find f c.cl_statics with Not_found -> error ("Method " ^ f ^ " not found on class " ^ s_type_path cpath) p)
 		| _ -> error "Macro should be called on a class" p