1.1 --- a/micropython/__init__.py Sun Sep 12 21:54:04 2010 +0200
1.2 +++ b/micropython/__init__.py Mon Sep 13 01:44:37 2010 +0200
1.3 @@ -562,10 +562,10 @@
1.4 for attrnames in usage:
1.5 objtypes = objtable.all_possible_objects_plus_status(attrnames)
1.6 if not objtypes:
1.7 - print "Warning: usage in %r finds no object supporting all attributes %r" % (from_name, attrnames)
1.8 + print "Warning: usage in %r for %r finds no object supporting all attributes %r" % (from_name, name, attrnames)
1.9 objtypes = objtable.any_possible_objects_plus_status(attrnames)
1.10 if not objtypes:
1.11 - print "Warning: usage in %r finds no object supporting any attributes %r" % (from_name, attrnames)
1.12 + print "Warning: usage in %r for %r finds no object supporting any attributes %r" % (from_name, name, attrnames)
1.13
1.14 all_objtypes.update(objtypes)
1.15
1.16 @@ -609,7 +609,8 @@
1.17 self.use_attribute(from_name, "__init__")
1.18 self._collect_attributes(from_name + ".__init__", objtable)
1.19
1.20 - # Visit attributes on objects not previously visited.
1.21 + # Visit attributes on this object that were queued in case of the object
1.22 + # being referenced.
1.23
1.24 attributes_to_visit = self.attributes_to_visit.get(from_name, [])
1.25
3.1 --- a/micropython/data.py Sun Sep 12 21:54:04 2010 +0200
3.2 +++ b/micropython/data.py Mon Sep 13 01:44:37 2010 +0200
3.3 @@ -373,7 +373,6 @@
3.4 # usage with the usage recorded directly on the user.
3.5
3.6 contributors, combined_usage = self.get_usage_from_contributors(user)
3.7 - user._attrcombined = combined_usage
3.8
3.9 # Record the defining user on each contributor.
3.10
3.11 @@ -382,8 +381,23 @@
3.12
3.13 # Then, tell the importer about the usage.
3.14
3.15 - for name, usage in combined_usage.items():
3.16 - importer.use_names(user, name, tuple(usage), self.full_name())
3.17 + for name in user._attrnames.keys():
3.18 +
3.19 + # Only provide information about names defined by this user.
3.20 +
3.21 + usage = combined_usage.get(name, [])
3.22 +
3.23 + # Skip reporting where no actual usage occurs.
3.24 +
3.25 + for attrnames in usage:
3.26 + if attrnames:
3.27 + break
3.28 + else:
3.29 + continue
3.30 +
3.31 + # Eliminate non-usage.
3.32 +
3.33 + importer.use_names(user, name, tuple([attrnames for attrnames in usage if attrnames]), self.full_name())
3.34
3.35 def get_usage_from_contributors(self, node):
3.36
3.37 @@ -394,62 +408,67 @@
3.38 usage possibilities (each a collection of attribute names).
3.39 """
3.40
3.41 - usage = {}
3.42 - contributor_usage = {}
3.43 - all_contributors = set()
3.44 -
3.45 - # Visit each contributor, gathering usage for each name.
3.46 -
3.47 - for contributor in node._attrbranches:
3.48 -
3.49 - # Get contributed usage for each contributor.
3.50 - # This gathers usage for each name such as {(a, b), (c, d)} and
3.51 - # {(a, b), (e, f)} into a single set {(a, b), (c, d), (e, f)}.
3.52 -
3.53 - contributors, contributed_usage = self.get_usage_from_contributors(contributor)
3.54 -
3.55 - for name, all_usage in contributed_usage.items():
3.56 - if not contributor_usage.has_key(name):
3.57 - contributor_usage[name] = set()
3.58 - contributor_usage[name].update(all_usage)
3.59 -
3.60 - # Record all contributors.
3.61 -
3.62 - all_contributors.add(contributor)
3.63 - all_contributors.update(contributors)
3.64 -
3.65 - # Then get the resulting usage.
3.66 -
3.67 - contributed_names = contributor_usage.keys()
3.68 - current_usage = node._attrnames
3.69 -
3.70 - for name in contributed_names:
3.71 -
3.72 - # Where contributors define names not present at this level, just
3.73 - # use the contributed usage.
3.74 -
3.75 - current_usage_for_name = current_usage.get(name)
3.76 -
3.77 - if current_usage_for_name is None:
3.78 - usage[name] = contributor_usage[name]
3.79 -
3.80 - # Otherwise, combine the current usage with the contributed usage.
3.81 - # Thus, usage of (f, g) combined with {(a, b), (c, d)} would give
3.82 - # {(f, g, a, b), (f, g, c, d)}.
3.83 -
3.84 - else:
3.85 - usage[name] = set()
3.86 - for attrnames in contributor_usage[name]:
3.87 - usage[name].add(tuple(current_usage_for_name.union(attrnames)))
3.88 -
3.89 - # Maintain usage not affected by contributors.
3.90 - # Usage of (f, g) would become {(f, g)}.
3.91 -
3.92 - for name in current_usage.keys():
3.93 - if name not in contributed_names:
3.94 - usage[name] = set([tuple(current_usage[name])])
3.95 -
3.96 - return all_contributors, usage
3.97 + if not hasattr(node, "_attrcombined"):
3.98 +
3.99 + usage = {}
3.100 + contributor_usage = {}
3.101 + all_contributors = set()
3.102 +
3.103 + # Visit each contributor, gathering usage for each name.
3.104 +
3.105 + for contributor in node._attrbranches:
3.106 +
3.107 + # Get contributed usage for each contributor.
3.108 + # This gathers usage for each name such as {(a, b), (c, d)} and
3.109 + # {(a, b), (e, f)} into a single set {(a, b), (c, d), (e, f)}.
3.110 +
3.111 + contributors, contributed_usage = self.get_usage_from_contributors(contributor)
3.112 +
3.113 + for name, all_usage in contributed_usage.items():
3.114 + if not contributor_usage.has_key(name):
3.115 + contributor_usage[name] = set()
3.116 + contributor_usage[name].update(all_usage)
3.117 +
3.118 + # Record all contributors.
3.119 +
3.120 + all_contributors.add(contributor)
3.121 + all_contributors.update(contributors)
3.122 +
3.123 + # Then get the resulting usage.
3.124 +
3.125 + contributed_names = contributor_usage.keys()
3.126 + current_usage = node._attrnames
3.127 +
3.128 + for name in contributed_names:
3.129 +
3.130 + # Where contributors define names not present at this level, just
3.131 + # use the contributed usage.
3.132 +
3.133 + current_usage_for_name = current_usage.get(name)
3.134 +
3.135 + if current_usage_for_name is None:
3.136 + usage[name] = contributor_usage[name]
3.137 +
3.138 + # Otherwise, combine the current usage with the contributed usage.
3.139 + # Thus, usage of (f, g) combined with {(a, b), (c, d)} would give
3.140 + # {(f, g, a, b), (f, g, c, d)}.
3.141 +
3.142 + else:
3.143 + usage[name] = set()
3.144 + for attrnames in contributor_usage[name]:
3.145 + usage[name].add(tuple(current_usage_for_name.union(attrnames)))
3.146 +
3.147 + # Maintain usage not affected by contributors.
3.148 + # Usage of (f, g) would become {(f, g)}.
3.149 +
3.150 + for name in current_usage.keys():
3.151 + if name not in contributed_names:
3.152 + usage[name] = set([tuple(current_usage[name])])
3.153 +
3.154 + node._attrcontributors = all_contributors
3.155 + node._attrcombined = usage
3.156 +
3.157 + return node._attrcontributors, node._attrcombined
3.158
3.159 def use_attribute(self, name, attrname):
3.160
3.161 @@ -554,6 +573,11 @@
3.162 if not hasattr(node, "_attrdefs"):
3.163 node._attrdefs = []
3.164
3.165 + # Eventual type information.
3.166 +
3.167 + if not hasattr(node, "_attrtypes"):
3.168 + node._attrtypes = {}
3.169 +
3.170 # Branch management methods.
3.171
3.172 def _new_branchpoint(self):