You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seems to be specific to constants. I get the reasoning for it, they are constant so the value is good enough, but maybe it should then strip out the constant declarations. This, while on the surface is not that big of an issue, it does create unnecessary variables that are not referenced anywhere. It would be nice if the output would mirror the cito source more closely.
Current approach is to perform constant folding during the semantic analysis, which among other things, replaces all constant references with their values.
Local and private constants end up unreferenced and they are omitted in C output because the compilers would warn. swiftc 5.8.1 doesn't warn.
My goal is to keep the constants and the references to them. This requires reworking the constant folder.
This is not trivial, because compile-time constants are required in some places, such as case values, array storage sizes and (obviously) values of constants. Fusion supports compile-time function execution (CTFE), unlike C/C#/Java/Python. C++ supports CTFE provided the functions are marked with constexpr.
If you have a variable that is a constant in Cito, all references in the generated output are replaced with the value.
becomes this in the output
Seems to be specific to constants. I get the reasoning for it, they are constant so the value is good enough, but maybe it should then strip out the constant declarations. This, while on the surface is not that big of an issue, it does create unnecessary variables that are not referenced anywhere. It would be nice if the output would mirror the cito source more closely.
Member variables work fine
The text was updated successfully, but these errors were encountered: