1.1 --- a/micropython/common.py Tue Aug 10 23:18:42 2010 +0200
1.2 +++ b/micropython/common.py Wed Aug 11 00:04:11 2010 +0200
1.3 @@ -26,13 +26,16 @@
1.4 except NameError:
1.5 from sets import Set as set
1.6
1.7 -# Visitors.
1.8 +# Visitors and activities related to node annotations.
1.9
1.10 class ASTVisitor(compiler.visitor.ASTVisitor):
1.11
1.12 "A base class for visitors."
1.13
1.14 def dispatch(self, node, *args):
1.15 +
1.16 + "Dispatch using 'node', annotating any raised exceptions."
1.17 +
1.18 try:
1.19 return compiler.visitor.ASTVisitor.dispatch(self, node, *args)
1.20 except NodeProcessingError, exc:
1.21 @@ -47,6 +50,25 @@
1.22 exc.unit_name = self.full_name()
1.23 raise
1.24
1.25 + def possible_accessor_types(self, node):
1.26 +
1.27 + """
1.28 + Given annotations made during the inspection process, return all possible
1.29 + types for a 'node' involved in attribute access, or return None if no
1.30 + annotations are available.
1.31 + """
1.32 +
1.33 + if hasattr(node, "_attrusers"):
1.34 + target_names = set()
1.35 +
1.36 + for user in node._attrusers:
1.37 + target_names.update(self.objtable.all_possible_objects(user._attrnames[node._username]))
1.38 +
1.39 + return target_names
1.40 +
1.41 + else:
1.42 + return None
1.43 +
1.44 def used_by_unit(node):
1.45
1.46 """