Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5916c10b241d
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 37811f690bab
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Aug 28, 2015

  1. Copy the full SHA
    b35051c View commit details
  2. Copy the full SHA
    bcba86d View commit details
  3. ARTIQIRGenerator: support comparisons against None.

    whitequark committed Aug 28, 2015
    Copy the full SHA
    37811f6 View commit details
Showing with 25 additions and 15 deletions.
  1. +22 −14 artiq/compiler/embedding.py
  2. +3 −1 artiq/compiler/transforms/artiq_ir_generator.py
36 changes: 22 additions & 14 deletions artiq/compiler/embedding.py
Original file line number Diff line number Diff line change
@@ -471,27 +471,33 @@ def _function_loc(self, function):
line += 1
source_line = linecache.getline(filename, line)

column = re.search("def", source_line).start(0)
if "<lambda>" in function.__qualname__:
column = 0 # can't get column of lambda
else:
column = re.search("def", source_line).start(0)
source_buffer = source.Buffer(source_line, filename, line)
return source.Range(source_buffer, column, column)

def _call_site_note(self, call_loc, is_syscall):
if is_syscall:
return diagnostic.Diagnostic("note",
"in system call here", {},
call_loc)
if call_loc:
if is_syscall:
return [diagnostic.Diagnostic("note",
"in system call here", {},
call_loc)]
else:
return [diagnostic.Diagnostic("note",
"in function called remotely here", {},
call_loc)]
else:
return diagnostic.Diagnostic("note",
"in function called remotely here", {},
call_loc)
return []

def _extract_annot(self, function, annot, kind, call_loc, is_syscall):
if not isinstance(annot, types.Type):
diag = diagnostic.Diagnostic("error",
"type annotation for {kind}, '{annot}', is not an ARTIQ type",
{"kind": kind, "annot": repr(annot)},
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)

return types.TVar()
@@ -510,7 +516,7 @@ def _type_of_param(self, function, loc, param, is_syscall):
"system call argument '{argument}' must have a type annotation",
{"argument": param.name},
self._function_loc(function),
notes=[self._call_site_note(loc, is_syscall)])
notes=self._call_site_note(loc, is_syscall))
self.engine.process(diag)
elif param.default is not inspect.Parameter.empty:
# Try and infer the type from the default value.
@@ -527,7 +533,9 @@ def proxy_diagnostic(diag):
self._function_loc(function))
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)

@@ -569,7 +577,7 @@ def _quote_foreign_function(self, function, loc, syscall):
"system call argument '{argument}' must not have a default value",
{"argument": param.name},
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)

if signature.return_annotation is not inspect.Signature.empty:
@@ -579,14 +587,14 @@ def _quote_foreign_function(self, function, loc, syscall):
diag = diagnostic.Diagnostic("error",
"function must have a return type annotation to be called remotely", {},
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)
ret_type = types.TVar()
else: # syscall is not None
diag = diagnostic.Diagnostic("error",
"system call must have a return type annotation", {},
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)
ret_type = types.TVar()

4 changes: 3 additions & 1 deletion artiq/compiler/transforms/artiq_ir_generator.py
Original file line number Diff line number Diff line change
@@ -1134,7 +1134,9 @@ def body_gen(lst_index):
assert False

def polymorphic_compare_pair_order(self, op, lhs, rhs):
if builtins.is_numeric(lhs.type) and builtins.is_numeric(rhs.type):
if builtins.is_none(lhs.type) and builtins.is_none(rhs.type):
return self.append(ir.Compare(op, lhs, rhs))
elif builtins.is_numeric(lhs.type) and builtins.is_numeric(rhs.type):
return self.append(ir.Compare(op, lhs, rhs))
elif builtins.is_bool(lhs.type) and builtins.is_bool(rhs.type):
return self.append(ir.Compare(op, lhs, rhs))