pub struct Scope {
pub id: usize,
pub parent: Option<usize>,
pub kind: ScopeKind,
pub location: ByteSpan,
pub symbols: HashSet<String>,
}Expand description
A lexical scope in Perl code with hierarchical symbol visibility for Parse/Analyze stages.
Represents a lexical scope boundary (subroutine, block, package) with symbol visibility rules according to Perl’s lexical scoping semantics.
§Performance Characteristics
- Scope lookup: O(log n) with parent chain traversal
- Symbol resolution: O(1) per scope level
- Memory: ~64 bytes per scope + symbol set
§Perl Scoping Rules
- Global scope: File-level and package symbols
- Package scope: Package-qualified symbols
- Subroutine scope: Local variables and parameters
- Block scope: Lexical variables in control structures
- Lexical precedence: Inner scopes shadow outer scopes
Workflow: Parse/Analyze scope tracking for symbol resolution.
Fields§
§id: usizeUnique scope identifier for reference tracking
parent: Option<usize>Parent scope for hierarchical lookup (None for global)
kind: ScopeKindClassification of scope type
location: ByteSpanSource location where scope begins
symbols: HashSet<String>Set of symbol names defined in this scope
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Scope
impl RefUnwindSafe for Scope
impl Send for Scope
impl Sync for Scope
impl Unpin for Scope
impl UnsafeUnpin for Scope
impl UnwindSafe for Scope
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more