-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove impl_opcode macro since repeation in metavariable expr is unst…
…able rust_issue: rust-lang/rust#83527
- Loading branch information
Showing
9 changed files
with
105 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[workspace] | ||
members = [ "asm","jnd", "vm"] | ||
members = [ "asm","jnd", "utils/jop", "vm"] | ||
resolver = "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use core::fmt; | ||
|
||
use super::Erroring; | ||
|
||
#[derive(Debug)] | ||
pub enum AsmErr { | ||
ReadFile, | ||
OpenFile, | ||
Parse, | ||
Write, | ||
} | ||
|
||
impl Erroring for AsmErr { | ||
fn err(&self) -> &str { | ||
match self { | ||
Self::ReadFile => "failed to read file to buffer", | ||
Self::OpenFile => "failed to open file", | ||
Self::Parse => "failed to parse token", | ||
Self::Write => "failed to write binary to stdout", | ||
} | ||
} | ||
} | ||
|
||
impl fmt::Display for AsmErr { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!(f, "{}", self.err()) | ||
} | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! asme { | ||
($err: expr, $kind: ident, $($args:tt)*) => {{ | ||
use $crate::errors::Erroring; | ||
$err.vme(format!("{}: {}", $crate::errors::vme::AsmErr::$kind.err(), format_args!($($args)*)).as_str()) | ||
}}; | ||
|
||
($kind:ident, $($args:tt)*) => {{ | ||
use $crate::errors::Erroring; | ||
$crate::errors::Jerror::Vme(format!("{}: {}", $crate::errors::vme::AsmErr::$kind.err(), format_args!($($args)*))) | ||
}}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
pub mod disassembler; | ||
pub mod errors; | ||
pub mod interrupts; | ||
pub mod macros; | ||
pub mod mem; | ||
pub mod op; | ||
pub mod reg; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "jop" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
proc-macro = true | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
extern crate proc_macro; | ||
use proc_macro::TokenStream; | ||
|
||
#[proc_macro_derive(AnswerFn)] | ||
pub fn derive_answer_fn(_item: TokenStream) -> TokenStream { | ||
"fn answer() -> u32 { 42 }".parse().unwrap() | ||
} |