diff --git a/src/protocol/eval/executor.rs b/src/protocol/eval/executor.rs index 130de897237dfa1854d68ef1225d452e527db3b2..feab9c135698e49f53dba5985a928d1644f48478 100644 --- a/src/protocol/eval/executor.rs +++ b/src/protocol/eval/executor.rs @@ -825,8 +825,13 @@ impl Prompt { Statement::Local(stmt) => { match stmt { LocalStatement::Memory(stmt) => { - let variable = &heap[stmt.variable]; - self.store.write(ValueId::Stack(variable.unique_id_in_scope as u32), Value::Unassigned); + if cfg!(debug_assertions) { + let variable = &heap[stmt.variable]; + debug_assert!(match self.store.read_ref(ValueId::Stack(variable.unique_id_in_scope as u32)) { + Value::Unassigned => false, + _ => true, + }); + } cur_frame.position = stmt.next; Ok(EvalContinuation::Stepping) @@ -891,12 +896,12 @@ impl Prompt { Ok(EvalContinuation::Stepping) }, Statement::Break(stmt) => { - cur_frame.position = stmt.target.unwrap().upcast(); + cur_frame.position = stmt.target.upcast(); Ok(EvalContinuation::Stepping) }, Statement::Continue(stmt) => { - cur_frame.position = stmt.target.unwrap().upcast(); + cur_frame.position = stmt.target.upcast(); Ok(EvalContinuation::Stepping) }, @@ -936,7 +941,15 @@ impl Prompt { cur_frame.position = stmt.next; Ok(EvalContinuation::Stepping) - } + }, + Statement::Select(_stmt) => { + todo!("implement select evaluation") + }, + Statement::EndSelect(stmt) => { + cur_frame.position = stmt.next; + + Ok(EvalContinuation::Stepping) + }, Statement::Return(_stmt) => { debug_assert!(heap[cur_frame.definition].is_function()); debug_assert_eq!(cur_frame.expr_values.len(), 1, "expected one expr value for return statement"); @@ -979,7 +992,7 @@ impl Prompt { return Ok(EvalContinuation::Stepping); }, Statement::Goto(stmt) => { - cur_frame.position = stmt.target.unwrap().upcast(); + cur_frame.position = stmt.target.upcast(); Ok(EvalContinuation::Stepping) }, @@ -1041,6 +1054,16 @@ impl Prompt { let stmt = &heap[cur_frame.position]; match stmt { + Statement::Local(stmt) => { + if let LocalStatement::Memory(stmt) = stmt { + // Setup as unassigned, when we execute the memory + // statement (after evaluating expression), it should no + // longer be `Unassigned`. + let variable = &heap[stmt.variable]; + self.store.write(ValueId::Stack(variable.unique_id_in_scope as u32), Value::Unassigned); + cur_frame.prepare_single_expression(heap, stmt.initial_expr.upcast()); + } + }, Statement::If(stmt) => cur_frame.prepare_single_expression(heap, stmt.test), Statement::While(stmt) => cur_frame.prepare_single_expression(heap, stmt.test), Statement::Return(stmt) => {