forked from M-Labs/nac3
1
0
Fork 0

core/model: add Pointer::{is_null,is_not_null}

This commit is contained in:
lyken 2024-07-27 02:12:55 +08:00
parent d2ab7b89be
commit cd777dcb52
1 changed files with 13 additions and 1 deletions

View File

@ -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)
}
}