1.1 --- a/micropython/report.py Mon Mar 10 23:14:26 2014 +0100
1.2 +++ b/micropython/report.py Thu Mar 13 23:10:25 2014 +0100
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 View annotated sources.
1.6
1.7 -Copyright (C) 2006, 2007, 2010, 2011, 2012, 2013 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2006, 2007, 2010, 2011, 2012, 2013, 2014 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -93,6 +93,8 @@
1.13 z-index: 3;
1.14 }
1.15
1.16 + .impossible-guard,
1.17 + .impossible-guard .name,
1.18 .no-attributes {
1.19 background-color: #d00;
1.20 color: white;
1.21 @@ -375,6 +377,14 @@
1.22 all_attrnames = list(all_attrnames)
1.23 all_attrnames.sort()
1.24
1.25 + # Show guard details.
1.26 +
1.27 + guard_type = node._guard_types and node._guard_types.get(name) or None
1.28 + guards = node._guards and node._guards.get(name) or []
1.29 + typenames = [obj.full_name() for obj in guards]
1.30 +
1.31 + self._accessor_start(typenames, guard_type)
1.32 +
1.33 # Write the lists of attribute names.
1.34
1.35 self._name_start()
1.36 @@ -384,6 +394,9 @@
1.37 self._attrnames(attrnames)
1.38 self._popup_end()
1.39 self._name_end()
1.40 +
1.41 + self._accessor_end(typenames, guard_type)
1.42 +
1.43 return True
1.44
1.45 def _attrnames(self, attrnames):
1.46 @@ -392,15 +405,21 @@
1.47 def _typenames(self, typenames):
1.48 self._names_list(typenames, "types", "typenames")
1.49
1.50 - def _accessor_start(self, target_names):
1.51 - if target_names:
1.52 - self._span_start("accessor")
1.53 - self._popup_start("types-popup")
1.54 - self._typenames(target_names)
1.55 - self._popup_end()
1.56 + def _accessor_start(self, target_names, guard_type=None):
1.57 + if target_names or guard_type:
1.58 + if guard_type == "impossible":
1.59 + self._span_start("impossible-guard")
1.60 + else:
1.61 + self._span_start("accessor")
1.62 + self._types_list(target_names)
1.63
1.64 - def _accessor_end(self, target_names):
1.65 - if target_names:
1.66 + def _types_list(self, typenames):
1.67 + self._popup_start("types-popup")
1.68 + self._typenames(typenames)
1.69 + self._popup_end()
1.70 +
1.71 + def _accessor_end(self, target_names, guard_type=None):
1.72 + if target_names or guard_type:
1.73 self._span_end()
1.74
1.75 def _values_to_attribute_names(self, attr):
1.76 @@ -430,14 +449,11 @@
1.77
1.78 def _attribute_value_to_name(self, attr, value, target=False):
1.79 fullname = None
1.80 +
1.81 if target:
1.82 - if attr:
1.83 - if isinstance(attr.parent, Instance):
1.84 - fullname = attr.parent_type.full_name()
1.85 - else:
1.86 - fullname = attr.parent.full_name()
1.87 - elif value and not isinstance(value, Instance) and value.parent:
1.88 - fullname = value.parent.full_name()
1.89 + type = self.get_type_for_attribute(attr, value)
1.90 + if type:
1.91 + return type.full_name()
1.92 else:
1.93 if value and not isinstance(value, Instance):
1.94 fullname = value.full_name()
1.95 @@ -462,7 +478,7 @@
1.96
1.97 if attributes:
1.98 for attr, value in attributes:
1.99 - values = value and [value] or attr and attr.get_values() or [None]
1.100 + values = self.get_values_for_attribute(attr, value)
1.101
1.102 for value in values:
1.103 fullname = self._attribute_value_to_name(attr, value, target)
1.104 @@ -471,9 +487,11 @@
1.105 elif not target:
1.106 output.add((fullname, value))
1.107
1.108 - output = list(output)
1.109 - output.sort()
1.110 - return output
1.111 + output = list(output)
1.112 + output.sort()
1.113 + return output
1.114 + else:
1.115 + return []
1.116
1.117 def _attribute_start(self, attrname, attributes):
1.118 if attributes: