Predator
[unstable] git snapshot
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
adt_op.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2013 Kamil Dudka <kdudka@redhat.com>
3
*
4
* This file is part of predator.
5
*
6
* predator is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* any later version.
10
*
11
* predator is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with predator. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#ifndef H_GUARD_ADT_OP_H
21
#define H_GUARD_ADT_OP_H
22
23
#include "
clean_list.hh
"
24
#include "
symheap.hh
"
25
#include "
shape.hh
"
26
27
#include <utility>
// for std::pair
28
29
namespace
AdtOp {
30
31
/// (preferred) search direction
32
enum
ESearchDirection
{
33
SD_INVALID
= 0,
34
SD_FORWARD
,
/// search forward along the CFG
35
SD_BACKWARD
/// search backward along the CFG
36
};
37
38
typedef
int
TTemplateIdx
;
39
typedef
int
TFootprintIdx
;
40
typedef
std::pair<TTemplateIdx, TFootprintIdx>
TFootprintIdent
;
41
42
/// operation footprint given by an input/output template pair
43
struct
OpFootprint
{
44
SymHeap
input
;
45
SymHeap
output
;
46
47
TObjList
inArgs
;
48
TObjList
outArgs
;
49
50
OpFootprint
(
const
SymHeap
&input_,
const
SymHeap
&output_);
51
};
52
53
/// an operation (push_back, erase, ...) template we can match by footprints
54
class
OpTemplate
{
55
public
:
56
/// @name a human-readable name of the operation
57
OpTemplate
(
const
std::string &
name
):
58
name_
(name),
59
dirty_
(false)
60
{
61
}
62
63
const
std::string&
name
()
const
{
64
return
name_
;
65
}
66
67
TFootprintIdx
size
()
const
{
68
return
fList_
.
size
();
69
}
70
71
const
OpFootprint
&
operator[]
(
TFootprintIdx
idx)
const
{
72
return
*
fList_
[idx];
73
}
74
75
/// takes ownership of *footprint and will release it on destruction
76
void
addFootprint
(
OpFootprint
*footprint) {
77
fList_
.
append
(footprint);
78
dirty_
=
true
;
79
}
80
81
const
TShapeListByHeapIdx
&
inShapes
()
const
{
82
this->
updateMetaIfNeeded
();
83
return
inShapes_
;
84
}
85
86
const
TShapeListByHeapIdx
&
outShapes
()
const
{
87
this->
updateMetaIfNeeded
();
88
return
outShapes_
;
89
}
90
91
ESearchDirection
searchDirection
()
const
{
92
this->
updateMetaIfNeeded
();
93
return
searchDirection_
;
94
}
95
96
void
plot
()
const
;
97
98
private
:
99
const
std::string
name_
;
100
CleanList<OpFootprint>
fList_
;
101
mutable
bool
dirty_
;
102
mutable
TShapeListByHeapIdx
inShapes_
;
103
mutable
TShapeListByHeapIdx
outShapes_
;
104
mutable
ESearchDirection
searchDirection_
;
105
106
void
updateMetaIfNeeded
()
const
;
107
};
108
109
/// collection of operation templates
110
class
OpCollection
{
111
public
:
112
TTemplateIdx
size
()
const
{
113
return
tList_
.
size
();
114
}
115
116
const
OpTemplate
&
operator[]
(
TTemplateIdx
idx)
const
{
117
return
*
tList_
[idx];
118
}
119
120
/// takes ownership of *tpl and will release it on destruction
121
void
addTemplate
(
OpTemplate
*tpl) {
122
tList_
.
append
(tpl);
123
}
124
125
void
plot
()
const
;
126
127
private
:
128
CleanList<OpTemplate>
tList_
;
129
};
130
131
}
// namespace AdtOp
132
133
#endif
/* H_GUARD_ADT_OP_H */
Generated on Mon Nov 9 2015 14:51:59 for Predator by
1.8.1.2