use llvm_sys::core::*;
use crate::*;
use crate::values::*;
pub trait ConstExprTrait<'ctx>: ValueRef {
fn num_operands(&self) -> usize {
unsafe { LLVMGetNumOperands(self.value_ref()) as usize }
}
fn operand(&self, index: usize) -> Option<Constant<'ctx>> {
if index < self.num_operands() {
Some(Constant::from_llvm(unsafe {
LLVMGetOperand(self.value_ref(), index as u32)
}))
} else {
None
}
}
fn to_string(&self) -> String {
unsafe { crate::utils::raw_to_string(LLVMPrintValueToString(self.value_ref())) }
}
}
pub trait AsConstExpr<'ctx> {
fn as_const_expr(&self) -> ConstExpr<'ctx>;
}