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 """