# HG changeset patch # User Paul Boddie # Date 1716159339 -7200 # Node ID e8ff2a117367b904684095bebdf96d1a0ab2b2d8 # Parent aa1826243f0c6e77cce2beafa5b4c0c967a6aefd Fixed accessor temporary storage reservation for lambdas and eliminated redundant temporary storage reservation in attribute accesses. diff -r aa1826243f0c -r e8ff2a117367 translator.py --- a/translator.py Sun May 19 22:53:43 2024 +0200 +++ b/translator.py Mon May 20 00:55:39 2024 +0200 @@ -607,9 +607,14 @@ # Record temporary name usage. + temps = set() + for sub in substituted: if self.temp_subs.has_key(sub): - self.record_temp(self.temp_subs[sub]) + temps.add(self.temp_subs[sub]) + + for temp in temps: + self.next_temp(temp) # Get full final identity details. @@ -1493,6 +1498,24 @@ len(args), "__ARGS(%s)" % argstr)) return InvocationResult(stages) + def next_temp(self, name): + + "Allocate the next temporary storage element for 'name'." + + if name == "__tmp_targets": + self.next_target() + elif name == "__tmp_contexts": + self.next_context() + elif name == "__tmp_values": + self.next_accessor() + elif name in ("__tmp_private_context", "__tmp_target_value", "__tmp_result"): + pass + else: + raise TranslateError("Temporary storage %s is not recognised." % name, + self.get_namespace_path()) + + self.record_temp(name) + def next_target(self): "Allocate the next function target storage." @@ -1582,15 +1605,17 @@ else: self.record_temp("__tmp_values") + accessor_index = self.accessor_index + self.next_accessor() return make_expression("""\ (__set_accessor(%d, __ATTRVALUE(__COPY(&%s, sizeof(%s)))), %s, __get_accessor(%d))""" % ( - self.accessor_index, + accessor_index, encode_path(function_name), encode_symbol("obj", function_name), ", ".join(defaults), - self.accessor_index)) + accessor_index)) def process_logical_node(self, n):