🐐 NON operator

This commit is contained in:
2026-04-01 13:21:07 +02:00
parent 0b712f5040
commit 77a4f8ae2b
4 changed files with 64 additions and 2 deletions

View File

@@ -462,6 +462,24 @@ class UnaryMinus(Node):
return vtable, ValInt(-val.value())
class UnaryNot(Node):
def __init__(self, expr):
self.expr = expr
def __eq__(self, other):
return type(self) == type(other) and self.expr == other.expr
def __repr__(self):
return f"UnaryNot({self.expr!r})"
def print(self):
return f"(NON {self.expr.print()})"
def _eval(self, vtable):
vtable, val = self.expr.eval(vtable)
return vtable, ValBool(not bool(val))
class ArrayIndex(Node):
def __init__(self, array, index) -> None:
self.array = array