Browse Source

fixed inheritance api : need context for local types

Nicolas Cannasse 17 years ago
parent
commit
aeaaa41881
5 changed files with 3 additions and 4 deletions
  1. 0 2
      common.ml
  2. 1 0
      main.ml
  3. 1 0
      typecore.ml
  4. 1 1
      typeload.ml
  5. 0 1
      typer.ml

+ 0 - 2
common.ml

@@ -44,7 +44,6 @@ type context_type_api = {
 	(* api *)
 	mutable load_module : path -> pos -> module_def;
 	mutable build_instance : module_type -> pos -> ((string * t) list * path * (t list -> t));
-	mutable on_inherit : tclass -> pos -> Ast.class_flag -> bool;
 	mutable on_generate : module_type -> unit;
 	mutable get_type_module : module_type -> module_def;
 }
@@ -97,7 +96,6 @@ let create() =
 			tarray = (fun _ -> assert false);
 			load_module = (fun _ _ -> assert false);
 			build_instance = (fun _ _ -> assert false);
-			on_inherit = (fun _ _ _ -> true);
 			on_generate = (fun _ -> ());
 			get_type_module = (fun _ -> assert false);
 		};

+ 1 - 0
main.ml

@@ -392,6 +392,7 @@ try
 		if com.verbose then print_endline ("Classpath : " ^ (String.concat ";" com.class_path));
 		let t = Common.timer "typing" in
 		Typecore.type_expr_ref := (fun ctx e need_val -> Typer.type_expr ~need_val ctx e);
+		Typecore.build_inheritance := Codegen.on_inherit;
 		let ctx = Typer.create com in		
 		List.iter (fun cpath -> ignore(com.type_api.load_module cpath Ast.null_pos)) (List.rev !classes);
 		Typer.finalize ctx;

+ 1 - 0
typecore.ml

@@ -64,6 +64,7 @@ type error_msg =
 exception Error of error_msg * pos
 
 let type_expr_ref : (typer -> Ast.expr -> bool -> texpr) ref = ref (fun _ _ _ -> assert false)
+let build_inheritance : (typer -> Type.tclass -> Ast.pos -> Ast.class_flag -> bool) ref = ref (fun _ _ _ _ -> true)
 
 let unify_error_msg ctx = function
 	| Cannot_unify (t1,t2) ->

+ 1 - 1
typeload.ml

@@ -374,7 +374,7 @@ let set_heritance ctx c herits p =
 				c.cl_dynamic <- Some t
 			| _ -> error "Should implement by using an interface or a class" p)
 	in
-	List.iter loop (List.filter (ctx.api.on_inherit c p) herits)
+	List.iter loop (List.filter ((!build_inheritance) ctx c p) herits)
 
 let type_type_params ctx path p (n,flags) =
 	let c = mk_class (fst path @ [snd path],n) p None false in

+ 0 - 1
typer.ml

@@ -1867,7 +1867,6 @@ let create com =
 	} in
 	ctx.api.load_module <- Typeload.load_module ctx;
 	ctx.api.build_instance <- Codegen.build_instance ctx;
-	ctx.api.on_inherit <- Codegen.on_inherit ctx;
 	ctx.api.on_generate <- Codegen.on_generate ctx;
 	ctx.api.get_type_module <- get_type_module ctx;
 	ctx.std <- (try