-
Notifications
You must be signed in to change notification settings - Fork 7
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
Use a 64-bit USize
as the sole integer type in the core
#376
Conversation
src/types/simple.rs
Outdated
#[inline] | ||
pub const fn int<const N: HugrIntWidthStore>() -> Self { | ||
Self::Hashable(HashableType::Int(N)) | ||
pub const fn int() -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably worth renaming this method at this point
src/types/simple.rs
Outdated
} | ||
|
||
/// Returns a new 64-bit integer type. | ||
#[inline] | ||
pub const fn i64() -> Self { | ||
Self::int::<64>() | ||
Self::int() | ||
} | ||
|
||
/// Returns a new 1-bit integer type. | ||
#[inline] | ||
pub const fn bit() -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this method and use int()
wherever this is used I think
src/types/simple.rs
Outdated
f.write_char('I')?; | ||
f.write_str(&i.to_string()) | ||
} | ||
HashableType::USize => f.write_str("I64"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HashableType::USize => f.write_str("I64"), | |
HashableType::USize => f.write_str("USize"), |
fn check_int_fits_in_width( | ||
value: HugrIntValueStore, | ||
width: HugrIntWidthStore, | ||
) -> Result<(), ConstIntError> { | ||
if width > HUGR_MAX_INT_WIDTH { | ||
return Err(ConstIntError::IntWidthTooLarge(width)); | ||
} | ||
|
||
if VALID_WIDTHS.contains(&width) { | ||
let max_value = if width == HUGR_MAX_INT_WIDTH { | ||
HugrIntValueStore::MAX | ||
} else { | ||
HugrIntValueStore::pow(2, width as u32) - 1 | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this code go in the int type resource or is some version already there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a test in int_types.rs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Closes #356 .