Code Listener  [unstable] git snapshot
cl_storage.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_CL_STORAGE_H
21 #define H_GUARD_CL_STORAGE_H
22 
23 /**
24  * @file cl_storage.hh
25  * ClStorageBuilder - base class for CodeStorage based code listeners
26  */
27 
28 #include "cl.hh"
29 
30 namespace CodeStorage {
31  struct Storage;
32  struct Insn;
33 
34  void destroyInsn(Insn *insn);
35 }
36 
37 /**
38  * base class for all CodeStorage based code listeners, see run()
39  * @note design pattern @b template @b method
40  */
42  protected:
44 
45  /**
46  * once the Storage model is built this @b template @b method is called
47  * to process its content, run some analysis, etc.
48  */
49  virtual void run(CodeStorage::Storage &) = 0;
50 
51  public:
52  virtual ~ClStorageBuilder();
53 
54  virtual void file_open(
55  const char *file_name);
56 
57  virtual void file_close();
58 
59  virtual void fnc_open(
60  const struct cl_operand *fnc);
61 
62  virtual void fnc_arg_decl(
63  int arg_id,
64  const struct cl_operand *arg_src);
65 
66  virtual void fnc_close();
67 
68  virtual void bb_open(
69  const char *bb_name);
70 
71  virtual void insn(
72  const struct cl_insn *cli);
73 
74  virtual void insn_call_open(
75  const struct cl_loc *loc,
76  const struct cl_operand *dst,
77  const struct cl_operand *fnc);
78 
79  virtual void insn_call_arg(
80  int arg_id,
81  const struct cl_operand *arg_src);
82 
83  virtual void insn_call_close();
84 
85  virtual void insn_switch_open(
86  const struct cl_loc *loc,
87  const struct cl_operand *src);
88 
89  virtual void insn_switch_case(
90  const struct cl_loc *loc,
91  const struct cl_operand *val_lo,
92  const struct cl_operand *val_hi,
93  const char *label);
94 
95  virtual void insn_switch_close();
96 
97  virtual void acknowledge();
98 
99  private:
100  struct Private;
101  Private *d;
102 };
103 
104 #endif /* H_GUARD_CL_STORAGE_H */