cleanup, optimize. use Arc for reference sharing

This commit is contained in:
2020-09-28 20:12:31 +02:00
parent d5de189af6
commit 3599cb46c4
20 changed files with 111 additions and 119 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
use crsn::asm::data::{Rd, Wr, RdObj};
use crsn::asm::data::{Rd, RdObj, Wr};
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum StackOp {
+3 -4
View File
@@ -1,13 +1,12 @@
use std::collections::{VecDeque, HashMap};
use std::collections::{HashMap, VecDeque};
use crsn::asm::data::literal::Value;
use crsn::asm::instr::Cond;
use crsn::module::{EvalRes, OpTrait, CrsnExtension};
use crsn::module::{CrsnExtension, EvalRes, OpTrait};
use crsn::runtime::fault::Fault;
use crsn::runtime::run_thread::{state::RunState, ThreadInfo};
use crate::defs::StackOp;
use crate::StackOps;
#[derive(Debug, Default)]
struct Stacks {
@@ -68,7 +67,7 @@ impl OpTrait for StackOp {
//
}
pub(crate) fn drop_stack(state: &mut RunState, handle : Value) -> Result<Option<()>, Fault> {
pub(crate) fn drop_stack(state: &mut RunState, handle: Value) -> Result<Option<()>, Fault> {
let stacks: &mut Stacks = state.ext_mut();
Ok(stacks.store.remove(&handle).map(|_| ()))
}
+4 -4
View File
@@ -1,12 +1,12 @@
use crsn::asm::data::literal::Value;
use crsn::asm::error::Error;
use crsn::asm::instr::Op;
use crsn::asm::parse::arg_parser::ArgParser;
use crsn::module::{CrsnExtension, ParseOpRes};
use crsn::runtime::fault::Fault;
use crsn::runtime::run_thread::{RunState, ThreadInfo};
use crate::defs::StackOp;
use crsn::runtime::run_thread::{ThreadInfo, RunState};
use crsn::asm::data::literal::Value;
use crsn::runtime::fault::Fault;
#[derive(Debug, Clone)]
pub struct StackOps {
@@ -54,7 +54,7 @@ impl CrsnExtension for StackOps {
}))))
}
fn drop_obj(&self, _ti: &ThreadInfo, state: &mut RunState, handle : Value) -> Result<Option<()>, Fault>
fn drop_obj(&self, _ti: &ThreadInfo, state: &mut RunState, handle: Value) -> Result<Option<()>, Fault>
{
crate::exec::drop_stack(state, handle)
}