1.1 --- a/micropython/common.py Sat Jul 14 20:38:19 2012 +0200
1.2 +++ b/micropython/common.py Sat Jul 14 21:20:47 2012 +0200
1.3 @@ -19,7 +19,7 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 -from compiler.ast import Class, Function, Module
1.8 +from compiler.ast import Class, Function, Module, AssAttr, Getattr, Name
1.9 from micropython.data import Attr
1.10 from micropython.errors import *
1.11
1.12 @@ -79,28 +79,30 @@
1.13 # not that of a general instance or an unresolved name, attempt to
1.14 # identify it.
1.15
1.16 - if node._attr and isinstance(node._attr, Attr):
1.17 - attr = node._attr
1.18 - target_names.add((attr.parent.full_name(), attr.is_static_attribute()))
1.19 + if isinstance(node, (AssAttr, Getattr, Name)):
1.20 +
1.21 + if isinstance(node._attr, Attr):
1.22 + attr = node._attr
1.23 + target_names.add((attr.parent.full_name(), attr.is_static_attribute()))
1.24
1.25 - # Otherwise, attempt to employ the attribute usage observations.
1.26 + # Otherwise, attempt to employ the attribute usage observations.
1.27
1.28 - elif node._attrusers:
1.29 + elif node._attrusers:
1.30
1.31 - # Visit each attribute user.
1.32 + # Visit each attribute user.
1.33
1.34 - for user in node._attrusers:
1.35 + for user in node._attrusers:
1.36
1.37 - # Since users such as branches may not provide type information,
1.38 - # attempt to find defining users.
1.39 + # Since users such as branches may not provide type information,
1.40 + # attempt to find defining users.
1.41
1.42 - if defining_users:
1.43 - for def_user in user._attrdefs or [user]:
1.44 - for target_name, is_static in def_user._attrtypes.get(node._username, []):
1.45 + if defining_users:
1.46 + for def_user in user._attrdefs or [user]:
1.47 + for target_name, is_static in def_user._attrtypes.get(node._username, []):
1.48 + target_names.add((target_name, is_static))
1.49 + else:
1.50 + for target_name, is_static in user._attrspecifictypes.get(node._username, []):
1.51 target_names.add((target_name, is_static))
1.52 - else:
1.53 - for target_name, is_static in user._attrspecifictypes.get(node._username, []):
1.54 - target_names.add((target_name, is_static))
1.55
1.56 return target_names
1.57