nitc: fix duplication on imports of public foreign code
authorAlexis Laferrière <alexis.laf@xymus.net>
Thu, 15 Jan 2015 16:04:31 +0000 (11:04 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Fri, 16 Jan 2015 04:28:35 +0000 (23:28 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

src/ffi/header_dependency.nit

index 10c1db3..84bbb29 100644 (file)
@@ -33,36 +33,32 @@ redef class AModule
 end
 
 redef class MModule
-       private var header_dependencies_cache: nullable Array[MModule] = null
-       fun header_dependencies: Array[MModule]
-       do
-               var cache = header_dependencies_cache
-               assert cache != null
-               return cache
-       end
+       # Modules with public foreign code blocks (C header)
+       var header_dependencies: nullable HashSet[MModule] = null
 
        private fun compute_header_dependencies(v: HeaderDependancyPhase)
        do
-               if header_dependencies_cache != null then return
+               if header_dependencies != null then return
 
-               var header_dependencies = new Array[MModule]
+               var header_dependencies = new HashSet[MModule]
 
                # gather from importation
                for m in in_importation.direct_greaters do
-                       m.compute_header_dependencies(v)
+                       m.compute_header_dependencies v
 
-                       # does the super module has inherited dependancies?
+                       # does the super module has inherited dependencies?
                        var hd = m.header_dependencies
+                       assert hd != null
                        if not hd.is_empty then
-                               header_dependencies.add_all(hd)
+                               header_dependencies.add_all hd
                        end
 
-                       # does the super module itself has extern dependancies?
+                       # does the super module itself has extern dependencies?
                        var amodule = v.toolcontext.modelbuilder.mmodule2node(m)
                        if amodule != null and amodule.has_public_c_header then header_dependencies.add(m)
                end
 
-               header_dependencies_cache = header_dependencies
+               self.header_dependencies = header_dependencies
        end
 end