ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
namespace.h
Go to the documentation of this file.
1#ifndef CPROVER_NAMESPACE_H
2#define CPROVER_NAMESPACE_H
3
5#include <irep2/irep2.h>
6#include <irep2/irep2_type.h>
7#include <util/irep/migrate.h>
8
10{
11public:
12 virtual const symbolt *lookup(const irep_idt &name) const;
13 const symbolt *lookup(const irept &irep) const
14 {
15 return lookup(irep.identifier());
16 }
17
18 void follow_symbol(irept &irep) const;
19
20 const typet &follow(const typet &src) const;
21 const type2tc follow(const type2tc &src) const
22 {
23 // Native IREP2 symbol-type resolution, mirroring follow(typet) without
24 // the back-migrate -> follow(typet) -> forward-migrate detour (hot path).
25 if (!is_symbol_type(src))
26 return src;
27
28 const symbolt *symbol = lookup(to_symbol_type(src).symbol_name);
29
30 // let's hope it's not cyclic...
31 while (true)
32 {
33 assert(symbol);
34 assert(symbol->is_type);
35 type2tc t = migrate_symbol_type(*symbol);
36 if (!is_symbol_type(t))
37 return t;
38 const symbolt *next = lookup(to_symbol_type(t).symbol_name);
39 assert(next != symbol && "cycle of length 1 in ns.follow()");
40 symbol = next;
41 }
42 }
43
44 namespacet() = delete;
45
46 virtual ~namespacet() = default;
47
48 namespacet(const contextt &_context) : context(&_context)
49 {
50 }
51
52 virtual unsigned get_max(const std::string &prefix) const;
53
54 const contextt &get_context() const
55 {
56 return *context;
57 }
58
59protected:
61};
62
63#endif
Definition context.h:57
Definition irep_idt.h:12
Definition irep.h:36
const irep_idt & identifier() const
Definition irep.h:167
const type2tc follow(const type2tc &src) const
Definition namespace.h:21
const typet & follow(const typet &src) const
Definition namespace.cpp:47
virtual ~namespacet()=default
void follow_symbol(irept &irep) const
Definition namespace.cpp:23
const symbolt * lookup(const irept &irep) const
Definition namespace.h:13
namespacet(const contextt &_context)
Definition namespace.h:48
const contextt & get_context() const
Definition namespace.h:54
namespacet()=delete
virtual unsigned get_max(const std::string &prefix) const
Definition namespace.cpp:6
const contextt * context
Definition namespace.h:60
virtual const symbolt * lookup(const irep_idt &name) const
Definition namespace.cpp:18
Definition symbol.h:12
bool is_type
Definition symbol.h:21
Definition type.h:9
Classes and definitions for non-stringy internal representation.
irep_container< type2t > type2tc
Definition irep2.h:430
type2tc migrate_symbol_type(const symbolt &sym)
Definition migrate.cpp:567
struct _ESBMC_Mapping * next
Definition solidity_mapping.c:3
const symbol_typet & to_symbol_type(const typet &type)
Cast a generic typet to a symbol_typet.
Definition std_types.h:60