forked from ground/ground
Re-add not instruction I accidentally deleted
This commit is contained in:
32
src/main.cpp
32
src/main.cpp
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user