# HG changeset patch # User Paul Boddie # Date 1489528805 -3600 # Node ID b7de08fc69b09d18630e97ddf469a3910ffee3bb # Parent 812f634ba99efd1574b1f56b3c10774bc51f696b Simplified the AliasResult class, exposing the access location of the alias instead of multiple access locations corresponding to initialising accesses. diff -r 812f634ba99e -r b7de08fc69b0 translator.py --- a/translator.py Tue Mar 14 22:54:03 2017 +0100 +++ b/translator.py Tue Mar 14 23:00:05 2017 +0100 @@ -647,16 +647,11 @@ access_location = self.deducer.const_accesses.get(location) return self.deducer.reference_invocations_unsuitable.get(access_location or location) - def get_accessor_kinds(self, locations): - - "Return the accessor kinds for 'locations'." - - accessor_kinds = set() - for location in locations: - kinds = self.deducer.accessor_kinds.get(location) - if kinds: - accessor_kinds.update(kinds) - return accessor_kinds + def get_accessor_kinds(self, location): + + "Return the accessor kinds for 'location'." + + return self.deducer.accessor_kinds.get(location) def get_access_location(self, name, attrnames=None): @@ -1025,7 +1020,6 @@ objpath = expr.get_origin() location = expr.access_location() - locations = expr.access_locations() # Identified target details. @@ -1080,8 +1074,7 @@ context_required = self.is_method(objpath) - accessor_kinds = location and self.get_accessor_kinds([location]) or \ - locations and self.get_accessor_kinds(locations) + accessor_kinds = location and self.get_accessor_kinds(location) instance_accessor = accessor_kinds and \ len(accessor_kinds) == 1 and \ @@ -1456,7 +1449,7 @@ refs = self.deducer.referenced_objects.get(location) refs = refs or self.deducer.accessor_all_types.get(location) - return AliasResult(name_ref, refs or set(), [location]) + return AliasResult(name_ref, refs or set(), location) def make_volatile(self, name): diff -r 812f634ba99e -r b7de08fc69b0 transresults.py --- a/transresults.py Tue Mar 14 22:54:03 2017 +0100 +++ b/transresults.py Tue Mar 14 23:00:05 2017 +0100 @@ -71,9 +71,6 @@ def access_location(self): return self.location - def access_locations(self): - return self.location and [self.location] - def __str__(self): "Return an output representation of the referenced name." @@ -188,9 +185,6 @@ def access_location(self): return self.location - def access_locations(self): - return self.location and [self.location] - def context(self): return self.context_identity @@ -218,11 +212,11 @@ "An alias for other values." - def __init__(self, name_ref, refs, locations): + def __init__(self, name_ref, refs, location): NameRef.__init__(self, name_ref.name, is_global=name_ref.is_global_name()) self.name_ref = name_ref self.refs = refs - self.locations = locations + self.location = location def references(self): ref = self.name_ref.reference() @@ -233,10 +227,7 @@ return len(refs) == 1 and first(refs) or None def access_location(self): - return len(self.locations) == 1 and first(self.locations) or None - - def access_locations(self): - return self.locations + return self.location def get_name(self): ref = self.reference()