# HG changeset patch # User Paul Boddie # Date 1716159800 -7200 # Node ID e3d77b4d9fa81aada1d25b8a13edc314dfdc678d # Parent 2df62f615d0c765f0e863b16e7b3465b2f069624# Parent 2ef21d25c6e5361e6b10cd93fdf559cb7191179a Merged changes from the trailing-data branch. diff -r 2df62f615d0c -r e3d77b4d9fa8 translator.py --- a/translator.py Sun May 19 22:56:31 2024 +0200 +++ b/translator.py Mon May 20 01:03:20 2024 +0200 @@ -625,9 +625,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. @@ -1567,6 +1572,28 @@ self.max_accessor_index = 0 self.max_attribute_ref_index = 0 + def next_temp(self, name): + + "Allocate the next temporary storage element for 'name'." + + if name == "__tmp_results": + self.next_result() + elif name == "__tmp_targets": + self.next_target() + elif name == "__tmp_contexts": + self.next_context() + elif name == "__tmp_values": + self.next_accessor() + elif name == "__tmp_attr_refs": + self.next_attribute_ref() + 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_result(self): "Allocate the next result target storage." @@ -1670,15 +1697,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):