diff --git a/src/main.cpp b/src/main.cpp index 19fc99a..189d829 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1895,6 +1895,38 @@ Literal exec(vector 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(l.args[0])) { + if (holds_alternative(get(l.args[0]).val)) { + boolean.val = !get(get(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(l.args[1])) { + varRef = get(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.