use llvm_sys::core::LLVMGetIntTypeWidth;
use llvm_sys::prelude::LLVMTypeRef;
use std::marker::PhantomData;
use crate::types::*;
use crate::{FromLLVMType, TypeRef};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct IntType<'ctx>(LLVMTypeRef, PhantomData<&'ctx ()>);
impl_send_sync!(IntType);
impl<'ctx> IntType<'ctx> {
pub fn width(&self) -> u32 {
unsafe { LLVMGetIntTypeWidth(self.0) }
}
}
impl<'ctx> AsType<'ctx> for IntType<'ctx> {
fn as_type(&self) -> Type<'ctx> {
Type::Int(self.clone())
}
}
impl_positional_type_ref!(IntType, 0);
impl_positional_from_llvm_type!(IntType);