Per-translation-unit variable indexing
- Dominant language
- C#
- Stars
- 451
- Forks
- 49
- Avg merge
- 13h 59m
- Merged PRs (30d)
- 6
Description
_Originally posted by @ForNeVeR in https://github.com/ForNeVeR/Cesium/pull/617#discussion_r1740190291_
Currently, we have a global static counter, `CurrentIndex` in the `Cesium.CodeGen.Contexts.VariableInfo` record.
https://github.com/ForNeVeR/Cesium/blob/f1b5204e9d1f0869ed8c4ee0caf3c3e41ad6a5a9/Cesium.CodeGen/Contexts/VariableInfo.cs#L7-L11
I'd like to have some sort of indexing that's tied to the translation unit.
Such a counter is too error-prone: it will easily overflow on 2 billion variables constructed in a single compilation session. Moreover, this construct makes it impossible to copy a `VariableInfo`.
Contributor guide
Research direction
Start with Cesium.CodeGen/Contexts/VariableInfo.cs and inspect how the translation unit and VariableInfo instances are constructed. Trace the current CurrentIndex usage to determine the required ownership and lifetime of per-translation-unit indexing; done means indexes no longer rely on one global static counter and VariableInfo can be copied without that global state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100