# HG changeset patch # User Paul Boddie # Date 1481582008 -3600 # Node ID fd5cc95c936a833ebbe750318bd266582b909a66 # Parent 0538ce057931e1a2de31385c7f8ead0720fe781b Store module dependencies in the cache so that the module ordering is repeatably computable in the importer. The importer must preserve the original dependencies for the cache while updating the references for the rest of the program. diff -r 0538ce057931 -r fd5cc95c936a importer.py --- a/importer.py Mon Dec 12 22:33:15 2016 +0100 +++ b/importer.py Mon Dec 12 23:33:28 2016 +0100 @@ -405,7 +405,16 @@ # Resolve all deferred references in each module. + original_deferred = [] + for ref in module.deferred: + + # Retain original references for caching. + + original_deferred.append(ref.copy()) + + # Update references throughout the program. + found = self.find_dependency(ref) if not found: self.missing.add((module.name, ref.get_origin())) @@ -450,6 +459,8 @@ init_item(self.depends, module.name, set) self.depends[module.name].add(provider) + module.deferred = original_deferred + # Check modules again to see if they are now required and should now # cause the inclusion of other modules providing objects to the program. diff -r 0538ce057931 -r fd5cc95c936a modules.py --- a/modules.py Mon Dec 12 22:33:15 2016 +0100 +++ b/modules.py Mon Dec 12 23:33:28 2016 +0100 @@ -378,6 +378,7 @@ f.readline() # (empty line) self._get_imports(f) + self._get_deferred(f) self._get_special(f) self._get_members(f) self._get_class_relationships(f) @@ -420,6 +421,12 @@ for name in self.imports: self.queue_module(name) + def _get_deferred(self, f): + f.readline() # "deferred:" + line = f.readline().rstrip() + self.deferred = map(decode_reference, line.split(" ")) + f.readline() + def _get_special(self, f): f.readline() # "special:" line = f.readline().rstrip() @@ -684,6 +691,8 @@ "imports:" required module names possibly required module names + "deferred:" + deferred references "special:" zero or more: special name " " reference (empty line) @@ -789,6 +798,10 @@ print >>f, imports and ", ".join(imports) or "{}" print >>f + print >>f, "deferred:" + print >>f, " ".join(map(str, self.deferred)) + + print >>f print >>f, "special:" names = self.special.keys() names.sort() diff -r 0538ce057931 -r fd5cc95c936a referencing.py --- a/referencing.py Mon Dec 12 22:33:15 2016 +0100 +++ b/referencing.py Mon Dec 12 23:33:28 2016 +0100 @@ -143,6 +143,12 @@ return Reference("", None, self.name) + def copy(self): + + "Copy this reference." + + return Reference(self.get_kind(), self.get_origin(), self.get_name()) + def alias(self, name): "Alias this reference employing 'name'."