# HG changeset patch # User Paul Boddie # Date 1314489784 -7200 # Node ID 84a95902ad6ec84f3239fdba030e92ca38650fe0 # Parent 2a80e3871c0018e1737bfb00805e387df9f7f0d3 Changed the _attrnames annotation to use a dictionary at the top level. Introduced singletons for abandoned branch dictionaries. Added some explanations. diff -r 2a80e3871c00 -r 84a95902ad6e micropython/common.py --- a/micropython/common.py Fri Aug 26 00:03:08 2011 +0200 +++ b/micropython/common.py Sun Aug 28 02:03:04 2011 +0200 @@ -180,6 +180,12 @@ values of the contributing dictionaries being themselves combined such that a "product" of the values for a given key are stored in the combined dictionary. + + For example: + + d1: {'a' : [{'f', 'g'}, {'f', 'h'}], ...} + d2: {'a' : [{'f'}, {'e', 'f', 'g'}], ...} + -> {'a' : [{'f', 'g'}, {'f', 'h'}, {'e', 'f', 'g'}, {'e', 'f', 'g', 'h'}], ...} """ combined = {} diff -r 2a80e3871c00 -r 84a95902ad6e micropython/data.py --- a/micropython/data.py Fri Aug 26 00:03:08 2011 +0200 +++ b/micropython/data.py Sun Aug 28 02:03:04 2011 +0200 @@ -510,9 +510,14 @@ if users.has_key(name): for user in users[name]: values = user._attrnames[name] + + # Add an entry for the attribute, optionally with an assigned + # value. + values.add(attrname) if value is not None: values[attrname].append(value) + return users[name] else: return [] @@ -557,7 +562,7 @@ # Attribute usage for names. if not hasattr(node, "_attrnames"): - node._attrnames = ObjectSet() + node._attrnames = {} # Branches contributing usage to this node. @@ -647,8 +652,8 @@ provided these cannot "escape" from the branch. """ - self.attribute_users[-1] = AbandonedBranchUsers() - self.scope_usage[-1] = AbandonedBranchScope() + self.attribute_users[-1] = abandoned_branch_users + self.scope_usage[-1] = abandoned_branch_scope def _suspend_broken_branch(self): @@ -859,6 +864,9 @@ pass +abandoned_branch_users = AbandonedBranchUsers() +abandoned_branch_scope = AbandonedBranchScope() + class ScopeConflict: """