use vize_l0::Span;
use super::{BindingId, BindingInput, EffectKind, EffectSet, Verdict};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u8)]
pub enum SourceKind {
Ref = 0,
ShallowRef = 1,
Reactive = 2,
ShallowReactive = 3,
Computed = 4,
Readonly = 5,
ShallowReadonly = 6,
ToRef = 7,
ToRefs = 8,
}
impl SourceKind {
#[must_use]
pub const fn binding_input(self, id: BindingId, span: Span) -> BindingInput {
let (effects, verdict) = match self {
Self::Ref | Self::ShallowRef | Self::Computed | Self::ToRef | Self::ToRefs => {
(EffectSet::one(EffectKind::ReadReactive), Verdict::Proven)
}
Self::Reactive | Self::ShallowReactive => (
EffectSet::one(EffectKind::ReadReactive).with(EffectKind::MutateLocal),
Verdict::Proven,
),
Self::Readonly | Self::ShallowReadonly => (
EffectSet::one(EffectKind::ReadReactive).with(EffectKind::Freeze),
Verdict::Unknown,
),
};
BindingInput::local(id, span)
.with_effects(effects)
.with_verdict(verdict)
}
}