forked from M-Labs/artiq
compiler.ir.Function: add loc field.
This commit is contained in:
parent
22570afbda
commit
8f510a4407
|
@ -184,9 +184,10 @@ class Stitcher:
|
|||
inferencer.visit(self.typedtree)
|
||||
|
||||
# After we have found all functions, synthesize a module to hold them.
|
||||
source_buffer = source.Buffer("", "<synthesized>")
|
||||
self.typedtree = asttyped.ModuleT(
|
||||
typing_env=self.globals, globals_in_scope=set(),
|
||||
body=self.typedtree, loc=None)
|
||||
body=self.typedtree, loc=source.Range(source_buffer, 0, 0))
|
||||
|
||||
def _quote_embedded_function(self, function):
|
||||
if not hasattr(function, "artiq_embedded"):
|
||||
|
|
|
@ -138,6 +138,9 @@ class User(NamedValue):
|
|||
class Instruction(User):
|
||||
"""
|
||||
An SSA instruction.
|
||||
|
||||
:ivar loc: (:class:`pythonparser.source.Range` or None)
|
||||
source location
|
||||
"""
|
||||
|
||||
def __init__(self, operands, typ, name=""):
|
||||
|
@ -388,13 +391,15 @@ class Function:
|
|||
"""
|
||||
A function containing SSA IR.
|
||||
|
||||
:ivar loc: (:class:`pythonparser.source.Range` or None)
|
||||
source location of function definition
|
||||
:ivar is_internal:
|
||||
(bool) if True, the function should not be accessible from outside
|
||||
the module it is contained in
|
||||
"""
|
||||
|
||||
def __init__(self, typ, name, arguments):
|
||||
self.type, self.name = typ, name
|
||||
def __init__(self, typ, name, arguments, loc=None):
|
||||
self.type, self.name, self.loc = typ, name, loc
|
||||
self.names, self.arguments, self.basic_blocks = set(), [], []
|
||||
self.next_name = 1
|
||||
self.set_arguments(arguments)
|
||||
|
|
|
@ -129,7 +129,8 @@ class ARTIQIRGenerator(algorithm.Visitor):
|
|||
|
||||
try:
|
||||
typ = types.TFunction(OrderedDict(), OrderedDict(), builtins.TNone())
|
||||
func = ir.Function(typ, ".".join(self.name + ['__modinit__']), [])
|
||||
func = ir.Function(typ, ".".join(self.name + ['__modinit__']), [],
|
||||
loc=node.loc.begin())
|
||||
self.functions.append(func)
|
||||
old_func, self.current_function = self.current_function, func
|
||||
|
||||
|
@ -184,7 +185,8 @@ class ARTIQIRGenerator(algorithm.Visitor):
|
|||
for arg_name in typ.optargs:
|
||||
optargs.append(ir.Argument(ir.TOption(typ.optargs[arg_name]), "arg." + arg_name))
|
||||
|
||||
func = ir.Function(typ, ".".join(self.name), [env_arg] + args + optargs)
|
||||
func = ir.Function(typ, ".".join(self.name), [env_arg] + args + optargs,
|
||||
loc=node.keyword_loc)
|
||||
func.is_internal = is_internal
|
||||
self.functions.append(func)
|
||||
old_func, self.current_function = self.current_function, func
|
||||
|
|
Loading…
Reference in New Issue