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

[lang-model]: Signed integer types #213

Open
Tracked by #186
archaephyrryx opened this issue Sep 17, 2024 · 0 comments
Open
Tracked by #186

[lang-model]: Signed integer types #213

archaephyrryx opened this issue Sep 17, 2024 · 0 comments

Comments

@archaephyrryx
Copy link
Contributor

We currently have no mechanism, first-class or otherwise, for properly representing unsigned integers of varying widths (i8, i16, i32), which are demanded by various fields of OpenType.

The current approach taken is to mark a parsed unsigned-integer as being 'signed' by wrapping it in a variant, and using twos-complement implicitly to preserve the same bit-sequence as would be used for negative value-ranges, within the unsigned type.

To clarify, the most we need is a generic operator for casting a particular bit-width of unsigned integer to its signed analogue, e.g. Expr::ToSigned{8. 16, 32}(Box<Expr>) that maps U8 -> I8, U16 -> I16, and U32 -> I32 respectively, using the const methods available in Rust for such conversions.

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

No branches or pull requests

1 participant