forked from M-Labs/artiq
embedding: refactor.
This commit is contained in:
parent
c94c411fd5
commit
d085d5a372
|
@ -786,31 +786,33 @@ class Stitcher:
|
||||||
self.functions[function] = function_type
|
self.functions[function] = function_type
|
||||||
return function_type
|
return function_type
|
||||||
|
|
||||||
def _quote_rpc(self, callee, loc):
|
def _quote_rpc(self, function, loc):
|
||||||
ret_type = builtins.TNone()
|
ret_type = builtins.TNone()
|
||||||
|
|
||||||
if isinstance(callee, pytypes.BuiltinFunctionType):
|
if isinstance(function, pytypes.BuiltinFunctionType):
|
||||||
pass
|
pass
|
||||||
elif isinstance(callee, pytypes.FunctionType) or isinstance(callee, pytypes.MethodType):
|
elif isinstance(function, pytypes.FunctionType) or isinstance(function, pytypes.MethodType):
|
||||||
if isinstance(callee, pytypes.FunctionType):
|
if isinstance(function, pytypes.FunctionType):
|
||||||
signature = inspect.signature(callee)
|
signature = inspect.signature(function)
|
||||||
else:
|
else:
|
||||||
# inspect bug?
|
# inspect bug?
|
||||||
signature = inspect.signature(callee.__func__)
|
signature = inspect.signature(function.__func__)
|
||||||
if signature.return_annotation is not inspect.Signature.empty:
|
if signature.return_annotation is not inspect.Signature.empty:
|
||||||
ret_type = self._extract_annot(callee, signature.return_annotation,
|
ret_type = self._extract_annot(function, signature.return_annotation,
|
||||||
"return type", loc, is_syscall=False)
|
"return type", loc, is_syscall=False)
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
|
|
||||||
function_type = types.TRPC(ret_type, service=self.object_map.store(callee))
|
function_type = types.TRPC(ret_type, service=self.object_map.store(function))
|
||||||
self.functions[callee] = function_type
|
self.functions[function] = function_type
|
||||||
return function_type
|
return function_type
|
||||||
|
|
||||||
def _quote_function(self, function, loc):
|
def _quote_function(self, function, loc):
|
||||||
if function not in self.functions:
|
if function in self.functions:
|
||||||
if hasattr(function, "artiq_embedded"):
|
pass
|
||||||
if function.artiq_embedded.function is not None:
|
elif not hasattr(function, "artiq_embedded"):
|
||||||
|
self._quote_rpc(function, loc)
|
||||||
|
elif function.artiq_embedded.function is not None:
|
||||||
if function.__name__ == "<lambda>":
|
if function.__name__ == "<lambda>":
|
||||||
note = diagnostic.Diagnostic("note",
|
note = diagnostic.Diagnostic("note",
|
||||||
"lambda created here", {},
|
"lambda created here", {},
|
||||||
|
@ -847,8 +849,6 @@ class Stitcher:
|
||||||
self.engine.process(diag)
|
self.engine.process(diag)
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
else:
|
|
||||||
self._quote_rpc(function, loc)
|
|
||||||
|
|
||||||
return self.functions[function]
|
return self.functions[function]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue