1.1 --- a/translator.py Sat May 25 17:55:55 2024 +0200
1.2 +++ b/translator.py Sat May 25 18:05:52 2024 +0200
1.3 @@ -1319,7 +1319,9 @@
1.4
1.5 # NOTE: Special case for optimisation.
1.6
1.7 - yields_integer = target and objpath == "native.int.is_int"
1.8 + int_type = "__builtins__.int.int"
1.9 + result_type = target and objpath == "native.int.is_int" and int_type or None
1.10 + yields_integer = result_type == int_type
1.11
1.12 # Employ result targets only in functions.
1.13
1.14 @@ -1556,8 +1558,8 @@
1.15 # Provide the parameter details for possible optimisation when
1.16 # translating the result.
1.17
1.18 - return InvocationResult(result_target, stages,
1.19 - yields_integer and final_args or None)
1.20 + return InvocationResult(result_target, stages, result_type,
1.21 + result_type and final_args or None)
1.22
1.23 # With unknown targets, the generic invocation function is applied to
1.24 # the callable and argument collections.
2.1 --- a/transresults.py Sat May 25 17:55:55 2024 +0200
2.2 +++ b/transresults.py Sat May 25 18:05:52 2024 +0200
2.3 @@ -295,23 +295,24 @@
2.4
2.5 "A translation result for an invocation."
2.6
2.7 - def __init__(self, result_target, instructions, args=None):
2.8 + def __init__(self, result_target, instructions, result_type=None, args=None):
2.9 InstructionSequence.__init__(self, instructions)
2.10 self.result_target = result_target
2.11 + self.result_type = result_type
2.12 self.args = args
2.13
2.14 def yields_integer(self):
2.15 - return self.args and True or False
2.16 + return self.result_type == "__builtins__.int.int"
2.17
2.18 def __str__(self):
2.19 - if self.yields_integer():
2.20 + if self.yields_integer() and self.args is not None:
2.21 return ", ".join(self.args)
2.22 else:
2.23 return encode_instructions(self.instructions)
2.24
2.25 def __repr__(self):
2.26 - return "InvocationResult(%r, %r, %r)" % (self.result_target,
2.27 - self.instructions, self.args)
2.28 + return "InvocationResult(%r, %r, %r, %r)" % (self.result_target,
2.29 + self.instructions, self.result_type, self.args)
2.30
2.31 class InstantiationResult(InvocationResult, TrInstanceRef):
2.32
2.33 @@ -321,6 +322,9 @@
2.34 InstanceRef.__init__(self, ref)
2.35 InvocationResult.__init__(self, "__NULL", instructions)
2.36
2.37 + def yields_integer(self):
2.38 + return self.ref.get_origin() == "__builtins__.int.int"
2.39 +
2.40 def __repr__(self):
2.41 return "InstantiationResult(%r, %r)" % (self.ref, self.instructions)
2.42