# HG changeset patch # User Paul Boddie # Date 1693352968 -7200 # Node ID ee9512fa0fc7d4ec613cc41e0ca5cca85355c37f # Parent 24a196b6666eb8413fca5fa7eb1a9bfd07f67898 Introduced missing assignment of intermediate result attributes, this having prevented value replacement from occurring within expressions. diff -r 24a196b6666e -r ee9512fa0fc7 templates/ops.c --- a/templates/ops.c Wed Aug 30 00:55:30 2023 +0200 +++ b/templates/ops.c Wed Aug 30 01:49:28 2023 +0200 @@ -452,33 +452,25 @@ replacement, a copied object is assigned when initialising the local. NOTE: Only floats are currently supported for value replacement. */ -void __set_local(volatile __attr *local, __attr attr) +__attr __set_local(volatile __attr *local, __attr attr) { __ref obj; /* Value already replaced in target by an operation. */ if (__REPLACING(attr)) - return; + return __REPLACED(attr); obj = __VALUE(attr); - /* Value not replaceable, suitable for direct propagation to a local. */ - - if ((obj == NULL) || !__is_instance(obj) || (__get_class(obj) != &__builtins___float_float)) - *local = attr; - /* Value is replaceable and should be copied to avoid inadvertent sharing. */ - else - *local = __ATTRVALUE(__COPY(obj, sizeof(__obj___builtins___float_float))); -} + if ((obj != NULL) && __is_instance(obj) && (__get_class(obj) == &__builtins___float_float)) + attr = __ATTRVALUE(__COPY(obj, sizeof(__obj___builtins___float_float))); -/* Make sure that attributes indicating value replacement are usable as - arguments. */ + /* Set and return the attribute. */ -__attr __to_arg(__attr attr) -{ - return __REPLACING(attr) ? __REPLACED(attr) : attr; + *local = attr; + return attr; } diff -r 24a196b6666e -r ee9512fa0fc7 templates/ops.h --- a/templates/ops.h Wed Aug 30 00:55:30 2023 +0200 +++ b/templates/ops.h Wed Aug 30 01:49:28 2023 +0200 @@ -155,7 +155,6 @@ /* Result target administration for potential value replacement. */ -void __set_local(volatile __attr *local, __attr attr); -__attr __to_arg(__attr attr); +__attr __set_local(volatile __attr *local, __attr attr); #endif /* __OPS_H__ */ diff -r 24a196b6666e -r ee9512fa0fc7 translator.py --- a/translator.py Wed Aug 30 00:55:30 2023 +0200 +++ b/translator.py Wed Aug 30 01:49:28 2023 +0200 @@ -1348,7 +1348,7 @@ # Convert any attributes indicating value replacement. if isinstance(argexpr, InvocationResult): - argexprstr = "__to_arg(%s)" % argexpr + argexprstr = "__set_local(&%s, %s)" % (argexpr.result_target, argexpr) else: argexprstr = str(argexpr) @@ -1508,7 +1508,7 @@ if instantiation: return InstantiationResult(instantiation, stages) else: - return InvocationResult(stages) + return InvocationResult(result_target, stages) # With unknown targets, the generic invocation function is applied to # the callable and argument collections. @@ -1519,7 +1519,7 @@ self.always_callable(refs) and 1 or 0, len(kwargs), kwcodestr, kwargstr, len(args), "__ARGS(%s)" % argstr)) - return InvocationResult(stages) + return InvocationResult(result_target, stages) def reset_temp_counters(self): diff -r 24a196b6666e -r ee9512fa0fc7 transresults.py --- a/transresults.py Wed Aug 30 00:55:30 2023 +0200 +++ b/transresults.py Wed Aug 30 01:49:28 2023 +0200 @@ -289,11 +289,15 @@ "A translation result for an invocation." + def __init__(self, result_target, instructions): + InstructionSequence.__init__(self, instructions) + self.result_target = result_target + def __str__(self): return encode_instructions(self.instructions) def __repr__(self): - return "InvocationResult(%r)" % self.instructions + return "InvocationResult(%r, %r)" % (self.result_target, self.instructions) class InstantiationResult(InvocationResult, TrInstanceRef): @@ -301,7 +305,7 @@ def __init__(self, ref, instructions): InstanceRef.__init__(self, ref) - InvocationResult.__init__(self, instructions) + InvocationResult.__init__(self, "__NULL", instructions) def __repr__(self): return "InstantiationResult(%r, %r)" % (self.ref, self.instructions)