ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
ld_converter.h
Go to the documentation of this file.
1#pragma once
2
7#include <optional>
8#include <string>
9
10// ld_converter translates LdIR into ESBMC's GOTO IR (irep2 / contextt).
11//
12// Pattern mirrors python_converter: the caller (ld_languaget::typecheck) passes
13// the context in; convert() adds all symbolt entries, the scan loop function,
14// and the loop-free __ESBMC_main that calls it. No C file is produced.
16{
17public:
18 ld_converter(contextt &context, const LdIR &ir);
19
22 void convert();
23
28
31 void enable_fault_injection(bool enabled)
32 {
33 fault_injection_ = enabled;
34 }
35
36private:
37 contextt &context_;
38 const LdIR &ir_;
39 bool fault_injection_ = false;
40
41 // Edge contact evaluations so far; each keeps its own previous sample.
42 unsigned edge_contacts_ = 0;
43
44 typet bool_t() const;
45 typet dint_type() const;
46 typet type_of_kind(VarKind kind) const; // IEC 61131-3 type -> ESBMC typet
47 exprt int_const(long long value, const typet &type) const;
48
49 symbol_exprt declare_variable(const VarDecl &v);
50 symbol_exprt declare_bool_shadow(const std::string &id);
51 symbol_exprt declare_scoped(const std::string &id, const typet &t);
52 symbol_exprt var_expr(const std::string &name) const;
53 exprt bool_value_of(const symbol_exprt &var) const;
54
55 code_blockt build_scan_body(const exprt &pf_in);
56
57 exprt translate_contact(const LdIRNode &n, code_blockt &blk);
58 codet translate_coil(const LdIRNode &n, const exprt &pf);
59 codet translate_timer(const LdIRNode &n);
60 codet translate_counter(const LdIRNode &n);
61 codet translate_arith(const LdIRNode &n);
62 codet translate_user_fb(const UserFBExec &ex);
63 std::optional<code_blockt> translate_fb_body(const UserFBExec &ex);
64 std::optional<exprt>
65 wire_source(const std::string &source, const typet &type) const;
66 exprt input_value(
67 const UserFBExec &ex,
68 const std::string &pin,
69 const typet &type) const;
70 void declare_user_fb_interfaces();
71
72 void emit_scan_function(const code_blockt &scan_body);
73 void emit_main_function();
74};
Definition std_code.h:49
Definition std_code.h:8
Definition context.h:57
Definition expr.h:34
void convert()
Build the symbol table, ld::scan_loop, and __ESBMC_main skeleton.
Definition ld_converter.cpp:922
ld_converter(contextt &context, const LdIR &ir)
Definition ld_converter.cpp:17
void enable_fault_injection(bool enabled)
Fault-injection mode: negate contact polarities / degrade coil assignments.
Definition ld_converter.h:31
void prepend_static_init()
Prepend static-lifetime initialisation assignments to __ESBMC_main.
Definition ld_converter.cpp:862
Definition std_expr.h:58
Definition type.h:9
Definition toml.hpp:1531
VarKind
Definition ld_ast.h:172
Definition ld_ir.h:30
Definition ld_ir.h:91
Definition ld_ir.h:78
Definition ld_ast.h:182