forked from M-Labs/artiq
1
0
Fork 0

compiler: add source location to SSA arguments.

Fixes #1006.
This commit is contained in:
whitequark 2018-05-22 18:14:06 +00:00
parent fcd12e3472
commit ce3c8fcd3e
2 changed files with 9 additions and 0 deletions

View File

@ -410,7 +410,13 @@ class BasicBlock(NamedValue):
class Argument(NamedValue): class Argument(NamedValue):
""" """
A function argument. 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): def as_entity(self, type_printer):
return self.as_operand(type_printer) return self.as_operand(type_printer)

View File

@ -268,6 +268,9 @@ class ARTIQIRGenerator(algorithm.Visitor):
self.current_args[arg_name] = arg self.current_args[arg_name] = arg
optargs.append(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, func = ir.Function(typ, ".".join(self.name), [env_arg] + args + optargs,
loc=node.lambda_loc if is_lambda else node.keyword_loc) loc=node.lambda_loc if is_lambda else node.keyword_loc)
func.is_internal = is_internal func.is_internal = is_internal