-
Notifications
You must be signed in to change notification settings - Fork 540
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
Added const for starknet types. #6961
base: dev-v2.10.0
Are you sure you want to change the base?
Conversation
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.
Reviewed 1 of 2 files at r1, all commit messages.
Reviewable status: 1 of 2 files reviewed, 3 unresolved discussions (waiting on @orizi)
a discussion (no related file):
Missing failure test (initializing with an invalid value)
crates/cairo-lang-sierra/src/extensions/modules/const_type.rs
line 12 at r1 (raw file):
use super::int::unsigned128::Uint128Type; use super::non_zero::NonZeroType; use super::starknet::interoperability::{ClassHashType, ContractAddressType};
Are we ok with this dependency? (I guess we are)
crates/cairo-lang-sierra/src/extensions/modules/const_type.rs
line 74 at r1 (raw file):
) -> Result<(), SpecializationError> { let inner_type_info = context.get_type_info(inner_ty.clone())?; let type_range = if inner_type_info.long_id.generic_id == StructType::ID {
This is slightly confusing.
Split to two paragraphs:
if ... {
return validate...(...);
} else if ... {
return validate...(...);
} else if ... {
return validate...(...);
}
let type_range = if ... {
...
} else {
...
}
...
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.
Reviewable status: 1 of 2 files reviewed, 4 unresolved discussions (waiting on @orizi)
crates/cairo-lang-sierra/src/extensions/modules/const_type.rs
line 81 at r1 (raw file):
return validate_const_nz_data(context, &inner_type_info, inner_data); } else if [ContractAddressType::id(), ClassHashType::id()] .contains(&inner_type_info.long_id.generic_id)
Move this to a variable. It appears many times in this function and will make this particular line shorter.
Code quote:
inner_type_info.long_id.generic_id
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.
Reviewable status: 1 of 2 files reviewed, 5 unresolved discussions (waiting on @orizi)
crates/cairo-lang-sierra/src/extensions/modules/const_type.rs
line 83 at r1 (raw file):
.contains(&inner_type_info.long_id.generic_id) { Range::half_open(0, BigInt::one().shl(251))
I guess this appears in the libfunc as well, so I prefer to have it defined once, in a starknet module and not here.
Code quote:
BigInt::one().shl(251)
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.
Reviewed 1 of 2 files at r1.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @orizi)
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.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @liorgold2)
a discussion (no related file):
Previously, liorgold2 wrote…
Missing failure test (initializing with an invalid value)
Done.
crates/cairo-lang-sierra/src/extensions/modules/const_type.rs
line 12 at r1 (raw file):
Previously, liorgold2 wrote…
Are we ok with this dependency? (I guess we are)
Don't think we have much of a choice.
crates/cairo-lang-sierra/src/extensions/modules/const_type.rs
line 74 at r1 (raw file):
Previously, liorgold2 wrote…
This is slightly confusing.
Split to two paragraphs:if ... { return validate...(...); } else if ... { return validate...(...); } else if ... { return validate...(...); } let type_range = if ... { ... } else { ... } ...
Done.
crates/cairo-lang-sierra/src/extensions/modules/const_type.rs
line 81 at r1 (raw file):
Previously, liorgold2 wrote…
Move this to a variable. It appears many times in this function and will make this particular line shorter.
Done.
No description provided.