1.1 --- a/micropython/basicdata.py Mon Oct 29 22:27:15 2012 +0100
1.2 +++ b/micropython/basicdata.py Fri Nov 02 00:34:27 2012 +0100
1.3 @@ -39,18 +39,20 @@
1.4 else:
1.5 return self.parent.full_name()
1.6
1.7 +no_attributes = {}
1.8 +
1.9 class Namespace:
1.10
1.11 "A mix-in providing basic namespace functionality."
1.12
1.13 - def get_static_attribute(self, name):
1.14 + def all_attributes(self):
1.15
1.16 """
1.17 - Return a static attribute for the given 'name' or None if no such
1.18 - attribute exists.
1.19 + Return all attributes accessible through a namespace, whether provided
1.20 + directly by the namespace or by other mechanisms.
1.21 """
1.22
1.23 - return None
1.24 + return no_attributes
1.25
1.26 class Constant:
1.27
2.1 --- a/micropython/common.py Mon Oct 29 22:27:15 2012 +0100
2.2 +++ b/micropython/common.py Fri Nov 02 00:34:27 2012 +0100
2.3 @@ -106,8 +106,14 @@
2.4 if exprs:
2.5 target_names = set()
2.6
2.7 + # For each expression value try and get a concrete
2.8 + # attribute.
2.9 +
2.10 for expr in exprs:
2.11 - attr = expr.get_static_attribute(node.attrname)
2.12 + attr = expr.all_attributes().get(node.attrname)
2.13 +
2.14 + # Where an attribute can be obtained, record its
2.15 + # details.
2.16
2.17 if attr:
2.18 target_names.add((attr.parent.full_name(), attr.is_static_attribute()))
2.19 @@ -135,11 +141,13 @@
2.20 for target_name, is_static in user._attrspecifictypes.get(node._username, []):
2.21 target_names.add((target_name, is_static))
2.22
2.23 - all_target_names.append(target_names)
2.24 + if target_names:
2.25 + all_target_names.append(target_names)
2.26
2.27 # Return the smallest set of target names.
2.28
2.29 all_target_names.sort(key=lambda x: len(x))
2.30 +
2.31 return all_target_names and all_target_names[0]
2.32
2.33 def used_by_unit(node):
3.1 --- a/micropython/data.py Mon Oct 29 22:27:15 2012 +0100
3.2 +++ b/micropython/data.py Fri Nov 02 00:34:27 2012 +0100
3.3 @@ -1656,15 +1656,6 @@
3.4 self.allattr[name] = attr
3.5 return self.allattr
3.6
3.7 - def get_static_attribute(self, name):
3.8 -
3.9 - """
3.10 - Return a static attribute for the given 'name' or None if no such
3.11 - attribute exists.
3.12 - """
3.13 -
3.14 - return self.all_class_attributes().get(name)
3.15 -
3.16 class TypeClass(Class):
3.17
3.18 "A special class for the type class."
3.19 @@ -2089,6 +2080,8 @@
3.20
3.21 return dict(self)
3.22
3.23 + all_attributes = module_attributes
3.24 +
3.25 def get_static_attribute(self, name):
3.26
3.27 """