Enum sway_core::parse_tree::Expression
source · [−]pub enum Expression {
Show 20 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,
},
TupleIndex {
prefix: Box<Expression>,
index: usize,
index_span: Span,
span: Span,
},
Array {
contents: Vec<Expression>,
span: Span,
},
MatchExpression {
primary_expression: Box<Expression>,
branches: Vec<MatchBranch>,
span: Span,
},
StructExpression {
struct_name: CallPath,
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,
contract_call_params: Vec<StructExpressionField>,
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,
},
SizeOfVal {
exp: Box<Expression>,
span: Span,
},
SizeOfType {
type_name: TypeInfo,
type_span: Span,
span: Span,
},
}
Expand description
Represents a parsed, but not yet type checked, Expression.
Variants
Literal
FunctionApplication
LazyOperator
VariableExpression
Tuple
TupleIndex
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)
SizeOfVal
SizeOfType
Trait Implementations
sourceimpl Clone for Expression
impl Clone for Expression
sourcefn clone(&self) -> Expression
fn clone(&self) -> Expression
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more