Enum brane_dsl::ast::Stmt

source ·
pub enum Stmt {
Show 15 variants Attribute(Attribute), AttributeInner(Attribute), Block { block: Box<Block>, }, Import { name: Identifier, version: Literal, st_funcs: Option<Vec<Rc<RefCell<FunctionEntry>>>>, st_classes: Option<Vec<Rc<RefCell<ClassEntry>>>>, attrs: Vec<Attribute>, range: TextRange, }, FuncDef { ident: Identifier, params: Vec<Identifier>, code: Box<Block>, st_entry: Option<Rc<RefCell<FunctionEntry>>>, attrs: Vec<Attribute>, range: TextRange, }, ClassDef { ident: Identifier, props: Vec<Property>, methods: Vec<Box<Stmt>>, st_entry: Option<Rc<RefCell<ClassEntry>>>, symbol_table: Rc<RefCell<SymbolTable>>, attrs: Vec<Attribute>, range: TextRange, }, Return { expr: Option<Expr>, data_type: DataType, output: HashSet<Data>, attrs: Vec<Attribute>, range: TextRange, }, If { cond: Expr, consequent: Box<Block>, alternative: Option<Box<Block>>, attrs: Vec<Attribute>, range: TextRange, }, For { initializer: Box<Stmt>, condition: Expr, increment: Box<Stmt>, consequent: Box<Block>, attrs: Vec<Attribute>, range: TextRange, }, While { condition: Expr, consequent: Box<Block>, attrs: Vec<Attribute>, range: TextRange, }, Parallel { result: Option<Identifier>, blocks: Vec<Block>, merge: Option<Identifier>, st_entry: Option<Rc<RefCell<VarEntry>>>, attrs: Vec<Attribute>, range: TextRange, }, LetAssign { name: Identifier, value: Expr, st_entry: Option<Rc<RefCell<VarEntry>>>, attrs: Vec<Attribute>, range: TextRange, }, Assign { name: Identifier, value: Expr, st_entry: Option<Rc<RefCell<VarEntry>>>, attrs: Vec<Attribute>, range: TextRange, }, Expr { expr: Expr, data_type: DataType, attrs: Vec<Attribute>, range: TextRange, }, Empty {},
}
Expand description

Defines a single statement.

Variants§

§

Attribute(Attribute)

Defines an unprocessed #[...] attirbute.

§

AttributeInner(Attribute)

Defines an unprocessed #![...] attriute.

§

Block

Defines a block statement (i.e., { ... }).

Fields

§block: Box<Block>

The actual block it references

§

Import

Defines a package import.

Fields

§name: Identifier

The name of the package that we import.

§version: Literal

The version of the package that we import.

§st_funcs: Option<Vec<Rc<RefCell<FunctionEntry>>>>

Reference to the function symbol table entries that this import generates.

§st_classes: Option<Vec<Rc<RefCell<ClassEntry>>>>

Reference to the class symbol table entries that this import generates.

§attrs: Vec<Attribute>

A list of attributes attached to this statement.

§range: TextRange

The range of the import statement in the source text.

§

FuncDef

Defines a function definition.

Fields

§ident: Identifier

The name of the function, as an identifier.

§params: Vec<Identifier>

The parameters of the function, as identifiers.

§code: Box<Block>

The code to execute when running this function.

§st_entry: Option<Rc<RefCell<FunctionEntry>>>

Reference to the symbol table entry this function generates.

§attrs: Vec<Attribute>

A list of attributes attached to this statement.

§range: TextRange

The range of the function definition in the source text.

§

ClassDef

Defines a class definition.

Fields

§ident: Identifier

The name of the class, as an identifier.

§props: Vec<Property>

The properties of the class, as (identifier, type) pairs.

§methods: Vec<Box<Stmt>>

The methods belonging to this class, as a vector of function definitions.

§st_entry: Option<Rc<RefCell<ClassEntry>>>

Reference to the symbol table entry this class generates.

§symbol_table: Rc<RefCell<SymbolTable>>

