1.1 --- a/templates/ops.c Wed Aug 30 00:55:30 2023 +0200
1.2 +++ b/templates/ops.c Wed Aug 30 01:49:28 2023 +0200
1.3 @@ -452,33 +452,25 @@
1.4 replacement, a copied object is assigned when initialising the local.
1.5 NOTE: Only floats are currently supported for value replacement. */
1.6
1.7 -void __set_local(volatile __attr *local, __attr attr)
1.8 +__attr __set_local(volatile __attr *local, __attr attr)
1.9 {
1.10 __ref obj;
1.11
1.12 /* Value already replaced in target by an operation. */
1.13
1.14 if (__REPLACING(attr))
1.15 - return;
1.16 + return __REPLACED(attr);
1.17
1.18 obj = __VALUE(attr);
1.19
1.20 - /* Value not replaceable, suitable for direct propagation to a local. */
1.21 -
1.22 - if ((obj == NULL) || !__is_instance(obj) || (__get_class(obj) != &__builtins___float_float))
1.23 - *local = attr;
1.24 -
1.25 /* Value is replaceable and should be copied to avoid inadvertent
1.26 sharing. */
1.27
1.28 - else
1.29 - *local = __ATTRVALUE(__COPY(obj, sizeof(__obj___builtins___float_float)));
1.30 -}
1.31 + if ((obj != NULL) && __is_instance(obj) && (__get_class(obj) == &__builtins___float_float))
1.32 + attr = __ATTRVALUE(__COPY(obj, sizeof(__obj___builtins___float_float)));
1.33
1.34 -/* Make sure that attributes indicating value replacement are usable as
1.35 - arguments. */
1.36 + /* Set and return the attribute. */
1.37
1.38 -__attr __to_arg(__attr attr)
1.39 -{
1.40 - return __REPLACING(attr) ? __REPLACED(attr) : attr;
1.41 + *local = attr;
1.42 + return attr;
1.43 }
2.1 --- a/templates/ops.h Wed Aug 30 00:55:30 2023 +0200
2.2 +++ b/templates/ops.h Wed Aug 30 01:49:28 2023 +0200
2.3 @@ -155,7 +155,6 @@
2.4
2.5 /* Result target administration for potential value replacement. */
2.6
2.7 -void __set_local(volatile __attr *local, __attr attr);
2.8 -__attr __to_arg(__attr attr);
2.9 +__attr __set_local(volatile __attr *local, __attr attr);
2.10
2.11 #endif /* __OPS_H__ */
3.1 --- a/translator.py Wed Aug 30 00:55:30 2023 +0200
3.2 +++ b/translator.py Wed Aug 30 01:49:28 2023 +0200
3.3 @@ -1348,7 +1348,7 @@
3.4 # Convert any attributes indicating value replacement.
3.5
3.6 if isinstance(argexpr, InvocationResult):
3.7 - argexprstr = "__to_arg(%s)" % argexpr
3.8 + argexprstr = "__set_local(&%s, %s)" % (argexpr.result_target, argexpr)
3.9 else:
3.10 argexprstr = str(argexpr)
3.11
3.12 @@ -1508,7 +1508,7 @@
3.13 if instantiation:
3.14 return InstantiationResult(instantiation, stages)
3.15 else:
3.16 - return InvocationResult(stages)
3.17 + return InvocationResult(result_target, stages)
3.18
3.19 # With unknown targets, the generic invocation function is applied to
3.20 # the callable and argument collections.
3.21 @@ -1519,7 +1519,7 @@
3.22 self.always_callable(refs) and 1 or 0,
3.23 len(kwargs), kwcodestr, kwargstr,
3.24 len(args), "__ARGS(%s)" % argstr))
3.25 - return InvocationResult(stages)
3.26 + return InvocationResult(result_target, stages)
3.27
3.28 def reset_temp_counters(self):
3.29
4.1 --- a/transresults.py Wed Aug 30 00:55:30 2023 +0200
4.2 +++ b/transresults.py Wed Aug 30 01:49:28 2023 +0200
4.3 @@ -289,11 +289,15 @@
4.4
4.5 "A translation result for an invocation."
4.6
4.7 + def __init__(self, result_target, instructions):
4.8 + InstructionSequence.__init__(self, instructions)
4.9 + self.result_target = result_target
4.10 +
4.11 def __str__(self):
4.12 return encode_instructions(self.instructions)
4.13
4.14 def __repr__(self):
4.15 - return "InvocationResult(%r)" % self.instructions
4.16 + return "InvocationResult(%r, %r)" % (self.result_target, self.instructions)
4.17
4.18 class InstantiationResult(InvocationResult, TrInstanceRef):
4.19
4.20 @@ -301,7 +305,7 @@
4.21
4.22 def __init__(self, ref, instructions):
4.23 InstanceRef.__init__(self, ref)
4.24 - InvocationResult.__init__(self, instructions)
4.25 + InvocationResult.__init__(self, "__NULL", instructions)
4.26
4.27 def __repr__(self):
4.28 return "InstantiationResult(%r, %r)" % (self.ref, self.instructions)