remove unnecessary cloning of SourcePosition, reduce SourcePosition size. clean, format
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
|
||||
use crsn::asm::data::{Rd, RdObj, Wr};
|
||||
use crsn::asm::data::literal::Value;
|
||||
use crsn::asm::instr::Cond;
|
||||
use crsn::module::{EvalRes, OpTrait};
|
||||
use crsn::runtime::fault::Fault;
|
||||
use crsn::runtime::run_thread::{state::RunState, ThreadInfo};
|
||||
use crsn::sexp;
|
||||
use crsn::sexp::Sexp;
|
||||
use crsn::utils::A;
|
||||
|
||||
use crate::defs::StackOp;
|
||||
use crsn::sexp::Sexp;
|
||||
use crsn::sexp;
|
||||
use crsn::utils::A;
|
||||
use crsn::asm::data::{RdObj, Rd, Wr};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct Stacks {
|
||||
@@ -66,7 +66,7 @@ pub(crate) fn drop_obj(state: &mut RunState, handle: Value) -> Result<Option<()>
|
||||
Ok(stacks.store.remove(&handle).map(|_| ()))
|
||||
}
|
||||
|
||||
fn prepare_push(state: &mut RunState, obj: &RdObj, src: &Rd, pushfn : impl FnOnce(&mut VecDeque<Value>, Value) -> ()) -> Result<(), Fault> {
|
||||
fn prepare_push(state: &mut RunState, obj: &RdObj, src: &Rd, pushfn: impl FnOnce(&mut VecDeque<Value>, Value) -> ()) -> Result<(), Fault> {
|
||||
state.clear_status();
|
||||
let handle = state.read_obj(*obj)?;
|
||||
let val = state.read(*src)?;
|
||||
@@ -79,7 +79,7 @@ fn prepare_push(state: &mut RunState, obj: &RdObj, src: &Rd, pushfn : impl FnOnc
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn prepare_pop(state: &mut RunState, dst: &Wr, obj: &RdObj, popfn : impl FnOnce(&mut VecDeque<Value>) -> Option<Value>) -> Result<(), Fault> {
|
||||
fn prepare_pop(state: &mut RunState, dst: &Wr, obj: &RdObj, popfn: impl FnOnce(&mut VecDeque<Value>) -> Option<Value>) -> Result<(), Fault> {
|
||||
state.clear_status();
|
||||
let handle = state.read_obj(*obj)?;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ impl CrsnExtension for StackOps {
|
||||
"stacks"
|
||||
}
|
||||
|
||||
fn parse_op<'a>(&self, pos: SourcePosition, keyword: &str, args: TokenParser<'a>) -> Result<ParseRes<'a, OpKind>, CrsnError> {
|
||||
fn parse_op<'a>(&self, pos: &SourcePosition, keyword: &str, args: TokenParser<'a>) -> Result<ParseRes<'a, OpKind>, CrsnError> {
|
||||
parse::parse(pos, keyword, args)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@ use crsn::asm::error::CrsnError;
|
||||
use crsn::asm::instr::op::OpKind;
|
||||
use crsn::asm::parse::arg_parser::TokenParser;
|
||||
use crsn::module::ParseRes;
|
||||
|
||||
use crate::defs::StackOp;
|
||||
use crsn::sexp::SourcePosition;
|
||||
|
||||
pub(crate) fn parse<'a>(pos: SourcePosition, keyword: &str, mut args: TokenParser<'a>) -> Result<ParseRes<'a, OpKind>, CrsnError> {
|
||||
use crate::defs::StackOp;
|
||||
|
||||
pub(crate) fn parse<'a>(_pos: &SourcePosition, keyword: &str, mut args: TokenParser<'a>) -> Result<ParseRes<'a, OpKind>, CrsnError> {
|
||||
Ok(ParseRes::ext(match keyword {
|
||||
"stack" => {
|
||||
StackOp::NewStack {
|
||||
|
||||
Reference in New Issue
Block a user