aboutsummaryrefslogtreecommitdiff
path: root/ql/ast/nodes/expressions/unary_operators/negation_operator.py
diff options
context:
space:
mode:
authorBicker <bickerkards@tuta.io>2019-05-22 17:45:37 +0200
committerBicker <bickerkards@tuta.io>2019-05-22 17:45:37 +0200
commit25314fd2aed81aa5281bc3d93dbcc7919368ebe1 (patch)
tree1995521ee652e419926de5fced0f2e3b655e70fb /ql/ast/nodes/expressions/unary_operators/negation_operator.py
Initial commitHEADmaster
Diffstat (limited to 'ql/ast/nodes/expressions/unary_operators/negation_operator.py')
-rw-r--r--ql/ast/nodes/expressions/unary_operators/negation_operator.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/ql/ast/nodes/expressions/unary_operators/negation_operator.py b/ql/ast/nodes/expressions/unary_operators/negation_operator.py
new file mode 100644
index 0000000..7b6b0c5
--- /dev/null
+++ b/ql/ast/nodes/expressions/unary_operators/negation_operator.py
@@ -0,0 +1,20 @@
+from ql.ast.nodes.expressions.unary_operators.unary_operator import UnaryOperatorNode
+from ql.types.boolean import QLBoolean
+from ql.types.undefined import QLUndefined
+
+
+class NegationOperatorNode(UnaryOperatorNode):
+ def __init__(self, metadata, expression_type, expression, value):
+ super(NegationOperatorNode, self).__init__(metadata, expression_type, expression, value)
+ self.__valid_types = {
+ QLBoolean: QLBoolean,
+ }
+
+ def get_result_type(self):
+ if self.__valid_types.get(self.expression.expression_type):
+ return self.__valid_types.get(self.expression.expression_type)
+
+ return QLUndefined
+
+ def evaluate(self):
+ self.value = QLBoolean(not self.expression.value)