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()
.
Trait Implementations§
source§impl DebugWithContext for Constant
impl DebugWithContext for Constant
fn fmt_with_context<'a, 'c>(
&'a self,
formatter: &mut Formatter<'_>,
context: &'c Context
) -> Result
fn with_context<'a, 'c>(
&'a self,
context: &'c Context
) -> WithContext<'a, 'c, Self>
Auto Trait Implementations§
impl RefUnwindSafe for Constant
impl Send for Constant
impl Sync for Constant
impl Unpin for Constant
impl UnwindSafe for Constant
Blanket Implementations§
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.