forked from M-Labs/artiq
compiler.embedding: treat RPC methods like any others (fixes #211).
This commit is contained in:
parent
14484216ec
commit
ff3206be07
|
@ -331,8 +331,7 @@ class StitchingInferencer(Inferencer):
|
||||||
# of having the host-to-ARTIQ mapping code in only one place and
|
# of having the host-to-ARTIQ mapping code in only one place and
|
||||||
# also immediately getting proper diagnostics on type errors.
|
# also immediately getting proper diagnostics on type errors.
|
||||||
attr_value = getattr(object_value, node.attr)
|
attr_value = getattr(object_value, node.attr)
|
||||||
if (inspect.ismethod(attr_value) and hasattr(attr_value.__func__, 'artiq_embedded')
|
if inspect.ismethod(attr_value) and types.is_instance(object_type):
|
||||||
and types.is_instance(object_type)):
|
|
||||||
# In cases like:
|
# In cases like:
|
||||||
# class c:
|
# class c:
|
||||||
# @kernel
|
# @kernel
|
||||||
|
@ -340,8 +339,10 @@ class StitchingInferencer(Inferencer):
|
||||||
# we want f to be defined on the class, not on the instance.
|
# we want f to be defined on the class, not on the instance.
|
||||||
attributes = object_type.constructor.attributes
|
attributes = object_type.constructor.attributes
|
||||||
attr_value = attr_value.__func__
|
attr_value = attr_value.__func__
|
||||||
|
is_method = True
|
||||||
else:
|
else:
|
||||||
attributes = object_type.attributes
|
attributes = object_type.attributes
|
||||||
|
is_method = False
|
||||||
|
|
||||||
attr_value_type = None
|
attr_value_type = None
|
||||||
|
|
||||||
|
@ -393,6 +394,12 @@ class StitchingInferencer(Inferencer):
|
||||||
IntMonomorphizer(engine=proxy_engine).visit(ast)
|
IntMonomorphizer(engine=proxy_engine).visit(ast)
|
||||||
attr_value_type = ast.type
|
attr_value_type = ast.type
|
||||||
|
|
||||||
|
if is_method:
|
||||||
|
assert types.is_function(attr_value_type)
|
||||||
|
self_type = list(attr_value_type.args.values())[0]
|
||||||
|
self._unify(object_type, self_type,
|
||||||
|
node.loc, None)
|
||||||
|
|
||||||
if node.attr not in attributes:
|
if node.attr not in attributes:
|
||||||
# We just figured out what the type should be. Add it.
|
# We just figured out what the type should be. Add it.
|
||||||
attributes[node.attr] = attr_value_type
|
attributes[node.attr] = attr_value_type
|
||||||
|
|
Loading…
Reference in New Issue