Refactored new ScopeData for improved abstraction.

(Previously, scopes were solely identified with NodeId's; this
refactoring prepares for a future where that does not hold.)

Ground work for a proper fix to #8861.
Similarly, this should be a `FnvHashSet`.