From: Alexis Laferrière Date: Thu, 15 Jan 2015 16:04:31 +0000 (-0500) Subject: nitc: fix duplication on imports of public foreign code X-Git-Tag: v0.7.1~25^2~3 X-Git-Url: http://nitlanguage.org nitc: fix duplication on imports of public foreign code Signed-off-by: Alexis Laferrière --- diff --git a/src/ffi/header_dependency.nit b/src/ffi/header_dependency.nit index 10c1db3..84bbb29 100644 --- a/src/ffi/header_dependency.nit +++ b/src/ffi/header_dependency.nit @@ -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