def get_constant_struct(self, builder, ty, val): assert self.is_struct_type(ty) module = cgutils.get_module(builder) if ty in types.complex_domain: if ty == types.complex64: innertype = types.float32 elif ty == types.complex128: innertype = types.float64 else: raise Exception("unreachable") real = self.get_constant(innertype, val.real) imag = self.get_constant(innertype, val.imag) const = Constant.struct([real, imag]) return const elif isinstance(ty, types.Tuple): consts = [ self.get_constant_generic(builder, ty.types[i], v) for i, v in enumerate(val) ] return Constant.struct(consts) elif isinstance(ty, types.Record): consts = [ self.get_constant(types.int8, b) for b in bytearray(val.tostring()) ] return Constant.array(consts[0].type, consts) else: raise NotImplementedError("%s as constant unsupported" % ty)
def get_constant_struct(self, builder, ty, val): assert self.is_struct_type(ty) if ty in types.complex_domain: if ty == types.complex64: innertype = types.float32 elif ty == types.complex128: innertype = types.float64 else: raise Exception("unreachable") real = self.get_constant(innertype, val.real) imag = self.get_constant(innertype, val.imag) const = Constant.struct([real, imag]) return const elif isinstance(ty, types.Tuple): consts = [self.get_constant_generic(builder, ty.types[i], v) for i, v in enumerate(val)] return Constant.struct(consts) elif isinstance(ty, types.Record): consts = [self.get_constant(types.int8, b) for b in bytearray(val.tostring())] return Constant.array(consts[0].type, consts) else: raise NotImplementedError("%s as constant unsupported" % ty)
def get_constant_struct(self, builder, ty, val): assert self.is_struct_type(ty) module = cgutils.get_module(builder) if ty in types.complex_domain: if ty == types.complex64: innertype = types.float32 elif ty == types.complex128: innertype = types.float64 else: raise Exception("unreachable") real = self.get_constant(innertype, val.real) imag = self.get_constant(innertype, val.imag) const = Constant.struct([real, imag]) return const elif isinstance(ty, types.Tuple): consts = [self.get_constant_generic(builder, ty.types[i], v) for i, v in enumerate(val)] return Constant.struct(consts) else: raise NotImplementedError(ty)
_plat_bits = struct_.calcsize("@P") * 8 _int8 = Type.int(8) _int32 = Type.int(32) _void_star = Type.pointer(_int8) _int8_star = _void_star _sizeof_py_ssize_t = ctypes.sizeof(getattr(ctypes, "c_size_t")) _llvm_py_ssize_t = Type.int(_sizeof_py_ssize_t * 8) if _trace_refs_: _pyobject_head = Type.struct( [_void_star, _void_star, _llvm_py_ssize_t, _void_star]) _pyobject_head_init = Constant.struct([ Constant.null(_void_star), # _ob_next Constant.null(_void_star), # _ob_prev Constant.int(_llvm_py_ssize_t, 1), # ob_refcnt Constant.null(_void_star), # ob_type ]) else: _pyobject_head = Type.struct([_llvm_py_ssize_t, _void_star]) _pyobject_head_init = Constant.struct([ Constant.int(_llvm_py_ssize_t, 1), # ob_refcnt Constant.null(_void_star), # ob_type ]) _pyobject_head_p = Type.pointer(_pyobject_head)
_plat_bits = struct_.calcsize("@P") * 8 _int8 = Type.int(8) _int32 = Type.int(32) _void_star = Type.pointer(_int8) _int8_star = _void_star _sizeof_py_ssize_t = ctypes.sizeof(getattr(ctypes, "c_size_t")) _llvm_py_ssize_t = Type.int(_sizeof_py_ssize_t * 8) if _trace_refs_: _pyobject_head = Type.struct([_void_star, _void_star, _llvm_py_ssize_t, _void_star]) _pyobject_head_init = Constant.struct( [ Constant.null(_void_star), # _ob_next Constant.null(_void_star), # _ob_prev Constant.int(_llvm_py_ssize_t, 1), # ob_refcnt Constant.null(_void_star), # ob_type ] ) else: _pyobject_head = Type.struct([_llvm_py_ssize_t, _void_star]) _pyobject_head_init = Constant.struct( [Constant.int(_llvm_py_ssize_t, 1), Constant.null(_void_star)] # ob_refcnt # ob_type ) _pyobject_head_p = Type.pointer(_pyobject_head)