Enum synfx_dsp_jit::ASTNode
source · [−]pub enum ASTNode {
Lit(f64),
Var(String),
Assign(String, Box<ASTNode>),
BinOp(ASTBinOp, Box<ASTNode>, Box<ASTNode>),
If(Box<ASTNode>, Box<ASTNode>, Option<Box<ASTNode>>),
Call(String, u64, Vec<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(String, Box<ASTNode>)
Assigns a value to a variable.
BinOp(ASTBinOp, Box<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(String, u64, Vec<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
Auto Trait Implementations
impl RefUnwindSafe for ASTNode
impl Send for ASTNode
impl Sync for ASTNode
impl Unpin for ASTNode
impl UnwindSafe for ASTNode
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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