add variable updates and some fixing

This commit is contained in:
afonya2 2025-05-24 18:22:08 +02:00
parent 581c301165
commit 8403628d7f
Signed by: afonya
GPG key ID: EBB9C4CAFAAFB2DC
2 changed files with 9 additions and 3 deletions

View file

@ -131,10 +131,10 @@ impl Executor {
let red = self.read_memory(key.clone(), true);
match red {
ASTPart::NOOP => {
self.delete_memory(key.clone());
panic!("Uanble to update non-existing memory key: {}", key);
},
_ => {
panic!("Uanble to update non-existing memory key: {}", key);
self.delete_memory(key.clone());
}
}
}
@ -254,6 +254,11 @@ impl Executor {
let data = self.read_memory(var.variable.clone(), false);
return data;
},
ASTPart::VarUpdate(updt) => {
let value = self.process_code(&updt.value, op_count);
self.write_memory(updt.variable.clone(), value, true);
return ASTPart::NOOP;
},
_ => {
return ASTPart::NOOP;
}