forked from M-Labs/artiq
1
0
Fork 0

compiler.embedding: handle errors during initial kernel call.

This commit is contained in:
whitequark 2015-08-28 05:14:06 -05:00
parent b35051cb08
commit bcba86de7e
1 changed files with 18 additions and 13 deletions

View File

@ -479,14 +479,17 @@ class Stitcher:
return source.Range(source_buffer, column, column) return source.Range(source_buffer, column, column)
def _call_site_note(self, call_loc, is_syscall): def _call_site_note(self, call_loc, is_syscall):
if is_syscall: if call_loc:
return diagnostic.Diagnostic("note", if is_syscall:
"in system call here", {}, return [diagnostic.Diagnostic("note",
call_loc) "in system call here", {},
call_loc)]
else:
return [diagnostic.Diagnostic("note",
"in function called remotely here", {},
call_loc)]
else: else:
return diagnostic.Diagnostic("note", return []
"in function called remotely here", {},
call_loc)
def _extract_annot(self, function, annot, kind, call_loc, is_syscall): def _extract_annot(self, function, annot, kind, call_loc, is_syscall):
if not isinstance(annot, types.Type): if not isinstance(annot, types.Type):
@ -494,7 +497,7 @@ class Stitcher:
"type annotation for {kind}, '{annot}', is not an ARTIQ type", "type annotation for {kind}, '{annot}', is not an ARTIQ type",
{"kind": kind, "annot": repr(annot)}, {"kind": kind, "annot": repr(annot)},
self._function_loc(function), self._function_loc(function),
notes=[self._call_site_note(call_loc, is_syscall)]) notes=self._call_site_note(call_loc, is_syscall))
self.engine.process(diag) self.engine.process(diag)
return types.TVar() return types.TVar()
@ -513,7 +516,7 @@ class Stitcher:
"system call argument '{argument}' must have a type annotation", "system call argument '{argument}' must have a type annotation",
{"argument": param.name}, {"argument": param.name},
self._function_loc(function), self._function_loc(function),
notes=[self._call_site_note(loc, is_syscall)]) notes=self._call_site_note(loc, is_syscall))
self.engine.process(diag) self.engine.process(diag)
elif param.default is not inspect.Parameter.empty: elif param.default is not inspect.Parameter.empty:
# Try and infer the type from the default value. # Try and infer the type from the default value.
@ -530,7 +533,9 @@ class Stitcher:
self._function_loc(function)) self._function_loc(function))
diag.notes.append(note) diag.notes.append(note)
diag.notes.append(self._call_site_note(loc, is_syscall)) note = self._call_site_note(loc, is_syscall)
if note:
diag.notes += note
self.engine.process(diag) self.engine.process(diag)
@ -572,7 +577,7 @@ class Stitcher:
"system call argument '{argument}' must not have a default value", "system call argument '{argument}' must not have a default value",
{"argument": param.name}, {"argument": param.name},
self._function_loc(function), self._function_loc(function),
notes=[self._call_site_note(loc, is_syscall=True)]) notes=self._call_site_note(loc, is_syscall=True))
self.engine.process(diag) self.engine.process(diag)
if signature.return_annotation is not inspect.Signature.empty: if signature.return_annotation is not inspect.Signature.empty:
@ -582,14 +587,14 @@ class Stitcher:
diag = diagnostic.Diagnostic("error", diag = diagnostic.Diagnostic("error",
"function must have a return type annotation to be called remotely", {}, "function must have a return type annotation to be called remotely", {},
self._function_loc(function), self._function_loc(function),
notes=[self._call_site_note(loc, is_syscall=False)]) notes=self._call_site_note(loc, is_syscall=False))
self.engine.process(diag) self.engine.process(diag)
ret_type = types.TVar() ret_type = types.TVar()
else: # syscall is not None else: # syscall is not None
diag = diagnostic.Diagnostic("error", diag = diagnostic.Diagnostic("error",
"system call must have a return type annotation", {}, "system call must have a return type annotation", {},
self._function_loc(function), self._function_loc(function),
notes=[self._call_site_note(loc, is_syscall=True)]) notes=self._call_site_note(loc, is_syscall=True))
self.engine.process(diag) self.engine.process(diag)
ret_type = types.TVar() ret_type = types.TVar()