forked from M-Labs/nac3
core/model: add Pointer::{is_null,is_not_null}
This commit is contained in:
parent
d2ab7b89be
commit
cd777dcb52
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue