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.
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
| array_str.push('['); | ||
| for byte in buf { | ||
| write!(array_str, "0x{byte:02x}, ").unwrap(); | ||
| } | ||
| array_str.pop(); | ||
| array_str.pop(); | ||
| array_str.push(']'); |
There was a problem hiding this comment.
This could check for the first element to have less manual shuffling of the characters in the string
| array_str.push('['); | |
| for byte in buf { | |
| write!(array_str, "0x{byte:02x}, ").unwrap(); | |
| } | |
| array_str.pop(); | |
| array_str.pop(); | |
| array_str.push(']'); | |
| array_str.push('['); | |
| for (i, byte) in buf.iter().enumerate() { | |
| if i > 0 { | |
| write!(array_str, ", ").unwrap(); | |
| } | |
| write!(array_str, "0x{byte:02x}").unwrap(); | |
| } | |
| array_str.push(']'); |
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 |
NOTE: WILL NOT PASS CI
NOTE: WILL NOT PASS CI
NOTE: WILL NOT PASS CI
NOTE: WILL NOT PASS CI
cdd3069 to
d00584e
Compare
d00584e to
95fa3d0
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).