Enum brane_dsl::ast::Expr

source ·
pub enum Expr {
Show 13 variants Cast { expr: Box<Expr>, target: DataType, range: TextRange, }, Call { expr: Box<Expr>, args: Vec<Box<Expr>>, st_entry: Option<Rc<RefCell<FunctionEntry>>>, locations: AllowedLocations, input: HashSet<Data>, result: HashSet<Data>, metadata: HashSet<Metadata>, range: TextRange, }, Array { values: Vec<Box<Expr>>, data_type: DataType, range: TextRange, }, ArrayIndex { array: Box<Expr>, index: Box<Expr>, data_type: DataType, range: TextRange, }, Pattern { exprs: Vec<Box<Expr>>, range: TextRange, }, UnaOp { op: UnaOp, expr: Box<Expr>, range: TextRange, }, BinOp { op: BinOp, lhs: Box<Expr>, rhs: Box<Expr>, range: TextRange, }, Proj { lhs: Box<Expr>, rhs: Box<Expr>, st_entry: Option<SymbolTableEntry>, range: TextRange, }, Instance { name: Identifier, properties: Vec<PropertyExpr>, st_entry: Option<Rc<RefCell<ClassEntry>>>, range: TextRange, }, VarRef { name: Identifier, st_entry: Option<Rc<RefCell<VarEntry>>>, }, Identifier { name: Identifier, st_entry: Option<Rc<RefCell<FunctionEntry>>>, }, Literal { literal: Literal, }, Empty {},
}
Expand description

Defines an expression.

Variants§

§

Cast

Casts between two functions types.

Fields

§expr: Box<Expr>

The expression to cast

§target: DataType

The type to cast to

§range: TextRange

The range of the call-expression in the source text.

§

Call

A function call.

Fields

§expr: Box<Expr>

The thing that we’re calling - obviously, this must be something with a function type.

§args: Vec<Box<Expr>>

The list of arguments for this call.

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

Reference to the call’s function entry.

§locations: AllowedLocations

The locations where this Call is allowed to run based on the location of the datasets.

§input: HashSet<Data>

If this call takes in Data or IntermediateResult, then this field will list their names. Used to only ever be the case if this call is an external call, but no more, since we’re also interested in tracking this for things like commit_result.

§result: HashSet<Data>

The intermediate result that this Call creates, if any. Used to only ever be the case if this call is an external call, but no more, since we’re also interested in tracking this for things like commit_result.

§metadata: HashSet<Metadata>

Metadata for this call. Only used for external calls.

§range: TextRange

The range of the call-expression in the source text.

§

Array

An array expression.

Fields

§values: Vec<Box<Expr>>

The value in the array.

§data_type: DataType

The type of the Array.

§range: TextRange

The range of the array-expression in the source text.

§

ArrayIndex

An ArrayIndex expression.

Fields

§array: Box<Expr>

The (array) expression that is indexed.

§index: Box<Expr>

The indexing expression.

§data_type: DataType

The type of the returned value.

§range: TextRange

The range of the index-expression in the source text.

§

Pattern

Bakery-specific Pattern expression.

Fields

§exprs: Vec<Box<Expr>>

The expressions in this pattern.

§range: TextRange

The range of the pattern-expression in the source text.

§

UnaOp

A unary operator.

Fields

§op: UnaOp

The operator to execute.

§expr: Box<Expr>

The expression.

§range: TextRange

The range of the unary operator in the source text.

§

BinOp

A binary operator.

Fields

§op: BinOp

The operator to execute.

§lhs: Box<Expr>

The lefthandside expression.

§rhs: Box<Expr>

The righthandside expression.

§range: TextRange

The range of the binary operator-expression in the source text.

§

Proj

A special case of a binary operator that implements projection.

Fields

§lhs: Box<Expr>

The lefthandside expression.

§rhs: Box<Expr>

The righthandside expression.

§st_entry: Option<SymbolTableEntry>

Reference to the entry that this projection points to.

§range: TextRange

The range of the projection-expression in the source text.

§

Instance

An instance expression (i.e., new ...).

Fields

§name: Identifier

The identifier of the class to instantiate.

§properties: Vec<PropertyExpr>

The parameters to instantiate it with, as (parameter_name, value).

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

The reference to the class we instantiate.

§range: TextRange

The range of the instance-expression in the source text.

§

VarRef

A variable reference.

Fields

