Lichen

Changeset

958:51b8fb982bf9
2021-11-14 Paul Boddie raw files shortlog changelog graph Merged changes from the default branch. tagged-address-values
     1.1 --- a/translator.py	Sat Nov 06 17:06:01 2021 +0100
     1.2 +++ b/translator.py	Sun Nov 14 00:32:11 2021 +0100
     1.3 @@ -1293,6 +1293,7 @@
     1.4              context_arg = "__NULL"
     1.5  
     1.6          args = [context_arg]
     1.7 +        reserved_args = 1
     1.8  
     1.9          # Complete the array with null values, permitting tests for a complete
    1.10          # set of arguments.
    1.11 @@ -1337,7 +1338,7 @@
    1.12                      except ValueError:
    1.13                          raise TranslateError("Argument %s is not recognised." % arg.name,
    1.14                                               self.get_namespace_path(), n)
    1.15 -                    args[argnum+1] = str(argexpr)
    1.16 +                    args[argnum + reserved_args] = str(argexpr)
    1.17  
    1.18                  # Otherwise, store the details in a separate collection.
    1.19  
    1.20 @@ -1351,7 +1352,7 @@
    1.21  
    1.22              else:
    1.23                  try:
    1.24 -                    args[i+1] = str(argexpr)
    1.25 +                    args[i + reserved_args] = str(argexpr)
    1.26                  except IndexError:
    1.27                      raise TranslateError("Too many arguments specified.",
    1.28                                           self.get_namespace_path(), n)
    1.29 @@ -1375,8 +1376,8 @@
    1.30  
    1.31              for i, (argname, default) in enumerate(function_defaults):
    1.32                  argnum = parameters.index(argname)
    1.33 -                if not args[argnum+1]:
    1.34 -                    args[argnum+1] = "__GETDEFAULT(%s, %d)" % (target_structure, i)
    1.35 +                if not args[argnum + reserved_args]:
    1.36 +                    args[argnum + reserved_args] = "__GETDEFAULT(%s, %d)" % (target_structure, i)
    1.37  
    1.38          elif known_parameters:
    1.39  
    1.40 @@ -1387,7 +1388,7 @@
    1.41              i = len(n.args)
    1.42              pos = i - (num_parameters - num_defaults)
    1.43              while i < num_parameters:
    1.44 -                args[i+1] = "__GETDEFAULT(%s.value, %d)" % (target_var, pos)
    1.45 +                args[i + reserved_args] = "__GETDEFAULT(%s.value, %d)" % (target_var, pos)
    1.46                  i += 1
    1.47                  pos += 1
    1.48  
    1.49 @@ -1403,7 +1404,7 @@
    1.50          # the number of values. The context is excluded.
    1.51  
    1.52          if literal_instantiation:
    1.53 -            argstr = "%d, %s" % (len(args) - 1, ", ".join(args[1:]))
    1.54 +            argstr = "%d, %s" % (len(args) - reserved_args, ", ".join(args[reserved_args:]))
    1.55          else:
    1.56              argstr = ", ".join(args)
    1.57