Example extension: Stacks; fixes to allow module data storage in thread context

This commit is contained in:
2020-09-26 22:49:06 +02:00
parent 3e0aaa71e9
commit 0cd800653f
21 changed files with 285 additions and 74 deletions
+5 -3
View File
@@ -4,13 +4,15 @@ use num_traits::PrimInt;
use crsn::asm::instr::op::{OpTrait, EvalRes};
use crsn::runtime::fault::Fault;
use crsn::runtime::frame::{CallStack, StackFrame};
use crsn::runtime::program::Program;
use crate::defs::ArithOp;
use crsn::runtime::run_thread::{ThreadInfo, RunState};
impl OpTrait for ArithOp {
fn execute(&self, _program: &Program, _call_stack: &mut CallStack, frame: &mut StackFrame) -> Result<EvalRes, Fault> {
fn execute(&self, _ti : &ThreadInfo, state: &mut RunState) -> Result<EvalRes, Fault> {
let frame = &mut state.frame;
let eres = EvalRes::default();
match self {
ArithOp::Test { a } => {
+1 -1
View File
@@ -1,4 +1,4 @@
pub use parse::ArithOpParser;
pub use parse::ArithOps;
mod defs;
mod parse;
+3 -3
View File
@@ -7,11 +7,11 @@ use crsn::asm::parse::arg_parser::ArgParser;
use crate::defs::ArithOp;
#[derive(Debug, Clone)]
pub struct ArithOpParser {
pub struct ArithOps {
_internal: ()
}
impl ArithOpParser {
impl ArithOps {
pub fn new() -> Box<dyn AsmModule> {
Box::new(Self {
_internal: ()
@@ -19,7 +19,7 @@ impl ArithOpParser {
}
}
impl AsmModule for ArithOpParser {
impl AsmModule for ArithOps {
fn name(&self) -> &'static str {
"arith"
}