Make metadata(), parse_u16() and view() generic#775
Conversation
| 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.
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.
Good point that it should be generic too. But where is the "indexing" in this function?
There was a problem hiding this comment.
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
ia0
left a comment
There was a problem hiding this comment.
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.
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