1.1 --- a/deducer.py Thu Dec 15 16:09:01 2016 +0100
1.2 +++ b/deducer.py Thu Dec 15 17:06:36 2016 +0100
1.3 @@ -137,6 +137,7 @@
1.4 self.classify_accessors()
1.5 self.classify_accesses()
1.6 self.initialise_access_plans()
1.7 + self.identify_dependencies()
1.8
1.9 def to_output(self):
1.10
1.11 @@ -647,6 +648,36 @@
1.12 original_location = self.const_accesses_rev.get(location)
1.13 self.access_plans[original_location or location] = self.get_access_plan(location)
1.14
1.15 + def identify_dependencies(self):
1.16 +
1.17 + "Introduce more module dependencies to the importer."
1.18 +
1.19 + for location, referenced_attrs in self.referenced_attrs.items():
1.20 + path, name, attrnames, version = location
1.21 +
1.22 + # Identify module-level paths.
1.23 +
1.24 + if self.importer.modules.has_key(path):
1.25 + module_name = path
1.26 +
1.27 + # Identify the module containing other paths.
1.28 +
1.29 + else:
1.30 + ref = self.importer.identify(path)
1.31 + for objpath in ref.ancestors():
1.32 + if self.importer.modules.has_key(objpath):
1.33 + module_name = objpath
1.34 + break
1.35 + else:
1.36 + raise DeduceError("Cannot find module for path %s." % path)
1.37 +
1.38 + # Identify usage of callables employing dynamic defaults.
1.39 +
1.40 + for attrtype, objtype, attr in referenced_attrs:
1.41 + if self.importer.uses_dynamic_callable(attr):
1.42 + provider = self.importer.get_module_provider(attr)
1.43 + self.importer.add_provider(path, provider)
1.44 +
1.45 def get_referenced_attrs(self, location):
1.46
1.47 """
2.1 --- a/importer.py Thu Dec 15 16:09:01 2016 +0100
2.2 +++ b/importer.py Thu Dec 15 17:06:36 2016 +0100
2.3 @@ -456,8 +456,7 @@
2.4 # Record a module ordering dependency.
2.5
2.6 if not found.static() or self.uses_dynamic_callable(found):
2.7 - init_item(self.depends, module.name, set)
2.8 - self.depends[module.name].add(provider)
2.9 + self.add_provider(module.name, provider)
2.10
2.11 module.deferred = original_deferred
2.12
2.13 @@ -467,6 +466,13 @@
2.14 for module_name in self.waiting.keys():
2.15 self.require_providers(module_name)
2.16
2.17 + def add_provider(self, module_name, provider):
2.18 +
2.19 + "Add a dependency for 'module_name' of 'provider'."
2.20 +
2.21 + init_item(self.depends, module_name, set)
2.22 + self.depends[module_name].add(provider)
2.23 +
2.24 def require_providers(self, module_name):
2.25
2.26 """