-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
src/nifc/codegen.nim
Outdated
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}: |
There was a problem hiding this comment.
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!
src/nifc/codegen.nim
Outdated
if vk == IsGlobal and | ||
t[d.value].kind notin {IntLit, UIntLit, FloatLit, | ||
CharLit, StrLit, FalseC, TrueC, AconstrC, | ||
OconstrC, InfC, NegInfC, NanC, SufC}: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
fixes top level var decls