The SymbolTable that hosts the nested declarations. Is also found in the ClassEntry itself to resolve children.

§attrs: Vec<Attribute>

A list of attributes attached to this statement.

§range: TextRange

The range of the class definition in the source text.

§

Return

Defines a return statement.

Fields

§expr: Option<Expr>

The expression to return.

§data_type: DataType

The expected return datatype.

§output: HashSet<Data>

If this is a return on workflow level, also mentions a data that is returned (if any).

§attrs: Vec<Attribute>

A list of attributes attached to this statement.

§range: TextRange

The range of the return statement in the source text.

§

If

Defines an if-statement.

Fields

§cond: Expr

The condition to branch on.

§consequent: Box<Block>

The block for if the condition was true.

§alternative: Option<Box<Block>>

The (optional) block for if the condition was false.

§attrs: Vec<Attribute>

A list of attributes attached to this statement.

§range: TextRange

The range of the if-statement in the source text.

§

For

Defines a for-loop.

Fields

§initializer: Box<Stmt>

The statement that is run at the start of the for-loop.

§condition: Expr

The expression that has to evaluate to true while running.

§increment: Box<Stmt>

The statement that is run at the end of every iteration.

§consequent: Box<Block>

The block to run every iteration.

§attrs: Vec<Attribute>

A list of attributes attached to this statement.

§range: TextRange

The range of the for-loop in the source text.

§

While

Defines a while-loop.

Fields

§condition: Expr

The expression that has to evaluate to true while running.

§consequent: Box<Block>

The block to run every iteration.

§attrs: Vec<Attribute>

A list of attributes attached to this statement.

§range: TextRange

The range of the while-loop in the source text.

§

Parallel

Defines a parallel block (i.e., multiple branches run in parallel).

Fields

§result: Option<Identifier>

The (optional) identifier to which to write the result of the parallel statement.

§blocks: Vec<Block>

The code blocks to run in parallel. This may either be a Block or an On-statement.

§merge: Option<Identifier>

The merge-strategy used in the parallel statement.

§st_entry: Option<Rc<RefCell<VarEntry>>>

Reference to the variable to which the Parallel writes.

§attrs: Vec<Attribute>

A list of attributes attached to this statement.

§range: TextRange

The range of the parallel-statement in the source text.

§

LetAssign

Defines a variable definition (i.e., let <name> := <expr>).

Fields

§name: Identifier

The name of the variable referenced.

§value: Expr

The expression that gives a value to the assignment.

§st_entry: Option<Rc<RefCell<VarEntry>>>

Reference to the variable to which the let-assign writes.

§attrs: Vec<Attribute>

A list of attributes attached to this statement.

§range: TextRange

The range of the let-assign statement in the source text.

§

Assign

Defines an assignment (i.e., <name> := <expr>).

Fields

§name: Identifier

The name of the variable referenced.

§value: Expr

The expression that gives a value to the assignment.

§st_entry: Option<Rc<RefCell<VarEntry>>>

Reference to the variable to which the assign writes.

§attrs: Vec<Attribute>

A list of attributes attached to this statement.

§range: TextRange

The range of the assignment in the source text.

§

Expr

Defines a loose expression.

Fields

§expr: Expr

The expression to call.

§data_type: DataType

The data type of this expression. Relevant for popping or not.

§attrs: Vec<Attribute>

A list of attributes attached to this statement.

§range: TextRange

The range of the expression statement in the source text.

§

Empty

A special, compile-time only statement that may be used to mem::take statements.

Implementations§

source§

impl Stmt

source

pub fn new_import(name: Identifier, version: Literal, range: TextRange) -> Self

Creates a new Import node with some auxillary fields set to empty.

§Arguments
  • name: The name of the package to import (as an identifier).
  • version: The literal with the package version (i.e., should ‘Literal::Semver’). ‘latest’ should be assumed if the user did not specify it.
  • range: The TextRange that relates this node to the source text.
§Returns

A new Stmt::Import instance.

source

