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

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,