ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
type_checker.h
Go to the documentation of this file.
1#pragma once
2
4#include <stdexcept>
5#include <string>
6#include <unordered_map>
7#include <unordered_set>
8
9struct TypeCheckError : std::runtime_error
10{
11 explicit TypeCheckError(const std::string &msg) : std::runtime_error(msg)
12 {
13 }
14};
15
17{
18public:
19 // Validate the AST and annotate variable types.
20 // Throws TypeCheckError on any violation.
21 void check(const LdAst &ast);
22
23private:
24 std::unordered_map<std::string, VarKind> var_types_;
25 std::unordered_set<std::string> inputs_;
26
27 void build_var_type_map(const LdAst &ast);
28 void check_rung_element(const RungElement &elem);
29 void check_timer_fb(const TimerFBNode &fb);
30 void check_counter_fb(const CounterFBNode &fb);
31 void check_arith_fb(const ArithFBNode &fb);
32
33 VarKind lookup_type(const std::string &var, const LdLocation &loc) const;
34 void require_distinct(
35 const std::string &instance,
36 const char *ports,
37 const std::string &a,
38 const std::string &b,
39 const LdLocation &loc) const;
40 void require_port(
41 const std::string &instance,
42 const char *port,
43 const std::string &var,
44 const LdLocation &loc) const;
45
46 static std::string loc_str(const LdLocation &loc);
47};
Definition type_checker.h:17
void check(const LdAst &ast)
Definition type_checker.cpp:239
@ instance
Definition converter_compare.cpp:886
VarKind
Definition ld_ast.h:172
Definition exception.cpp:51
Definition ld_ast.h:117
Definition ld_ast.h:103
Definition ld_ast.h:256
Definition ld_ast.h:9
Definition ld_ast.h:141
Definition ld_ast.h:92
TypeCheckError(const std::string &msg)
Definition type_checker.h:11