pub enum ASTNode {
    Lit(f64),
    Var(String),
    Assign(StringBox<ASTNode>),
    BinOp(ASTBinOpBox<ASTNode>, Box<ASTNode>),
    If(Box<ASTNode>, Box<ASTNode>, Option<Box<ASTNode>>),
    Call(Stringu64Vec<Box<ASTNode>>),
    Stmts(Vec<Box<ASTNode>>),
}
Expand description

The abstract syntax tree that the crate::JIT can compile down to machine code (in form of a crate::DSPFunction) for you.

See also the crate::build module about creating these trees conveniently directly from Rust code.

Variants

Lit(f64)

Literal fixed f64 values.

Var(String)

Variable and parameter names. Variables that start with a “*” are stored persistently across multiple crate::DSPFunction invocations for you.

Assign(StringBox<ASTNode>)

Assigns a value to a variable.

BinOp(ASTBinOpBox<ASTNode>, Box<ASTNode>)

A binary operator. See also ASTBinOp which operations are possible.

If(Box<ASTNode>, Box<ASTNode>, Option<Box<ASTNode>>)

A conditional statement.

You can specify a ASTBinOp with a comparison operation as first element here (the condition), or any other kind of expression that returns a value. In the latter case the value must be larger or equal to 0.5 to be true.

Call(Stringu64Vec<Box<ASTNode>>)

Calls a DSP node/function by it’s name. The second parameter here, the u64 is the unique ID for this ASTNode. It’s used to track state of this DSP node. You have to make sure that the IDs don’t change and that you are not using the same ID for multiple stateful DSP nodes here.

Stmts(Vec<Box<ASTNode>>)

A list of statements that must be executed in the here specified order.

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

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

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.