-
Notifications
You must be signed in to change notification settings - Fork 27
Make metadata()
, parse_u16()
and view()
generic
#775
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
Conversation
crates/interpreter/src/side_table.rs
Outdated
delta_ip: (parse_u16(&self.0, 0) as i16) as i32, | ||
delta_stp: (parse_u16(&self.0, 2) as i16) as i32, | ||
delta_ip: (parse_u16::<Use>(&self.0, 0).unwrap() as i16) as i32, | ||
delta_stp: (parse_u16::<Use>(&self.0, 2).unwrap() as i16) as i32, |
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.
Same here, we want this function to be parametric over the mode. We use it in patch_branch()
during verification. And actually, we should not panic when indexing with [source.branch_table]
there. We should also use get()
(unless we have a test somewhere 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.
Good point that it should be generic too. But where is the "indexing" in this function?
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.
There's no "indexing" in this function. The indexing I mentioned was where it is called in valid.rs
. That can be done in the next PR. I hope I'll be able to find out all those issues in the final review from dev/fast-interp
to main
. There are actually many places where we would panic instead of returning an error on user errors.
metadata()
and view()
genericmetadata()
, parse_u16()
and view()
generic
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.
Thanks! LGTM. We can do type_idx
and branch_table
in another PR since this one is good.
@@ -42,7 +43,7 @@ pub struct Metadata<'m>(&'m [u8]); | |||
|
|||
impl<'m> Metadata<'m> { | |||
pub fn type_idx(&self) -> usize { |
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.
type_idx
and branch_table
also need to be polymorphic, because they are called from valid.rs
too. But this can be done in another PR.
#46