embedding: refactor.

This commit is contained in:
whitequark 2016-05-16 12:33:26 +00:00
parent c94c411fd5
commit d085d5a372
1 changed files with 48 additions and 48 deletions

View File

@ -786,31 +786,33 @@ class Stitcher:
self.functions[function] = function_type
return function_type
def _quote_rpc(self, callee, loc):
def _quote_rpc(self, function, loc):
ret_type = builtins.TNone()
if isinstance(callee, pytypes.BuiltinFunctionType):
if isinstance(function, pytypes.BuiltinFunctionType):
pass
elif isinstance(callee, pytypes.FunctionType) or isinstance(callee, pytypes.MethodType):
if isinstance(callee, pytypes.FunctionType):
signature = inspect.signature(callee)
elif isinstance(function, pytypes.FunctionType) or isinstance(function, pytypes.MethodType):
if isinstance(function, pytypes.FunctionType):
signature = inspect.signature(function)
else:
# inspect bug?
signature = inspect.signature(callee.__func__)
signature = inspect.signature(function.__func__)
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)
else:
assert False
function_type = types.TRPC(ret_type, service=self.object_map.store(callee))
self.functions[callee] = function_type
function_type = types.TRPC(ret_type, service=self.object_map.store(function))
self.functions[function] = function_type
return function_type
def _quote_function(self, function, loc):
if function not in self.functions:
if hasattr(function, "artiq_embedded"):
if function.artiq_embedded.function is not None:
if function in self.functions:
pass
elif not hasattr(function, "artiq_embedded"):
self._quote_rpc(function, loc)
elif function.artiq_embedded.function is not None:
if function.__name__ == "<lambda>":
note = diagnostic.Diagnostic("note",
"lambda created here", {},
@ -847,8 +849,6 @@ class Stitcher:
self.engine.process(diag)
else:
assert False
else:
self._quote_rpc(function, loc)
return self.functions[function]