Lichen

Change of translator.py

1037:2ef21d25c6e5
translator.py trailing-data
     1.1 --- a/translator.py	Sun May 19 22:53:57 2024 +0200
     1.2 +++ b/translator.py	Mon May 20 01:00:32 2024 +0200
     1.3 @@ -607,9 +607,14 @@
     1.4  
     1.5          # Record temporary name usage.
     1.6  
     1.7 +        temps = set()
     1.8 +
     1.9          for sub in substituted:
    1.10              if self.temp_subs.has_key(sub):
    1.11 -                self.record_temp(self.temp_subs[sub])
    1.12 +                temps.add(self.temp_subs[sub])
    1.13 +
    1.14 +        for temp in temps:
    1.15 +            self.next_temp(temp)
    1.16  
    1.17          # Get full final identity details.
    1.18  
    1.19 @@ -1493,6 +1498,24 @@
    1.20                  len(args), "__ARGS(%s)" % argstr))
    1.21              return InvocationResult(stages)
    1.22  
    1.23 +    def next_temp(self, name):
    1.24 +
    1.25 +        "Allocate the next temporary storage element for 'name'."
    1.26 +
    1.27 +        if name == "__tmp_targets":
    1.28 +            self.next_target()
    1.29 +        elif name == "__tmp_contexts":
    1.30 +            self.next_context()
    1.31 +        elif name == "__tmp_values":
    1.32 +            self.next_accessor()
    1.33 +        elif name in ("__tmp_private_context", "__tmp_target_value", "__tmp_result"):
    1.34 +            pass
    1.35 +        else:
    1.36 +            raise TranslateError("Temporary storage %s is not recognised." % name,
    1.37 +                                 self.get_namespace_path())
    1.38 +
    1.39 +        self.record_temp(name)
    1.40 +
    1.41      def next_target(self):
    1.42  
    1.43          "Allocate the next function target storage."
    1.44 @@ -1582,15 +1605,17 @@
    1.45  
    1.46          else:
    1.47              self.record_temp("__tmp_values")
    1.48 +            accessor_index = self.accessor_index
    1.49 +            self.next_accessor()
    1.50              return make_expression("""\
    1.51  (__set_accessor(%d, __ATTRVALUE(__COPY(&%s, sizeof(%s)))),
    1.52   %s,
    1.53   __get_accessor(%d))""" % (
    1.54 -                self.accessor_index,
    1.55 +                accessor_index,
    1.56                  encode_path(function_name),
    1.57                  encode_symbol("obj", function_name),
    1.58                  ", ".join(defaults),
    1.59 -                self.accessor_index))
    1.60 +                accessor_index))
    1.61  
    1.62      def process_logical_node(self, n):
    1.63