Преглед на файлове

resolve imports before build_inheritance

Nicolas Cannasse преди 17 години
родител
ревизия
e4512a3102
променени са 2 файла, в които са добавени 26 реда и са изтрити 0 реда
  1. 7 0
      doc/CHANGES.txt
  2. 19 0
      typeload.ml

+ 7 - 0
doc/CHANGES.txt

@@ -1,3 +1,9 @@
+TODO :
+	SWC input support
+	SWC output support
+	optimizer : reduce/calculate expressions
+	flash9 : optimize enum parameters storage
+	
 2009-??-??: 2.03
 	optimized Type.enumEq : use index instead of tag comparison for neko/flash9/php
 	bugfix for flash.display.BitmapDataChannel and GraphicsPathCommand (allow inline static)
@@ -5,6 +11,7 @@
 	added flash.Vector.indexOf and lastIndexOf
 	fixed bug in interfaces that define the method toString (haXe/PHP)
 	fixed bug in haxe.io.BytesInput.readBytes in Flash9 (was throwing Eof if full buffer can't be readed)
+	fixed implements/extends special classes when they are imported
 
 2008-11-23: 2.02
 	Std.is(MyInterface, Class) now returns true (haXe/PHP)

+ 19 - 0
typeload.ml

@@ -423,6 +423,25 @@ let set_heritance ctx c herits p =
 				c.cl_dynamic <- Some t
 			| _ -> error "Should implement by using an interface or a class" p)
 	in
+	(*
+		resolve imports before calling build_inheritance, since it requires full paths.
+		that means that typedefs are not working, but that's a fair limitation
+	*)
+	let rec resolve_imports t =
+		match t.tpackage with
+		| _ :: _ -> t
+		| [] ->
+			try
+				let lt = List.find (fun lt -> snd (t_path lt) = t.tname) ctx.local_types in
+				{ t with tpackage = fst (t_path lt) }
+			with
+				Not_found -> t
+	in
+	let herits = List.map (function
+		| HExtends t -> HExtends (resolve_imports t)
+		| HImplements t -> HImplements (resolve_imports t)
+		| h -> h
+	) herits in
 	List.iter loop (List.filter ((!build_inheritance) ctx c p) herits)
 
 let type_type_params ctx path p (n,flags) =