pub enum Expression {
Show 45 variants
Literal {
literal: Literal,
ty: Type,
span: Span,
},
Function {
doc: Option<String>,
attributes: Vec<Attribute>,
name: EcoString,
name_span: Span,
generics: Vec<Generic>,
params: Vec<Binding>,
return_annotation: Annotation,
return_type: Type,
visibility: Visibility,
body: FunctionBody,
ty: Type,
span: Span,
},
Lambda {
params: Vec<Binding>,
return_annotation: Annotation,
body: Box<Expression>,
ty: Type,
span: Span,
},
Block {
items: Vec<Expression>,
ty: Type,
span: Span,
},
Let {
binding: Box<Binding>,
value: Box<Expression>,
mode: LetMode,
ty: Type,
span: Span,
},
Identifier {
value: EcoString,
ty: Type,
span: Span,
resolution: IdentifierResolution,
},
Call {
expression: Box<Expression>,
args: Vec<Expression>,
spread: Option<Box<Expression>>,
type_arguments: CallTypeArguments,
ty: Type,
span: Span,
call_kind: CallKind,
},
If {
condition: Box<Expression>,
consequence: Box<Expression>,
alternative: Option<Box<Expression>>,
ty: Type,
span: Span,
},
IfLet {
pattern: Pattern,
scrutinee: Box<Expression>,
consequence: Box<Expression>,
alternative: IfLetAlternative,
ty: Type,
span: Span,
},
Match {
subject: Box<Expression>,
arms: Vec<MatchArm>,
ty: Type,
span: Span,
},
Tuple {
elements: Vec<Expression>,
ty: Type,
span: Span,
},
StructCall {
name: EcoString,
field_assignments: Vec<StructFieldAssignment>,
spread: StructSpread,
ty: Type,
span: Span,
},
DotAccess {
expression: Box<Expression>,
member: EcoString,
ty: Type,
span: Span,
resolution: DotAccessResolution,
},
Assignment {
target: Box<Expression>,
value: Box<Expression>,
compound_operator: Option<BinaryOperator>,
span: Span,
},
Return {
expression: Box<Expression>,
ty: Type,
span: Span,
},
Propagate {
expression: Box<Expression>,
ty: Type,
span: Span,
},
TryBlock {
items: Vec<Expression>,
ty: Type,
try_keyword_span: Span,
span: Span,
},
RecoverBlock {
items: Vec<Expression>,
ty: Type,
recover_keyword_span: Span,
span: Span,
},
ImplBlock {
annotation: Annotation,
receiver_name: EcoString,
methods: Vec<Expression>,
generics: Vec<Generic>,
ty: Type,
span: Span,
},
Binary {
operator: BinaryOperator,
left: Box<Expression>,
right: Box<Expression>,
ty: Type,
span: Span,
},
Unary {
operator: UnaryOperator,
expression: Box<Expression>,
ty: Type,
span: Span,
},
Paren {
expression: Box<Expression>,
ty: Type,
span: Span,
},
Const {
doc: Option<String>,
identifier: EcoString,
identifier_span: Span,
annotation: Option<Annotation>,
expression: ConstInitializer,
visibility: Visibility,
ty: Type,
span: Span,
},
VariableDeclaration {
doc: Option<String>,
attributes: Vec<Attribute>,
name: EcoString,
name_span: Span,
annotation: Annotation,
visibility: Visibility,
ty: Type,
span: Span,
},
RawGo {
text: String,
},
Loop {
body: Box<Expression>,
ty: Type,
span: Span,
},
While {
condition: Box<Expression>,
body: Box<Expression>,
span: Span,
},
WhileLet {
pattern: Pattern,
scrutinee: Box<Expression>,
body: Box<Expression>,
span: Span,
},
For {
binding: Box<Binding>,
iterable: Box<Expression>,
body: Box<Expression>,
span: Span,
},
Break {
value: Option<Box<Expression>>,
span: Span,
},
Continue {
span: Span,
},
Enum {
doc: Option<String>,
attributes: Vec<Attribute>,
name: EcoString,
name_span: Span,
generics: Vec<Generic>,
variants: Vec<EnumVariant>,
visibility: Visibility,
span: Span,
},
Struct {
doc: Option<String>,
attributes: Vec<Attribute>,
name: EcoString,
name_span: Span,
generics: Vec<Generic>,
fields: StructFields,
visibility: Visibility,
span: Span,
},
TypeAlias {
doc: Option<String>,
attributes: Vec<Attribute>,
name: EcoString,
name_span: Span,
generics: Vec<Generic>,
annotation: Annotation,
ty: Type,
visibility: Visibility,
span: Span,
},
PackageImport {
name: EcoString,
name_span: Span,
alias: Option<ImportAlias>,
span: Span,
},
Reference {
expression: Box<Expression>,
ty: Type,
span: Span,
},
Interface {
doc: Option<String>,
attributes: Vec<Attribute>,
name: EcoString,
name_span: Span,
generics: Vec<Generic>,
parents: Vec<ParentInterface>,
method_signatures: Vec<Expression>,
visibility: Visibility,
span: Span,
},
IndexedAccess {
expression: Box<Expression>,
index: Box<Expression>,
ty: Type,
span: Span,
from_colon_syntax: bool,
},
Task {
expression: Box<Expression>,
ty: Type,
span: Span,
},
Defer {
expression: Box<Expression>,
ty: Type,
span: Span,
},
Assert {
expression: Box<Expression>,
ty: Type,
span: Span,
},
Select {
arms: Vec<SelectArm>,
ty: Type,
span: Span,
},
Unit {
ty: Type,
span: Span,
},
Range {
start: Option<Box<Expression>>,
end: Option<Box<Expression>>,
inclusive: bool,
ty: Type,
span: Span,
},
Cast {
expression: Box<Expression>,
target_type: Annotation,
ty: Type,
span: Span,
},
}Variants§
Literal
Function
Lambda
Block
Let
Identifier
Call
Fields
§
expression: Box<Expression>§
args: Vec<Expression>§
spread: Option<Box<Expression>>§
type_arguments: CallTypeArgumentsIf
IfLet
Match
Tuple
StructCall
DotAccess
Assignment
Return
Propagate
TryBlock
RecoverBlock
ImplBlock
Binary
Unary
Paren
Const
VariableDeclaration
RawGo
Loop
While
WhileLet
For
Break
Continue
Enum
Struct
TypeAlias
PackageImport
Reference
Interface
IndexedAccess
Task
Defer
Assert
Select
Unit
Range
Cast
Implementations§
Source§impl Expression
impl Expression
pub fn is_range(&self) -> bool
pub fn is_conditional(&self) -> bool
pub fn is_control_flow(&self) -> bool
pub fn is_temp_producing(&self) -> bool
pub fn function_definition_view(&self) -> FunctionDefinitionView<'_>
pub fn get_type(&self) -> Type
pub fn get_span(&self) -> Span
pub fn contains_break(&self) -> bool
pub fn diverges(&self) -> Option<DeadCodeCause>
Sourcepub fn children(&self) -> Vec<&Expression>
pub fn children(&self) -> Vec<&Expression>
Returns references to all direct child expressions.
This is the single source of truth for expression tree recursion. Use this instead of writing per-variant match arms when you need to walk an expression tree.
pub fn unwrap_parens(&self) -> &Expression
pub fn binding_id(&self) -> Option<BindingId>
pub fn as_integer(&self) -> Option<u64>
Sourcepub fn fold_constant(
&self,
value_of: &dyn Fn(&str) -> Option<Literal>,
) -> Option<Constant>
pub fn fold_constant( &self, value_of: &dyn Fn(&str) -> Option<Literal>, ) -> Option<Constant>
Folds literals, and the named constants whose value value_of gives.
Sourcepub fn deref_inner(&self) -> Option<&Expression>
pub fn deref_inner(&self) -> Option<&Expression>
Inner expression of an explicit x.* deref, or None for anything else.
pub fn as_dotted_path(&self) -> Option<String>
pub fn root_identifier(&self) -> Option<&str>
pub fn root_binding_id(&self) -> Option<BindingId>
pub fn is_empty_collection(&self) -> bool
pub fn is_all_literals(&self) -> bool
pub fn get_var_name(&self) -> Option<String>
pub fn has_else(&self) -> bool
Trait Implementations§
Source§impl Clone for Expression
impl Clone for Expression
Source§impl Debug for Expression
impl Debug for Expression
Source§impl PartialEq for Expression
impl PartialEq for Expression
impl StructuralPartialEq for Expression
Auto Trait Implementations§
impl Freeze for Expression
impl RefUnwindSafe for Expression
impl Send for Expression
impl Sync for Expression
impl Unpin for Expression
impl UnsafeUnpin 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
Mutably borrows from an owned value. Read more