shuck-semantic 0.0.23

Semantic analysis model for shell scripts with scopes, bindings, and dataflow
Documentation
use rustc_hash::FxHashSet;
use shuck_ast::{Name, Span};

use crate::{BindingId, ScopeId};

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CallSite {
    pub callee: Name,
    pub span: Span,
    pub name_span: Span,
    pub scope: ScopeId,
    pub arg_count: usize,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CallGraph {
    pub reachable: FxHashSet<Name>,
    pub uncalled: Vec<BindingId>,
    pub overwritten: Vec<OverwrittenFunction>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct OverwrittenFunction {
    pub name: Name,
    pub first: BindingId,
    pub second: BindingId,
    pub first_called: bool,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum UnreachedFunctionReason {
    UnreachableDefinition,
    ScriptTerminates,
    EnclosingFunctionUnreached,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct UnreachedFunction {
    pub name: Name,
    pub binding: BindingId,
    pub reason: UnreachedFunctionReason,
}