QueryTree

open class QueryTree<T>(var value: T, val children: MutableList<QueryTree<*>> = mutableListOf(), var stringRepresentation: String = "") : Comparable<QueryTree<T>>

Holds the value to which the statements have been evaluated. The children define previous steps of the evaluation, thus building a tree of all steps of the evaluation recursively until we reach the nodes of the CPG. This is necessary if we want to store all steps which are performed when evaluating a query. It helps to make the reasoning of the query more understandable to the user and gives an analyst the maximum of information available.

Numerous methods allow to evaluate the queries while keeping track of all the steps. Currently, the following operations are supported:

  • eq: Equality of two values.

  • ne: Inequality of two values.

  • IN: Checks if a value is contained in a Collection

  • IS: Checks if a value implements a type (Class).

Additionally, some functions are available only for certain types of values.

For boolean values:

  • and: Logical and operation (&&)

  • or: Logical or operation (||)

  • xor: Logical exclusive or operation (xor)

  • implies: Logical implication

For numeric values:

  • gt: Grater than (>)

  • ge: Grater than or equal (>=)

  • lt: Less than (<)

  • le: Less than or equal (<=)

Constructors

Link copied to clipboard
constructor(value: T, children: MutableList<QueryTree<*>> = mutableListOf(), stringRepresentation: String = "")

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open var value: T

Functions

Link copied to clipboard

Performs a logical and (&&) operation between the values of two QueryTrees.

Link copied to clipboard
open operator override fun compareTo(other: QueryTree<T>): Int
operator fun compareTo(other: Number): Int
Link copied to clipboard
infix fun eq(other: T): QueryTree<Boolean>

Checks for equality of a QueryTree with a value of the same type (e.g. useful to check for constants).

infix fun eq(other: QueryTree<T>): QueryTree<Boolean>

Checks for equality of two QueryTrees.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
infix fun <T : Number, S : Number> QueryTree<T>.ge(other: S): QueryTree<Boolean>

Compares the numeric values of a QueryTree and another number for this being "greater than or equal" (>=) other.

infix fun <T : Number, S : Number> QueryTree<T>.ge(other: QueryTree<S>): QueryTree<Boolean>

Compares the numeric values of two QueryTrees for this being "greater than or equal" (>=) other.

Link copied to clipboard
infix fun <T : Number, S : Number> QueryTree<T>.gt(other: S): QueryTree<Boolean>

Compares the numeric values of a QueryTree and another number for this being "greater than" (>) other.

infix fun <T : Number, S : Number> QueryTree<T>.gt(other: QueryTree<S>): QueryTree<Boolean>

Compares the numeric values of two QueryTrees for this being "greater than" (>) other.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Evaluates a logical implication (->) operation between the values of two QueryTrees.

Link copied to clipboard
infix fun IN(other: QueryTree<Collection<*>>): QueryTree<Boolean>

Checks if the value is contained in the collection of the other QueryTree.

infix fun IN(other: Collection<*>): QueryTree<Boolean>

Checks if the value is contained in the collection other.

Link copied to clipboard
infix fun IS(other: QueryTree<Class<*>>): QueryTree<Boolean>

Checks if the value is a member of the type of the other QueryTree.

infix fun IS(other: Class<*>): QueryTree<Boolean>

Checks if the value is a member of the type of other.

Link copied to clipboard
infix fun <T : Number, S : Number> QueryTree<T>.le(other: S): QueryTree<Boolean>

Compares the numeric values of a QueryTree and another number for this being "less than or equal" (<=) other.

infix fun <T : Number, S : Number> QueryTree<T>.le(other: QueryTree<S>): QueryTree<Boolean>

Compares the numeric values of two QueryTrees for this being "less than or equal" (=) other.

Link copied to clipboard
infix fun <T : Number, S : Number> QueryTree<T>.lt(other: S): QueryTree<Boolean>

Compares the numeric values of a QueryTree and another number for this being "less than" (<) other.

infix fun <T : Number, S : Number> QueryTree<T>.lt(other: QueryTree<S>): QueryTree<Boolean>

Compares the numeric values of two QueryTrees for this being "less than" (<) other.

Link copied to clipboard
infix fun ne(other: T): QueryTree<Boolean>

Checks for inequality of a QueryTree with a value of the same type (e.g. useful to check for constants).

infix fun ne(other: QueryTree<T>): QueryTree<Boolean>

Checks for inequality of two QueryTrees.

Link copied to clipboard

Performs a logical or (||) operation between the values of two QueryTrees.

Link copied to clipboard
fun printNicely(depth: Int = 0): String
Link copied to clipboard

Performs a logical xor operation between the values of two QueryTrees.