Enum sway_core::Expression
source · [−]pub enum Expression {
Show 17 variants
Literal {
value: Literal,
span: Span,
},
FunctionApplication {
name: CallPath,
arguments: Vec<Expression>,
type_arguments: Vec<(TypeInfo, Span)>,
span: Span,
},
LazyOperator {
op: LazyOp,
lhs: Box<Expression>,
rhs: Box<Expression>,
span: Span,
},
VariableExpression {
name: Ident,
span: Span,
},
Tuple {
fields: Vec<Expression>,
span: Span,
},
Array {
contents: Vec<Expression>,
span: Span,
},
MatchExpression {
primary_expression: Box<Expression>,
branches: Vec<MatchBranch>,
span: Span,
},
StructExpression {
struct_name: Ident,
fields: Vec<StructExpressionField>,
span: Span,
},
CodeBlock {
contents: CodeBlock,
span: Span,
},
IfExp {
condition: Box<Expression>,
then: Box<Expression>,
else: Option<Box<Expression>>,
span: Span,
},
AsmExpression {
span: Span,
asm: AsmExpression,
},
MethodApplication {
method_name: MethodName,
arguments: Vec<Expression>,
span: Span,
},
SubfieldExpression {
prefix: Box<Expression>,
span: Span,
field_to_access: Ident,
},
DelineatedPath {
call_path: CallPath,
args: Vec<Expression>,
span: Span,
type_arguments: Vec<TypeInfo>,
},
AbiCast {
abi_name: CallPath,
address: Box<Expression>,
span: Span,
},
ArrayIndex {
prefix: Box<Expression>,
index: Box<Expression>,
span: Span,
},
DelayedMatchTypeResolution {
variant: DelayedResolutionVariant,
span: Span,
},
}
Expand description
Represents a parsed, but not yet type checked, Expression.
Variants
Literal
FunctionApplication
LazyOperator
VariableExpression
Tuple
Array
MatchExpression
StructExpression
CodeBlock
IfExp
AsmExpression
MethodApplication
SubfieldExpression
A subfield expression is anything of the form:
<ident>.<ident>
DelineatedPath
A delineated path is anything of the form:
<ident>::<ident>
Where there are n >= 2
idents.
These could be either enum variant constructions, or they could be
references to some sort of module in the module tree.
For example, a reference to a module:
std::ops::add
And, an enum declaration:
enum MyEnum {
Variant1,
Variant2
}
MyEnum::Variant1
AbiCast
A cast of a hash to an ABI for calling a contract.
ArrayIndex
DelayedMatchTypeResolution
This variant serves as a stand-in for parsing-level match expression desugaring. Because types cannot be known at parsing-time, a desugared struct or enum gets special cased into this variant. During type checking, this variant is removed as is replaced with the corresponding field or argument access (given that the expression inside of the delayed resolution has the appropriate struct or enum type)
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Expression
impl Send for Expression
impl Sync for Expression
impl Unpin for Expression
impl UnwindSafe for Expression
Blanket Implementations
Mutably borrows from an owned value. Read more