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.
I believe this should be a `FnvHashMap`.