|
ESBMC
Efficient SMT-based Context-Bounded Model Checker
|
Dedicated handler for complex number operations in the Python frontend. More...
#include <complex_handler.h>
Public Member Functions | |
| complex_handler (python_converter &converter, contextt &symbol_table, type_handler &type_handler_ref) | |
| exprt | handle_binary_op (const std::string &op, const exprt &lhs, const exprt &rhs, const nlohmann::json &element) const |
| Handles binary operations when at least one operand is complex. | |
| exprt | handle_unary_op (const std::string &op, const exprt &operand) const |
| Handles unary +/- on complex values. | |
| exprt | handle_attribute (const nlohmann::json &element) const |
| Handles attribute access / method calls on complex objects. | |
| exprt | handle_attribute_access (const exprt &obj, const std::string &attr) const |
| Handles direct attribute access on a complex object: .real, .imag. | |
| exprt | handle_abs (const exprt &z) const |
| Computes abs(z) = sqrt(real^2 + imag^2). | |
| exprt | handle_cmath_log (const std::string &func_name, const nlohmann::json &call, const nlohmann::json &args, const nlohmann::json &keywords) const |
| Handles cmath.log / cmath.log10 with complex arguments. | |
| exprt | normalize_numeric_expr (const exprt &value) const |
| Normalises a numeric expression for use in complex arithmetic. | |
Dedicated handler for complex number operations in the Python frontend.
Centralises complex arithmetic (mul, div, pow, log, exp), unary operations, attribute access (.real, .imag, .conjugate()), abs(), and numeric normalisation that were previously scattered across python_converter.cpp and function_call_expr.cpp.
Follows the pattern established by string_handler and python_math.
| complex_handler::complex_handler | ( | python_converter & | converter, |
| contextt & | symbol_table, | ||
| type_handler & | type_handler_ref ) |
| exprt complex_handler::handle_attribute | ( | const nlohmann::json & | element | ) | const |
Handles attribute access / method calls on complex objects.
Dispatches conjugate() when the method name matches.
| element | The full JSON node of the Call expression (must contain func.attr and func.value). |
| exprt complex_handler::handle_attribute_access | ( | const exprt & | obj, |
| const std::string & | attr ) const |
Handles direct attribute access on a complex object: .real, .imag.
| exprt complex_handler::handle_binary_op | ( | const std::string & | op, |
| const exprt & | lhs, | ||
| const exprt & | rhs, | ||
| const nlohmann::json & | element ) const |
Handles binary operations when at least one operand is complex.
Covers Add, Sub, Mult, Div, Pow, Eq, NotEq and rejects unsupported comparisons/floor ops with proper TypeErrors.
| exprt complex_handler::handle_cmath_log | ( | const std::string & | func_name, |
| const nlohmann::json & | call, | ||
| const nlohmann::json & | args, | ||
| const nlohmann::json & | keywords ) const |
Handles cmath.log / cmath.log10 with complex arguments.
| func_name | "log" or "log10". |
| call | The full Call JSON node (used for location info). |
| args | Positional arguments array. |
| keywords | Keyword arguments array. |
Handles unary +/- on complex values.
UAdd returns the operand unchanged; USub negates both components.
Normalises a numeric expression for use in complex arithmetic.
Integer/bool trees are recursively promoted to IEEE double; complex values pass through unchanged.