mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-26 03:38:25 +08:00
core: allow re-creation of Core object, do not use _allow_registration global variable
This commit is contained in:
parent
b77f6886be
commit
ba30705fa5
@ -56,15 +56,16 @@ class Core:
|
||||
self.core = self
|
||||
self.comm.core = self
|
||||
self.target = target
|
||||
self.analyzed = False
|
||||
self.compiler = nac3artiq.NAC3(target)
|
||||
|
||||
def close(self):
|
||||
self.comm.close()
|
||||
|
||||
def compile(self, method, args, kwargs, embedding_map, file_output=None):
|
||||
if core_language._allow_registration:
|
||||
if not self.analyzed:
|
||||
self.compiler.analyze(core_language._registered_functions, core_language._registered_classes)
|
||||
core_language._allow_registration = False
|
||||
self.analyzed = True
|
||||
|
||||
if hasattr(method, "__self__"):
|
||||
obj = method.__self__
|
||||
|
@ -46,18 +46,15 @@ def ceil64(x):
|
||||
return ceil(x)
|
||||
|
||||
|
||||
_allow_registration = True
|
||||
# Delay NAC3 analysis until all referenced variables are supposed to exist on the CPython side.
|
||||
_registered_functions = set()
|
||||
_registered_classes = set()
|
||||
|
||||
def _register_function(fun):
|
||||
assert _allow_registration
|
||||
import_cache.add_module_to_cache(getmodule(fun))
|
||||
_registered_functions.add(fun)
|
||||
|
||||
def _register_class(cls):
|
||||
assert _allow_registration
|
||||
import_cache.add_module_to_cache(getmodule(cls))
|
||||
_registered_classes.add(cls)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user