pub struct Constant {
pub ty: Type,
pub value: ConstantValue,
}
Expand description
A Type
and constant value, including ConstantValue::Undef
for uninitialized constants.
Fields§
§ty: Type
§value: ConstantValue
Implementations§
source§impl Constant
impl Constant
pub fn new_unit(context: &Context) -> Self
pub fn new_bool(context: &Context, b: bool) -> Self
pub fn new_uint(context: &mut Context, nbits: u8, n: u64) -> Self
pub fn new_b256(context: &Context, bytes: [u8; 32]) -> Self
pub fn new_string(context: &mut Context, string: Vec<u8>) -> Self
pub fn new_array(
context: &mut Context,
elm_ty: Type,
elems: Vec<Constant>
) -> Self
pub fn new_struct(
context: &mut Context,
field_tys: Vec<Type>,
fields: Vec<Constant>
) -> Self
pub fn get_undef(ty: Type) -> Self
pub fn get_unit(context: &mut Context) -> Value
pub fn get_bool(context: &mut Context, value: bool) -> Value
pub fn get_uint(context: &mut Context, nbits: u8, value: u64) -> Value
pub fn get_b256(context: &mut Context, value: [u8; 32]) -> Value
pub fn get_string(context: &mut Context, value: Vec<u8>) -> Value
sourcepub fn get_array(context: &mut Context, value: Constant) -> Value
pub fn get_array(context: &mut Context, value: Constant) -> Value
value
must be created as an array constant first, using Constant::new_array()
.
sourcepub fn get_struct(context: &mut Context, value: Constant) -> Value
pub fn get_struct(context: &mut Context, value: Constant) -> Value
value
must be created as a struct constant first, using Constant::new_struct()
.