Integer Types, Parser Fixes, and Segfaults!
Phew — this one was biiiiiggg. Flower is pretty much just a glorified C transpiler, which is NOT what I want for it! In order to move on, the data has to be handled explicitly by the FloC.
So essentially, I implemented i8, u8, i16, u16, i32, u32, i64, and u64. For now, int canonically refers to an i32 value.
A New Era?
With these new literals, the old hoist-sized representation had to go. The decimal source text is preserved, meaning values such as 18446744073709551615 remain after parsing without causing any overflow. Types are picked up from declarations, assignments, function arguments, return values, field writes, array-element writes, *breath in* and binary expressions! Oof, that was a mouthful.
That, of course, resulted in proper errors for things like:
- 256 assigned to u8
- −1 assigned to an unsigned type
- values beyond u64
- unconstrained literals outside the default i32 range
I Hate Memory
During printing, every width is handled. Integer conditions retain existing zero / nonzero behavior, and literal types print their values rather than a character.
Halfway through, I ran into sudden segfaults and memory leaks. I was taken aback, because I didn’t even change anything parser related yet. Turns out, I forgot an assignment in a declaration, which apparently the parser wasn’t able to handle (whoops!). Anyways, I fixed it by propagating errors through the compilation process, so the compiler doesn’t try to typecheck or code gen if the parser reports back errors, and instead will print them out.
And that’s it! Not that’s it, but that’s all I’m going to explain for now. More specifics available on the GitHub, of course.
Speaking of GitHub thank you so much to S1monr3dst0ne07 on GitHub for fixing some memory leaks in the previous version of Flower — I forgot to prune allocations before returning from a function :p
Love y’all!! <3
P.S.: So glad I gave up on documentation, I was genuinely dreading workong on the project and that’s why I’ve been ianctive for a long time :c
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.