From ce3c8fcd3e7b3d604d4bc56ce882f557a39917dd Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 22 May 2018 18:14:06 +0000 Subject: [PATCH] compiler: add source location to SSA arguments. Fixes #1006. --- artiq/compiler/ir.py | 6 ++++++ artiq/compiler/transforms/artiq_ir_generator.py | 3 +++ 2 files changed, 9 insertions(+) diff --git a/artiq/compiler/ir.py b/artiq/compiler/ir.py index d54ce0518..c20359962 100644 --- a/artiq/compiler/ir.py +++ b/artiq/compiler/ir.py @@ -410,7 +410,13 @@ class BasicBlock(NamedValue): class Argument(NamedValue): """ A function argument. + + :ivar loc: (:class:`pythonparser.source.Range` or None) + source location """ + def __init__(self, typ, name): + super().__init__(typ, name) + self.loc = None def as_entity(self, type_printer): return self.as_operand(type_printer) diff --git a/artiq/compiler/transforms/artiq_ir_generator.py b/artiq/compiler/transforms/artiq_ir_generator.py index df274b794..970803454 100644 --- a/artiq/compiler/transforms/artiq_ir_generator.py +++ b/artiq/compiler/transforms/artiq_ir_generator.py @@ -268,6 +268,9 @@ class ARTIQIRGenerator(algorithm.Visitor): self.current_args[arg_name] = arg optargs.append(arg) + for (arg, arg_node) in zip(args + optargs, node.args.args): + arg.loc = arg_node.loc + func = ir.Function(typ, ".".join(self.name), [env_arg] + args + optargs, loc=node.lambda_loc if is_lambda else node.keyword_loc) func.is_internal = is_internal