remove unnecessary cloning of SourcePosition, reduce SourcePosition size. clean, format
This commit is contained in:
+5
-11
@@ -1,18 +1,18 @@
|
||||
use std::ops::Sub;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use minifb::{ScaleMode, Window, WindowOptions, MouseMode, Key, MouseButton};
|
||||
use minifb::{Key, MouseButton, MouseMode, ScaleMode, Window, WindowOptions};
|
||||
|
||||
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::ScreenOp;
|
||||
use crsn::sexp::Sexp;
|
||||
use crsn::sexp;
|
||||
use crsn::utils::A;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Opts {
|
||||
@@ -299,7 +299,7 @@ fn blit(backend: &mut Backend) {
|
||||
backend.last_render = Instant::now();
|
||||
}
|
||||
|
||||
fn num2key(num : Value) -> Option<Key> {
|
||||
fn num2key(num: Value) -> Option<Key> {
|
||||
let remap = [
|
||||
Key::Key0,
|
||||
Key::Key1,
|
||||
@@ -311,7 +311,6 @@ fn num2key(num : Value) -> Option<Key> {
|
||||
Key::Key7,
|
||||
Key::Key8,
|
||||
Key::Key9,
|
||||
|
||||
Key::A, // 10
|
||||
Key::B,
|
||||
Key::C,
|
||||
@@ -361,7 +360,6 @@ fn num2key(num : Value) -> Option<Key> {
|
||||
Key::Up,
|
||||
Key::Apostrophe,
|
||||
Key::Backquote,
|
||||
|
||||
Key::Backslash, // 57
|
||||
Key::Comma,
|
||||
Key::Equal,
|
||||
@@ -370,20 +368,17 @@ fn num2key(num : Value) -> Option<Key> {
|
||||
Key::Period,
|
||||
Key::RightBracket,
|
||||
Key::Semicolon,
|
||||
|
||||
Key::Slash, // 65
|
||||
Key::Backspace,
|
||||
Key::Delete,
|
||||
Key::End,
|
||||
Key::Enter,
|
||||
|
||||
Key::Escape, // 70
|
||||
Key::Home,
|
||||
Key::Insert,
|
||||
Key::Menu,
|
||||
Key::PageDown,
|
||||
Key::PageUp,
|
||||
|
||||
Key::Pause, // 76
|
||||
Key::Space,
|
||||
Key::Tab,
|
||||
@@ -394,7 +389,6 @@ fn num2key(num : Value) -> Option<Key> {
|
||||
Key::RightShift,
|
||||
Key::LeftCtrl,
|
||||
Key::RightCtrl,
|
||||
|
||||
Key::NumPad0, // 86
|
||||
Key::NumPad1,
|
||||
Key::NumPad2,
|
||||
|
||||
@@ -25,7 +25,7 @@ impl CrsnExtension for ScreenOps {
|
||||
"screen"
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use crsn::asm::data::{Rd};
|
||||
use crsn::asm::data::Rd;
|
||||
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::ScreenOp;
|
||||
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::ScreenOp;
|
||||
|
||||
pub(crate) fn parse<'a>(_pos: &SourcePosition, keyword: &str, mut args: TokenParser<'a>) -> Result<ParseRes<'a, OpKind>, CrsnError> {
|
||||
Ok(ParseRes::ext(match keyword {
|
||||
"sc-init" => {
|
||||
ScreenOp::ScreenInit {
|
||||
@@ -65,14 +65,14 @@ pub(crate) fn parse<'a>(pos: SourcePosition, keyword: &str, mut args: TokenParse
|
||||
"sc-key" => {
|
||||
ScreenOp::TestKey {
|
||||
pressed: args.next_wr()?,
|
||||
code: args.next_rd()?
|
||||
code: args.next_rd()?,
|
||||
}
|
||||
}
|
||||
|
||||
"sc-mbtn" => {
|
||||
ScreenOp::TestMouse {
|
||||
pressed: args.next_wr()?,
|
||||
button: args.next_rd()?
|
||||
button: args.next_rd()?,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user