mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 19:28:26 +08:00
artiq_compile: make print() write to core log, not an invalid op.
Fixes #710.
This commit is contained in:
parent
49baba26e3
commit
90e2e22765
@ -699,7 +699,7 @@ class TypedtreeHasher(algorithm.Visitor):
|
|||||||
return hash(tuple(freeze(getattr(node, field_name)) for field_name in fields))
|
return hash(tuple(freeze(getattr(node, field_name)) for field_name in fields))
|
||||||
|
|
||||||
class Stitcher:
|
class Stitcher:
|
||||||
def __init__(self, core, dmgr, engine=None):
|
def __init__(self, core, dmgr, engine=None, print_as_rpc=True):
|
||||||
self.core = core
|
self.core = core
|
||||||
self.dmgr = dmgr
|
self.dmgr = dmgr
|
||||||
if engine is None:
|
if engine is None:
|
||||||
@ -715,7 +715,8 @@ class Stitcher:
|
|||||||
# We don't want some things from the prelude as they are provided in
|
# We don't want some things from the prelude as they are provided in
|
||||||
# the host Python namespace and gain special meaning when quoted.
|
# the host Python namespace and gain special meaning when quoted.
|
||||||
self.prelude = prelude.globals()
|
self.prelude = prelude.globals()
|
||||||
self.prelude.pop("print")
|
if print_as_rpc:
|
||||||
|
self.prelude.pop("print")
|
||||||
self.prelude.pop("array")
|
self.prelude.pop("array")
|
||||||
|
|
||||||
self.functions = {}
|
self.functions = {}
|
||||||
|
@ -81,11 +81,13 @@ class Core:
|
|||||||
self.core = self
|
self.core = self
|
||||||
self.comm.core = self
|
self.comm.core = self
|
||||||
|
|
||||||
def compile(self, function, args, kwargs, set_result=None, attribute_writeback=True):
|
def compile(self, function, args, kwargs, set_result=None,
|
||||||
|
attribute_writeback=True, print_as_rpc=True):
|
||||||
try:
|
try:
|
||||||
engine = _DiagnosticEngine(all_errors_are_fatal=True)
|
engine = _DiagnosticEngine(all_errors_are_fatal=True)
|
||||||
|
|
||||||
stitcher = Stitcher(engine=engine, core=self, dmgr=self.dmgr)
|
stitcher = Stitcher(engine=engine, core=self, dmgr=self.dmgr,
|
||||||
|
print_as_rpc=print_as_rpc)
|
||||||
stitcher.stitch_call(function, args, kwargs, set_result)
|
stitcher.stitch_call(function, args, kwargs, set_result)
|
||||||
stitcher.finalize()
|
stitcher.finalize()
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ def main():
|
|||||||
|
|
||||||
object_map, kernel_library, _, _ = \
|
object_map, kernel_library, _, _ = \
|
||||||
core.compile(exp.run, [exp_inst], {},
|
core.compile(exp.run, [exp_inst], {},
|
||||||
attribute_writeback=False)
|
attribute_writeback=False, print_as_rpc=False)
|
||||||
except CompileError as error:
|
except CompileError as error:
|
||||||
return
|
return
|
||||||
finally:
|
finally:
|
||||||
|
Loading…
Reference in New Issue
Block a user