- Notifications
You must be signed in to change notification settings - Fork1.4k
Opcode metadata auto generation#6174
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes from43 commits
21d9632f6ab8d2b8ebe9b8510815bcea0bfc7ffa2af1948c684c7f459adf90899ed36056c0dc83fdc4795cf1888eaee21eacd74c7f71ad1bb860f65ff4fb09493da32657660feacab037b36086dd761d0aeedbdc33a90f34a11f38029e53411369f8a5813ea6e6accdf8a887aa2014b56c48b4946f3e29742b7092a8fb1e465528ee4372321ae0c7e28bab70fe3f94aaca45083daec5a9436354File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -12,6 +12,7 @@ cellvar | ||
| cellvars | ||
| cmpop | ||
| denom | ||
| deopt | ||
| dictoffset | ||
| elts | ||
| excepthandler | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| use crate::marshal::MarshalError; | ||
| pub use crate::opcodes::{PseudoOpcode, RealOpcode}; | ||
| #[derive(Copy, Clone, Debug, Eq, PartialEq)] | ||
| pub enum Opcode { | ||
| Real(RealOpcode), | ||
| Pseudo(PseudoOpcode), | ||
| } | ||
| impl TryFrom<u16> for Opcode { | ||
| type Error = MarshalError; | ||
| fn try_from(raw: u16) -> Result<Self, Self::Error> { | ||
| // Try first pseudo opcode. If not, fallback to real opcode. | ||
| PseudoOpcode::try_from(raw) | ||
| .map(Opcode::Pseudo) | ||
| .or_else(|_| { | ||
| Self::try_from(u8::try_from(raw).map_err(|_| Self::Error::InvalidBytecode)?) | ||
| }) | ||
| } | ||
| } | ||
| impl TryFrom<u8> for Opcode { | ||
| type Error = MarshalError; | ||
| fn try_from(raw: u8) -> Result<Self, Self::Error> { | ||
| // u8 can never be a pseduo. | ||
| RealOpcode::try_from(raw).map(Opcode::Real) | ||
| } | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| macro_rules! impl_try_from { | ||
| ($struct_name:ident, $($t:ty),+ $(,)?) => { | ||
| $( | ||
| impl TryFrom<$t> for $struct_name { | ||
| type Error = MarshalError; | ||
| fn try_from(raw: $t) -> Result<Self, Self::Error> { | ||
| Self::try_from(u16::try_from(raw).map_err(|_| Self::Error::InvalidBytecode)?) | ||
| } | ||
| } | ||
| )+ | ||
| }; | ||
| } | ||
| impl_try_from!( | ||
| Opcode, i8, i16, i32, i64, i128, isize, u32, u64, u128, usize | ||
| ); | ||
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.