use llvm_sys::core::LLVMGetElementType;
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 PointerType<'ctx>(LLVMTypeRef, PhantomData<&'ctx ()>);
impl_send_sync!(PointerType);
impl<'ctx> PointerType<'ctx> {
pub fn element_type(&self) -> Type<'ctx> {
Type::from_llvm(unsafe { LLVMGetElementType(self.0) })
}
}
impl<'ctx> AsType<'ctx> for PointerType<'ctx> {
fn as_type(&self) -> Type<'ctx> {
Type::Pointer(self.clone())
}
}
impl_positional_type_ref!(PointerType, 0);
impl_positional_from_llvm_type!(PointerType);