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

pub enum Expression {
    Invalid,
    Uncompiled(SyntaxNodeWithSourceFile),
    TwoWayBinding(NamedReference),
    StringLiteral(String),
    NumberLiteral(f64Unit),
    BoolLiteral(bool),
    SignalReference(NamedReference),
    PropertyReference(NamedReference),
    BuiltinFunctionReference(BuiltinFunction),
    MemberFunction {
        base: Box<Expression>,
        base_node: SyntaxNodeWithSourceFile,
        member: Box<Expression>,
    },
    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,
    },
    ObjectAccess {
        base: Box<Expression>,
        name: String,
    },
    Cast {
        from: Box<Expression>,
        to: Type,
    },
    CodeBlock(Vec<Expression>),
    FunctionCall {
        function: Box<Expression>,
        arguments: Vec<Expression>,
    },
    SelfAssignment {
        lhs: Box<Expression>,
        rhs: Box<Expression>,
        op: char,
    },
    BinaryExpression {
        lhs: Box<Expression>,
        rhs: Box<Expression>,
        op: char,
    },
    UnaryOp {
        sub: Box<Expression>,
        op: char,
    },
    ResourceReference {
        absolute_source_path: String,
    },
    Condition {
        condition: Box<Expression>,
        true_expr: Box<Expression>,
        false_expr: Box<Expression>,
    },
    Array {
        element_ty: Type,
        values: Vec<Expression>,
    },
    Object {
        ty: Type,
        values: HashMap<String, Expression>,
    },
    PathElements {
        elements: Path,
    },
    EasingCurve(EasingCurve),
    EnumerationValue(EnumerationValue),
}

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)

We haven't done the lookup yet

TwoWayBinding(NamedReference)

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

StringLiteral(String)

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

NumberLiteral(f64Unit)

Number

BoolLiteral(bool)
SignalReference(NamedReference)

Reference to the signal in the

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

PropertyReference(NamedReference)

Reference to the signal in the

BuiltinFunctionReference(BuiltinFunction)

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.

Fields of MemberFunction

base: Box<Expression>base_node: SyntaxNodeWithSourceFilemember: Box<Expression>
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

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

Fields of RepeaterModelReference

element: Weak<RefCell<Element>>
FunctionParameterReference

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

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

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

Fields of ReadLocalVariable

name: Stringty: Type
ObjectAccess

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

Fields of ObjectAccess

base: Box<Expression>

This expression should have Type::Object type

name: String
Cast

Cast an expression to the given type

Fields of Cast

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

a code block with different expression

FunctionCall

A function call

Fields of FunctionCall

function: Box<Expression>arguments: Vec<Expression>
SelfAssignment

A SelfAssignment or an Assignment. When op is '=' this is a signel assignment.

Fields of SelfAssignment

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

'+', '-', '/', '*', or '='

BinaryExpression

Fields of BinaryExpression

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

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

UnaryOp

Fields of UnaryOp

sub: Box<Expression>op: char

'+', '-', '!'

ResourceReference

Fields of ResourceReference

absolute_source_path: String
Condition

Fields of Condition

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

Fields of Array

element_ty: Typevalues: Vec<Expression>
Object

Fields of Object

ty: Typevalues: HashMap<String, Expression>
PathElements

Fields of PathElements

elements: Path
EasingCurve(EasingCurve)
EnumerationValue(EnumerationValue)

Implementations

impl Expression[src]

pub fn ty(&self) -> Type[src]

Return the type of this property

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

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

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

pub fn is_constant(&self) -> bool[src]

pub fn maybe_convert_to(
    self,
    target_type: Type,
    node: &impl SpannedWithSourceFile,
    diag: &mut BuildDiagnostics
) -> Expression
[src]

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

pub fn default_value_for_type(ty: &Type) -> Expression[src]

Return the default value for the given type

pub fn is_rw(&self) -> bool[src]

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

Trait Implementations

impl Clone for Expression[src]

impl Debug for Expression[src]

impl Default for Expression[src]

impl From<Expression> for ExpressionSpanned[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.