blob: 99c3e41f9f91dbea406491f84a32c328c3085739 [file] [log] [blame]
Reid Spencerdac69c82004-06-07 17:53:43 +00001//===-- BytecodeHandler.cpp - Parsing Handler -------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Reid Spencer and is distributed under the
6// University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This header file defines the BytecodeHandler class that gets called by the
11// AbstractBytecodeParser when parsing events occur.
12//
13//===----------------------------------------------------------------------===//
14
15#include "AnalyzerInternals.h"
16
17using namespace llvm;
18
19
20namespace {
21
22class AnalyzerHandler : public BytecodeHandler {
23public:
24 bool handleError(const std::string& str )
25 {
26 return false;
27 }
28
29 void handleStart()
30 {
31 }
32
33 void handleFinish()
34 {
35 }
36
37 void handleModuleBegin(const std::string& id)
38 {
39 }
40
41 void handleModuleEnd(const std::string& id)
42 {
43 }
44
45 void handleVersionInfo(
46 unsigned char RevisionNum, ///< Byte code revision number
47 Module::Endianness Endianness, ///< Endianness indicator
48 Module::PointerSize PointerSize ///< PointerSize indicator
49 )
50 {
51 }
52
53 void handleModuleGlobalsBegin()
54 {
55 }
56
57 void handleGlobalVariable(
58 const Type* ElemType, ///< The type of the global variable
59 bool isConstant, ///< Whether the GV is constant or not
60 GlobalValue::LinkageTypes ///< The linkage type of the GV
61 )
62 {
63 }
64
65 void handleInitializedGV(
66 const Type* ElemType, ///< The type of the global variable
67 bool isConstant, ///< Whether the GV is constant or not
68 GlobalValue::LinkageTypes,///< The linkage type of the GV
69 unsigned initSlot ///< Slot number of GV's initializer
70 )
71 {
72 }
73
74 virtual void handleType( const Type* Ty )
75 {
76 }
77
78 void handleFunctionDeclaration(
79 const Type* FuncType ///< The type of the function
80 )
81 {
82 }
83
84 void handleModuleGlobalsEnd()
85 {
86 }
87
88 void handleCompactionTableBegin()
89 {
90 }
91
92 void handleCompactionTablePlane(
93 unsigned Ty,
94 unsigned NumEntries
95 )
96 {
97 }
98
99 void handleCompactionTableType(
100 unsigned i,
101 unsigned TypSlot,
102 const Type*
103 )
104 {
105 }
106
107 void handleCompactionTableValue(
108 unsigned i,
109 unsigned ValSlot,
110 const Type*
111 )
112 {
113 }
114
115 void handleCompactionTableEnd()
116 {
117 }
118
119 void handleSymbolTableBegin()
120 {
121 }
122
123 void handleSymbolTablePlane(
124 unsigned Ty,
125 unsigned NumEntries,
126 const Type* Typ
127 )
128 {
129 }
130
131 void handleSymbolTableType(
132 unsigned i,
133 unsigned slot,
134 const std::string& name
135 )
136 {
137 }
138
139 void handleSymbolTableValue(
140 unsigned i,
141 unsigned slot,
142 const std::string& name
143 )
144 {
145 }
146
147 void handleSymbolTableEnd()
148 {
149 }
150
151 void handleFunctionBegin(
152 const Type* FType,
153 GlobalValue::LinkageTypes linkage
154 )
155 {
156 }
157
158 void handleFunctionEnd(
159 const Type* FType
160 )
161 {
162 }
163
164 void handleBasicBlockBegin(
165 unsigned blocknum
166 )
167 {
168 }
169
170 bool handleInstruction(
171 unsigned Opcode,
172 const Type* iType,
173 std::vector<unsigned>& Operands
174 )
175 {
176 return false;
177 }
178
179 void handleBasicBlockEnd(unsigned blocknum)
180 {
181 }
182
183 void handleGlobalConstantsBegin()
184 {
185 }
186
187 void handleConstantExpression(
188 unsigned Opcode,
189 const Type* Typ,
190 std::vector<std::pair<const Type*,unsigned> > ArgVec
191 )
192 {
193 }
194
195 void handleConstantValue( Constant * c )
196 {
197 }
198
199 void handleConstantArray(
200 const ArrayType* AT,
201 std::vector<unsigned>& Elements )
202 {
203 }
204
205 void handleConstantStruct(
206 const StructType* ST,
207 std::vector<unsigned>& ElementSlots)
208 {
209 }
210
211 void handleConstantPointer(
212 const PointerType* PT, unsigned Slot)
213 {
214 }
215
216 void handleConstantString( const ConstantArray* CA )
217 {
218 }
219
220
221 void handleGlobalConstantsEnd()
222 {
223 }
224
225};
226
227}
228
229void llvm::BytecodeAnalyzer::AnalyzeBytecode(
230 const unsigned char *Buf,
231 unsigned Length,
232 BytecodeAnalysis& bca,
233 const std::string &ModuleID
234)
235{
236 AnalyzerHandler TheHandler;
237 AbstractBytecodeParser TheParser(&TheHandler);
238 TheParser.ParseBytecode( Buf, Length, ModuleID );
239 TheParser.ParseAllFunctionBodies();
240}
241
242// vim: sw=2