# HG changeset patch # User Paul Boddie # Date 1716653164 -7200 # Node ID afe6d057b09b5ef39fe8339545ce678f54e41d81 # Parent 5c82d4e83af95beb0e32f59394cfc370cc53b8c9# Parent 45cf903a5062659b301d72030efd87abb6a31907 Merged changes from the value-replacement branch. diff -r 5c82d4e83af9 -r afe6d057b09b translator.py --- a/translator.py Sat May 25 17:56:19 2024 +0200 +++ b/translator.py Sat May 25 18:06:04 2024 +0200 @@ -1320,7 +1320,9 @@ # NOTE: Special case for optimisation. - yields_integer = target and objpath == "native.int.is_int" + int_type = "__builtins__.int.int" + result_type = target and objpath == "native.int.is_int" and int_type or None + yields_integer = result_type == int_type # Employ result targets only in functions. @@ -1557,8 +1559,8 @@ # Provide the parameter details for possible optimisation when # translating the result. - return InvocationResult(result_target, stages, - yields_integer and final_args or None) + return InvocationResult(result_target, stages, result_type, + result_type and final_args or None) # With unknown targets, the generic invocation function is applied to # the callable and argument collections. diff -r 5c82d4e83af9 -r afe6d057b09b transresults.py --- a/transresults.py Sat May 25 17:56:19 2024 +0200 +++ b/transresults.py Sat May 25 18:06:04 2024 +0200 @@ -295,23 +295,24 @@ "A translation result for an invocation." - def __init__(self, result_target, instructions, args=None): + def __init__(self, result_target, instructions, result_type=None, args=None): InstructionSequence.__init__(self, instructions) self.result_target = result_target + self.result_type = result_type self.args = args def yields_integer(self): - return self.args and True or False + return self.result_type == "__builtins__.int.int" def __str__(self): - if self.yields_integer(): + if self.yields_integer() and self.args is not None: return ", ".join(self.args) else: return encode_instructions(self.instructions) def __repr__(self): - return "InvocationResult(%r, %r, %r)" % (self.result_target, - self.instructions, self.args) + return "InvocationResult(%r, %r, %r, %r)" % (self.result_target, + self.instructions, self.result_type, self.args) class InstantiationResult(InvocationResult, TrInstanceRef): @@ -321,6 +322,9 @@ InstanceRef.__init__(self, ref) InvocationResult.__init__(self, "__NULL", instructions) + def yields_integer(self): + return self.ref.get_origin() == "__builtins__.int.int" + def __repr__(self): return "InstantiationResult(%r, %r)" % (self.ref, self.instructions)