1.1 --- a/importer.py Thu Sep 08 18:34:23 2016 +0200
1.2 +++ b/importer.py Thu Sep 08 18:39:38 2016 +0200
1.3 @@ -50,14 +50,21 @@
1.4 self.cache = cache
1.5 self.verbose = verbose
1.6
1.7 + # Module importing queue, required modules, removed modules and active
1.8 + # modules in the final program.
1.9 +
1.10 self.to_import = set()
1.11 self.required = set(["__main__"])
1.12 self.removed = {}
1.13 + self.modules = {}
1.14
1.15 - self.modules = {}
1.16 + # Module relationships and invalidated cached modules.
1.17 +
1.18 self.accessing_modules = {}
1.19 self.invalidated = set()
1.20
1.21 + # Basic program information.
1.22 +
1.23 self.objects = {}
1.24 self.classes = {}
1.25 self.function_parameters = {}
1.26 @@ -65,6 +72,10 @@
1.27 self.function_targets = {}
1.28 self.function_arguments = {}
1.29
1.30 + # Unresolved names.
1.31 +
1.32 + self.missing = set()
1.33 +
1.34 # Derived information.
1.35
1.36 self.subclasses = {}
1.37 @@ -322,7 +333,13 @@
1.38
1.39 def finalise(self):
1.40
1.41 - "Finalise the inspected program."
1.42 + """
1.43 + Finalise the inspected program, returning whether the program could be
1.44 + finalised.
1.45 + """
1.46 +
1.47 + if self.missing:
1.48 + return False
1.49
1.50 self.finalise_classes()
1.51 self.to_cache()
1.52 @@ -330,6 +347,8 @@
1.53 self.define_instantiators()
1.54 self.collect_constants()
1.55
1.56 + return True
1.57 +
1.58 # Supporting operations.
1.59
1.60 def resolve(self):
1.61 @@ -345,7 +364,7 @@
1.62 for ref in module.deferred:
1.63 found = self.find_dependency(ref)
1.64 if not found:
1.65 - print >>sys.stderr, "Module %s references an unknown object: %s" % (module.name, ref.get_origin())
1.66 + self.missing.add((module.name, ref.get_origin()))
1.67
1.68 # Record the resolved names and identify required modules.
1.69