1.1 --- a/micropython/__init__.py Sat Jun 05 01:39:16 2010 +0200
1.2 +++ b/micropython/__init__.py Fri Jun 11 00:56:08 2010 +0200
1.3 @@ -5,7 +5,7 @@
1.4 from the simplify package but has had various details related to that package
1.5 removed.
1.6
1.7 -Copyright (C) 2006, 2007, 2008, 2009 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2006, 2007, 2008, 2009, 2010 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -334,7 +334,7 @@
1.13 }
1.14
1.15 names_always_used = [
1.16 - "bool", "__init__", "__call__", "__bool__", "__builtins__", "__main__"
1.17 + "bool", "__init__", "__call__", "__bool__"
1.18 ]
1.19
1.20 def __init__(self, path=None, verbose=0, optimisations=None):
1.21 @@ -498,9 +498,10 @@
1.22 # Include names which may not be explicitly used in programs.
1.23 # NOTE: Potentially declare these when inspecting.
1.24
1.25 - for name in self.names_always_used:
1.26 - for objname in objtable.all_possible_objects([name]):
1.27 - self.use_attribute(objname, name)
1.28 + for attrname in self.names_always_used:
1.29 + for objname in objtable.all_possible_objects([attrname]):
1.30 + self.use_attribute(objname, attrname)
1.31 + self._collect_attributes(objname + "." + attrname, objtable)
1.32
1.33 def _collect_attributes(self, from_name, objtable):
1.34
1.35 @@ -536,6 +537,13 @@
1.36 self.use_attribute(objname, attrname)
1.37 self._collect_attributes(objname + "." + attrname, objtable)
1.38
1.39 + # Where the object has an __init__ attribute, assume that it is an
1.40 + # initialiser which is called at some point, and collect attributes used
1.41 + # in this initialiser.
1.42 +
1.43 + if "__init__" in objtable.table.get(from_name, []):
1.44 + self._collect_attributes(from_name + ".__init__", objtable)
1.45 +
1.46 # Constant accounting.
1.47
1.48 def init_predefined_constants(self):