# HG changeset patch # User Paul Boddie # Date 1716653152 -7200 # Node ID 45cf903a5062659b301d72030efd87abb6a31907 # Parent a03f89d0f603a2ae8ad46482bd6fcd09bd167213# Parent 23d55ac5643345a091a1d13271171c1791a83476 Merged and adapted changes from the trailing-data branch. diff -r a03f89d0f603 -r 45cf903a5062 translator.py --- a/translator.py Sat May 25 17:55:55 2024 +0200 +++ b/translator.py Sat May 25 18:05:52 2024 +0200 @@ -1319,7 +1319,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. @@ -1556,8 +1558,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 a03f89d0f603 -r 45cf903a5062 transresults.py --- a/transresults.py Sat May 25 17:55:55 2024 +0200 +++ b/transresults.py Sat May 25 18:05:52 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)