Enum sway_core::Expression [−][src]
pub enum Expression<'sc> {
Show 17 variants
Literal {
value: Literal<'sc>,
span: Span<'sc>,
},
FunctionApplication {
name: CallPath<'sc>,
arguments: Vec<Expression<'sc>>,
type_arguments: Vec<(TypeInfo, Span<'sc>)>,
span: Span<'sc>,
},
LazyOperator {
op: LazyOp,
lhs: Box<Expression<'sc>>,
rhs: Box<Expression<'sc>>,
span: Span<'sc>,
},
VariableExpression {
name: Ident<'sc>,
span: Span<'sc>,
},
Unit {
span: Span<'sc>,
},
Array {
contents: Vec<Expression<'sc>>,
span: Span<'sc>,
},
MatchExpression {
primary_expression: Box<Expression<'sc>>,
branches: Vec<MatchBranch<'sc>>,
span: Span<'sc>,
},
StructExpression {
struct_name: Ident<'sc>,
fields: Vec<StructExpressionField<'sc>>,
span: Span<'sc>,
},
CodeBlock {
contents: CodeBlock<'sc>,
span: Span<'sc>,
},
IfExp {
condition: Box<Expression<'sc>>,
then: Box<Expression<'sc>>,
else: Option<Box<Expression<'sc>>>,
span: Span<'sc>,
},
AsmExpression {
span: Span<'sc>,
asm: AsmExpression<'sc>,
},
MethodApplication {
method_name: MethodName<'sc>,
arguments: Vec<Expression<'sc>>,
span: Span<'sc>,
},
SubfieldExpression {
prefix: Box<Expression<'sc>>,
span: Span<'sc>,
field_to_access: Ident<'sc>,
},
DelineatedPath {
call_path: CallPath<'sc>,
args: Vec<Expression<'sc>>,
span: Span<'sc>,
type_arguments: Vec<TypeInfo>,
},
AbiCast {
abi_name: CallPath<'sc>,
address: Box<Expression<'sc>>,
span: Span<'sc>,
},
ArrayIndex {
prefix: Box<Expression<'sc>>,
index: Box<Expression<'sc>>,
span: Span<'sc>,
},
DelayedMatchTypeResolution {
variant: DelayedResolutionVariant<'sc>,
span: Span<'sc>,
},
}
Variants
Literal
FunctionApplication
LazyOperator
VariableExpression
Unit
Fields
span: Span<'sc>
Array
MatchExpression
StructExpression
CodeBlock
IfExp
Fields
condition: Box<Expression<'sc>>
then: Box<Expression<'sc>>
else: Option<Box<Expression<'sc>>>
span: Span<'sc>
AsmExpression
MethodApplication
SubfieldExpression
A subfield expression is anything of the form:
<ident>.<ident>
DelineatedPath
A [DelineatedPath] 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<'sc> RefUnwindSafe for Expression<'sc>
impl<'sc> Send for Expression<'sc>
impl<'sc> Sync for Expression<'sc>
impl<'sc> Unpin for Expression<'sc>
impl<'sc> UnwindSafe for Expression<'sc>
Blanket Implementations
Mutably borrows from an owned value. Read more