Module utils

Module utils 

Source
Expand description

Utility functions for expression simplification

Statics§

POWS_OF_TEN

Functions§

as_bool_lit
returns the contained boolean value in expr as Expr::Literal(ScalarValue::Boolean(v)).
can_reduce_to_equal_statement
delete_xor_in_complex_expr
Deletes all ‘needles’ or remains one ‘needle’ that are found in a chain of xor expressions. Such as: A ^ (A ^ (B ^ A))
distribute_negation
bitwise negate a Negative clause input is the clause to be bitwise negated.(args for Negative clause) For BinaryExpr: ~(A & B) ===> ~A | ~B ~(A | B) ===> ~A & ~B For Negative: ~(~A) ===> A For others, use Negative clause
expr_contains
check volatile calls and return if expr contains needle
expr_contains_inner 🔒
returns true if needle is found in a chain of search_op expressions. Such as: (A AND B) AND C
into_case
is_bool_lit
returns true if expr is a Expr::Literal(ScalarValue::Boolean(v)) , false otherwise
is_case_with_literal_outputs
is_false
is_lit
is_negative_of
returns true if not_expr is !expr (bitwise not)
is_not_of
returns true if not_expr is !expr (not)
is_null
is_one
is_op_with
returns true if haystack looks like (needle OP X) or (X OP needle)
is_true
is_zero
lit_bool_null
Return a literal NULL value of Boolean data type
negate_clause
negate a Not clause input is the clause to be negated.(args of Not clause) For BinaryExpr, use the negation of op instead. not ( A > B) ===> (A <= B) For BoolExpr, not (A and B) ===> (not A) or (not B) not (A or B) ===> (not A) and (not B) not (not A) ===> A For NullExpr, not (A is not null) ===> A is null not (A is null) ===> A is not null For InList, not (A not in (..)) ===> A in (..) not (A in (..)) ===> A not in (..) For Between, not (A between B and C) ===> (A not between B and C) not (A not between B and C) ===> (A between B and C) For others, use Not clause