mindustry logic execution, map- and schematic- parsing and rendering
2024?
| -rw-r--r-- | lemu/Cargo.toml | 2 | ||||
| -rw-r--r-- | lemu/src/executor/mod.rs | 2 | ||||
| -rw-r--r-- | lemu/src/parser/mod.rs | 24 |
3 files changed, 14 insertions, 14 deletions
diff --git a/lemu/Cargo.toml b/lemu/Cargo.toml index b441df2..b12e365 100644 --- a/lemu/Cargo.toml +++ b/lemu/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "lemu" version = "0.2.20" -edition = "2021" +edition = "2024" description = "M-LOG runner" authors = ["bend-n <[email protected]>"] repository = "https://github.com/bend-n/mindus.git" diff --git a/lemu/src/executor/mod.rs b/lemu/src/executor/mod.rs index e2501dd..acc8284 100644 --- a/lemu/src/executor/mod.rs +++ b/lemu/src/executor/mod.rs @@ -183,7 +183,7 @@ impl Default for DisplayState { impl<'s, W: Write> ExecutorContext<'s, W> { pub fn flush(&mut self, to: Display) { - let (ref mut img, ref mut state) = &mut self.display.displays[to.0]; + let (img, state) = &mut self.display.displays[to.0]; while let Some(d) = self.display.buffer.pop_front() { use crate::instructions::draw::Apply; #[cfg(feature = "debug")] diff --git a/lemu/src/parser/mod.rs b/lemu/src/parser/mod.rs index b72c3b8..fc87a7a 100644 --- a/lemu/src/parser/mod.rs +++ b/lemu/src/parser/mod.rs @@ -16,13 +16,13 @@ use super::{ debug::info::{VarData, VarInfo}, executor::{ExecutorBuilderInternal, Instruction, UPInstr}, instructions::{ + AlwaysJump, ConditionOp, DynJump, End, Instr, Jump, MathOp1, MathOp2, Op1, Op2, PackColor, + Set, Stop, draw::{ Clear, Flush, Line, LinePoly, Poly, RectBordered, RectFilled, SetCol, SetColor, SetStroke, Triangle, }, io::{Print, Read, Write}, - AlwaysJump, ConditionOp, DynJump, End, Instr, Jump, MathOp1, MathOp2, Op1, Op2, PackColor, - Set, Stop, }, lexer::{Lexer, Token}, memory::{LAddress, LVar}, @@ -111,31 +111,31 @@ pub fn parse<'source, W: Wr>( let mut dbg_info: Vec<VarInfo> = Vec::with_capacity(64); macro_rules! push { // push a ident - ($var:expr) => {{ + (const $var:expr) => {{ let v = $var; dbg_info.push(VarInfo { - data: VarData::Variable(v), + data: VarData::Constant(v.clone().into()), span: tokens.span(), }); - executor.mem.push(LVar::null()); - mem.push(Some(v)); + executor.mem.push(LVar::from(v)); + mem.push(None); used = used .checked_add(1) .ok_or(Error::TooManyVariables(tokens.span()))?; - // SAFETY: just initialized executor.mem unsafe { Ok(LAddress::addr(used - 1)) } }}; - (const $var:expr) => {{ + ($var:expr) => {{ let v = $var; dbg_info.push(VarInfo { - data: VarData::Constant(v.clone().into()), + data: VarData::Variable(v), span: tokens.span(), }); - executor.mem.push(LVar::from(v)); - mem.push(None); + executor.mem.push(LVar::null()); + mem.push(Some(v)); used = used .checked_add(1) .ok_or(Error::TooManyVariables(tokens.span()))?; + // SAFETY: just initialized executor.mem unsafe { Ok(LAddress::addr(used - 1)) } }}; } @@ -145,7 +145,7 @@ pub fn parse<'source, W: Wr>( match mem .iter() .zip(0..used) - .find(|(&v, _)| v == Some(val)) + .find(|&(&v, _)| v == Some(val)) .map(|(_, i)| i) { Some(n) => unsafe { Ok(LAddress::addr(n)) }, |