mindustry logic execution, map- and schematic- parsing and rendering
get 65281 more variables
| -rw-r--r-- | lemu/Cargo.toml | 2 | ||||
| -rw-r--r-- | lemu/src/debug/info.rs | 12 | ||||
| -rw-r--r-- | lemu/src/executor/builder.rs | 2 | ||||
| -rw-r--r-- | lemu/src/lib.rs | 4 | ||||
| -rw-r--r-- | lemu/src/memory.rs | 14 | ||||
| -rw-r--r-- | lemu/src/parser/error.rs | 2 | ||||
| -rw-r--r-- | lemu/src/parser/mod.rs | 4 |
7 files changed, 20 insertions, 20 deletions
diff --git a/lemu/Cargo.toml b/lemu/Cargo.toml index b0d8ef8..e207df1 100644 --- a/lemu/Cargo.toml +++ b/lemu/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lemu" -version = "0.2.17" +version = "0.2.18" edition = "2021" description = "M-LOG runner" authors = ["bend-n <[email protected]>"] diff --git a/lemu/src/debug/info.rs b/lemu/src/debug/info.rs index 6f370ba..5b38f81 100644 --- a/lemu/src/debug/info.rs +++ b/lemu/src/debug/info.rs @@ -6,7 +6,7 @@ use crate::{ }; pub struct DebugInfo<'s> { - variables: Box<[Option<VarInfo<'s>>; 255]>, + variables: Box<[Option<VarInfo<'s>>; 65536]>, /// maps "start" to 0 pub labels: Vec<(&'s str, Instruction)>, } @@ -14,7 +14,7 @@ pub struct DebugInfo<'s> { impl<'s> Default for DebugInfo<'s> { fn default() -> Self { Self { - variables: Box::new([const { None }; 255]), + variables: vec![None; 65536].try_into().unwrap(), labels: vec![], } } @@ -38,14 +38,14 @@ impl<'s> std::ops::Index<LAddress> for DebugInfo<'s> { } impl<'s> DebugInfo<'s> { - pub fn set_var(&mut self, at: u8, name: &'s str, span: Range<usize>) { + pub fn set_var(&mut self, at: u16, name: &'s str, span: Range<usize>) { self.variables[at as usize] = Some(VarInfo { data: VarData::Variable(name), span, }); } - pub fn set_const(&mut self, at: u8, var: impl Into<LVar<'s>>, span: Range<usize>) { + pub fn set_const(&mut self, at: u16, var: impl Into<LVar<'s>>, span: Range<usize>) { self.variables[at as usize] = Some(VarInfo { data: VarData::Constant(var.into()), span, @@ -53,14 +53,14 @@ impl<'s> DebugInfo<'s> { } } -#[derive(Clone)] +#[derive(Clone, Debug)] struct VarInfo<'s> { pub data: VarData<'s>, #[allow(dead_code)] pub span: Range<usize>, } -#[derive(Clone)] +#[derive(Clone, Debug)] pub enum VarData<'s> { Variable(&'s str), // not necessary, but convenient. diff --git a/lemu/src/executor/builder.rs b/lemu/src/executor/builder.rs index fbc7284..ae78996 100644 --- a/lemu/src/executor/builder.rs +++ b/lemu/src/executor/builder.rs @@ -147,7 +147,7 @@ impl<'s, W: Wr> ExecutorBuilderInternal<'s, W> { counter: 0, iterations: 0, display: Drawing { - displays: displays.into(), + displays, buffer: VecDeque::new(), }, output, diff --git a/lemu/src/lib.rs b/lemu/src/lib.rs index 64cd653..a45be20 100644 --- a/lemu/src/lib.rs +++ b/lemu/src/lib.rs @@ -1,6 +1,6 @@ //! crate for [MLOG](https://mindustrygame.github.io/wiki/logic/0-introduction/#what-is-mindustry-logic) emulation. -#![feature(let_chains, inline_const)] -#![allow(clippy::redundant_closure_call, incomplete_features)] +#![feature(let_chains)] +#![allow(clippy::redundant_closure_call)] // yeah so like well you see i kinda well kinda have to yes but sorta #![allow(clippy::fn_address_comparisons)] #![warn( diff --git a/lemu/src/memory.rs b/lemu/src/memory.rs index 9f808f9..133fe8e 100644 --- a/lemu/src/memory.rs +++ b/lemu/src/memory.rs @@ -29,7 +29,7 @@ impl LVar<'_> { LVar::Num(0.0) } - pub fn num(&self) -> Option<f64> { + pub const fn num(&self) -> Option<f64> { match *self { Self::Num(n) => Some(n), Self::String(_) => None, @@ -39,11 +39,11 @@ impl LVar<'_> { #[derive(Clone, Copy)] pub struct LAddress { - pub address: u8, + pub address: u16, } impl LAddress { - pub(crate) const fn addr(address: u8) -> Self { + pub(crate) const fn addr(address: u16) -> Self { LAddress { address } } } @@ -98,9 +98,9 @@ impl<'s> From<Cow<'s, str>> for LVar<'s> { } } -/// cleared every loop +/// whats a megabyte among friends #[derive(Debug)] -pub struct LRegistry<'str>(pub [LVar<'str>; 255]); +pub struct LRegistry<'str>(pub Box<[LVar<'str>; 65536]>); impl<'s> std::ops::Index<LAddress> for LRegistry<'s> { type Output = LVar<'s>; @@ -118,7 +118,7 @@ impl<'s> std::ops::IndexMut<LAddress> for LRegistry<'s> { impl<'s> Default for LRegistry<'s> { fn default() -> Self { - Self([const { LVar::null() }; 255]) + Self(vec![LVar::null(); 65536].try_into().unwrap()) } } @@ -156,7 +156,7 @@ impl Printable for LRegistry<'_> { let mut iter = self .0 .iter() - .zip(0..u8::MAX) + .zip(0..u16::MAX) .filter(|&(v, _)| v != &LVar::null()) .map(|(v, i)| (&info[LAddress::addr(i)], v)) .filter_map(|(d, v)| match d { diff --git a/lemu/src/parser/error.rs b/lemu/src/parser/error.rs index 658f236..41a0296 100644 --- a/lemu/src/parser/error.rs +++ b/lemu/src/parser/error.rs @@ -144,7 +144,7 @@ pub enum Error<'s> { /// .display(); /// ``` NoDisplay(usize, Span), - /// We have a limit of [`u8::MAX`] variables. + /// We have a limit of [`u16::MAX`] variables. #[error("too many variables")] TooManyVariables(Span), } diff --git a/lemu/src/parser/mod.rs b/lemu/src/parser/mod.rs index 5b667cb..6a5b601 100644 --- a/lemu/src/parser/mod.rs +++ b/lemu/src/parser/mod.rs @@ -94,8 +94,8 @@ pub fn parse<'source, W: Wr>( mut tokens: Lexer<'source>, executor: &mut ExecutorBuilderInternal<'source, W>, ) -> Result<(), Error<'source>> { - let mut used = 0u8; - let mut mem: [Option<&str>; 255] = [None; 255]; // maps &str to usize + let mut used = 0u16; + let mut mem: Box<[Option<&str>; 65536]> = vec![None; 65536].try_into().unwrap(); // maps &str to usize macro_rules! push { // push a ident ($var:expr) => {{ |