mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 03:08:27 +08:00
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
|
||||
# also immediately getting proper diagnostics on type errors.
|
||||
attr_value = getattr(object_value, node.attr)
|
||||
if (inspect.ismethod(attr_value) and hasattr(attr_value.__func__, 'artiq_embedded')
|
||||
and types.is_instance(object_type)):
|
||||
if inspect.ismethod(attr_value) and types.is_instance(object_type):
|
||||
# In cases like:
|
||||
# class c:
|
||||
# @kernel
|
||||
@ -340,8 +339,10 @@ class StitchingInferencer(Inferencer):
|
||||
# we want f to be defined on the class, not on the instance.
|
||||
attributes = object_type.constructor.attributes
|
||||
attr_value = attr_value.__func__
|
||||
is_method = True
|
||||
else:
|
||||
attributes = object_type.attributes
|
||||
is_method = False
|
||||
|
||||
attr_value_type = None
|
||||
|
||||
@ -393,6 +394,12 @@ class StitchingInferencer(Inferencer):
|
||||
IntMonomorphizer(engine=proxy_engine).visit(ast)
|
||||
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:
|
||||
# We just figured out what the type should be. Add it.
|
||||
attributes[node.attr] = attr_value_type
|
||||
|
Loading…
Reference in New Issue
Block a user