Totem-Studios / lotus

Lotus is a type-safe compiled programming languages designed to simplify systems programming, achieving memory safety using RAII.
https://totemstudios.org/lotus
MIT License
4 stars 2 forks source link

Unsigned integers are not implemented [FEATURE REQUEST] #35

Open lucasnorman07 opened 3 months ago

lucasnorman07 commented 3 months ago

Is your feature request related to a problem? Please describe.

Unsigned integers are not supported.

Describe the solution you'd like

An implementation of a data structure or something similar that stores the signedness information of variables and values in the codegen phase to create the correct operations for both unsigned and signed integers.

Describe alternatives you've considered

Some ways to implement this would be to add a signedness map, or some other kind of data structure to store the signedness information of all llvm::Values. The problem is just that the signedness map needs to be updated for each new llvm::Value which leads to a lot of code everywhere just to maintain the signedness map. Another way to do this would be to create a wrapper around the llvm::Value type to store a boolean flag if the variable is signed or not. This has the problem though that each llvm::Value would need to be replaced in the code, and it stores unnecessary information if the value is not an integer, which is most of the time.

Additional context

LLVM does not track the signedness of llvm::Value, instead it just has different operations for signed and unsigned integers, meaning the signedness information needs to be tracked in the AST and codegen phase. This makes it very hard to implement unsigned integers with the current AST implementation and parser, since it relies heavily on the llvm::Value type to pass around values and determine what operations to perform.