forked from M-Labs/artiq
Reformat.
This commit is contained in:
parent
cb9e7d15bf
commit
73c358a59a
@ -1558,68 +1558,79 @@ class ARTIQIRGenerator(algorithm.Visitor):
|
|||||||
|
|
||||||
if types.is_builtin(typ):
|
if types.is_builtin(typ):
|
||||||
insn = self.visit_builtin_call(node)
|
insn = self.visit_builtin_call(node)
|
||||||
|
|
||||||
|
# Temporary.
|
||||||
|
if node.iodelay is not None and not iodelay.is_const(node.iodelay, 0):
|
||||||
|
after_delay = self.add_block()
|
||||||
|
self.append(ir.Delay(node.iodelay,
|
||||||
|
{var_name: self.current_args[var_name]
|
||||||
|
for var_name in node.iodelay.free_vars()},
|
||||||
|
after_delay))
|
||||||
|
self.current_block = after_delay
|
||||||
|
|
||||||
|
return insn
|
||||||
|
|
||||||
|
if types.is_function(typ):
|
||||||
|
func = self.visit(node.func)
|
||||||
|
self_arg = None
|
||||||
|
fn_typ = typ
|
||||||
|
offset = 0
|
||||||
|
elif types.is_method(typ):
|
||||||
|
method = self.visit(node.func)
|
||||||
|
func = self.append(ir.GetAttr(method, "__func__"))
|
||||||
|
self_arg = self.append(ir.GetAttr(method, "__self__"))
|
||||||
|
fn_typ = types.get_method_function(typ)
|
||||||
|
offset = 1
|
||||||
else:
|
else:
|
||||||
if types.is_function(typ):
|
assert False
|
||||||
func = self.visit(node.func)
|
|
||||||
self_arg = None
|
args = [None] * (len(fn_typ.args) + len(fn_typ.optargs))
|
||||||
fn_typ = typ
|
|
||||||
offset = 0
|
for index, arg_node in enumerate(node.args):
|
||||||
elif types.is_method(typ):
|
arg = self.visit(arg_node)
|
||||||
method = self.visit(node.func)
|
if index < len(fn_typ.args):
|
||||||
func = self.append(ir.GetAttr(method, "__func__"))
|
args[index + offset] = arg
|
||||||
self_arg = self.append(ir.GetAttr(method, "__self__"))
|
|
||||||
fn_typ = types.get_method_function(typ)
|
|
||||||
offset = 1
|
|
||||||
else:
|
else:
|
||||||
assert False
|
args[index + offset] = self.append(ir.Alloc([arg], ir.TOption(arg.type)))
|
||||||
|
|
||||||
args = [None] * (len(fn_typ.args) + len(fn_typ.optargs))
|
for keyword in node.keywords:
|
||||||
|
arg = self.visit(keyword.value)
|
||||||
|
if keyword.arg in fn_typ.args:
|
||||||
|
for index, arg_name in enumerate(fn_typ.args):
|
||||||
|
if keyword.arg == arg_name:
|
||||||
|
assert args[index] is None
|
||||||
|
args[index] = arg
|
||||||
|
break
|
||||||
|
elif keyword.arg in fn_typ.optargs:
|
||||||
|
for index, optarg_name in enumerate(fn_typ.optargs):
|
||||||
|
if keyword.arg == optarg_name:
|
||||||
|
assert args[len(fn_typ.args) + index] is None
|
||||||
|
args[len(fn_typ.args) + index] = \
|
||||||
|
self.append(ir.Alloc([arg], ir.TOption(arg.type)))
|
||||||
|
break
|
||||||
|
|
||||||
for index, arg_node in enumerate(node.args):
|
for index, optarg_name in enumerate(fn_typ.optargs):
|
||||||
arg = self.visit(arg_node)
|
if args[len(fn_typ.args) + index] is None:
|
||||||
if index < len(fn_typ.args):
|
args[len(fn_typ.args) + index] = \
|
||||||
args[index + offset] = arg
|
self.append(ir.Alloc([], ir.TOption(fn_typ.optargs[optarg_name])))
|
||||||
else:
|
|
||||||
args[index + offset] = self.append(ir.Alloc([arg], ir.TOption(arg.type)))
|
|
||||||
|
|
||||||
for keyword in node.keywords:
|
if self_arg is not None:
|
||||||
arg = self.visit(keyword.value)
|
assert args[0] is None
|
||||||
if keyword.arg in fn_typ.args:
|
args[0] = self_arg
|
||||||
for index, arg_name in enumerate(fn_typ.args):
|
|
||||||
if keyword.arg == arg_name:
|
|
||||||
assert args[index] is None
|
|
||||||
args[index] = arg
|
|
||||||
break
|
|
||||||
elif keyword.arg in fn_typ.optargs:
|
|
||||||
for index, optarg_name in enumerate(fn_typ.optargs):
|
|
||||||
if keyword.arg == optarg_name:
|
|
||||||
assert args[len(fn_typ.args) + index] is None
|
|
||||||
args[len(fn_typ.args) + index] = \
|
|
||||||
self.append(ir.Alloc([arg], ir.TOption(arg.type)))
|
|
||||||
break
|
|
||||||
|
|
||||||
for index, optarg_name in enumerate(fn_typ.optargs):
|
assert None not in args
|
||||||
if args[len(fn_typ.args) + index] is None:
|
|
||||||
args[len(fn_typ.args) + index] = \
|
|
||||||
self.append(ir.Alloc([], ir.TOption(fn_typ.optargs[optarg_name])))
|
|
||||||
|
|
||||||
if self_arg is not None:
|
if self.unwind_target is None:
|
||||||
assert args[0] is None
|
insn = self.append(ir.Call(func, args))
|
||||||
args[0] = self_arg
|
else:
|
||||||
|
after_invoke = self.add_block()
|
||||||
|
insn = self.append(ir.Invoke(func, args, after_invoke, self.unwind_target))
|
||||||
|
self.current_block = after_invoke
|
||||||
|
|
||||||
assert None not in args
|
method_key = None
|
||||||
|
if isinstance(node.func, asttyped.AttributeT):
|
||||||
if self.unwind_target is None:
|
attr_node = node.func
|
||||||
insn = self.append(ir.Call(func, args))
|
self.method_map[(attr_node.value.type, attr_node.attr)].append(insn)
|
||||||
else:
|
|
||||||
after_invoke = self.add_block()
|
|
||||||
insn = self.append(ir.Invoke(func, args, after_invoke, self.unwind_target))
|
|
||||||
self.current_block = after_invoke
|
|
||||||
|
|
||||||
method_key = None
|
|
||||||
if isinstance(node.func, asttyped.AttributeT):
|
|
||||||
attr_node = node.func
|
|
||||||
self.method_map[(attr_node.value.type, attr_node.attr)].append(insn)
|
|
||||||
|
|
||||||
if node.iodelay is not None and not iodelay.is_const(node.iodelay, 0):
|
if node.iodelay is not None and not iodelay.is_const(node.iodelay, 0):
|
||||||
after_delay = self.add_block()
|
after_delay = self.add_block()
|
||||||
|
Loading…
Reference in New Issue
Block a user