pub enum Expression {
Show 32 variants StringLiteral(String), NumberLiteral(f64), BoolLiteral(bool), PropertyReference(PropertyReference), FunctionParameterReference { index: usize, }, StoreLocalVariable { name: String, value: Box<Expression>, }, ReadLocalVariable { name: String, ty: Type, }, StructFieldAccess { base: Box<Expression>, name: String, }, ArrayIndex { array: Box<Expression>, index: Box<Expression>, }, Cast { from: Box<Expression>, to: Type, }, CodeBlock(Vec<Expression>), BuiltinFunctionCall { function: BuiltinFunction, arguments: Vec<Expression>, }, CallBackCall { callback: PropertyReference, arguments: Vec<Expression>, }, FunctionCall { function: PropertyReference, arguments: Vec<Expression>, }, ExtraBuiltinFunctionCall { return_ty: Type, function: String, arguments: Vec<Expression>, }, PropertyAssignment { property: PropertyReference, value: Box<Expression>, }, ModelDataAssignment { level: usize, value: Box<Expression>, }, ArrayIndexAssignment { array: Box<Expression>, index: Box<Expression>, value: Box<Expression>, }, BinaryExpression { lhs: Box<Expression>, rhs: Box<Expression>, op: char, }, UnaryOp { sub: Box<Expression>, op: char, }, ImageReference { resource_ref: ImageReference, }, Condition { condition: Box<Expression>, true_expr: Box<Expression>, false_expr: Box<Expression>, }, Array { element_ty: Type, values: Vec<Expression>, as_model: bool, }, Struct { ty: Type, values: HashMap<String, Expression>, }, EasingCurve(EasingCurve), LinearGradient { angle: Box<Expression>, stops: Vec<(Expression, Expression)>, }, RadialGradient { stops: Vec<(Expression, Expression)>, }, EnumerationValue(EnumerationValue), ReturnStatement(Option<Box<Expression>>), LayoutCacheAccess { layout_cache_prop: PropertyReference, index: usize, repeater_index: Option<Box<Expression>>, }, BoxLayoutFunction { cells_variable: String, repeater_indices: Option<String>, elements: Vec<Either<Expression, usize>>, orientation: Orientation, sub_expression: Box<Expression>, }, ComputeDialogLayoutCells { cells_variable: String, roles: Box<Expression>, unsorted_cells: Box<Expression>, },
}

Variants§

§

StringLiteral(String)

A string literal. The .0 is the content of the string, without the quotes

§

NumberLiteral(f64)

Number

§

BoolLiteral(bool)

Bool

§

PropertyReference(PropertyReference)

Reference to a property (which can also be a callback) or an element (property name is empty then).

§

FunctionParameterReference

Fields

§index: usize

Reference the parameter at the given index of the current function.

§

StoreLocalVariable

Fields

§name: String

Should be directly within a CodeBlock expression, and store the value of the expression in a local variable

§

ReadLocalVariable

Fields

§name: String
§ty: Type

a reference to the local variable with the given name. The type system should ensure that a variable has been stored with this name and this type before in one of the statement of an enclosing codeblock

§

StructFieldAccess

Fields

§base: Box<Expression>

This expression should have Type::Struct type

§name: String

Access to a field of the given name within a struct.

§

ArrayIndex

Fields

§array: Box<Expression>

This expression should have Type::Array type

Access to a index within an array.

§

Cast

Fields

§to: Type

Cast an expression to the given type

§

CodeBlock(Vec<Expression>)

a code block with different expression

§

BuiltinFunctionCall

Fields

§arguments: Vec<Expression>

A function call

§

CallBackCall

Fields

§arguments: Vec<Expression>
§

FunctionCall

Fields

§arguments: Vec<Expression>
§

ExtraBuiltinFunctionCall

Fields

§return_ty: Type
§function: String
§arguments: Vec<Expression>

A BuiltinFunctionCall, but the function is not yet in the BuiltinFunction enum TODO: merge in BuiltinFunctionCall

§

PropertyAssignment

Fields

An assignment of a value to a property

§

ModelDataAssignment

Fields

§level: usize

an assignment of a value to the model data

§

ArrayIndexAssignment

Fields

An assignment done with the foo[idx] = ...

§

BinaryExpression

Fields

§op: char

‘+’, ‘-’, ‘/’, ‘*’, ‘=’, ‘!’, ‘<’, ‘>’, ‘≤’, ‘≥’, ‘&’, ‘|’

§

UnaryOp

Fields

§op: char

‘+’, ‘-’, ‘!’

§

ImageReference

Fields

§resource_ref: ImageReference
§

Condition

Fields

§condition: Box<Expression>
§true_expr: Box<Expression>
§false_expr: Box<Expression>
§

Array

Fields

§element_ty: Type
§values: Vec<Expression>
§as_model: bool

When true, this should be converted to a model. When false, this should stay as a slice

§

Struct

Fields

§ty: Type
§

EasingCurve(EasingCurve)

§

LinearGradient

Fields

§stops: Vec<(Expression, Expression)>

First expression in the tuple is a color, second expression is the stop position

§

RadialGradient

Fields

§stops: Vec<(Expression, Expression)>

First expression in the tuple is a color, second expression is the stop position

§

EnumerationValue(EnumerationValue)

§

ReturnStatement(Option<Box<Expression>>)

§

LayoutCacheAccess

Fields

§layout_cache_prop: PropertyReference
§index: usize
§repeater_index: Option<Box<Expression>>

When set, this is the index within a repeater, and the index is then the location of another offset. So this looks like layout_cache_prop[layout_cache_prop[index] + repeater_index]

§

BoxLayoutFunction

Fields

§cells_variable: String

The local variable (as read with Self::ReadLocalVariable) that contains the sell

§repeater_indices: Option<String>

The name for the local variable that contains the repeater indices

§elements: Vec<Either<Expression, usize>>

Either an expression of type BoxLayoutCellData, or an index to the repeater

§orientation: Orientation
§sub_expression: Box<Expression>

Will call the sub_expression, with the cell variable set to the array the array of BoxLayoutCellData form the elements

§

ComputeDialogLayoutCells

Fields

§cells_variable: String

The local variable where the slice of cells is going to be stored

§unsorted_cells: Box<Expression>

This is an Expression::Array

Implementations§

source§

impl Expression

source

pub fn default_value_for_type(ty: &Type) -> Option<Self>

source

pub fn ty(&self, ctx: &dyn TypeResolutionContext) -> Type

source§

impl Expression

source

pub fn visit(&self, visitor: impl FnMut(&Self))

Call the visitor for each sub-expression (not recursive)

source

pub fn visit_mut(&mut self, visitor: impl FnMut(&mut Self))

Call the visitor for each sub-expression (not recursive)

source

pub fn visit_recursive(&self, visitor: &mut dyn FnMut(&Self))

Visit itself and each sub expression recursively

Trait Implementations§

source§

impl Clone for Expression

source§

fn clone(&self) -> Expression

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 Expression

source§

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

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

impl From<Expression> for MutExpression

source§

fn from(e: Expression) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.