def insert_const_string(self, mod, string): stringtype = GENERIC_POINTER text = Constant.stringz(string) name = ".const.%s" % string for gv in mod.global_variables: if gv.name == name and gv.type.pointee == text.type: break else: gv = cgutils.global_constant(mod, name, text) return Constant.bitcast(gv, stringtype)
def make_keywords(self, kws): strings = [] stringtype = Type.pointer(Type.int(8)) for k in kws: strings.append(self.make_const_string(k)) strings.append(Constant.null(stringtype)) kwlist = Constant.array(stringtype, strings) kwlist = cgutils.global_constant(self.module, ".kwlist", kwlist) return Constant.bitcast(kwlist, Type.pointer(stringtype))
def make_keywords(self, kws): strings = [] stringtype = Type.pointer(Type.int(8)) for k in kws: strings.append(self.make_const_string(k)) strings.append(Constant.null(stringtype)) kwlist = Constant.array(stringtype, strings) kwlist = cgutils.global_constant(self.module, ".kwlist", kwlist) return Constant.bitcast(kwlist, Type.pointer(stringtype))
def insert_const_string(self, mod, string): stringtype = GENERIC_POINTER text = Constant.stringz(string) name = ".const.%s" % string for gv in mod.global_variables: if gv.name == name and gv.type.pointee == text.type: break else: gv = cgutils.global_constant(mod, name, text) return Constant.bitcast(gv, stringtype)
def insert_const_string(self, mod, string): stringtype = Type.pointer(Type.int(8)) text = Constant.stringz(string) name = ".const.%s" % string for gv in mod.global_variables: if gv.name == name and gv.type.pointee == text.type: break else: gv = mod.add_global_variable(text.type, name=name) gv.global_constant = True gv.initializer = text gv.linkage = lc.LINKAGE_INTERNAL return Constant.bitcast(gv, stringtype)
def make_keywords(self, kws): strings = [] stringtype = Type.pointer(Type.int(8)) for k in kws: strings.append(self.make_const_string(k)) strings.append(Constant.null(stringtype)) kwlist = Constant.array(stringtype, strings) gv = self.module.add_global_variable(kwlist.type, name=".kwlist") gv.global_constant = True gv.initializer = kwlist gv.linkage = lc.LINKAGE_INTERNAL return Constant.bitcast(gv, Type.pointer(stringtype))
def make_keywords(self, kws): strings = [] stringtype = Type.pointer(Type.int(8)) for k in kws: strings.append(self.make_const_string(k)) strings.append(Constant.null(stringtype)) kwlist = Constant.array(stringtype, strings) gv = self.module.add_global_variable(kwlist.type, name=".kwlist") gv.global_constant = True gv.initializer = kwlist gv.linkage = lc.LINKAGE_INTERNAL return Constant.bitcast(gv, Type.pointer(stringtype))