From 8ad05b778deb73895bd12e322b3a32020c59219a Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Sat, 29 May 2021 08:20:16 +0000 Subject: [PATCH] add support for boolean literals --- ql/src/codeql_ql/ast/Ast.qll | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ql/src/codeql_ql/ast/Ast.qll b/ql/src/codeql_ql/ast/Ast.qll index dc378cf190e..fc96dabb75c 100644 --- a/ql/src/codeql_ql/ast/Ast.qll +++ b/ql/src/codeql_ql/ast/Ast.qll @@ -990,6 +990,21 @@ class Float extends Literal { float getValue() { result = lit.getChild().(Generated::Float).getValue().toFloat() } } +/** A boolean literal */ +class Boolean extends Literal { + Generated::Bool bool; + + Boolean() { lit.getChild() = bool } + + /** Holds if the value is `true` */ + predicate isTrue() { bool.getChild() instanceof Generated::True } + + /** Holds if the value is `false` */ + predicate isFalse() { bool.getChild() instanceof Generated::False } + + override string getAPrimaryQlClass() { result = "Boolean" } +} + /** A comparison symbol, such as `"<"` or `"="`. */ class ComparisonSymbol extends string { ComparisonSymbol() {