def __init__(self, ptr=None): # FIXME: Rename this to ptr or context_ptr to be consistent with other # API objects self.external_ptr = True if ptr is None: self.external_ptr = False ptr = libcoreir_c.CORENewContext() self.context = ptr self.global_namespace = Namespace( libcoreir_c.COREGetGlobal(self.context), self) self.named_types = NamedTypesDict(self)
def load_library(self, name): lib = load_coreir_lib(name) func = getattr(lib, "CORELoadLibrary_{}".format(name)) func.argtypes = [COREContext_p] func.restype = CORENamespace_p return Namespace(func(self.context), self)
def new_namespace(self, name): ns = libcoreir_c.CORENewNamespace(self.context, ct.c_char_p(str.encode(name))) return Namespace(ns, self)
def __init__(self): # FIXME: Rename this to ptr or context_ptr to be consistent with other # API objects self.context = libcoreir_c.CORENewContext() self.G = Namespace(libcoreir_c.COREGetGlobal(self.context), self)