use rowan::TextRange;
use super::binding::BindingId;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct ScopeId(pub u32);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ScopeKind {
File,
Module,
Function,
Let,
Comprehension,
Struct,
For,
While,
Try,
Catch,
Finally,
}
impl ScopeKind {
pub fn is_global(self) -> bool {
matches!(self, ScopeKind::File | ScopeKind::Module)
}
pub fn is_hard(self) -> bool {
!matches!(
self,
ScopeKind::For
| ScopeKind::While
| ScopeKind::Try
| ScopeKind::Catch
| ScopeKind::Finally
)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Scope {
pub kind: ScopeKind,
pub parent: Option<ScopeId>,
pub range: TextRange,
pub bindings: Vec<BindingId>,
}