pub enum Expression {
InfixOp {
meta: Meta,
lhe: Box<Expression>,
infix_op: ExpressionInfixOpcode,
rhe: Box<Expression>,
},
PrefixOp {
meta: Meta,
prefix_op: ExpressionPrefixOpcode,
rhe: Box<Expression>,
},
SwitchOp {
meta: Meta,
cond: Box<Expression>,
if_true: Box<Expression>,
if_false: Box<Expression>,
},
Variable {
meta: Meta,
name: VariableName,
},
Number(Meta, BigInt),
Call {
meta: Meta,
name: String,
args: Vec<Expression>,
},
InlineArray {
meta: Meta,
values: Vec<Expression>,
},
Access {
meta: Meta,
var: VariableName,
access: Vec<AccessType>,
},
Update {
meta: Meta,
var: VariableName,
access: Vec<AccessType>,
rhe: Box<Expression>,
},
Phi {
meta: Meta,
args: Vec<VariableName>,
},
}Variants
InfixOp
An infix operation of the form lhe * rhe.
PrefixOp
A prefix operation of the form * rhe.
SwitchOp
An inline switch operation (or inline if-then-else) of the form cond? if_true: if_false.
Variable
A local variable, signal, or component.
Number(Meta, BigInt)
A constant field element.
Call
A function call node.
InlineArray
An inline array on the form [value, ...].
Access
An Access node represents an array access of the form a[i]...[k].
Update
Updates of the form var[i]...[k] = rhe lift to IR statements of the
form var = update(var, (i, ..., k), rhe). This is needed when we
convert the CFG to SSA. Since arrays are versioned atomically, we need
to track which version of the array that is updated to obtain the new
version. (This is needed to track variable use, dead assignments, and
data flow.)
Note: The type metadata in meta tracks the type of the variable var.
Phi
An SSA phi-expression.
Implementations
Trait Implementations
sourceimpl Clone for Expression
impl Clone for Expression
sourcefn clone(&self) -> Expression
fn clone(&self) -> Expression
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for Expression
impl Debug for Expression
sourceimpl DegreeMeta for Expression
impl DegreeMeta for Expression
sourcefn propagate_degrees(&mut self, env: &DegreeEnvironment)
fn propagate_degrees(&mut self, env: &DegreeEnvironment)
Compute expression degrees for this node and child nodes.
sourcefn degree(&self) -> Option<&DegreeRange>
fn degree(&self) -> Option<&DegreeRange>
Returns an inclusive range the degree of the node may take.
sourceimpl Display for Expression
impl Display for Expression
sourceimpl Hash for Expression
impl Hash for Expression
sourceimpl PartialEq<Expression> for Expression
impl PartialEq<Expression> for Expression
Syntactic equality for expressions.
sourcefn eq(&self, other: &Expression) -> bool
fn eq(&self, other: &Expression) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourceimpl TypeMeta for Expression
impl TypeMeta for Expression
sourcefn propagate_types(&mut self, vars: &Declarations)
fn propagate_types(&mut self, vars: &Declarations)
Propagate variable types to variable child nodes.
sourcefn is_component(&self) -> bool
fn is_component(&self) -> bool
Returns true if the node is a component.
sourcefn variable_type(&self) -> Option<&VariableType>
fn variable_type(&self) -> Option<&VariableType>
For declared variables, this returns the type. For undeclared variables
and other expression nodes this returns None. Read more
sourceimpl ValueMeta for Expression
impl ValueMeta for Expression
sourcefn propagate_values(&mut self, env: &mut ValueEnvironment) -> bool
fn propagate_values(&mut self, env: &mut ValueEnvironment) -> bool
Propagate variable values defined by the environment to each sub-node. The method returns true if the node (or a sub-node) was updated. Read more
sourcefn is_constant(&self) -> bool
fn is_constant(&self) -> bool
Returns true if the node reduces to a constant value.
sourcefn is_boolean(&self) -> bool
fn is_boolean(&self) -> bool
Returns true if the node reduces to a boolean value.
sourcefn is_field_element(&self) -> bool
fn is_field_element(&self) -> bool
Returns true if the node reduces to a field element.
sourcefn value(&self) -> Option<&ValueReduction>
fn value(&self) -> Option<&ValueReduction>
Returns the value if the node reduces to a constant, and None otherwise.
sourceimpl VariableMeta for Expression
impl VariableMeta for Expression
sourcefn cache_variable_use(&mut self)
fn cache_variable_use(&mut self)
Compute variables read/written by the node. Must be called before either of the getters are called. To avoid interior mutability this needs to be called again whenever the node is mutated in a way that may invalidate the cached variable use. Read more
sourcefn locals_read(&self) -> &VariableUses
fn locals_read(&self) -> &VariableUses
Get the set of variables read by the IR node.
sourcefn locals_written(&self) -> &VariableUses
fn locals_written(&self) -> &VariableUses
Get the set of variables written by the IR node.
sourcefn signals_read(&self) -> &VariableUses
fn signals_read(&self) -> &VariableUses
Get the set of signals read by the IR node. Note that this does not include signals belonging to sub-components. Read more
sourcefn signals_written(&self) -> &VariableUses
fn signals_written(&self) -> &VariableUses
Get the set of signals written by the IR node. Note that this does not include signals belonging to sub-components. Read more
sourcefn components_read(&self) -> &VariableUses
fn components_read(&self) -> &VariableUses
Get the set of components read by the IR node. Note that a component read is typically a signal read for a signal exported by the component. Read more
sourcefn components_written(&self) -> &VariableUses
fn components_written(&self) -> &VariableUses
Get the set of components written by the IR node. Note that a component write may either be a component initialization, or a signal write for a signal exported by the component. Read more
sourcefn variables_read<'a>(
&'a self
) -> Box<dyn Iterator<Item = &'a VariableUse> + 'a>
fn variables_read<'a>(
&'a self
) -> Box<dyn Iterator<Item = &'a VariableUse> + 'a>
Get the set of variables read by the IR node. Note that this is simply the union of all locals, signals, and components read by the node. Read more
sourcefn variables_written<'a>(
&'a self
) -> Box<dyn Iterator<Item = &'a VariableUse> + 'a>
fn variables_written<'a>(
&'a self
) -> Box<dyn Iterator<Item = &'a VariableUse> + 'a>
Get the set of variables written by the IR node. Note that this is simply the union of all locals, signals, and components written. Read more
sourcefn variables_used<'a>(
&'a self
) -> Box<dyn Iterator<Item = &'a VariableUse> + 'a>
fn variables_used<'a>(
&'a self
) -> Box<dyn Iterator<Item = &'a VariableUse> + 'a>
Get the set of variables either read or written by the IR node.
impl Eq for Expression
Auto Trait Implementations
impl RefUnwindSafe for Expression
impl Send for Expression
impl Sync for Expression
impl Unpin for Expression
impl UnwindSafe for Expression
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more