|
ESBMC
Efficient SMT-based Context-Bounded Model Checker
|
Handler for Python dictionary operations in ESBMC's Python frontend. More...
#include <python-frontend/symbol_id.h>#include <python-frontend/type/element_type_registry.h>#include <util/irep/std_types.h>#include <util/irep/std_code.h>#include <util/irep/expr.h>#include <nlohmann/json.hpp>#include <optional>#include <string>#include <unordered_map>Go to the source code of this file.
Classes | |
| class | python_dict_handler |
| Handles Python dictionary operations for ESBMC verification. More... | |
Handler for Python dictionary operations in ESBMC's Python frontend.
This module provides support for converting Python dictionary constructs into ESBMC's intermediate representation (GOTO programs). It handles dictionary literals, subscript access, assignment, membership testing, and deletion operations.
Python dictionaries are represented as a struct containing two parallel lists: one for keys and one for values. The struct type is defined as:
Dictionary values are stored as PyObject instances with type information (type_id) that allows runtime type identification for proper value extraction.
Nested dictionaries (e.g., dict[int, dict[int, int]]) require special handling because dict structs contain pointer fields. Instead of copying the entire nested dict struct, we store a pointer to the dict.
Memory Model:
Type Safety: Each nested dict type gets a unique hash based on its full type structure, ensuring dict[int, dict[int, int]] has a different hash than dict[str, dict[str, str]]. This prevents type confusion during retrieval.
The handler supports dictionaries with values of the following types: