ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
jimple_method_body.h
Go to the documentation of this file.
1#ifndef ESBMC_JIMPLE_METHOD_BODY_H
2#define ESBMC_JIMPLE_METHOD_BODY_H
3
5#include <util/irep/migrate.h>
7
14{
15public:
16 virtual exprt
17 to_exprt(contextt &, const std::string &, const std::string &) const
18 {
19 exprt dummy;
20 return dummy;
21 }
22
32 contextt &ctx,
33 const std::string &class_name,
34 const std::string &function_name) const
35 {
36 expr2tc body;
37 migrate_expr(to_exprt(ctx, class_name, function_name), body);
38 return body;
39 }
40};
41
48{
49public:
50 virtual exprt
51 to_exprt(contextt &, const std::string &, const std::string &) const
52 {
53 code_skipt dummy;
54 return dummy;
55 }
56
68 contextt &ctx,
69 const std::string &class_name,
70 const std::string &function_name,
71 const locationt &loc) const
72 {
73 exprt e = to_exprt(ctx, class_name, function_name);
74 // A nil location means "leave whatever to_exprt produced": jimple_label
75 // does not stamp its members, where jimple_full_method_body does.
76 if (!loc.is_nil())
77 e.location() = loc;
78 expr2tc stmt;
79 migrate_expr(e, stmt);
80 return stmt;
81 }
82};
83
92
99{
100public:
101 virtual void from_json(const json &j) override;
102 virtual std::string to_string() const override;
103 virtual expr2tc to_code2t(
104 contextt &ctx,
105 const std::string &class_name,
106 const std::string &function_name) const override;
107
108 enum class statement
109 {
110 Assignment, // A = 42
111 Identity, // @this, @parameter0, @parameter1, ...; This will be removed as
112 // it can solved directly in the frontend
113 StaticInvoke, // foo() (where foo is a static function)
114 SpecialInvoke, // Special methods of the class:
115 // constructors/static-constructor
116 VirtualInvoke, // A.foo() (where A is an object)
117 Return, // return; return 42;
118 Label, // 1:, 2:; (GOTO labels)
119 Goto, // goto 1;
120 If, // if <expr> goto <Label>
121 Declaration, // int a;
122 Throw, // throw <expr>
123 Location // Extra, reffers to the line number
124 };
125
126 std::vector<std::shared_ptr<jimple_method_field>> members;
127
128private:
129 std::map<std::string, statement> from_map = {
130 {"Variable", statement::Declaration},
131 {"identity", statement::Identity},
132 {"StaticInvoke", statement::StaticInvoke},
133 {"SpecialInvoke", statement::SpecialInvoke},
134 {"VirtualInvoke", statement::VirtualInvoke},
135 {"Return", statement::Return},
136 {"Label", statement::Label},
137 {"Goto", statement::Goto},
138 {"SetVariable", statement::Assignment},
139 {"If", statement::If},
140 {"Throw", statement::Throw},
141 {"Location", statement::Location}};
142
143 std::map<statement, std::string> to_map = {
144 {statement::Identity, "Identity"},
145 {statement::StaticInvoke, "StaticInvoke"},
146 {statement::SpecialInvoke, "SpecialInvoke"},
147 {statement::VirtualInvoke, "VirtualInvoke"},
148 {statement::Return, "Return"},
149 {statement::Label, "Label"},
150 {statement::Goto, "Goto"},
151 {statement::Assignment, "Assignment"},
152 {statement::If, "If"},
153 {statement::Declaration, "Declaration"},
154 {statement::Throw, "Throw"},
155 {statement::Location, "Location"}};
156};
157
158#endif // ESBMC_JIMPLE_METHOD_BODY_H
Definition std_code.h:69
Definition context.h:57
Definition expr.h:34
bool is_nil() const
Definition irep.h:46
Base interface for Jimple AST.
Definition jimple_ast.h:19
A Jimple method definition.
Definition jimple_method_body.h:90
A Jimple method definition.
Definition jimple_method_body.h:99
virtual void from_json(const json &j) override
Initializes the current instance by parsing a JSON.
Definition jimple_method_body.cpp:45
virtual expr2tc to_code2t(contextt &ctx, const std::string &class_name, const std::string &function_name) const override
The IREP2 form of the body, for symbolt::set_value(const expr2tc &).
Definition jimple_method_body.cpp:14
statement
Definition jimple_method_body.h:109
@ SpecialInvoke
Definition jimple_method_body.h:114
@ StaticInvoke
Definition jimple_method_body.h:113
@ Declaration
Definition jimple_method_body.h:121
@ If
Definition jimple_method_body.h:120
@ Throw
Definition jimple_method_body.h:122
@ Return
Definition jimple_method_body.h:117
@ Goto
Definition jimple_method_body.h:119
@ Label
Definition jimple_method_body.h:118
@ VirtualInvoke
Definition jimple_method_body.h:116
@ Identity
Definition jimple_method_body.h:111
@ Location
Definition jimple_method_body.h:123
@ Assignment
Definition jimple_method_body.h:110
virtual std::string to_string() const override
Converts the object into a string.
Definition jimple_method_body.cpp:175
std::vector< std::shared_ptr< jimple_method_field > > members
Definition jimple_method_body.h:126
A Jimple method declaration.
Definition jimple_method_body.h:14
virtual exprt to_exprt(contextt &, const std::string &, const std::string &) const
Definition jimple_method_body.h:17
virtual expr2tc to_code2t(contextt &ctx, const std::string &class_name, const std::string &function_name) const
The IREP2 form of the body, for symbolt::set_value(const expr2tc &).
Definition jimple_method_body.h:31
The contents of a Jimple method.
Definition jimple_method_body.h:48
virtual exprt to_exprt(contextt &, const std::string &, const std::string &) const
Definition jimple_method_body.h:51
virtual expr2tc to_code2t(contextt &ctx, const std::string &class_name, const std::string &function_name, const locationt &loc) const
The IREP2 form of this statement, located at loc.
Definition jimple_method_body.h:67
Definition location.h:7
irep_container< expr2t > expr2tc
Definition irep2.h:431
nlohmann::json json
Definition json.cpp:12
void migrate_expr(const exprt &expr, expr2tc &new_expr_ref)
Definition migrate.cpp:1512