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

nifc: fixes top level var decls with non-literals #322

Merged
merged 5 commits into from
Jan 7, 2025
Merged

Conversation

ringabout
Copy link
Member

fixes top level var decls

if vk != IsLocal: dec c.inSimpleInit
c.add Semicolon
if vk == IsGlobal and
t[d.value].kind notin {IntLit, UIntLit, FloatLit, CharLit, StrLit, FalseC, TrueC}:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But "bracket expressions" for arrays and objects are fine too and it would be wrong to move them!

if vk == IsGlobal and
t[d.value].kind notin {IntLit, UIntLit, FloatLit,
CharLit, StrLit, FalseC, TrueC, AconstrC,
OconstrC, InfC, NegInfC, NanC, SufC}:
Copy link
Member

@Araq Araq Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need some isLiteral deep check for OconstrC and AconstrC as [1, 2] is very different from [myVar, 3]. Thanks to NIF you can do this iteratively and no recursion is required.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no clues how to deal with Tree iteratively. Do I need to use hasNext to query the end of the tree or something?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You use the simple while n.kind != ParRi:... loop but your way is fine too. Also NIFC doesn't yet use the newer APIs so that's probably why you were confused.

@Araq Araq merged commit f0506a4 into master Jan 7, 2025
3 checks passed
@Araq Araq deleted the pr_gvar_refine branch January 7, 2025 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants