1.1 --- a/deducer.py Tue Oct 04 15:12:13 2016 +0200
1.2 +++ b/deducer.py Wed Oct 05 17:25:39 2016 +0200
1.3 @@ -121,7 +121,7 @@
1.4 self.reference_all_accessor_types = {}
1.5 self.reference_all_accessor_general_types = {}
1.6 self.reference_test_types = {}
1.7 - self.reference_test_accessor_types = {}
1.8 + self.reference_test_accessor_type = {}
1.9
1.10 # The processing workflow itself.
1.11
1.12 @@ -365,10 +365,10 @@
1.13
1.14 # Write any type checks for anonymous accesses.
1.15
1.16 - elif test_type and self.reference_test_accessor_types.get(location):
1.17 + elif test_type and self.reference_test_accessor_type.get(location):
1.18 print >>f_tests, encode_access_location(location), test_type, \
1.19 sorted_output(all_accessed_attrs), \
1.20 - self.reference_test_accessor_types[location]
1.21 + self.reference_test_accessor_type[location]
1.22
1.23 print >>f_attr_summary, encode_access_location(location), encode_constrained(constrained), \
1.24 test_type or "untested", sorted_output(all_accessed_attrs)
1.25 @@ -393,13 +393,15 @@
1.26 locations.sort()
1.27
1.28 for location in locations:
1.29 - base, traversed, attrnames, method, test, attr = self.access_plans[location]
1.30 + name, test, test_type, base, traversed, attrnames, context, \
1.31 + method, attr = self.access_plans[location]
1.32 +
1.33 print >>f_attrs, encode_access_location(location), \
1.34 + name, test, test_type or "{}", \
1.35 base or "{}", \
1.36 ".".join(traversed) or "{}", \
1.37 ".".join(attrnames) or "{}", \
1.38 - method, test, \
1.39 - attr or "{}"
1.40 + context, method, attr or "{}"
1.41
1.42 finally:
1.43 f_attrs.close()
1.44 @@ -601,7 +603,7 @@
1.45 else:
1.46 test_type = "specific-object"
1.47 self.reference_test_types[location] = test_type
1.48 - self.reference_test_accessor_types[location] = provider
1.49 + self.reference_test_accessor_type[location] = provider
1.50
1.51 elif len(all_general_providers) == 1:
1.52 provider = first(all_general_providers)
1.53 @@ -612,7 +614,7 @@
1.54 else:
1.55 test_type = "common-object"
1.56 self.reference_test_types[location] = test_type
1.57 - self.reference_test_accessor_types[location] = provider
1.58 + self.reference_test_accessor_type[location] = provider
1.59
1.60 # Record the need to test the identity of the attribute.
1.61
1.62 @@ -1731,7 +1733,23 @@
1.63
1.64 def get_access_plan(self, location):
1.65
1.66 - "Return details of the access at the given 'location'."
1.67 + """
1.68 + Return details of the access at the given 'location'. The details are as
1.69 + follows:
1.70 +
1.71 + * the initial accessor (from which accesses will be performed if no
1.72 + computed static accessor is found)
1.73 + * details of any test required on the initial accessor
1.74 + * details of any type employed by the test
1.75 + * any static accessor (from which accesses will be performed in
1.76 + preference to the initial accessor)
1.77 + * attributes needing to be traversed from the base that yield
1.78 + unambiguous objects
1.79 + * remaining attributes needing to be tested and traversed
1.80 + * details of the context
1.81 + * the method of obtaining the final attribute
1.82 + * any static final attribute
1.83 + """
1.84
1.85 const_access = self.const_accesses_rev.has_key(location)
1.86
1.87 @@ -1761,6 +1779,7 @@
1.88
1.89 constrained = location in self.access_constrained
1.90 test = self.reference_test_types[location]
1.91 + test_type = self.reference_test_accessor_type.get(location)
1.92
1.93 # Determine the accessor and provider properties.
1.94
1.95 @@ -1810,7 +1829,7 @@
1.96 # Such tests allow single or multiple kinds of a type.
1.97
1.98 elif test in self.common_tests or test in self.specific_tests:
1.99 - dynamic_base = self.reference_test_accessor_types[location]
1.100 + dynamic_base = test_type
1.101
1.102 # Static accessors.
1.103
1.104 @@ -1880,6 +1899,8 @@
1.105
1.106 # Determine the nature of the context.
1.107
1.108 - return base or name, traversed, remaining, method, test, origin
1.109 + context = base and "base" or len(traversed or remaining) > 1 and "traversal" or "accessor"
1.110 +
1.111 + return name, test, test_type, base, traversed, remaining, context, method, origin
1.112
1.113 # vim: tabstop=4 expandtab shiftwidth=4