# HG changeset patch # User Paul Boddie # Date 1342293647 -7200 # Node ID 9742d533899515b578f8f0849932a04377f6ae91 # Parent 8dc737ce59edc986af21a4c701146fd7a3820f16 Restricted the nodes that can be used to obtain type information. diff -r 8dc737ce59ed -r 9742d5338995 micropython/common.py --- a/micropython/common.py Sat Jul 14 20:38:19 2012 +0200 +++ b/micropython/common.py Sat Jul 14 21:20:47 2012 +0200 @@ -19,7 +19,7 @@ this program. If not, see . """ -from compiler.ast import Class, Function, Module +from compiler.ast import Class, Function, Module, AssAttr, Getattr, Name from micropython.data import Attr from micropython.errors import * @@ -79,28 +79,30 @@ # not that of a general instance or an unresolved name, attempt to # identify it. - if node._attr and isinstance(node._attr, Attr): - attr = node._attr - target_names.add((attr.parent.full_name(), attr.is_static_attribute())) + if isinstance(node, (AssAttr, Getattr, Name)): + + if isinstance(node._attr, Attr): + attr = node._attr + target_names.add((attr.parent.full_name(), attr.is_static_attribute())) - # Otherwise, attempt to employ the attribute usage observations. + # Otherwise, attempt to employ the attribute usage observations. - elif node._attrusers: + elif node._attrusers: - # Visit each attribute user. + # Visit each attribute user. - for user in node._attrusers: + for user in node._attrusers: - # Since users such as branches may not provide type information, - # attempt to find defining users. + # Since users such as branches may not provide type information, + # attempt to find defining users. - if defining_users: - for def_user in user._attrdefs or [user]: - for target_name, is_static in def_user._attrtypes.get(node._username, []): + if defining_users: + for def_user in user._attrdefs or [user]: + for target_name, is_static in def_user._attrtypes.get(node._username, []): + target_names.add((target_name, is_static)) + else: + for target_name, is_static in user._attrspecifictypes.get(node._username, []): target_names.add((target_name, is_static)) - else: - for target_name, is_static in user._attrspecifictypes.get(node._username, []): - target_names.add((target_name, is_static)) return target_names