add variable updates and some fixing
This commit is contained in:
parent
581c301165
commit
8403628d7f
2 changed files with 9 additions and 3 deletions
|
@ -131,10 +131,10 @@ impl Executor {
|
||||||
let red = self.read_memory(key.clone(), true);
|
let red = self.read_memory(key.clone(), true);
|
||||||
match red {
|
match red {
|
||||||
ASTPart::NOOP => {
|
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);
|
let data = self.read_memory(var.variable.clone(), false);
|
||||||
return data;
|
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;
|
return ASTPart::NOOP;
|
||||||
}
|
}
|
||||||
|
|
1
test.as
1
test.as
|
@ -1,2 +1,3 @@
|
||||||
gethelj a = 1
|
gethelj a = 1
|
||||||
gethelj b = (a + 2) * 3
|
gethelj b = (a + 2) * 3
|
||||||
|
a = 3
|
Loading…
Add table
Add a link
Reference in a new issue