blob: ad27739bb2bd5f113ea84976d00d2475a152b60a [file] [log] [blame]
Chris Lattnere9bb2df2001-12-03 22:26:30 +00001//===- ReadConst.cpp - Code to constants and constant pools ---------------===//
Chris Lattner00950542001-06-06 20:29:01 +00002//
3// This file implements functionality to deserialize constants and entire
4// constant pools.
5//
6// Note that this library should be as fast as possible, reentrant, and
7// threadsafe!!
8//
Chris Lattnere9bb2df2001-12-03 22:26:30 +00009//===----------------------------------------------------------------------===//
Chris Lattner00950542001-06-06 20:29:01 +000010
Chris Lattner7061dc52001-12-03 18:02:31 +000011#include "ReaderInternals.h"
Chris Lattner00950542001-06-06 20:29:01 +000012#include "llvm/Module.h"
Chris Lattner31bcdb82002-04-28 19:55:58 +000013#include "llvm/Constants.h"
Chris Lattner05950c32001-10-13 06:47:01 +000014#include "llvm/GlobalVariable.h"
Chris Lattner1d670cc2001-09-07 16:37:43 +000015#include <algorithm>
Chris Lattner697954c2002-01-20 22:54:45 +000016#include <iostream>
17using std::make_pair;
18using std::cerr;
Chris Lattner1d670cc2001-09-07 16:37:43 +000019
20const Type *BytecodeParser::parseTypeConstant(const uchar *&Buf,
21 const uchar *EndBuf) {
Chris Lattner00950542001-06-06 20:29:01 +000022 unsigned PrimType;
Chris Lattner1d670cc2001-09-07 16:37:43 +000023 if (read_vbr(Buf, EndBuf, PrimType)) return failure<const Type*>(0);
Chris Lattner00950542001-06-06 20:29:01 +000024
Chris Lattner1d670cc2001-09-07 16:37:43 +000025 const Type *Val = 0;
26 if ((Val = Type::getPrimitiveType((Type::PrimitiveID)PrimType)))
27 return Val;
Chris Lattner00950542001-06-06 20:29:01 +000028
29 switch (PrimType) {
Chris Lattnerc9aa7df2002-03-29 03:51:11 +000030 case Type::FunctionTyID: {
Chris Lattner00950542001-06-06 20:29:01 +000031 unsigned Typ;
Chris Lattner1d670cc2001-09-07 16:37:43 +000032 if (read_vbr(Buf, EndBuf, Typ)) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000033 const Type *RetType = getType(Typ);
Chris Lattner1d670cc2001-09-07 16:37:43 +000034 if (RetType == 0) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000035
Chris Lattnere5a57ee2001-07-25 22:47:55 +000036 unsigned NumParams;
Chris Lattner1d670cc2001-09-07 16:37:43 +000037 if (read_vbr(Buf, EndBuf, NumParams)) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000038
Chris Lattner697954c2002-01-20 22:54:45 +000039 std::vector<const Type*> Params;
Chris Lattnere5a57ee2001-07-25 22:47:55 +000040 while (NumParams--) {
Chris Lattner1d670cc2001-09-07 16:37:43 +000041 if (read_vbr(Buf, EndBuf, Typ)) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000042 const Type *Ty = getType(Typ);
Chris Lattner1d670cc2001-09-07 16:37:43 +000043 if (Ty == 0) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000044 Params.push_back(Ty);
Chris Lattner00950542001-06-06 20:29:01 +000045 }
46
Chris Lattner05950c32001-10-13 06:47:01 +000047 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
48 if (isVarArg) Params.pop_back();
49
Chris Lattnerc9aa7df2002-03-29 03:51:11 +000050 return FunctionType::get(RetType, Params, isVarArg);
Chris Lattner00950542001-06-06 20:29:01 +000051 }
52 case Type::ArrayTyID: {
53 unsigned ElTyp;
Chris Lattner1d670cc2001-09-07 16:37:43 +000054 if (read_vbr(Buf, EndBuf, ElTyp)) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000055 const Type *ElementType = getType(ElTyp);
Chris Lattner1d670cc2001-09-07 16:37:43 +000056 if (ElementType == 0) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000057
Chris Lattner90865152001-12-14 16:30:51 +000058 unsigned NumElements;
Chris Lattner1d670cc2001-09-07 16:37:43 +000059 if (read_vbr(Buf, EndBuf, NumElements)) return failure(Val);
Chris Lattner7eadfa12001-10-24 06:21:22 +000060
61 BCR_TRACE(5, "Array Type Constant #" << ElTyp << " size="
Chris Lattner697954c2002-01-20 22:54:45 +000062 << NumElements << "\n");
Chris Lattner7eadfa12001-10-24 06:21:22 +000063 return ArrayType::get(ElementType, NumElements);
Chris Lattner00950542001-06-06 20:29:01 +000064 }
65 case Type::StructTyID: {
66 unsigned Typ;
Chris Lattner697954c2002-01-20 22:54:45 +000067 std::vector<const Type*> Elements;
Chris Lattner00950542001-06-06 20:29:01 +000068
Chris Lattner1d670cc2001-09-07 16:37:43 +000069 if (read_vbr(Buf, EndBuf, Typ)) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000070 while (Typ) { // List is terminated by void/0 typeid
71 const Type *Ty = getType(Typ);
Chris Lattner1d670cc2001-09-07 16:37:43 +000072 if (Ty == 0) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000073 Elements.push_back(Ty);
74
Chris Lattner1d670cc2001-09-07 16:37:43 +000075 if (read_vbr(Buf, EndBuf, Typ)) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000076 }
77
Chris Lattner7eadfa12001-10-24 06:21:22 +000078 return StructType::get(Elements);
Chris Lattner00950542001-06-06 20:29:01 +000079 }
80 case Type::PointerTyID: {
81 unsigned ElTyp;
Chris Lattner1d670cc2001-09-07 16:37:43 +000082 if (read_vbr(Buf, EndBuf, ElTyp)) return failure(Val);
Chris Lattner697954c2002-01-20 22:54:45 +000083 BCR_TRACE(5, "Pointer Type Constant #" << (ElTyp-14) << "\n");
Chris Lattner00950542001-06-06 20:29:01 +000084 const Type *ElementType = getType(ElTyp);
Chris Lattner1d670cc2001-09-07 16:37:43 +000085 if (ElementType == 0) return failure(Val);
Chris Lattner7eadfa12001-10-24 06:21:22 +000086 return PointerType::get(ElementType);
Chris Lattner00950542001-06-06 20:29:01 +000087 }
88
Chris Lattnerd48d6c72001-10-23 01:53:01 +000089 case Type::OpaqueTyID: {
Chris Lattner7eadfa12001-10-24 06:21:22 +000090 return OpaqueType::get();
Chris Lattnerd48d6c72001-10-23 01:53:01 +000091 }
92
Chris Lattner00950542001-06-06 20:29:01 +000093 default:
94 cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to deserialize"
Chris Lattner7eadfa12001-10-24 06:21:22 +000095 << " primitive Type " << PrimType << "\n";
Chris Lattner1d670cc2001-09-07 16:37:43 +000096 return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000097 }
Chris Lattner1d670cc2001-09-07 16:37:43 +000098}
99
100// refineAbstractType - The callback method is invoked when one of the
101// elements of TypeValues becomes more concrete...
102//
103void BytecodeParser::refineAbstractType(const DerivedType *OldType,
104 const Type *NewType) {
Chris Lattnere244a252001-11-03 03:27:53 +0000105 if (OldType == NewType &&
106 OldType->isAbstract()) return; // Type is modified, but same
Chris Lattner05950c32001-10-13 06:47:01 +0000107
Chris Lattner1d670cc2001-09-07 16:37:43 +0000108 TypeValuesListTy::iterator I = find(MethodTypeValues.begin(),
109 MethodTypeValues.end(), OldType);
110 if (I == MethodTypeValues.end()) {
111 I = find(ModuleTypeValues.begin(), ModuleTypeValues.end(), OldType);
112 assert(I != ModuleTypeValues.end() &&
113 "Can't refine a type I don't know about!");
114 }
115
Chris Lattnere244a252001-11-03 03:27:53 +0000116 if (OldType == NewType) {
117 assert(!OldType->isAbstract());
118 I->removeUserFromConcrete();
119 } else {
120 *I = NewType; // Update to point to new, more refined type.
121 }
Chris Lattner1d670cc2001-09-07 16:37:43 +0000122}
123
124
125
126// parseTypeConstants - We have to use this wierd code to handle recursive
127// types. We know that recursive types will only reference the current slab of
128// values in the type plane, but they can forward reference types before they
129// have been read. For example, Type #0 might be '{ Ty#1 }' and Type #1 might
130// be 'Ty#0*'. When reading Type #0, type number one doesn't exist. To fix
131// this ugly problem, we pesimistically insert an opaque type for each type we
132// are about to read. This means that forward references will resolve to
133// something and when we reread the type later, we can replace the opaque type
134// with a new resolved concrete type.
135//
Chris Lattner92940ac2002-04-07 06:11:22 +0000136void debug_type_tables();
Chris Lattner1d670cc2001-09-07 16:37:43 +0000137bool BytecodeParser::parseTypeConstants(const uchar *&Buf, const uchar *EndBuf,
138 TypeValuesListTy &Tab,
139 unsigned NumEntries) {
Chris Lattner05950c32001-10-13 06:47:01 +0000140 assert(Tab.size() == 0 && "should not have read type constants in before!");
Chris Lattner1d670cc2001-09-07 16:37:43 +0000141
142 // Insert a bunch of opaque types to be resolved later...
Chris Lattner7eadfa12001-10-24 06:21:22 +0000143 for (unsigned i = 0; i < NumEntries; ++i)
Chris Lattner1d670cc2001-09-07 16:37:43 +0000144 Tab.push_back(PATypeHandle<Type>(OpaqueType::get(), this));
145
146 // Loop through reading all of the types. Forward types will make use of the
147 // opaque types just inserted.
148 //
Chris Lattner7eadfa12001-10-24 06:21:22 +0000149 for (unsigned i = 0; i < NumEntries; ++i) {
Chris Lattner05950c32001-10-13 06:47:01 +0000150 const Type *NewTy = parseTypeConstant(Buf, EndBuf), *OldTy = Tab[i].get();
Chris Lattner1d670cc2001-09-07 16:37:43 +0000151 if (NewTy == 0) return failure(true);
Chris Lattner7eadfa12001-10-24 06:21:22 +0000152 BCR_TRACE(4, "#" << i << ": Read Type Constant: '" << NewTy <<
153 "' Replacing: " << OldTy << "\n");
Chris Lattner1d670cc2001-09-07 16:37:43 +0000154
155 // Don't insertValue the new type... instead we want to replace the opaque
156 // type with the new concrete value...
157 //
158
159 // Refine the abstract type to the new type. This causes all uses of the
160 // abstract type to use the newty. This also will cause the opaque type
161 // to be deleted...
162 //
Chris Lattnera48836b2002-06-05 17:38:28 +0000163 ((DerivedType*)Tab[i].get())->refineAbstractTypeTo(NewTy);
Chris Lattner1d670cc2001-09-07 16:37:43 +0000164
165 // This should have replace the old opaque type with the new type in the
Chris Lattner05950c32001-10-13 06:47:01 +0000166 // value table... or with a preexisting type that was already in the system
167 assert(Tab[i] != OldTy && "refineAbstractType didn't work!");
Chris Lattner1d670cc2001-09-07 16:37:43 +0000168 }
169
170 BCR_TRACE(5, "Resulting types:\n");
Chris Lattner7eadfa12001-10-24 06:21:22 +0000171 for (unsigned i = 0; i < NumEntries; ++i) {
Chris Lattner92940ac2002-04-07 06:11:22 +0000172 BCR_TRACE(5, (void*)Tab[i].get() << " - " << Tab[i].get() << "\n");
Chris Lattner1d670cc2001-09-07 16:37:43 +0000173 }
Chris Lattner92940ac2002-04-07 06:11:22 +0000174 debug_type_tables();
Chris Lattner00950542001-06-06 20:29:01 +0000175 return false;
176}
177
Chris Lattner1d670cc2001-09-07 16:37:43 +0000178
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000179bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf,
180 const Type *Ty, Constant *&V) {
Chris Lattner00950542001-06-06 20:29:01 +0000181 switch (Ty->getPrimitiveID()) {
182 case Type::BoolTyID: {
183 unsigned Val;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000184 if (read_vbr(Buf, EndBuf, Val)) return failure(true);
185 if (Val != 0 && Val != 1) return failure(true);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000186 V = ConstantBool::get(Val == 1);
Chris Lattner00950542001-06-06 20:29:01 +0000187 break;
188 }
189
190 case Type::UByteTyID: // Unsigned integer types...
191 case Type::UShortTyID:
192 case Type::UIntTyID: {
193 unsigned Val;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000194 if (read_vbr(Buf, EndBuf, Val)) return failure(true);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000195 if (!ConstantUInt::isValueValidForType(Ty, Val)) return failure(true);
196 V = ConstantUInt::get(Ty, Val);
Chris Lattner00950542001-06-06 20:29:01 +0000197 break;
198 }
199
200 case Type::ULongTyID: {
201 uint64_t Val;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000202 if (read_vbr(Buf, EndBuf, Val)) return failure(true);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000203 V = ConstantUInt::get(Ty, Val);
Chris Lattner00950542001-06-06 20:29:01 +0000204 break;
205 }
206
207 case Type::SByteTyID: // Unsigned integer types...
208 case Type::ShortTyID:
209 case Type::IntTyID: {
210 int Val;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000211 if (read_vbr(Buf, EndBuf, Val)) return failure(true);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000212 if (!ConstantSInt::isValueValidForType(Ty, Val)) return failure(true);
213 V = ConstantSInt::get(Ty, Val);
Chris Lattner00950542001-06-06 20:29:01 +0000214 break;
215 }
216
217 case Type::LongTyID: {
218 int64_t Val;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000219 if (read_vbr(Buf, EndBuf, Val)) return failure(true);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000220 V = ConstantSInt::get(Ty, Val);
Chris Lattner00950542001-06-06 20:29:01 +0000221 break;
222 }
223
Chris Lattnera1375302001-07-15 00:17:18 +0000224 case Type::FloatTyID: {
225 float F;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000226 if (input_data(Buf, EndBuf, &F, &F+1)) return failure(true);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000227 V = ConstantFP::get(Ty, F);
Chris Lattnera1375302001-07-15 00:17:18 +0000228 break;
229 }
230
231 case Type::DoubleTyID: {
232 double Val;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000233 if (input_data(Buf, EndBuf, &Val, &Val+1)) return failure(true);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000234 V = ConstantFP::get(Ty, Val);
Chris Lattnera1375302001-07-15 00:17:18 +0000235 break;
236 }
237
Chris Lattner00950542001-06-06 20:29:01 +0000238 case Type::TypeTyID:
Chris Lattner1d670cc2001-09-07 16:37:43 +0000239 assert(0 && "Type constants should be handled seperately!!!");
240 abort();
Chris Lattner00950542001-06-06 20:29:01 +0000241
242 case Type::ArrayTyID: {
Chris Lattnerb00c5822001-10-02 03:41:24 +0000243 const ArrayType *AT = cast<const ArrayType>(Ty);
Chris Lattner90865152001-12-14 16:30:51 +0000244 unsigned NumElements = AT->getNumElements();
Chris Lattner00950542001-06-06 20:29:01 +0000245
Chris Lattner697954c2002-01-20 22:54:45 +0000246 std::vector<Constant*> Elements;
Chris Lattner00950542001-06-06 20:29:01 +0000247 while (NumElements--) { // Read all of the elements of the constant.
248 unsigned Slot;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000249 if (read_vbr(Buf, EndBuf, Slot)) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +0000250 Value *V = getValue(AT->getElementType(), Slot, false);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000251 if (!V || !isa<Constant>(V)) return failure(true);
252 Elements.push_back(cast<Constant>(V));
Chris Lattner00950542001-06-06 20:29:01 +0000253 }
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000254 V = ConstantArray::get(AT, Elements);
Chris Lattner00950542001-06-06 20:29:01 +0000255 break;
256 }
257
258 case Type::StructTyID: {
Chris Lattnerb00c5822001-10-02 03:41:24 +0000259 const StructType *ST = cast<StructType>(Ty);
Chris Lattner00950542001-06-06 20:29:01 +0000260 const StructType::ElementTypes &ET = ST->getElementTypes();
261
Chris Lattner697954c2002-01-20 22:54:45 +0000262 std::vector<Constant *> Elements;
Chris Lattner00950542001-06-06 20:29:01 +0000263 for (unsigned i = 0; i < ET.size(); ++i) {
264 unsigned Slot;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000265 if (read_vbr(Buf, EndBuf, Slot)) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +0000266 Value *V = getValue(ET[i], Slot, false);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000267 if (!V || !isa<Constant>(V))
Chris Lattner3d3f2892001-07-28 17:50:18 +0000268 return failure(true);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000269 Elements.push_back(cast<Constant>(V));
Chris Lattner00950542001-06-06 20:29:01 +0000270 }
271
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000272 V = ConstantStruct::get(ST, Elements);
Chris Lattner00950542001-06-06 20:29:01 +0000273 break;
274 }
275
Chris Lattner1a1cb112001-09-30 22:46:54 +0000276 case Type::PointerTyID: {
Chris Lattnerb00c5822001-10-02 03:41:24 +0000277 const PointerType *PT = cast<const PointerType>(Ty);
Chris Lattner1a1cb112001-09-30 22:46:54 +0000278 unsigned SubClass;
279 if (read_vbr(Buf, EndBuf, SubClass)) return failure(true);
Chris Lattner05950c32001-10-13 06:47:01 +0000280 switch (SubClass) {
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000281 case 0: // ConstantPointerNull value...
282 V = ConstantPointerNull::get(PT);
Chris Lattner05950c32001-10-13 06:47:01 +0000283 break;
Chris Lattner1a1cb112001-09-30 22:46:54 +0000284
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000285 case 1: { // ConstantPointerRef value...
Chris Lattner05950c32001-10-13 06:47:01 +0000286 unsigned Slot;
287 if (read_vbr(Buf, EndBuf, Slot)) return failure(true);
288 BCR_TRACE(4, "CPPR: Type: '" << Ty << "' slot: " << Slot << "\n");
Chris Lattner1a1cb112001-09-30 22:46:54 +0000289
Chris Lattner05950c32001-10-13 06:47:01 +0000290 // Check to see if we have already read this global variable yet...
291 Value *Val = getValue(PT, Slot, false);
292 GlobalValue *GV;
293 if (Val) {
294 if (!(GV = dyn_cast<GlobalValue>(Val))) return failure(true);
295 BCR_TRACE(5, "Value Found in ValueTable!\n");
296 } else { // Nope... see if we have previously forward ref'd it
297 GlobalRefsType::iterator I = GlobalRefs.find(make_pair(PT, Slot));
298 if (I != GlobalRefs.end()) {
299 BCR_TRACE(5, "Previous forward ref found!\n");
300 GV = I->second;
301 } else {
302 BCR_TRACE(5, "Creating new forward ref variable!\n");
303
304 // Create a placeholder for the global variable reference...
Chris Lattnerd23b1d32001-11-26 18:56:10 +0000305 GlobalVariable *GVar =
Chris Lattner7a176752001-12-04 00:03:30 +0000306 new GlobalVariable(PT->getElementType(), false, true);
Chris Lattner05950c32001-10-13 06:47:01 +0000307
308 // Keep track of the fact that we have a forward ref to recycle it
309 GlobalRefs.insert(make_pair(make_pair(PT, Slot), GVar));
310
311 // Must temporarily push this value into the module table...
312 TheModule->getGlobalList().push_back(GVar);
313 GV = GVar;
314 }
315 }
316
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000317 V = ConstantPointerRef::get(GV);
Chris Lattner05950c32001-10-13 06:47:01 +0000318 break;
319 }
320 default:
Chris Lattner90865152001-12-14 16:30:51 +0000321 BCR_TRACE(5, "UNKNOWN Pointer Constant Type!\n");
Chris Lattner05950c32001-10-13 06:47:01 +0000322 return failure(true);
323 }
Chris Lattner1a1cb112001-09-30 22:46:54 +0000324 break;
325 }
326
Chris Lattner00950542001-06-06 20:29:01 +0000327 default:
328 cerr << __FILE__ << ":" << __LINE__
329 << ": Don't know how to deserialize constant value of type '"
330 << Ty->getName() << "'\n";
Chris Lattner3d3f2892001-07-28 17:50:18 +0000331 return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +0000332 }
Chris Lattner1d670cc2001-09-07 16:37:43 +0000333
Chris Lattner00950542001-06-06 20:29:01 +0000334 return false;
335}
336
337bool BytecodeParser::ParseConstantPool(const uchar *&Buf, const uchar *EndBuf,
Chris Lattner1d670cc2001-09-07 16:37:43 +0000338 ValueTable &Tab,
339 TypeValuesListTy &TypeTab) {
Chris Lattner00950542001-06-06 20:29:01 +0000340 while (Buf < EndBuf) {
341 unsigned NumEntries, Typ;
342
343 if (read_vbr(Buf, EndBuf, NumEntries) ||
Chris Lattner3d3f2892001-07-28 17:50:18 +0000344 read_vbr(Buf, EndBuf, Typ)) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +0000345 const Type *Ty = getType(Typ);
Chris Lattner3d3f2892001-07-28 17:50:18 +0000346 if (Ty == 0) return failure(true);
Chris Lattner1d670cc2001-09-07 16:37:43 +0000347 BCR_TRACE(3, "Type: '" << Ty << "' NumEntries: " << NumEntries << "\n");
Chris Lattner00950542001-06-06 20:29:01 +0000348
Chris Lattner1d670cc2001-09-07 16:37:43 +0000349 if (Typ == Type::TypeTyID) {
350 if (parseTypeConstants(Buf, EndBuf, TypeTab, NumEntries)) return true;
351 } else {
Chris Lattner7eadfa12001-10-24 06:21:22 +0000352 for (unsigned i = 0; i < NumEntries; ++i) {
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000353 Constant *I;
354 if (parseConstantValue(Buf, EndBuf, Ty, I)) return failure(true);
Chris Lattner1d670cc2001-09-07 16:37:43 +0000355 BCR_TRACE(4, "Read Constant: '" << I << "'\n");
Chris Lattner05950c32001-10-13 06:47:01 +0000356 if (insertValue(I, Tab) == -1) return failure(true);
Chris Lattner1d670cc2001-09-07 16:37:43 +0000357 }
Chris Lattner00950542001-06-06 20:29:01 +0000358 }
359 }
360
Chris Lattner3d3f2892001-07-28 17:50:18 +0000361 if (Buf > EndBuf) return failure(true);
362 return false;
Chris Lattner00950542001-06-06 20:29:01 +0000363}