|
|
|
use std::fmt::Debug;
|
|
|
|
|
|
|
|
use crate::builtin::defs::BuiltinOp;
|
|
|
|
use crate::module::{EvalRes, OpTrait};
|
|
|
|
use crate::runtime::fault::Fault;
|
|
|
|
use crate::runtime::run_thread::{info::ThreadInfo, state::RunState};
|
|
|
|
|
|
|
|
/// A higher level simple opration
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Op {
|
|
|
|
BuiltIn(BuiltinOp),
|
|
|
|
/// Instruction added by an extension
|
|
|
|
Ext(Box<dyn OpTrait>),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl OpTrait for Op {
|
|
|
|
fn execute(&self, ti: &ThreadInfo, state: &mut RunState) -> Result<EvalRes, Fault> {
|
|
|
|
match self {
|
|
|
|
Op::BuiltIn(op) => {
|
|
|
|
op.execute(ti, state)
|
|
|
|
}
|
|
|
|
Op::Ext(op) => {
|
|
|
|
op.execute(ti, state)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|