1.1 --- a/deducer.py Tue Mar 28 22:12:11 2017 +0200
1.2 +++ b/deducer.py Tue Mar 28 22:46:19 2017 +0200
1.3 @@ -205,7 +205,7 @@
1.4
1.5 Locations have the following format:
1.6
1.7 - qualified name of scope "." local name ":" name version
1.8 + qualified name of scope ":" local name ":" name version
1.9
1.10 The attribute type can be "<class>", "<instance>", "<module>" or "<>",
1.11 where the latter indicates an absence of suitable references.
1.12 @@ -238,12 +238,19 @@
1.13 location " " ( "specific" | "common" ) " " object kind " " object types
1.14
1.15 Object kind can be "<class>", "<instance>" or "<module>".
1.16 +
1.17 + ----
1.18 +
1.19 + A summary of aliases is formatted as follows:
1.20 +
1.21 + location " " locations
1.22 """
1.23
1.24 f_type_summary = open(join(self.output, "type_summary"), "w")
1.25 f_types = open(join(self.output, "types"), "w")
1.26 f_warnings = open(join(self.output, "type_warnings"), "w")
1.27 f_guards = open(join(self.output, "guards"), "w")
1.28 + f_aliases = open(join(self.output, "aliases"), "w")
1.29
1.30 try:
1.31 locations = self.accessor_class_types.keys()
1.32 @@ -304,11 +311,24 @@
1.33 print >>f_type_summary, encode_location(location), encode_constrained(constrained), \
1.34 guard_test and "-".join(guard_test) or "unguarded", sorted_output(all_general_types), len(all_types)
1.35
1.36 + # Aliases are visited separately from accessors, even though they
1.37 + # are often the same thing.
1.38 +
1.39 + locations = self.alias_index.keys()
1.40 + locations.sort()
1.41 +
1.42 + for location in locations:
1.43 + accesses = []
1.44 + for access_location in self.alias_index[location]:
1.45 + accesses.append(encode_access_location(access_location))
1.46 + print >>f_aliases, encode_location(location), ", ".join(accesses)
1.47 +
1.48 finally:
1.49 f_type_summary.close()
1.50 f_types.close()
1.51 f_warnings.close()
1.52 f_guards.close()
1.53 + f_aliases.close()
1.54
1.55 def write_accesses(self):
1.56
1.57 @@ -322,7 +342,7 @@
1.58
1.59 Locations have the following format:
1.60
1.61 - qualified name of scope "." local name " " attribute name ":" access number
1.62 + qualified name of scope ":" local name ":" attribute name ":" access number
1.63
1.64 The attribute type can be "<class>", "<instance>", "<module>" or "<>",
1.65 where the latter indicates an absence of suitable references.
2.1 --- a/encoders.py Tue Mar 28 22:12:11 2017 +0200
2.2 +++ b/encoders.py Tue Mar 28 22:46:19 2017 +0200
2.3 @@ -77,7 +77,7 @@
2.4 "Encode the access location 't'."
2.5
2.6 path, name, attrname, version = t
2.7 - return "%s %s %s:%d" % (path, name or "{}", attrname, version)
2.8 + return "%s:%s:%s:%d" % (path, name or "{}", attrname or "{}", version)
2.9
2.10 def encode_location(t):
2.11
2.12 @@ -85,11 +85,11 @@
2.13
2.14 path, name, attrname, version = t
2.15 if name is not None and version is not None:
2.16 - return "%s %s:%d" % (path, name, version)
2.17 + return "%s:%s:%d" % (path, name, version)
2.18 elif name is not None:
2.19 - return "%s %s" % (path, name)
2.20 + return "%s:%s" % (path, name)
2.21 else:
2.22 - return "%s :%s" % (path, attrname)
2.23 + return "%s::%s" % (path, attrname)
2.24
2.25 def encode_modifiers(modifiers):
2.26