Enum sixtyfps_compilerlib::expression_tree::Expression[][src]

pub enum Expression {
Show variants Invalid, Uncompiled(SyntaxNode), TwoWayBinding(NamedReferenceOption<Box<Expression>>), StringLiteral(String), NumberLiteral(f64Unit), BoolLiteral(bool), CallbackReference(NamedReference), PropertyReference(NamedReference), BuiltinFunctionReference(BuiltinFunctionOption<SourceLocation>), MemberFunction { base: Box<Expression>, base_node: Option<NodeOrToken>, member: Box<Expression>, }, BuiltinMacroReference(BuiltinMacroFunctionOption<NodeOrToken>), ElementReference(Weak<RefCell<Element>>), RepeaterIndexReference { element: Weak<RefCell<Element>>, }, RepeaterModelReference { element: Weak<RefCell<Element>>, }, FunctionParameterReference { index: usize, ty: Type, }, StoreLocalVariable { name: String, value: Box<Expression>, }, ReadLocalVariable { name: String, ty: Type, }, StructFieldAccess { base: Box<Expression>, name: String, }, Cast { from: Box<Expression>, to: Type, }, CodeBlock(Vec<Expression>), FunctionCall { function: Box<Expression>, arguments: Vec<Expression>, source_location: Option<SourceLocation>, }, SelfAssignment { lhs: Box<Expression>, rhs: Box<Expression>, op: char, }, BinaryExpression { lhs: Box<Expression>, rhs: Box<Expression>, op: char, }, UnaryOp { sub: Box<Expression>, op: char, }, ImageReference(ImageReference), Condition { condition: Box<Expression>, true_expr: Box<Expression>, false_expr: Box<Expression>, }, Array { element_ty: Type, values: Vec<Expression>, }, Struct { ty: Type, values: HashMap<String, Expression>, }, PathElements { elements: Path, }, EasingCurve(EasingCurve), LinearGradient { angle: Box<Expression>, stops: Vec<(Expression, Expression)>, }, EnumerationValue(EnumerationValue), ReturnStatement(Option<Box<Expression>>), LayoutCacheAccess { layout_cache_prop: NamedReference, index: usize, repeater_index: Option<Box<Expression>>, }, ComputeLayoutInfo(LayoutOrientation), SolveLayout(LayoutOrientation),
}
Expand description

The Expression is hold by properties, so it should not hold any strong references to node from the object_tree

Variants

Invalid

Something went wrong (and an error will be reported)

Uncompiled(SyntaxNode)

We haven’t done the lookup yet

TwoWayBinding(NamedReferenceOption<Box<Expression>>)

Special expression that can be the value of a two way binding

The named reference is what it is aliased to, and the optional Expression is the initialization expression, if any. That expression can be a TwoWayBinding as well

StringLiteral(String)

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

NumberLiteral(f64Unit)

Number

BoolLiteral(bool)
CallbackReference(NamedReference)

Reference to the callback in the

Note: if we are to separate expression and statement, we probably do not need to have callback reference within expressions

PropertyReference(NamedReference)

Reference to the callback in the

BuiltinFunctionReference(BuiltinFunctionOption<SourceLocation>)

Reference to a function built into the run-time, implemented natively

MemberFunction

A MemberFunction expression exists only for a short time, for example for item.focus() to be translated to a regular FunctionCall expression where the base becomes the first argument.

Show fields

Fields of MemberFunction

base: Box<Expression>base_node: Option<NodeOrToken>member: Box<Expression>
BuiltinMacroReference(BuiltinMacroFunctionOption<NodeOrToken>)

Reference to a macro understood by the compiler. These should be transformed to other expression before reaching generation

ElementReference(Weak<RefCell<Element>>)

A reference to a specific element. This isn’t possible to create in .60 syntax itself, but intermediate passes may generate this type of expression.

RepeaterIndexReference

Reference to the index variable of a repeater

Example: idx in for xxx[idx] in .... The element is the reference to the element that is repeated

Show fields

Fields of RepeaterIndexReference

element: Weak<RefCell<Element>>
RepeaterModelReference

Reference to the model variable of a repeater

Example: xxx in for xxx[idx] in .... The element is the reference to the element that is repeated

Show fields

Fields of RepeaterModelReference

element: Weak<RefCell<Element>>
FunctionParameterReference

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

Show fields

Fields of FunctionParameterReference

index: usizety: Type
StoreLocalVariable

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

Show fields

Fields of StoreLocalVariable

name: Stringvalue: Box<Expression>
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

Show fields

Fields of ReadLocalVariable

name: Stringty: Type
StructFieldAccess

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

Show fields

Fields of StructFieldAccess

base: Box<Expression>

This expression should have Type::Struct type

name: String
Cast

Cast an expression to the given type

Show fields

Fields of Cast

from: Box<Expression>to: Type
CodeBlock(Vec<Expression>)

a code block with different expression

FunctionCall

A function call

Show fields

Fields of FunctionCall

function: Box<Expression>arguments: Vec<Expression>source_location: Option<SourceLocation>
SelfAssignment

A SelfAssignment or an Assignment. When op is ‘=’ this is a signal assignment.

Show fields

Fields of SelfAssignment

lhs: Box<Expression>rhs: Box<Expression>op: char

‘+’, ‘-’, ‘/’, ‘*’, or ‘=’

BinaryExpression
Show fields

Fields of BinaryExpression

lhs: Box<Expression>rhs: Box<Expression>op: char

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

UnaryOp
Show fields

Fields of UnaryOp

sub: Box<Expression>op: char

‘+’, ‘-’, ‘!’

ImageReference(ImageReference)
Condition
Show fields

Fields of Condition

condition: Box<Expression>true_expr: Box<Expression>false_expr: Box<Expression>
Array
Show fields

Fields of Array

element_ty: Typevalues: Vec<Expression>
Struct
Show fields

Fields of Struct

ty: Typevalues: HashMap<String, Expression>
PathElements
Show fields

Fields of PathElements

elements: Path
EasingCurve(EasingCurve)
LinearGradient
Show fields

Fields of LinearGradient

angle: Box<Expression>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
Show fields

Fields of LayoutCacheAccess

layout_cache_prop: NamedReferenceindex: usizerepeater_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]

ComputeLayoutInfo(LayoutOrientation)

Compute the LayoutInfo for the given layout. The orientation is the orientation of the cache, not the orientation of the layout

SolveLayout(LayoutOrientation)

Implementations

Return the type of this property

Call the visitor for each sub-expression. (note: this function does not recurse)

Visit itself and each sub expression recursively

Create a conversion node if needed, or throw an error if the type is not matching

Return the default value for the given type

Try to mark this expression to a lvalue that can be assigned to.

Return true if the expression is a “lvalue” that can be used as the left hand side of a = or += or similar

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Performs the conversion.

fn for_each_entry<R>(
    &self,
    ctx: &LookupCtx<'_>,
    f: &mut impl FnMut(&str, Expression) -> Option<R>
) -> Option<R>

Will call the function for each entry (useful for completion) If the function return Some, it will immediately be returned and not called further Read more

Perform a lookup of a given identifier. One does not have to re-implement unless we can make it faster Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.