diff --git a/nac3core/src/codegen/model/pointer.rs b/nac3core/src/codegen/model/pointer.rs index 22f3c765..bdb29d51 100644 --- a/nac3core/src/codegen/model/pointer.rs +++ b/nac3core/src/codegen/model/pointer.rs @@ -5,7 +5,7 @@ use inkwell::{ AddressSpace, }; -use crate::codegen::CodeGenContext; +use crate::codegen::{model::*, CodeGenContext}; use super::{core::*, OpaqueModel}; @@ -111,4 +111,16 @@ impl<'ctx, E: Model<'ctx>> Pointer<'ctx, E> { .unwrap(); casted_ptr_model.believe_value(casted_ptr) } + + pub fn is_null(&self, ctx: &CodeGenContext<'ctx, '_>, name: &str) -> NInt<'ctx, Bool> { + let model = NIntModel(Bool); + let value = ctx.builder.build_is_null(self.value, name).unwrap(); + model.believe_value(value) + } + + pub fn is_not_null(&self, ctx: &CodeGenContext<'ctx, '_>, name: &str) -> NInt<'ctx, Bool> { + let model = NIntModel(Bool); + let value = ctx.builder.build_is_not_null(self.value, name).unwrap(); + model.believe_value(value) + } }