Rename, comment
This commit is contained in:
@@ -443,7 +443,7 @@ impl std::iter::FusedIterator for DeclarationsIterator<'_, '_> {}
|
||||
#[derive(Clone, Debug)]
|
||||
pub(super) struct FlowSnapshot {
|
||||
symbol_states: IndexVec<ScopedSymbolId, SymbolState>,
|
||||
unbound_visibility_constraint_id: ScopedVisibilityConstraintId,
|
||||
unbound_visibility: ScopedVisibilityConstraintId,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -457,7 +457,9 @@ pub(super) struct UseDefMapBuilder<'db> {
|
||||
/// Append-only array of [`VisibilityConstraintRef`].
|
||||
visibility_constraints: VisibilityConstraints,
|
||||
|
||||
unbound_visibility_constraint_id: ScopedVisibilityConstraintId,
|
||||
/// A constraint which describes the visibility of the unbound/undeclared state, i.e.
|
||||
/// whether or not the start of the scope is visible.
|
||||
unbound_visibility: ScopedVisibilityConstraintId,
|
||||
|
||||
/// Live bindings at each so-far-recorded use.
|
||||
bindings_by_use: IndexVec<ScopedUseId, SymbolBindings>,
|
||||
@@ -475,7 +477,7 @@ impl<'db> UseDefMapBuilder<'db> {
|
||||
all_definitions: IndexVec::from_iter([None]),
|
||||
all_constraints: IndexVec::new(),
|
||||
visibility_constraints: VisibilityConstraints::new(),
|
||||
unbound_visibility_constraint_id: ScopedVisibilityConstraintId::from_u32(0),
|
||||
unbound_visibility: ScopedVisibilityConstraintId::from_u32(0),
|
||||
bindings_by_use: IndexVec::new(),
|
||||
definitions_by_definition: FxHashMap::default(),
|
||||
symbol_states: IndexVec::new(),
|
||||
@@ -483,9 +485,9 @@ impl<'db> UseDefMapBuilder<'db> {
|
||||
}
|
||||
|
||||
pub(super) fn add_symbol(&mut self, symbol: ScopedSymbolId) {
|
||||
let new_symbol = self.symbol_states.push(SymbolState::undefined(
|
||||
self.unbound_visibility_constraint_id,
|
||||
));
|
||||
let new_symbol = self
|
||||
.symbol_states
|
||||
.push(SymbolState::undefined(self.unbound_visibility));
|
||||
debug_assert_eq!(symbol, new_symbol);
|
||||
}
|
||||
|
||||
@@ -523,9 +525,9 @@ impl<'db> UseDefMapBuilder<'db> {
|
||||
state.record_visibility_constraint(&mut self.visibility_constraints, new_constraint_id);
|
||||
}
|
||||
|
||||
self.unbound_visibility_constraint_id = self
|
||||
self.unbound_visibility = self
|
||||
.visibility_constraints
|
||||
.add_sequence(self.unbound_visibility_constraint_id, new_constraint_id);
|
||||
.add_sequence(self.unbound_visibility, new_constraint_id);
|
||||
|
||||
new_constraint_id
|
||||
}
|
||||
@@ -534,7 +536,7 @@ impl<'db> UseDefMapBuilder<'db> {
|
||||
let num_symbols = self.symbol_states.len();
|
||||
debug_assert!(num_symbols >= snapshot.symbol_states.len());
|
||||
|
||||
self.unbound_visibility_constraint_id = snapshot.unbound_visibility_constraint_id;
|
||||
self.unbound_visibility = snapshot.unbound_visibility;
|
||||
|
||||
let mut snapshot_definitions_iter = snapshot.symbol_states.into_iter();
|
||||
for current in &mut self.symbol_states {
|
||||
@@ -585,7 +587,7 @@ impl<'db> UseDefMapBuilder<'db> {
|
||||
pub(super) fn snapshot(&self) -> FlowSnapshot {
|
||||
FlowSnapshot {
|
||||
symbol_states: self.symbol_states.clone(),
|
||||
unbound_visibility_constraint_id: self.unbound_visibility_constraint_id,
|
||||
unbound_visibility: self.unbound_visibility,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,15 +601,13 @@ impl<'db> UseDefMapBuilder<'db> {
|
||||
|
||||
// Restore the current visible-definitions state to the given snapshot.
|
||||
self.symbol_states = snapshot.symbol_states;
|
||||
self.unbound_visibility_constraint_id = snapshot.unbound_visibility_constraint_id;
|
||||
self.unbound_visibility = snapshot.unbound_visibility;
|
||||
|
||||
// If the snapshot we are restoring is missing some symbols we've recorded since, we need
|
||||
// to fill them in so the symbol IDs continue to line up. Since they don't exist in the
|
||||
// snapshot, the correct state to fill them in with is "undefined".
|
||||
self.symbol_states.resize(
|
||||
num_symbols,
|
||||
SymbolState::undefined(self.unbound_visibility_constraint_id),
|
||||
);
|
||||
self.symbol_states
|
||||
.resize(num_symbols, SymbolState::undefined(self.unbound_visibility));
|
||||
}
|
||||
|
||||
/// Merge the given snapshot into the current state, reflecting that we might have taken either
|
||||
@@ -625,19 +625,16 @@ impl<'db> UseDefMapBuilder<'db> {
|
||||
current.merge(snapshot, &mut self.visibility_constraints);
|
||||
} else {
|
||||
current.merge(
|
||||
SymbolState::undefined(snapshot.unbound_visibility_constraint_id),
|
||||
SymbolState::undefined(snapshot.unbound_visibility),
|
||||
&mut self.visibility_constraints,
|
||||
);
|
||||
// Symbol not present in snapshot, so it's unbound/undeclared from that path.
|
||||
}
|
||||
}
|
||||
|
||||
// Merge unbound visibility constraints:
|
||||
|
||||
self.unbound_visibility_constraint_id = self.visibility_constraints.add_merged(
|
||||
self.unbound_visibility_constraint_id,
|
||||
snapshot.unbound_visibility_constraint_id,
|
||||
);
|
||||
self.unbound_visibility = self
|
||||
.visibility_constraints
|
||||
.add_merged(self.unbound_visibility, snapshot.unbound_visibility);
|
||||
}
|
||||
|
||||
pub(super) fn finish(mut self) -> UseDefMap<'db> {
|
||||
|
||||
@@ -110,11 +110,11 @@ pub(super) struct SymbolDeclarations {
|
||||
}
|
||||
|
||||
impl SymbolDeclarations {
|
||||
fn undeclared(unbound_visibility_constraint_id: ScopedVisibilityConstraintId) -> Self {
|
||||
fn undeclared(undeclared_visibility: ScopedVisibilityConstraintId) -> Self {
|
||||
Self {
|
||||
live_declarations: Declarations::with(0),
|
||||
visibility_constraints: VisibilityConstraintPerBinding::from_iter([
|
||||
unbound_visibility_constraint_id,
|
||||
undeclared_visibility,
|
||||
]),
|
||||
}
|
||||
}
|
||||
@@ -173,13 +173,11 @@ pub(super) struct SymbolBindings {
|
||||
}
|
||||
|
||||
impl SymbolBindings {
|
||||
fn unbound(unbound_visibility_constraint_id: ScopedVisibilityConstraintId) -> Self {
|
||||
fn unbound(unbound_visibility: ScopedVisibilityConstraintId) -> Self {
|
||||
Self {
|
||||
live_bindings: Bindings::with(0),
|
||||
constraints: ConstraintsPerBinding::from_iter([Constraints::default()]),
|
||||
visibility_constraints: VisibilityConstraintPerBinding::from_iter([
|
||||
unbound_visibility_constraint_id,
|
||||
]),
|
||||
visibility_constraints: VisibilityConstraintPerBinding::from_iter([unbound_visibility]),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,10 +236,10 @@ pub(super) struct SymbolState {
|
||||
|
||||
impl SymbolState {
|
||||
/// Return a new [`SymbolState`] representing an unbound, undeclared symbol.
|
||||
pub(super) fn undefined(unbound_visibility_constraint: ScopedVisibilityConstraintId) -> Self {
|
||||
pub(super) fn undefined(unbound_visibility: ScopedVisibilityConstraintId) -> Self {
|
||||
Self {
|
||||
declarations: SymbolDeclarations::undeclared(unbound_visibility_constraint),
|
||||
bindings: SymbolBindings::unbound(unbound_visibility_constraint),
|
||||
declarations: SymbolDeclarations::undeclared(unbound_visibility),
|
||||
bindings: SymbolBindings::unbound(unbound_visibility),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user