pub enum Declaration {
Variable {
dtype: Dtype,
initializer: Option<Initializer>,
},
Function {
signature: FunctionSignature,
definition: Option<FunctionDefinition>,
},
}
Variants§
Implementations§
Source§impl Declaration
impl Declaration
pub fn get_variable(&self) -> Option<(&Dtype, &Option<Initializer>)>
pub fn get_function( &self, ) -> Option<(&FunctionSignature, &Option<FunctionDefinition>)>
pub fn get_function_mut( &mut self, ) -> Option<(&mut FunctionSignature, &mut Option<FunctionDefinition>)>
Sourcepub fn is_compatible(&self, other: &Declaration) -> bool
pub fn is_compatible(&self, other: &Declaration) -> bool
Check if type is conflicting for pre-declared one
Trait Implementations§
Source§impl Clone for Declaration
impl Clone for Declaration
Source§fn clone(&self) -> Declaration
fn clone(&self) -> Declaration
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Declaration
impl Debug for Declaration
Source§impl IsEquiv for Declaration
impl IsEquiv for Declaration
Source§fn is_equiv(&self, other: &Self) -> bool
fn is_equiv(&self, other: &Self) -> bool
See
PartialEq::eq
.Source§impl<T> Optimize<Declaration> for FunctionPass<T>where
T: Optimize<FunctionDefinition>,
impl<T> Optimize<Declaration> for FunctionPass<T>where
T: Optimize<FunctionDefinition>,
fn optimize(&mut self, code: &mut Declaration) -> bool
Source§impl PartialEq for Declaration
impl PartialEq for Declaration
Source§impl TryFrom<Dtype> for Declaration
impl TryFrom<Dtype> for Declaration
Source§fn try_from(dtype: Dtype) -> Result<Self, Self::Error>
fn try_from(dtype: Dtype) -> Result<Self, Self::Error>
Create an appropriate declaration according to dtype
.
§Example
If int g = 0;
is declared, dtype
is ir::Dtype::Int{ width:32, is_signed:true, is_const:false }
.
In this case, ir::Declaration::Variable{ dtype, initializer: Some(Constant::I32(1)) }
is generated.
Conversely, if int foo();
is declared, dtype
is ir::Dtype::Function{ret: Scalar(Int), params: []}
. Thus, in this case, ir::Declaration::Function
is generated.
Source§type Error = DtypeError
type Error = DtypeError
The type returned in the event of a conversion error.
impl StructuralPartialEq for Declaration
Auto Trait Implementations§
impl Freeze for Declaration
impl RefUnwindSafe for Declaration
impl Send for Declaration
impl Sync for Declaration
impl Unpin for Declaration
impl UnwindSafe for Declaration
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more