hypervisor: emulator: drop InstructionMap

It is not needed anymore.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2020-12-01 15:21:38 +00:00 committed by Samuel Ortiz
parent ab89b48143
commit c352b59857

View File

@ -10,7 +10,6 @@ use crate::arch::emulator::{EmulationError, PlatformEmulator, PlatformError};
use crate::arch::x86::emulator::CpuStateManager;
use crate::arch::x86::Exception;
use iced_x86::*;
use std::collections::HashMap;
macro_rules! imm_op {
(u8, $insn:ident) => {
@ -83,38 +82,6 @@ pub trait InstructionHandler<T: CpuStateManager> {
) -> Result<(), EmulationError<Exception>>;
}
pub struct InstructionMap<T: CpuStateManager> {
pub instructions: HashMap<Code, Box<dyn InstructionHandler<T> + Sync + Send>>,
}
impl<T: CpuStateManager> InstructionMap<T> {
pub fn new() -> InstructionMap<T> {
InstructionMap {
instructions: HashMap::new(),
}
}
pub fn add_insn(
&mut self,
insn: Code,
insn_handler: Box<dyn InstructionHandler<T> + Sync + Send>,
) {
self.instructions.insert(insn, insn_handler);
}
}
impl<T: CpuStateManager> Default for InstructionMap<T> {
fn default() -> Self {
Self::new()
}
}
macro_rules! insn_add {
($insn_map:ident, $mnemonic:ident, $code:ident) => {
$insn_map.add_insn(Code::$code, Box::new($mnemonic::$code {}));
};
}
macro_rules! insn_format {
($insn:ident) => {{
let mut output = String::new();