use source_map::{Span, SpanWithSource};
use crate::{CheckingData, Environment, TypeId};
use super::operations::{Logical, MathematicalAndBitwise};
pub enum Assignable {
Reference(Reference),
ObjectDestructuring(Vec<(TypeId, Reference)>),
ArrayDestructuring(Vec<Reference>),
}
#[derive(Clone)]
pub enum Reference {
Variable(String, SpanWithSource),
Property { on: TypeId, with: TypeId, span: SpanWithSource },
}
pub enum AssignmentKind {
Assign,
PureUpdate(MathematicalAndBitwise),
ConditionalUpdate(Logical),
IncrementOrDecrement(IncrementOrDecrement, AssignmentReturnStatus),
}
pub enum IncrementOrDecrement {
Increment,
Decrement,
}
pub enum AssignmentReturnStatus {
Previous,
New,
}
impl Reference {
pub fn get_position(&self) -> SpanWithSource {
match self {
Reference::Variable(_, span) | Reference::Property { span, .. } => span.clone(),
}
}
}
pub trait SynthesizableExpression {
fn synthesize_expression<U: crate::FSResolver>(
&self,
environment: &mut Environment,
checking_data: &mut CheckingData<U>,
) -> TypeId;
fn get_position(&self) -> &Span;
}