Code Listener
[unstable] git snapshot
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
clf_opchk.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2009 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_CLF_OPCHK_H
21
#define H_GUARD_CLF_OPCHK_H
22
23
#include "
cl_filter.hh
"
24
#include "cl_private.hh"
25
26
class
ClfOpCheckerBase
:
public
ClFilterBase
{
27
public
:
28
ClfOpCheckerBase
(
ICodeListener
*slave);
29
30
protected
:
31
const
struct
cl_loc
*
lastLocation
()
const
{
32
return
&
loc_
;
33
}
34
35
protected
:
36
/**
37
* @note design pattern @b template @b method
38
*/
39
virtual
void
checkDstOperand
(
const
struct
cl_operand
*) = 0;
40
41
/**
42
* @note design pattern @b template @b method
43
*/
44
virtual
void
checkSrcOperand
(
const
struct
cl_operand
*) = 0;
45
46
public
:
47
virtual
void
file_open
(
48
const
char
*file_name)
49
{
50
CL_LOC_SET_FILE(
loc_
, file_name);
51
ClFilterBase::file_open
(file_name);
52
}
53
54
virtual
void
fnc_open
(
55
const
struct
cl_operand
*fnc)
56
{
57
loc_
= fnc->
data
.
cst
.
data
.
cst_fnc
.loc;
58
ClFilterBase::fnc_open
(fnc);
59
}
60
61
virtual
void
fnc_arg_decl
(
62
int
arg_id,
63
const
struct
cl_operand
*arg_src)
64
{
65
this->
handleDstSrc
(arg_src);
66
ClFilterBase::fnc_arg_decl
(arg_id, arg_src);
67
}
68
69
virtual
void
insn
(
70
const
struct
cl_insn
*cli)
71
{
72
loc_
= cli->
loc
;
73
74
switch
(cli->
code
) {
75
case
CL_INSN_COND
:
76
this->
handleSrc
(cli->
data
.
insn_cond
.src);
77
break
;
78
79
case
CL_INSN_RET
:
80
this->
handleSrc
(cli->
data
.
insn_ret
.src);
81
break
;
82
83
case
CL_INSN_UNOP
:
84
this->
handleDstSrc
(cli->
data
.
insn_unop
.dst);
85
this->
handleSrc
(cli->
data
.
insn_unop
.src);
86
break
;
87
88
case
CL_INSN_BINOP
:
89
this->
handleDstSrc
(cli->
data
.
insn_binop
.dst);
90
this->
handleSrc
(cli->
data
.
insn_binop
.src1);
91
this->
handleSrc
(cli->
data
.
insn_binop
.src2);
92
break
;
93
94
default
:
95
break
;
96
}
97
98
ClFilterBase::insn
(cli);
99
}
100
101
virtual
void
insn_call_open
(
102
const
struct
cl_loc
*loc,
103
const
struct
cl_operand
*dst,
104
const
struct
cl_operand
*fnc)
105
{
106
CL_LOC_SETIF(
loc_
, loc);
107
this->
handleDstSrc
(dst);
108
this->
handleSrc
(fnc);
109
ClFilterBase::insn_call_open
(loc, dst, fnc);
110
}
111
112
virtual
void
insn_call_arg
(
113
int
arg_id,
114
const
struct
cl_operand
*arg_src)
115
{
116
this->
handleSrc
(arg_src);
117
ClFilterBase::insn_call_arg
(arg_id, arg_src);
118
}
119
120
virtual
void
insn_switch_open
(
121
const
struct
cl_loc
*loc,
122
const
struct
cl_operand
*src)
123
{
124
CL_LOC_SETIF(
loc_
, loc);
125
this->
handleSrc
(src);
126
ClFilterBase::insn_switch_open
(loc, src);
127
}
128
129
private
:
130
struct
cl_loc
loc_
;
131
132
private
:
133
void
handleArrayIdx
(
const
struct
cl_operand
*);
134
void
handleSrc
(
const
struct
cl_operand
*);
135
void
handleDstSrc
(
const
struct
cl_operand
*);
136
};
137
138
#endif
/* H_GUARD_CLF_OPCHK_H */
Generated on Tue Nov 5 2013 22:26:58 for Code Listener by
1.8.4