pub enum Expression {
Show 36 variants
StringLiteral(SmolStr),
NumberLiteral(f64),
BoolLiteral(bool),
PropertyReference(PropertyReference),
FunctionParameterReference {
index: usize,
},
StoreLocalVariable {
name: SmolStr,
value: Box<Expression>,
},
ReadLocalVariable {
name: SmolStr,
ty: Type,
},
StructFieldAccess {
base: Box<Expression>,
name: SmolStr,
},
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>,
},
ItemMemberFunctionCall {
function: PropertyReference,
},
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,
nine_slice: Option<[u16; 4]>,
},
Condition {
condition: Box<Expression>,
true_expr: Box<Expression>,
false_expr: Box<Expression>,
},
Array {
element_ty: Type,
values: Vec<Expression>,
as_model: bool,
},
Struct {
ty: Rc<Struct>,
values: BTreeMap<SmolStr, Expression>,
},
EasingCurve(EasingCurve),
LinearGradient {
angle: Box<Expression>,
stops: Vec<(Expression, Expression)>,
},
RadialGradient {
stops: Vec<(Expression, Expression)>,
},
ConicGradient {
stops: Vec<(Expression, Expression)>,
},
EnumerationValue(EnumerationValue),
LayoutCacheAccess {
layout_cache_prop: PropertyReference,
index: usize,
repeater_index: Option<Box<Expression>>,
},
BoxLayoutFunction {
cells_variable: String,
repeater_indices: Option<SmolStr>,
elements: Vec<Either<Expression, RepeatedElementIdx>>,
orientation: Orientation,
sub_expression: Box<Expression>,
},
ComputeDialogLayoutCells {
cells_variable: String,
roles: Box<Expression>,
unsorted_cells: Box<Expression>,
},
MinMax {
ty: Type,
op: MinMaxOp,
lhs: Box<Expression>,
rhs: Box<Expression>,
},
EmptyComponentFactory,
TranslationReference {
format_args: Box<Expression>,
string_index: usize,
plural: Option<Box<Expression>>,
},
}
Variants§
StringLiteral(SmolStr)
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
Reference the parameter at the given index of the current function.
StoreLocalVariable
Should be directly within a CodeBlock expression, and store the value of the expression in a local variable
ReadLocalVariable
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
Access to a field of the given name within a struct.
ArrayIndex
Access to a index within an array.
Cast
Cast an expression to the given type
CodeBlock(Vec<Expression>)
a code block with different expression
BuiltinFunctionCall
A function call
CallBackCall
FunctionCall
ItemMemberFunctionCall
Fields
function: PropertyReference
ExtraBuiltinFunctionCall
A BuiltinFunctionCall, but the function is not yet in the BuiltinFunction
enum
TODO: merge in BuiltinFunctionCall
PropertyAssignment
An assignment of a value to a property
ModelDataAssignment
an assignment of a value to the model data
ArrayIndexAssignment
An assignment done with the foo[idx] = ...
BinaryExpression
UnaryOp
ImageReference
Condition
Array
Fields
values: Vec<Expression>
Struct
EasingCurve(EasingCurve)
LinearGradient
Fields
angle: Box<Expression>
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
ConicGradient
Fields
stops: Vec<(Expression, Expression)>
First expression in the tuple is a color, second expression is the stop position (normalized angle 0-1)
EnumerationValue(EnumerationValue)
LayoutCacheAccess
Fields
layout_cache_prop: PropertyReference
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
Will call the sub_expression, with the cell variable set to the array of BoxLayoutCellData from the elements
Fields
cells_variable: String
The local variable (as read with Self::ReadLocalVariable
) that contains the sell
repeater_indices: Option<SmolStr>
The name for the local variable that contains the repeater indices
elements: Vec<Either<Expression, RepeatedElementIdx>>
Either an expression of type BoxLayoutCellData, or an index to the repeater
orientation: Orientation
sub_expression: Box<Expression>
ComputeDialogLayoutCells
MinMax
EmptyComponentFactory
TranslationReference
A reference to bundled translated string
Fields
format_args: Box<Expression>
An expression of type array of strings
plural: Option<Box<Expression>>
The n
value to use for the plural form if it is a plural form
Implementations§
Source§impl Expression
impl Expression
pub fn default_value_for_type(ty: &Type) -> Option<Self>
pub fn ty(&self, ctx: &dyn TypeResolutionContext) -> Type
Source§impl Expression
impl Expression
Sourcepub fn visit(&self, visitor: impl FnMut(&Self))
pub fn visit(&self, visitor: impl FnMut(&Self))
Call the visitor for each sub-expression (not recursive)
Sourcepub fn visit_mut(&mut self, visitor: impl FnMut(&mut Self))
pub fn visit_mut(&mut self, visitor: impl FnMut(&mut Self))
Call the visitor for each sub-expression (not recursive)
Sourcepub fn visit_recursive(&self, visitor: &mut dyn FnMut(&Self))
pub fn visit_recursive(&self, visitor: &mut dyn FnMut(&Self))
Visit itself and each sub expression recursively
pub fn visit_property_references( &self, ctx: &EvaluationContext<'_>, visitor: &mut dyn FnMut(&PropertyReference, &EvaluationContext<'_>), )
Trait Implementations§
Source§impl Clone for Expression
impl Clone for Expression
Source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for Expression
impl Debug for Expression
Source§impl From<Expression> for MutExpression
impl From<Expression> for MutExpression
Source§fn from(e: Expression) -> Self
fn from(e: Expression) -> Self
Auto Trait Implementations§
impl Freeze for Expression
impl !RefUnwindSafe for Expression
impl !Send for Expression
impl !Sync for Expression
impl Unpin for Expression
impl !UnwindSafe for Expression
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more