forked from M-Labs/artiq
1
0
Fork 0

compiler.embedding: instantiate type of even the first embedding of an RPC.

This commit is contained in:
whitequark 2015-11-27 14:55:47 +08:00
parent cde21bcd26
commit 0a794fe7e4
1 changed files with 25 additions and 24 deletions

View File

@ -670,11 +670,8 @@ class Stitcher:
return typ return typ
if function in self.functions: if function in self.functions:
function_name, function_type = self.functions[function] result = self.functions[function]
if types.is_rpc_function(function_type): else:
function_type = function_type.map(instantiate)
return function_name, function_type
if hasattr(function, "artiq_embedded"): if hasattr(function, "artiq_embedded"):
if function.artiq_embedded.function is not None: if function.artiq_embedded.function is not None:
# Insert the typed AST for the new function and restart inference. # Insert the typed AST for the new function and restart inference.
@ -682,19 +679,23 @@ class Stitcher:
# the final call. # the final call.
function_node = self._quote_embedded_function(function) function_node = self._quote_embedded_function(function)
self._inject(function_node) self._inject(function_node)
return function_node.name, self.globals[function_node.name] result = function_node.name, self.globals[function_node.name]
elif function.artiq_embedded.syscall is not None: elif function.artiq_embedded.syscall is not None:
# Insert a storage-less global whose type instructs the compiler # Insert a storage-less global whose type instructs the compiler
# to perform a system call instead of a regular call. # to perform a system call instead of a regular call.
return self._quote_foreign_function(function, loc, result = self._quote_foreign_function(function, loc,
syscall=function.artiq_embedded.syscall) syscall=function.artiq_embedded.syscall)
else: else:
assert False assert False
else: else:
# Insert a storage-less global whose type instructs the compiler # Insert a storage-less global whose type instructs the compiler
# to perform an RPC instead of a regular call. # to perform an RPC instead of a regular call.
return self._quote_foreign_function(function, loc, result = self._quote_foreign_function(function, loc, syscall=None)
syscall=None)
function_name, function_type = result
if types.is_rpc_function(function_type):
function_type = function_type.map(instantiate)
return function_name, function_type
def _quote(self, value, loc): def _quote(self, value, loc):
synthesizer = self._synthesizer(loc) synthesizer = self._synthesizer(loc)