From 511beade910e5115f46d79342af76b81f85cf336 Mon Sep 17 00:00:00 2001 From: brian cully Date: Tue, 23 Dec 2025 15:24:24 -0500 Subject: change out to a single datum it can only get, at most, one item per tick, so only represent that. --- src/forth/vm.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/forth/vm.rs') diff --git a/src/forth/vm.rs b/src/forth/vm.rs index 25ed516..6bab8b9 100644 --- a/src/forth/vm.rs +++ b/src/forth/vm.rs @@ -126,7 +126,7 @@ pub struct VM { pub wordlist: WordList, pub ip: InstructionPointer, - pub out: Vec, + pub out: Option, pub heading: DataStackType, pub speed: DataStackType, pub doppler: DataStackType, @@ -153,7 +153,7 @@ impl VM { ip: InstructionPointer::new(), wordlist, - out: vec![], + out: None, heading: 0, speed: 0, doppler: 0, @@ -313,7 +313,7 @@ impl VM { } OpCode::Say => { let v = self.stack.0.pop().ok_or(RuntimeError::StackUnderflow)?; - self.out.push(format!("{}", v)); + let _ = self.out.insert(v); } OpCode::Heading => { self.stack.0.push(self.heading); @@ -829,8 +829,7 @@ mod tests { let mut vm = VM::new(wordlist); vm.run().expect("should run to completion"); assert_eq!(vm.stack.0.len(), 0, "empty stack"); - assert_eq!(vm.out.len(), 1, "output length"); - assert_eq!(vm.out[0], "-1", "output value"); + assert_eq!(vm.out.expect("output is set"), -1, "output value"); } #[test] -- cgit v1.3