Prechádzať zdrojové kódy

added module imports, added imports in generated proxys.

Nicolas Cannasse 19 rokov pred
rodič
commit
a694ce819e
2 zmenil súbory, kde vykonal 10 pridanie a 3 odobranie
  1. 1 0
      type.ml
  2. 9 3
      typer.ml

+ 1 - 0
type.ml

@@ -145,6 +145,7 @@ and module_type =
 type module_def = {
 type module_def = {
 	mpath : module_path;		
 	mpath : module_path;		
 	mtypes : module_type list;
 	mtypes : module_type list;
+	mutable mimports : module_def list;
 }
 }
 
 
 let mk e t p = { eexpr = e; etype = t; epos = p }
 let mk e t p = { eexpr = e; etype = t; epos = p }

+ 9 - 3
typer.ml

@@ -105,6 +105,7 @@ let context warn =
 	let empty =	{
 	let empty =	{
 		mpath = [] , "";
 		mpath = [] , "";
 		mtypes = [];
 		mtypes = [];
+		mimports = [];
 	} in
 	} in
 	let ctx = {
 	let ctx = {
 		modules = Hashtbl.create 0;
 		modules = Hashtbl.create 0;
@@ -407,7 +408,9 @@ let extend_remoting ctx c t p async =
 			error "Remoting type parameter should be a class" p
 			error "Remoting type parameter should be a class" p
 	) in
 	) in
 	let class_decl = (EClass (t.tname,None,[],[],class_fields),p) in
 	let class_decl = (EClass (t.tname,None,[],[],class_fields),p) in
-	let m = (!type_module_ref) ctx ("Remoting" :: t.tpackage,t.tname) [class_decl] p in
+	let m = (try Hashtbl.find ctx2.modules (t.tpackage,t.tname) with Not_found -> assert false) in
+	let mdecl = (List.map (fun m -> (EImport m.mpath,p)) m.mimports) @ [class_decl] in
+	let m = (!type_module_ref) ctx ("Remoting" :: t.tpackage,t.tname) mdecl p in
 	c.cl_super <- Some (match m.mtypes with
 	c.cl_super <- Some (match m.mtypes with
 		| [TClassDecl c] -> (c,[])
 		| [TClassDecl c] -> (c,[])
 		| _ -> assert false
 		| _ -> assert false
@@ -1881,6 +1884,7 @@ let type_module ctx m tdecls loadp =
 	let m = {
 	let m = {
 		mpath = m;
 		mpath = m;
 		mtypes = List.rev !decls;
 		mtypes = List.rev !decls;
+		mimports = [];
 	} in
 	} in
 	Hashtbl.add ctx.modules m.mpath m;
 	Hashtbl.add ctx.modules m.mpath m;
 	(* PASS 2 : build types structure - does not type any expression ! *)
 	(* PASS 2 : build types structure - does not type any expression ! *)
@@ -1937,8 +1941,9 @@ let type_module ctx m tdecls loadp =
 	List.iter (fun (d,p) ->
 	List.iter (fun (d,p) ->
 		match d with
 		match d with
 		| EImport t ->
 		| EImport t ->
-			let m = load ctx t p in
-			ctx.local_types <- ctx.local_types @ (List.filter (fun t -> not (t_private t)) m.mtypes)
+			let md = load ctx t p in
+			m.mimports <- md :: m.mimports;
+			ctx.local_types <- ctx.local_types @ (List.filter (fun t -> not (t_private t)) md.mtypes)
 		| EClass (name,_,_,herits,fields) ->
 		| EClass (name,_,_,herits,fields) ->
 			let c = get_class name in
 			let c = get_class name in
 			delays := !delays @ check_overloading c p :: check_interfaces c p :: init_class ctx c p herits fields
 			delays := !delays @ check_overloading c p :: check_interfaces c p :: init_class ctx c p herits fields
@@ -1975,6 +1980,7 @@ let type_module ctx m tdecls loadp =
 	) tdecls;
 	) tdecls;
 	(* PASS 3 : type checking, delayed until all modules and types are built *)
 	(* PASS 3 : type checking, delayed until all modules and types are built *)
 	ctx.delays := !delays :: !(ctx.delays);
 	ctx.delays := !delays :: !(ctx.delays);
+	m.mimports <- List.rev m.mimports;
 	m
 	m
 
 
 let load ctx m p =
 let load ctx m p =