|
HAL
v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
|
#include </home/runner/work/hal/hal/plugins/z3_utils/include/z3_utils/converter/converter.h>


Public Types | |
| enum | Operation { bvand , bvnot , bvor , bvxor , NONE } |
Public Member Functions | |
| std::string | convert_z3_expr_to_func (const z3::expr &e) const |
Protected Member Functions | |
| virtual std::string | build_operand (const std::string &operand) const =0 |
| virtual std::string | build_operation (const Operation &operation, const std::vector< std::string > &operands) const =0 |
| virtual std::string | generate_assignment (const std::string &l) const =0 |
| virtual std::string | generate_initialization (const std::vector< std::string > &input_vars) const =0 |
| virtual std::string | construct_function (const std::string &assignments, const std::string &initalization, const std::vector< std::string > &input_vars) const =0 |
| std::string | integer_with_leading_zeros (const u32 i, const u32 total_length) const |
| std::string | replace_all (const std::string &str, const std::string &from, const std::string &to) const |
| std::string | operation_to_string (const Operation &op) const |
| bool | does_line_contain_assignment (const std::string &l) const |
| std::string | extract_lhs (const std::string &l) const |
| std::map< u32, u32 > | extract_paranthesis_pairs (const std::string &l) const |
| bool | contains_one_operation (const std::string &l) const |
| std::map< std::string, std::string > | extract_sub_exrepssions (const std::string &l) const |
| Operation | extract_operation (const std::string &se) const |
| std::vector< std::string > | extract_operands (const std::string &se) const |
| std::map< std::string, std::string > | translate_sub_expressions (const std::map< std::string, std::string > &se) const |
| std::string | merge_sub_expressions (const std::map< std::string, std::string > &translated_sub_expressions) const |
| std::string | generate_function (const std::vector< std::string > &assignments, std::vector< std::string > &input_vars) const |
Protected Attributes | |
| std::vector< Operation > | m_operations = {Converter::bvand, Converter::bvnot, Converter::bvor, Converter::bvxor} |
The base class for the converters that translate a Boolean function given in SMT-LIB notation into another language.
Definition at line 41 of file converter.h.
The bit-vector operations that the converters can translate.
| Enumerator | |
|---|---|
| bvand | Bitwise AND. |
| bvnot | Bitwise NOT. |
| bvor | Bitwise OR. |
| bvxor | Bitwise XOR. |
| NONE | No operation, returned when no known operation could be extracted. |
Definition at line 47 of file converter.h.
|
protectedpure virtual |
Translate a single operand into the target language.
| [in] | operand | - The operand in SMT-LIB notation. |
|
protectedpure virtual |
Translate a single operation and its operands into the target language.
| [in] | operation | - The operation to translate. |
| [in] | operands | - The operands of the operation, already translated. |
Referenced by translate_sub_expressions().
|
protectedpure virtual |
Assemble the complete function of the target language from its parts.
| [in] | assignments | - The translated assignments that make up the body. |
| [in] | initalization | - The translated initialization code. |
| [in] | input_vars | - The input variables of the function. |
Referenced by convert_z3_expr_to_func().
|
protected |
Check whether the given line consists of exactly one operation, i.e., whether it needs no further splitting.
| [in] | l | - The line to check. |
true if the line contains exactly one operation, false otherwise. Definition at line 122 of file converter.cpp.
References log_debug, m_operations, operation_to_string(), and start_index.
Referenced by extract_sub_exrepssions().
| std::string hal::z3_utils::Converter::convert_z3_expr_to_func | ( | const z3::expr & | e | ) | const |
This base function prases and splits up the smt representation of a wrapped z3 expression and converts it into another representation depending on the child class that overrides the virtual methods.
| [in] | e | - z3 expression that is converted. |
Definition at line 294 of file converter.cpp.
References construct_function(), does_line_contain_assignment(), generate_assignment(), generate_initialization(), hal::z3_utils::get_variable_names(), log_debug, hal::z3_utils::to_smt2(), and hal::utils::to_vector().
|
protected |
Check whether the given line of the SMT-LIB representation holds an assignment.
| [in] | l | - The line to check. |
true if the line holds an assignment, false otherwise. Definition at line 70 of file converter.cpp.
Referenced by convert_z3_expr_to_func().
|
protected |
Get the variable that is assigned to in the given line.
| [in] | l | - The line holding the assignment. |
Definition at line 75 of file converter.cpp.
References start_index.
|
protected |
Get the operands that the given sub-expression applies its operation to.
| [in] | se | - The sub-expression. |
Definition at line 235 of file converter.cpp.
Referenced by translate_sub_expressions().
|
protected |
Get the operation that the given sub-expression applies.
| [in] | se | - The sub-expression. |
Converter::NONE if no known operation was found. Definition at line 220 of file converter.cpp.
References log_error, m_operations, NONE, and operation_to_string().
Referenced by translate_sub_expressions().
|
protected |
Get the matching parenthesis for every opening parenthesis of the given line.
| [in] | l | - The line to analyze. |
Definition at line 83 of file converter.cpp.
References log_debug, and start_index.
Referenced by extract_sub_exrepssions().
|
protected |
Split the given line into the sub-expressions that it is composed of.
| [in] | l | - The line to split. |
Definition at line 147 of file converter.cpp.
References contains_one_operation(), extract_paranthesis_pairs(), integer_with_leading_zeros(), log_debug, and replace_all().
|
protectedpure virtual |
Translate a single assignment of the SMT-LIB representation into the target language.
| [in] | l | - The line holding the assignment. |
Referenced by convert_z3_expr_to_func().
|
protected |
Translate all assignments into the target language and assemble them into a complete function.
| [in] | assignments | - The assignments of the SMT-LIB representation. |
| [in,out] | input_vars | - The input variables of the function, filled by this function. |
|
protectedpure virtual |
Generate the code that reads the input variables before the translated function is evaluated.
| [in] | input_vars | - The input variables of the function. |
Referenced by convert_z3_expr_to_func().
|
protected |
Convert an integer into a string of the given length, padded with leading zeros.
| [in] | i | - The integer to convert. |
| [in] | total_length | - The length of the resulting string. |
Definition at line 16 of file converter.cpp.
Referenced by extract_sub_exrepssions().
|
protected |
Substitute the translated sub-expressions back into one another to form a single expression.
| [in] | translated_sub_expressions | - A map from each placeholder to the translated sub-expression. |
Definition at line 271 of file converter.cpp.
References replace_all().
|
protected |
Get the SMT-LIB name of an operation.
| [in] | op | - The operation. |
Definition at line 43 of file converter.cpp.
References bvand, bvnot, bvor, bvxor, and log_error.
Referenced by contains_one_operation(), and extract_operation().
|
protected |
Replace every occurrence of a substring within a string.
| [in] | str | - The string to operate on. |
| [in] | from | - The substring to replace. |
| [in] | to | - The replacement. |
Definition at line 23 of file converter.cpp.
References start_index, and hal::core_strings::to().
Referenced by extract_sub_exrepssions(), and merge_sub_expressions().
|
protected |
Translate every sub-expression into the target language.
| [in] | se | - A map from a placeholder to the sub-expression that it stands for. |
Definition at line 256 of file converter.cpp.
References build_operation(), extract_operands(), and extract_operation().
|
protected |
The operations that the converter supports.
Definition at line 224 of file converter.h.
Referenced by contains_one_operation(), and extract_operation().