Conversation
|
Have you done any tests to see if generated code does not need any trait bounds? To me it seems like it it shouldn't be required, but there's no usage examples, just making sure since I'm afraid of trait bounds 😱 |
I haven't done that yet, no. That's what I'll be working on today, so hopefully it's something I can complete today (^: |
85ac603 to
fed0aeb
Compare
| let input_str = input.to_string(); | ||
| if !(input_str.starts_with("0x") || input_str.starts_with("0X")) | ||
| || input_str | ||
| .chars() | ||
| .skip(2) | ||
| .any(|c| !(c.is_ascii_hexdigit() || c == ' ' || c == '_')) | ||
| { | ||
| return syn::Error::new( | ||
| input.span(), | ||
| concat!( | ||
| "Expected a hexadecimal literal! Must start with `0x` or `0X` and contain ", | ||
| "only hexdigits, spaces, and underscores", | ||
| ) | ||
| .to_string(), | ||
| ) | ||
| .into_compile_error() | ||
| .into(); | ||
| } |
There was a problem hiding this comment.
Wouldn't it make sense to also support binary literals and maybe even base 10 literals?
There was a problem hiding this comment.
I could add support for binary literals pretty easily, just the issue is that for decimal literals there's the issue of not having a way to turn that into binary very easily past a certain size.
There was a problem hiding this comment.
Added binary literals, at least. Still not sure what to do for decimal literals.
3c4d3da to
5da7507
Compare
| let mut char_iter = input_str.chars().filter(char::is_ascii_hexdigit).rev(); | ||
| let mut lower = true; | ||
| let mut idx = 0; | ||
| loop { |
There was a problem hiding this comment.
I've been thinking if there is a good way to use from_str_radix for this instead of hand rolling this, but I guess you want arbitrarily large literals too, so this wouldn't work 😔 Maybe this could be a comment here though? Otherwise I'll wonder the same thing in two months when I look at this again haha
dbbb82e to
f2ca52c
Compare
2bf627f to
cdd3069
Compare
|
Marked as ready for review. I know there's one more thing I need to do (sign extension for |
d00584e to
95fa3d0
Compare
hydrolarus
left a comment
There was a problem hiding this comment.
Overall looking good, but some questions regarding macro hygiene, style of type macros and usage of expr-macros
| let n = n as usize; | ||
| let len = n.div_ceil(8); | ||
| quote! { BitVector<#n, #len> } |
There was a problem hiding this comment.
This leaves suffixes everywhere, right? So BitVector<24usize, 3usize>. Wouldn't it make sense to use unsuffixed literals since usually the types of the literals aren't so important on the type level?
There was a problem hiding this comment.
Same goes for the other types below
95fa3d0 to
1b1b622
Compare
NOTE: WILL NOT PASS CI
NOTE: WILL NOT PASS CI
NOTE: WILL NOT PASS CI
1b1b622 to
b21fcbd
Compare
b21fcbd to
16b0cb6
Compare
This implements basic functionality for
Index<N, T>,Unsigned<N, T>,Signed<N, T>, andBitVec<N, M>. This PR is currently marked as draft since I still need to:Anywho, at least an initial review pass and/or suggestions on things I should add in this PR that I didn't (and that I don't have WIP stuff for already from before I did a lot of downscoping, like operator
impls).