§name: Identifier

The identifier of the referenced variable.

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

The entry referring to the variable referred.

§

Identifier

An identifier is like a variable reference but even weaker (i.e., does not expliticly link to anything - just as a placeholder for certain functions).

Fields

§name: Identifier

The identifier that this expression represents.

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

The entry referring to the function referred. This only happens when used as identifier in a call expression.

§

Literal

A literal expression.

Fields

§literal: Literal

The nested Literal.

§

Empty

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

Implementations§

source§

impl Expr

source

pub fn new_cast(expr: Box<Expr>, target: DataType, range: TextRange) -> Self

Creates a new Cast expression with some auxillary fields set to empty.

§Arguments
  • expr: The expression to cast.
  • target: The target type to cast to.
  • range: The TextRange that relates this node to the source text.
§Returns

A new Expr::Cast instance.

source

pub fn new_call( expr: Box<Expr>, args: Vec<Box<Expr>>, range: TextRange, locations: AllowedLocations, ) -> Self

Creates a new Call expression with some auxillary fields set to empty.

§Arguments
  • expr: The expression that produces the object that we call.
  • args: The arguments to call it with.
  • range: The TextRange that relates this node to the source text.
  • locations: The list of locations (as an AllowedLocation) where the call may be executed.
§Returns

A new Expr::Call instance.

source

pub fn new_array(values: Vec<Box<Expr>>, range: TextRange) -> Self

Creates a new Array expression with some auxillary fields set to empty.

§Arguments
  • values: The list of values that make up this Array.
  • range: The TextRange that links this Array to the source text.
source

pub fn new_array_index( array: Box<Expr>, index: Box<Expr>, range: TextRange, ) -> Self

Creates a new ArrayIndex expression with some auxillary fields set to empty.

§Arguments
  • array: The expression that evaluates to the Array.
  • index: The expression that evaluates to the Array’s index.
  • range: The TextRange that links this Array to the source text.
source

pub fn new_unaop(op: UnaOp, expr: Box<Expr>, range: TextRange) -> Self

Creates a new UnaOp expression with some auxillary fields set to empty.

§Arguments
  • op: The unary operator that this expression operates.
  • expr: The expression to execute the unary operation on.
  • range: The TextRange that relates this node to the source text.
§Returns

A new Expr::UnaOp instance.

source

pub fn new_binop( op: BinOp, lhs: Box<Expr>, rhs: Box<Expr>, range: TextRange, ) -> Self

Creates a new BinOp expression with some auxillary fields set to empty.

§Arguments
  • op: The binary operator that this expression operates.
  • lhs: The lefthand-side expression to execute the binary operation on.
  • rhs: The righthand-side expression to execute the binary operation on.
  • range: The TextRange that relates this node to the source text.
§Returns

A new Expr::BinOp instance.

source

pub fn new_proj(lhs: Box<Expr>, rhs: Box<Expr>, range: TextRange) -> Self

Creates a new Proj expression with some auxillary fields set to empty.

§Arguments
  • lhs: The left-hand side expression containing a nested projection or an identifier.
§Returns

A new Expr::Proj instance.

source

pub fn new_instance( name: Identifier, properties: Vec<PropertyExpr>, range: TextRange, ) -> Self

Creates a new Instance expression with some auxillary fields set to empty.

§Arguments
  • name: The name of the class that is being instantiated.
  • properties: The properties to instantiate it with.
  • range: The TextRange that relates this node to the source text.
§Returns

A new Expr::Instance instance.

source

pub fn new_varref(name: Identifier) -> Self

Creates a new VarRef expression with some auxillary fields set to empty.

§Arguments
  • name: The name of the variable that is being referenced.
§Returns

A new Expr::VarRef instance.

source

pub fn new_identifier(name: Identifier) -> Self

Creates a new Identifier expression with some auxillary fields set to empty.

§Arguments
  • name: The name of the identifier that is being stored here.
§Returns

A new Expr::Identifier instance.

Trait Implementations§

source§

impl Clone for Expr

source§

fn clone(&self) -> Expr

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 Expr

source§

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

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

impl Default for Expr

source§

fn default() -> Self

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

impl EnumDebug for Expr

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 Expr

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 Expr

§

impl !RefUnwindSafe for Expr

§

impl !Send for Expr

§

impl !Sync for Expr

§

impl Unpin for Expr

§

impl !UnwindSafe for Expr

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