by user modules.
nitc :: header_dependency $ MModule
A Nit module is usually associated with a Nit source file.nitc :: header_dependency $ MModule
A Nit module is usually associated with a Nit source file.Serializable::inspect
to show more useful information
nitc :: modelbuilder
more_collections :: more_collections
Highly specific, but useful, collections-related classes.serialization :: serialization_core
Abstract services to serialize Nit objects to different formatsnitc :: toolcontext
Common command-line tool infrastructure than handle options and error messagescore :: union_find
union–find algorithm using an efficient disjoint-set data structureclone
method of the astbuilder tool
# Tracks which modules has public header code that must be imported
# by user modules.
module header_dependency
import ffi_base
import c
redef class ToolContext
var header_dependancy_phase: Phase = new HeaderDependancyPhase(self, [ffi_language_assignation_phase, modelize_class_phase])
end
redef class AModule
private fun has_public_c_header: Bool do
for code_block in n_extern_code_blocks do if code_block.is_c_header then return true
return false
end
end
redef class MModule
# 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 != null then return
var header_dependencies = new HashSet[MModule]
# gather from importation
for m in in_importation.direct_greaters do
m.compute_header_dependencies v
# 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
end
# 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
self.header_dependencies = header_dependencies
end
end
private class HeaderDependancyPhase
super Phase
redef fun process_nmodule(nmodule)
do
var mmodule = nmodule.mmodule
mmodule.compute_header_dependencies(self)
end
end
src/ffi/header_dependency.nit:17,1--73,3