Add serialization support
This commit is contained in:
@@ -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>,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
extern crate core;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
pub mod ijvmreader;
|
||||
pub mod binread;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user