mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 17:01:05 +01:00
By adding an InstId to the NameScope, we can determine whether the declaration is being added to a scoped entity (versus a namespace). The choice of InstId on NameScope is chosen versus other solutions because, for imports, we want to just have a list of InstIds to import and, from those, get the containing namespaces for addition. Similar may also be desirable for printing fully qualified names given a singular InstId. That means an InstId must have a path to find enclosing name scopes. What we're looking at here is: - NameScopeId knows its InstId. (done here) - Inst knows the enclosing NameScopeId. (future work) - To walk up enclosing scopes for an Inst: 1. Fetch the Inst. 2. Find its enclosing NameScopeId (which will be per-declaration due to Function etc complexity). 3. Fetch the NameScope if not Package scope. (if Package scope, done) 4. Use the InstId on the NameScope to go back to step 1.