Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per-translation-unit variable indexing #634

Open
ForNeVeR opened this issue Sep 1, 2024 · 2 comments
Open

Per-translation-unit variable indexing #634

ForNeVeR opened this issue Sep 1, 2024 · 2 comments
Labels
area:compiler Related to code compilation or type checking good-first-issue An issue considered simple enough for new contributors kind:refactor Internal changes not affecting the compiler behavior status:help-wanted Open for contributors

Comments

@ForNeVeR
Copy link
Owner

ForNeVeR commented Sep 1, 2024

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.

@ForNeVeR ForNeVeR added status:help-wanted Open for contributors area:compiler Related to code compilation or type checking kind:refactor Internal changes not affecting the compiler behavior good-first-issue An issue considered simple enough for new contributors labels Sep 1, 2024
@kant2002
Copy link
Contributor

kant2002 commented Sep 2, 2024

I think if put CurrentIndex into FunctionScope that would work.

@ForNeVeR
Copy link
Owner Author

ForNeVeR commented Sep 2, 2024

Yep, most likely it will.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:compiler Related to code compilation or type checking good-first-issue An issue considered simple enough for new contributors kind:refactor Internal changes not affecting the compiler behavior status:help-wanted Open for contributors
Projects
None yet
Development

No branches or pull requests

2 participants