ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
complex_handler.h
Go to the documentation of this file.
1#ifndef PYTHON_FRONTEND_COMPLEX_HANDLER_H
2#define PYTHON_FRONTEND_COMPLEX_HANDLER_H
3
4#include <nlohmann/json.hpp>
5#include <util/irep/expr.h>
6#include <string>
7#include <unordered_map>
8
10class contextt;
11class type_handler;
12class symbolt;
13
26{
27public:
29 python_converter &converter,
30 contextt &symbol_table,
31 type_handler &type_handler_ref);
32
39 const std::string &op,
40 const exprt &lhs,
41 const exprt &rhs,
42 const nlohmann::json &element) const;
43
48 exprt handle_unary_op(const std::string &op, const exprt &operand) const;
49
59 exprt handle_attribute(const nlohmann::json &element) const;
60
65 exprt
66 handle_attribute_access(const exprt &obj, const std::string &attr) const;
67
71 exprt handle_abs(const exprt &z) const;
72
83 const std::string &func_name,
84 const nlohmann::json &call,
85 const nlohmann::json &args,
86 const nlohmann::json &keywords) const;
87
94
95private:
96 python_converter &converter_;
97 contextt &symbol_table_;
98 type_handler &type_handler_;
99
101 mutable std::unordered_map<std::string, const symbolt *> symbol_cache_;
102
104 void clear_cache() const;
105
107 const symbolt *find_cached_symbol(const std::string &id) const;
108
109 // ---- shared IEEE / complex arithmetic helpers ----
110
112 exprt complex_mul(const exprt &x, const exprt &y) const;
113
118 exprt complex_div(
119 const exprt &x,
120 const exprt &y,
121 const nlohmann::json &loc_source) const;
122
124 exprt complex_log(const exprt &z, const nlohmann::json &loc_source) const;
125
127 exprt complex_exp(const exprt &z, const nlohmann::json &loc_source) const;
128
130 exprt
131 promote_int_arith_to_double(const exprt &input_expr, std::size_t depth) const;
132};
133
134#endif // PYTHON_FRONTEND_COMPLEX_HANDLER_H
exprt normalize_numeric_expr(const exprt &value) const
Normalises a numeric expression for use in complex arithmetic.
Definition complex_handler.cpp:314
exprt handle_unary_op(const std::string &op, const exprt &operand) const
Handles unary +/- on complex values.
Definition complex_handler.cpp:624
exprt handle_attribute(const nlohmann::json &element) const
Handles attribute access / method calls on complex objects.
Definition complex_handler.cpp:654
exprt handle_abs(const exprt &z) const
Computes abs(z) = sqrt(real^2 + imag^2).
Definition complex_handler.cpp:714
complex_handler(python_converter &converter, contextt &symbol_table, type_handler &type_handler_ref)
Definition complex_handler.cpp:48
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.
Definition complex_handler.cpp:333
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.
Definition complex_handler.cpp:737
exprt handle_attribute_access(const exprt &obj, const std::string &attr) const
Handles direct attribute access on a complex object: .real, .imag.
Definition complex_handler.cpp:691
Definition context.h:57
Definition expr.h:34
Main converter for transforming Python AST into ESBMC's intermediate representation.
Definition python_converter.h:76
Definition symbol.h:12
Definition type_handler.h:113
Definition toml.hpp:1531
unsigned stack_budget_guardt< Tag >::depth
Definition stack_budget.h:72