1.1 --- a/micropython/data.py Mon Feb 27 23:22:33 2012 +0100
1.2 +++ b/micropython/data.py Wed Feb 29 00:39:20 2012 +0100
1.3 @@ -7,7 +7,7 @@
1.4 program but which are wrapped in context-dependent structures in the running
1.5 program.
1.6
1.7 -Copyright (C) 2007, 2008, 2009, 2010, 2011 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 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 @@ -418,10 +418,33 @@
1.13 # Visit each user and examine the attribute usage for each name.
1.14
1.15 for user in self.all_attribute_users:
1.16 - user._attrtypes = {}
1.17 - for name, usage in user._attrcombined.items():
1.18 - if usage is not None:
1.19 - user._attrtypes[name] = get_object_types_for_usage(usage, objtable, name, self.full_name())
1.20 + self._finalise_contributor(user, objtable)
1.21 +
1.22 + def _finalise_contributor(self, node, objtable):
1.23 +
1.24 + """
1.25 + Record the specific object types being used in various regions of a
1.26 + program unit.
1.27 + """
1.28 +
1.29 + if not hasattr(node, "_attrtypes"):
1.30 + node._attrtypes = self._deduce_types(node, objtable)
1.31 +
1.32 + for contributor in node._attrcontributors:
1.33 + self._finalise_contributor(contributor, objtable)
1.34 +
1.35 + def _deduce_types(self, user, objtable):
1.36 +
1.37 + """
1.38 + Deduce the types for names using attributes on the given 'user' node
1.39 + using the given 'objtable'.
1.40 + """
1.41 +
1.42 + attrtypes = {}
1.43 + for name, usage in user._attrcombined.items():
1.44 + if usage is not None:
1.45 + attrtypes[name] = get_object_types_for_usage(usage, objtable, name, self.full_name())
1.46 + return attrtypes
1.47
1.48 def get_usage_from_contributors(self, node):
1.49
1.50 @@ -588,11 +611,6 @@
1.51 if not hasattr(node, "_attrdefs"):
1.52 node._attrdefs = []
1.53
1.54 - # Eventual type information.
1.55 -
1.56 - if not hasattr(node, "_attrtypes"):
1.57 - node._attrtypes = {}
1.58 -
1.59 # Branch management methods.
1.60
1.61 def _new_branchpoint(self, loop_node=None):