diff --git a/src/debugger/command.rs b/src/debugger/command.rs index 48b5daa..9c813ed 100644 --- a/src/debugger/command.rs +++ b/src/debugger/command.rs @@ -35,7 +35,9 @@ pub enum Command { count: u16, location: MemoryLocation, }, - Eval(EvalInstruction), + Eval { + instruction: String, + }, } #[derive(Clone, Copy, Debug, PartialEq)] @@ -102,9 +104,6 @@ pub struct Label { pub offset: i16, } -#[derive(Debug)] -pub enum EvalInstruction {} - // TODO(refactor): Rename these variants // TODO(opt): Most `String` fields could be `&str` (with difficulty, no doubt) #[derive(Debug, PartialEq)] @@ -199,10 +198,8 @@ impl TryFrom<&str> for Command { } CommandName::Eval => { - eprintln!("unimplemented: eval command"); - return Err(Error::InvalidCommandName { - name: "eval".to_string(), - }); + let instruction = iter.collect_rest(); + Self::Eval { instruction } } }; diff --git a/src/debugger/mod.rs b/src/debugger/mod.rs index eb3198e..10e8aba 100644 --- a/src/debugger/mod.rs +++ b/src/debugger/mod.rs @@ -336,8 +336,10 @@ impl Debugger { } Command::Source { .. } => dprintln!(Always, "unimplemented: source"), - Command::Eval { .. } => { + + Command::Eval { instruction } => { self.was_pc_changed = true; + dprintln!(Always, "<{}>", instruction); dprintln!(Always, "unimplemented: eval") } diff --git a/src/debugger/parse.rs b/src/debugger/parse.rs index ecc3d60..9b4cfc6 100644 --- a/src/debugger/parse.rs +++ b/src/debugger/parse.rs @@ -180,6 +180,12 @@ impl<'a> CommandIter<'a> { Ok(()) } + pub fn collect_rest(&mut self) -> String { + let rest = self.buffer[self.head..].trim().to_string(); + self.head = self.buffer.len(); + rest + } + /// Get next character at head, WITHOUT incrementing head fn peek(&self) -> Option { if self.head >= self.buffer.len() {