Skip to content

Per-translation-unit variable indexing #634

@ForNeVeR

Description

@ForNeVeR

Originally posted by @ForNeVeR in #617 (comment)

Currently, we have a global static counter, CurrentIndex in the Cesium.CodeGen.Contexts.VariableInfo record.

internal record VariableInfo(StorageClass StorageClass, IType Type, IExpression? Constant)
{
static int CurrentIndex = 0;
public int Index { get; } = checked(CurrentIndex++);
}

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerRelated to code compilation or type checkinggood-first-issueAn issue considered simple enough for new contributorskind:refactorInternal changes not affecting the compiler behaviorstatus:help-wantedOpen for contributors

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions