Re-add not instruction I accidentally deleted

This commit is contained in:
2025-09-21 08:12:10 +10:00
parent 0a962b569a
commit 063cdc92e3

View File

@@ -1895,6 +1895,38 @@ Literal exec(vector<Instruction> in, bool executingFunction) {
setVal(varRef.varName, final);
}
break;
/*
not instruction
Negates a boolean
*/
case Instructions::Not:
if (l.args.size() < 2) {
error("Could not find all arguments required for Not inbuilt");
}
{
Literal boolean;
Direct varRef;
if (holds_alternative<Literal>(l.args[0])) {
if (holds_alternative<bool>(get<Literal>(l.args[0]).val)) {
boolean.val = !get<bool>(get<Literal>(l.args[0]).val);
} else {
error("First argument of not must be a boolean literal");
}
} else {
error("First argument of not must be a boolean literal");
}
if (holds_alternative<Direct>(l.args[1])) {
varRef = get<Direct>(l.args[1]);
} else {
error("Second argument of not must be a direct reference");
}
setVal(varRef.varName, boolean);
}
break;
/*
jump instruction
Jumps to the line reference provided.