1.1 --- a/micropython/inspect.py Sun Jul 08 19:21:56 2012 +0200
1.2 +++ b/micropython/inspect.py Sun Jul 08 21:01:52 2012 +0200
1.3 @@ -1316,7 +1316,9 @@
1.4 visitMul = _visitOperator
1.5
1.6 def visitName(self, node):
1.7 - return self.get_namespace().get_using_node(node.name, node) or make_instance()
1.8 + attr = self.get_namespace().get_using_node(node.name, node) or make_instance()
1.9 + node._attr = attr
1.10 + return attr
1.11
1.12 def visitNot(self, node):
1.13 self.use_name("__bool__", node)
2.1 --- a/micropython/report.py Sun Jul 08 19:21:56 2012 +0200
2.2 +++ b/micropython/report.py Sun Jul 08 21:01:52 2012 +0200
2.3 @@ -129,7 +129,8 @@
2.4 }
2.5
2.6 .attrnames a,
2.7 - .opnames a {
2.8 + .opnames a,
2.9 + .scope a {
2.10 color: white;
2.11 }
2.12
2.13 @@ -287,8 +288,14 @@
2.14 classes or "specific-ref", module_name, os.path.extsep,
2.15 self._attr(full_name), self._text(name)))
2.16
2.17 - def _scope(self, scope):
2.18 - self.stream.write("<div class='scope'><span class='label'>scope</span><br />%s</div>\n" % scope)
2.19 + def _scope(self, scope, attr):
2.20 + self.stream.write("<div class='scope'>"
2.21 + "<span class='label'>scope</span><br />%s<br/>" % scope)
2.22 + values = self._values_to_attribute_names(attr)
2.23 + if values:
2.24 + self.stream.write("<span class='label'>values</span><br />")
2.25 + self._attribute_list(values)
2.26 + self.stream.write("</div>\n")
2.27
2.28 def _assname(self, name, node):
2.29 self._span_start("assname")
2.30 @@ -368,42 +375,61 @@
2.31 if target_names:
2.32 self._span_end()
2.33
2.34 + def _values_to_attribute_names(self, attr):
2.35 +
2.36 + "Get the output form of the values referenced by 'attr'."
2.37 +
2.38 + if isinstance(attr, Instance):
2.39 + return [(str(attr), attr)]
2.40 +
2.41 + values = []
2.42 + for v in attr.get_values():
2.43 + if not isinstance(v, Instance):
2.44 + values.append((v.full_name(), v))
2.45 +
2.46 + values.sort()
2.47 + return values
2.48 +
2.49 + def _attributes_to_attribute_names(self, attributes, attrname):
2.50 +
2.51 + "Get the output form of the 'attributes'."
2.52 +
2.53 + output = []
2.54 + for value, target, target_name in attributes:
2.55 + if value and not isinstance(value, Instance):
2.56 + fullname = value.full_name()
2.57 + else:
2.58 + fullname = target_name + "." + attrname
2.59 + output.append((fullname, value))
2.60 +
2.61 + output.sort()
2.62 + return output
2.63 +
2.64 def _attribute_start(self, attrname, attributes):
2.65 if attributes:
2.66 -
2.67 - # Get the output form of the attributes.
2.68 -
2.69 - output = []
2.70 - for value, target, target_name in attributes:
2.71 - if value and not isinstance(value, Instance):
2.72 - fullname = value.full_name()
2.73 - else:
2.74 - fullname = target_name + "." + attrname
2.75 - output.append((fullname, value))
2.76 -
2.77 - output.sort()
2.78 -
2.79 self._span_start("attr")
2.80 self._popup_start("attributes-popup")
2.81 self._names_list_start("attributes", "attrnames")
2.82 -
2.83 - # Mix links to attributes with labels indicating undetermined
2.84 - # attributes.
2.85 -
2.86 - last = None
2.87 - for fullname, value in output:
2.88 - if fullname != last:
2.89 - if last is not None:
2.90 - self.stream.write("<br />")
2.91 - if value is not None and not isinstance(value, Instance):
2.92 - self._object_name_ref(value.module, value, fullname, classes="attribute-name")
2.93 - else:
2.94 - self.stream.write(fullname)
2.95 - last = fullname
2.96 -
2.97 + self._attribute_list(attributes)
2.98 self._names_list_end()
2.99 self._popup_end()
2.100
2.101 + def _attribute_list(self, attributes):
2.102 +
2.103 + # Mix links to attributes with labels indicating undetermined
2.104 + # attributes.
2.105 +
2.106 + last = None
2.107 + for fullname, value in attributes:
2.108 + if fullname != last:
2.109 + if last is not None:
2.110 + self.stream.write("<br />")
2.111 + if value is not None and not isinstance(value, Instance):
2.112 + self._object_name_ref(value.module, value, fullname, classes="attribute-name")
2.113 + else:
2.114 + self.stream.write(fullname)
2.115 + last = fullname
2.116 +
2.117 def _attribute_end(self, attributes):
2.118 if attributes:
2.119 self._span_end()
2.120 @@ -1001,7 +1027,7 @@
2.121 if not wraps_getattr:
2.122 self._accessor_end(target_names)
2.123 self.stream.write(".")
2.124 - self._attribute_start(node.attrname, attributes)
2.125 + self._attribute_start(node.attrname, self._attributes_to_attribute_names(attributes, node.attrname))
2.126 self._span(node.attrname, "attrname" + (not target_names and " no-targets" or ""))
2.127 self._attribute_end(attributes)
2.128 if not wraps_getattr:
2.129 @@ -1101,7 +1127,7 @@
2.130 if not wraps_getattr:
2.131 self._accessor_end(target_names)
2.132 self.stream.write(".")
2.133 - self._attribute_start(node.attrname, attributes)
2.134 + self._attribute_start(node.attrname, self._attributes_to_attribute_names(attributes, node.attrname))
2.135 self._span(node.attrname, "attrname" + (not target_names and " no-targets" or ""))
2.136 self._attribute_end(attributes)
2.137 if not wraps_getattr:
2.138 @@ -1226,7 +1252,7 @@
2.139 self._name_start()
2.140 self.stream.write(node.name)
2.141 self._popup_start()
2.142 - self._scope(scope)
2.143 + self._scope(node._scope, node._attr)
2.144 self._popup_end()
2.145 self._name_end()
2.146 else: