Add serialization support

This commit is contained in:
2018-06-02 00:02:30 +02:00
parent 540de72032
commit 6ee88325c5
5 changed files with 67 additions and 7 deletions

57
Cargo.lock generated
View File

@@ -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"

View File

@@ -4,6 +4,8 @@ version = "0.1.0"
authors = ["Jur van den Berg <Jurl.berg@gmail.com>"]
[dependencies]
serde = "1.0"
serde_derive = "1.0"
[features]
default = ["bonus", "extra"]

View File

@@ -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<Constant>,
methods: Vec<Method>,

View File

@@ -1,4 +1,5 @@
extern crate core;
#[macro_use]
extern crate serde_derive;
pub mod ijvmreader;
pub mod binread;

View File

@@ -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,