pub fn new_funcdef( ident: Identifier, params: Vec<Identifier>, code: Box<Block>, range: TextRange, ) -> Self

Creates a new FuncDef node with some auxillary fields set to empty.

§Arguments
  • ident: The name of the function, as an identifier.
  • params: The parameters of the function, as identifiers.
  • code: The code to execute when running this function.
  • range: The TextRange that relates this node to the source text.
§Returns

A new Stmt::FuncDef instance.

source

pub fn new_classdef( ident: Identifier, props: Vec<Property>, methods: Vec<Box<Stmt>>, range: TextRange, ) -> Self

Creates a new ClassDef node with some auxillary fields set to empty.

§Arguments
  • ident: The name of the class, as an identifier.
  • props: The properties of the class, as (identifier, type) pairs.
  • methods: The methods belonging to this class, as a vector of function definitions.
  • range: The TextRange that relates this node to the source text.
§Returns

A new Stmt::ClassDef instance.

source

pub fn new_return(expr: Option<Expr>, range: TextRange) -> Self

Creates a new Return node with some auxillary fields set to empty.

§Arguments
  • expr: An optional expression to return from the function.
  • range: The TextRange that relates this node to the source text.
§Returns

A new Stmt::Return instance.

source

pub fn new_parallel( result: Option<Identifier>, blocks: Vec<Block>, merge: Option<Identifier>, range: TextRange, ) -> Self

Creates a new Parallel node with some auxillary fields set to empty.

§Arguments
  • result: An optional identifier to which this Parallel may write its result.
  • blocks: The codeblocks to run in parallel.
  • merge: The merge strategy to use for this Parallel statement.
  • range: The TextRange that relates this node to the source text.
§Returns

A new Stmt::Parallel instance.

source

pub fn new_letassign(name: Identifier, value: Expr, range: TextRange) -> Self

Creates a new LetAssign node with some auxillary fields set to empty.

§Arguments
  • name: The identifier of the variable to write to and initialize.
  • value: The value to write.
  • range: The TextRange that relates this node to the source text.
§Returns

A new Stmt::LetAssign instance.

source

pub fn new_assign(name: Identifier, value: Expr, range: TextRange) -> Self

Creates a new Assign node with some auxillary fields set to empty.

§Arguments
  • name: The identifier of the variable to write to.
  • value: The value to write.
  • range: The TextRange that relates this node to the source text.
§Returns

A new Stmt::LetAssign instance.

source

pub fn new_expr(expr: Expr, range: TextRange) -> Self

Creates a new Expr node with some auxillary fields set to empty.

§Arguments
  • expr: The Expr to wrap.
  • range: The TextRange that relates this node to the source text.
§Returns

A new Stmt::Expr instance.

Trait Implementations§

source§

impl Clone for Stmt

source§

fn clone(&self) -> Stmt

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Stmt

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Stmt

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl EnumDebug for Stmt

source§

fn type_name() -> &'static str

Returns the static name of the type used for EnumDebug-printing. Read more
source§

fn variant_names() -> &'static [&'static str]

Returns all variants in the trait as a list of names. Read more
source§

fn variant_name(&self) -> &'static str

Returns the static name of the variant. Read more
source§

fn variant(&self) -> EnumDebugFormatter<'_, Self>

Returns a formatter for this enum that writes its variant name. Read more
source§

fn variants() -> Copied<Iter<'static, &'static str>>

Returns an iterator over all variants in this enum. Read more
source§

impl Node for Stmt

source§

fn range(&self) -> &TextRange

Returns the node’s source range.

source§

fn start(&self) -> &TextPos

Returns the node’s start position.
source§

fn end(&self) -> &TextPos

Returns the node’s end position.

Auto Trait Implementations§

§

impl Freeze for Stmt

§

impl !RefUnwindSafe for Stmt

§

impl !Send for Stmt

§

impl !Sync for Stmt

§

impl Unpin for Stmt

§

impl !UnwindSafe for Stmt

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromRef<T> for T
where T: Clone,

source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T