diff --git a/Cargo.lock b/Cargo.lock index 915d492..ff0dc3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,4 +1,61 @@ +[[package]] +name = "proc-macro2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quote" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rustijvm" version = "0.1.0" +dependencies = [ + "serde 1.0.65 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.65 (registry+https://github.com/rust-lang/crates.io-index)", +] +[[package]] +name = "serde" +version = "1.0.65" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde_derive" +version = "1.0.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syn" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum proc-macro2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1fa93823f53cfd0f5ac117b189aed6cfdfb2cfc0a9d82e956dd7927595ed7d46" +"checksum quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e44651a0dc4cdd99f71c83b561e221f714912d11af1a4dff0631f923d53af035" +"checksum serde 1.0.65 (registry+https://github.com/rust-lang/crates.io-index)" = "5d47469df098fe8701d4da22680da5145e83801bdaaafea0cf91a180436fc343" +"checksum serde_derive 1.0.65 (registry+https://github.com/rust-lang/crates.io-index)" = "35eff0f5f70b6a2e902a2bbf4b079be4aacb14afc9676ba4798e0486401cedcb" +"checksum syn 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6dfd71b2be5a58ee30a6f8ea355ba8290d397131c00dfa55c3d34e6e13db5101" +"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" diff --git a/Cargo.toml b/Cargo.toml index 6183d1b..888ca5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,8 @@ version = "0.1.0" authors = ["Jur van den Berg "] [dependencies] +serde = "1.0" +serde_derive = "1.0" [features] default = ["bonus", "extra"] diff --git a/src/disassembler.rs b/src/disassembler.rs index 8f2df2a..7b06d42 100644 --- a/src/disassembler.rs +++ b/src/disassembler.rs @@ -6,11 +6,11 @@ use Result; use ops; use std::clone::Clone; -use core::fmt; +use std::fmt; type OpCode = u8; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize)] pub struct Instruction { op: OpCode, name: &'static str, @@ -54,7 +54,7 @@ impl fmt::Display for Instruction { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize)] pub struct Constant { value: i32, method: bool, @@ -69,7 +69,7 @@ impl Constant { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize)] pub struct Method { name: String, pos: usize, @@ -334,7 +334,7 @@ impl Disassembler { } } -#[derive(Debug, Default, Clone)] +#[derive(Debug, Default, Clone, Serialize)] pub struct Disassembly { constants: Vec, methods: Vec, diff --git a/src/lib.rs b/src/lib.rs index caadf4e..a6bf2db 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ -extern crate core; +#[macro_use] +extern crate serde_derive; pub mod ijvmreader; pub mod binread; diff --git a/src/ops.rs b/src/ops.rs index 09440af..ef3ed74 100644 --- a/src/ops.rs +++ b/src/ops.rs @@ -6,7 +6,7 @@ use std::io::{Read}; pub type OpFunc = fn(&mut Machine) -> Result<()>; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub enum Args { Byte, Short,