1.1 --- a/translator.py Tue Feb 07 23:37:40 2017 +0100
1.2 +++ b/translator.py Tue Feb 07 23:45:16 2017 +0100
1.3 @@ -67,8 +67,7 @@
1.4
1.5 "An abstract translation result mix-in."
1.6
1.7 - def get_accessor_kinds(self):
1.8 - return None
1.9 + pass
1.10
1.11 class ReturnRef(TranslationResult):
1.12
1.13 @@ -91,13 +90,13 @@
1.14
1.15 "A reference to a name in the translation."
1.16
1.17 - def __init__(self, name, ref, expr=None, parameter=None, unsuitable=None):
1.18 + def __init__(self, name, ref, expr=None, parameter=None, location=None):
1.19 results.ResolvedNameRef.__init__(self, name, ref, expr)
1.20 self.parameter = parameter
1.21 - self.unsuitable = unsuitable
1.22 -
1.23 - def unsuitable_invocations(self):
1.24 - return self.unsuitable
1.25 + self.location = location
1.26 +
1.27 + def access_location(self):
1.28 + return self.location
1.29
1.30 def __str__(self):
1.31
1.32 @@ -193,17 +192,16 @@
1.33
1.34 "A translation result for an attribute access."
1.35
1.36 - def __init__(self, instructions, refs, accessor_kinds, unsuitable):
1.37 + def __init__(self, instructions, refs, location):
1.38 InstructionSequence.__init__(self, instructions)
1.39 self.refs = refs
1.40 - self.accessor_kinds = accessor_kinds
1.41 - self.unsuitable = unsuitable
1.42 + self.location = location
1.43
1.44 def references(self):
1.45 return self.refs
1.46
1.47 - def unsuitable_invocations(self):
1.48 - return self.unsuitable
1.49 + def access_location(self):
1.50 + return self.location
1.51
1.52 def get_origin(self):
1.53 return self.refs and len(self.refs) == 1 and first(self.refs).get_origin()
1.54 @@ -216,14 +214,11 @@
1.55 return True
1.56 return False
1.57
1.58 - def get_accessor_kinds(self):
1.59 - return self.accessor_kinds
1.60 -
1.61 def __str__(self):
1.62 return encode_instructions(self.instructions)
1.63
1.64 def __repr__(self):
1.65 - return "AttrResult(%r, %r, %r)" % (self.instructions, self.refs, self.accessor_kinds)
1.66 + return "AttrResult(%r, %r, %r)" % (self.instructions, self.refs, self.location)
1.67
1.68 class InvocationResult(Expression, TranslationResult, InstructionSequence):
1.69
1.70 @@ -734,7 +729,6 @@
1.71
1.72 location = self.get_access_location(name, self.attrs)
1.73 refs = self.get_referenced_attributes(location)
1.74 - unsuitable = self.get_referenced_attribute_invocations(location)
1.75
1.76 # Generate access instructions.
1.77
1.78 @@ -777,7 +771,7 @@
1.79 self.record_temp(temp_subs[sub])
1.80
1.81 del self.attrs[0]
1.82 - return AttrResult(output, refs, self.get_accessor_kinds(location), unsuitable)
1.83 + return AttrResult(output, refs, location)
1.84
1.85 def get_referenced_attributes(self, location):
1.86
1.87 @@ -806,7 +800,7 @@
1.88
1.89 "Return the accessor kinds for 'location'."
1.90
1.91 - return self.optimiser.accessor_kinds[location]
1.92 + return self.optimiser.accessor_kinds.get(location)
1.93
1.94 def get_access_location(self, name, attrnames=None):
1.95
1.96 @@ -1153,6 +1147,7 @@
1.97
1.98 expr = self.process_structure_node(n.node)
1.99 objpath = expr.get_origin()
1.100 + location = expr.access_location()
1.101
1.102 # Identified target details.
1.103
1.104 @@ -1204,7 +1199,7 @@
1.105 # Test for functions and methods.
1.106
1.107 context_required = self.is_method(objpath)
1.108 - accessor_kinds = expr.get_accessor_kinds()
1.109 + accessor_kinds = self.get_accessor_kinds(location)
1.110 instance_accessor = accessor_kinds and \
1.111 len(accessor_kinds) == 1 and \
1.112 first(accessor_kinds) == "<instance>"
1.113 @@ -1222,7 +1217,7 @@
1.114 # Other targets are retrieved at run-time.
1.115
1.116 else:
1.117 - unsuitable = expr.unsuitable_invocations()
1.118 + unsuitable = self.get_referenced_attribute_invocations(location)
1.119
1.120 if unsuitable:
1.121 for ref in unsuitable:
1.122 @@ -1511,13 +1506,12 @@
1.123 # Find any invocation details.
1.124
1.125 location = self.get_access_location(n.name)
1.126 - unsuitable = self.get_referenced_attribute_invocations(location)
1.127
1.128 # Qualified names are used for resolved static references or for
1.129 # static namespace members. The reference should be configured to return
1.130 # such names.
1.131
1.132 - return TrResolvedNameRef(n.name, ref, expr=expr, parameter=parameter, unsuitable=unsuitable)
1.133 + return TrResolvedNameRef(n.name, ref, expr=expr, parameter=parameter, location=location)
1.134
1.135 def process_not_node(self, n):
1.136