|
|
@ -14,13 +14,20 @@ use crate::runtime::run_thread::ThreadInfo; |
|
|
|
mod eval_res; |
|
|
|
mod eval_res; |
|
|
|
|
|
|
|
|
|
|
|
/// Result type returned from the op parser. This is the Ok variant of a Result.
|
|
|
|
/// Result type returned from the op parser. This is the Ok variant of a Result.
|
|
|
|
pub enum ParseOpRes { |
|
|
|
pub enum ParseOpRes<T> { |
|
|
|
/// Parsing successful.
|
|
|
|
/// Parsing successful.
|
|
|
|
Parsed(Op), |
|
|
|
Parsed(T), |
|
|
|
/// Instruction not recognized, but there was no error.
|
|
|
|
/// Instruction not recognized, but there was no error.
|
|
|
|
Unknown(ArgParser), |
|
|
|
Unknown(ArgParser), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl ParseOpRes<Op> { |
|
|
|
|
|
|
|
/// Helper to construct an extension op
|
|
|
|
|
|
|
|
pub fn parsed(op : impl OpTrait) -> Self { |
|
|
|
|
|
|
|
Self::Parsed(Op::Ext(Box::new(op))) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub trait OpTrait: Debug + Send + Sync + 'static { |
|
|
|
pub trait OpTrait: Debug + Send + Sync + 'static { |
|
|
|
fn execute(&self, ti: &ThreadInfo, state: &mut RunState) -> Result<EvalRes, Fault>; |
|
|
|
fn execute(&self, ti: &ThreadInfo, state: &mut RunState) -> Result<EvalRes, Fault>; |
|
|
|
} |
|
|
|
} |
|
|
@ -34,7 +41,7 @@ pub trait CrsnExtension: Debug + Send + Sync + 'static { |
|
|
|
/// the argument list and either return Ok or Err.
|
|
|
|
/// the argument list and either return Ok or Err.
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// If the instruction keyword is not recognized, return Unknown with the unchanged argument list.
|
|
|
|
/// If the instruction keyword is not recognized, return Unknown with the unchanged argument list.
|
|
|
|
fn parse_op(&self, keyword: &str, arg_tokens: ArgParser) -> Result<ParseOpRes, Error>; |
|
|
|
fn parse_op(&self, keyword: &str, arg_tokens: ArgParser) -> Result<ParseOpRes<Op>, Error>; |
|
|
|
|
|
|
|
|
|
|
|
/// Drop an object referenced by a handle
|
|
|
|
/// Drop an object referenced by a handle
|
|
|
|
fn drop_obj(&self, |
|
|
|
fn drop_obj(&self, |
|
|
|