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(MetaBigInt),
    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

Fields

meta: Meta

An infix operation of the form lhe * rhe.

PrefixOp

Fields

meta: Meta

A prefix operation of the form * rhe.

SwitchOp

Fields

meta: Meta
cond: Box<Expression>
if_true: Box<Expression>
if_false: Box<Expression>

An inline switch operation (or inline if-then-else) of the form cond? if_true: if_false.

Variable

Fields

meta: Meta

A local variable, signal, or component.

Number(MetaBigInt)

A constant field element.

Call

Fields

meta: Meta
name: String
args: Vec<Expression>

A function call node.

InlineArray

Fields

meta: Meta
values: Vec<Expression>

An inline array on the form [value, ...].

Access

Fields

meta: Meta
access: Vec<AccessType>

An Access node represents an array access of the form a[i]...[k].

Update

Fields

meta: Meta
access: Vec<AccessType>

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

Fields

meta: Meta

An SSA phi-expression.

Implementations

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Compute expression degrees for this node and child nodes.

Returns an inclusive range the degree of the node may take.

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Syntactic equality for expressions.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Propagate variable types to variable child nodes.

Returns true if the node is a local variable.

Returns true if the node is a signal.

Returns true if the node is a component.

For declared variables, this returns the type. For undeclared variables and other expression nodes this returns None. Read more

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

Returns true if the node reduces to a constant value.

Returns true if the node reduces to a boolean value.

Returns true if the node reduces to a field element.

Returns the value if the node reduces to a constant, and None otherwise.

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

Get the set of variables read by the IR node.

Get the set of variables written by the IR node.

Get the set of signals read by the IR node. Note that this does not include signals belonging to sub-components. Read more

Get the set of signals written by the IR node. Note that this does not include signals belonging to sub-components. Read more

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

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

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

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

Get the set of variables either read or written by the IR node.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.