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: d473d58b4189
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: 9605e8215fea
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Aug 28, 2015

  1. artiq_run: pretty-print diagnostics.

    whitequark committed Aug 28, 2015
    Copy the full SHA
    ed236eb View commit details
  2. ARTIQIRGenerator: fix non-nullary method calls.

    whitequark committed Aug 28, 2015
    Copy the full SHA
    9936768 View commit details
  3. coredevice.ttl: update for new int semantics.

    whitequark committed Aug 28, 2015
    Copy the full SHA
    9605e82 View commit details
Showing with 22 additions and 11 deletions.
  1. +8 −6 artiq/compiler/transforms/artiq_ir_generator.py
  2. +4 −4 artiq/coredevice/ttl.py
  3. +7 −1 artiq/frontend/artiq_run.py
  4. +3 −0 lit-test/test/integration/class.py
14 changes: 8 additions & 6 deletions artiq/compiler/transforms/artiq_ir_generator.py
Original file line number Diff line number Diff line change
@@ -1424,40 +1424,42 @@ def visit_CallT(self, node):
func = self.visit(node.func)
self_arg = None
fn_typ = typ
offset = 0
elif types.is_method(typ):
method = self.visit(node.func)
func = self.append(ir.GetAttr(method, "__func__"))
self_arg = self.append(ir.GetAttr(method, "__self__"))
fn_typ = types.get_method_function(typ)
offset = 1

args = [None] * (len(fn_typ.args) + len(fn_typ.optargs))

for index, arg_node in enumerate(node.args):
arg = self.visit(arg_node)
if index < len(fn_typ.args):
args[index] = arg
args[index + offset] = arg
else:
args[index] = self.append(ir.Alloc([arg], ir.TOption(arg.type)))
args[index + offset] = self.append(ir.Alloc([arg], ir.TOption(arg.type)))

for keyword in node.keywords:
arg = self.visit(keyword.value)
if keyword.arg in fn_typ.args:
for index, arg_name in enumerate(fn_typ.args):
if keyword.arg == arg_name:
assert args[index] is None
args[index] = arg
args[index + offset] = arg
break
elif keyword.arg in fn_typ.optargs:
for index, optarg_name in enumerate(fn_typ.optargs):
if keyword.arg == optarg_name:
assert args[len(fn_typ.args) + index] is None
args[len(fn_typ.args) + index] = \
args[len(fn_typ.args) + index + offset] = \
self.append(ir.Alloc([arg], ir.TOption(arg.type)))
break

for index, optarg_name in enumerate(fn_typ.optargs):
if args[len(fn_typ.args) + index] is None:
args[len(fn_typ.args) + index] = \
if args[len(fn_typ.args) + index + offset] is None:
args[len(fn_typ.args) + index + offset] = \
self.append(ir.Alloc([], ir.TOption(fn_typ.optargs[optarg_name])))

if self_arg is not None:
8 changes: 4 additions & 4 deletions artiq/coredevice/ttl.py
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ def __init__(self, dmgr, channel):
self.channel = channel

# in RTIO cycles
self.o_previous_timestamp = int64(0)
self.o_previous_timestamp = int(0, width=64)

@kernel
def set_o(self, o):
@@ -100,8 +100,8 @@ def __init__(self, dmgr, channel):
self.channel = channel

# in RTIO cycles
self.o_previous_timestamp = int64(0)
self.i_previous_timestamp = int64(0)
self.o_previous_timestamp = int(0, width=64)
self.i_previous_timestamp = int(0, width=64)

@kernel
def set_oe(self, oe):
@@ -240,7 +240,7 @@ def __init__(self, dmgr, channel):

def build(self):
# in RTIO cycles
self.previous_timestamp = int64(0)
self.previous_timestamp = int(0, width=64)
self.acc_width = 24

@portable
8 changes: 7 additions & 1 deletion artiq/frontend/artiq_run.py
Original file line number Diff line number Diff line change
@@ -12,9 +12,10 @@
from artiq.language.environment import EnvExperiment
from artiq.protocols.file_db import FlatFileDB
from artiq.master.worker_db import DeviceManager, ResultDB
from artiq.tools import *
from artiq.coredevice.core import CompileError
from artiq.compiler.embedding import ObjectMap
from artiq.compiler.targets import OR1KTarget
from artiq.tools import *

logger = logging.getLogger(__name__)

@@ -122,6 +123,11 @@ def run(with_file=False):
exp_inst.prepare()
exp_inst.run()
exp_inst.analyze()
except CompileError as error:
message = "\n".join(error.__cause__.diagnostic.render(colored=True))
message = message.replace(os.path.normpath(os.path.join(os.path.dirname(__file__), "..")),
"<artiq>")
print(message, file=sys.stderr)
finally:
dmgr.close_devices()

3 changes: 3 additions & 0 deletions lit-test/test/integration/class.py
Original file line number Diff line number Diff line change
@@ -7,7 +7,10 @@ def f():
return 2
def g(self):
return self.a + 5
def h(self, x):
return self.a + x

assert c.a == 1
assert c.f() == 2
assert c().g() == 6
assert c().h(9) == 10