1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use crate::parse_tree::Expression;
use sway_types::{span::Span, Ident, Spanned};
#[derive(Debug, Clone)]
pub enum ReassignmentTarget {
VariableExpression(Box<Expression>),
StorageField(Vec<Ident>),
}
#[derive(Debug, Clone)]
pub struct Reassignment {
pub lhs: ReassignmentTarget,
pub rhs: Expression,
pub(crate) span: Span,
}
impl Reassignment {
pub fn lhs_span(&self) -> Span {
match &self.lhs {
ReassignmentTarget::VariableExpression(var) => var.span.clone(),
ReassignmentTarget::StorageField(ref idents) => idents
.iter()
.fold(idents[0].span(), |acc, ident| Span::join(acc, ident.span())),
}
}
}