blob: 89beddb956800c97466fe15d6a461cd362d23561 [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"
13#include "llvm/BasicBlock.h"
Chris Lattnere9bb2df2001-12-03 22:26:30 +000014#include "llvm/ConstantVals.h"
Chris Lattner05950c32001-10-13 06:47:01 +000015#include "llvm/GlobalVariable.h"
Chris Lattner1d670cc2001-09-07 16:37:43 +000016#include <algorithm>
Chris Lattner697954c2002-01-20 22:54:45 +000017#include <iostream>
18using std::make_pair;
19using std::cerr;
Chris Lattner1d670cc2001-09-07 16:37:43 +000020
21const Type *BytecodeParser::parseTypeConstant(const uchar *&Buf,
22 const uchar *EndBuf) {
Chris Lattner00950542001-06-06 20:29:01 +000023 unsigned PrimType;
Chris Lattner1d670cc2001-09-07 16:37:43 +000024 if (read_vbr(Buf, EndBuf, PrimType)) return failure<const Type*>(0);
Chris Lattner00950542001-06-06 20:29:01 +000025
Chris Lattner1d670cc2001-09-07 16:37:43 +000026 const Type *Val = 0;
27 if ((Val = Type::getPrimitiveType((Type::PrimitiveID)PrimType)))
28 return Val;
Chris Lattner00950542001-06-06 20:29:01 +000029
30 switch (PrimType) {
Chris Lattnerc9aa7df2002-03-29 03:51:11 +000031 case Type::FunctionTyID: {
Chris Lattner00950542001-06-06 20:29:01 +000032 unsigned Typ;
Chris Lattner1d670cc2001-09-07 16:37:43 +000033 if (read_vbr(Buf, EndBuf, Typ)) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000034 const Type *RetType = getType(Typ);
Chris Lattner1d670cc2001-09-07 16:37:43 +000035 if (RetType == 0) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000036
Chris Lattnere5a57ee2001-07-25 22:47:55 +000037 unsigned NumParams;
Chris Lattner1d670cc2001-09-07 16:37:43 +000038 if (read_vbr(Buf, EndBuf, NumParams)) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000039
Chris Lattner697954c2002-01-20 22:54:45 +000040 std::vector<const Type*> Params;
Chris Lattnere5a57ee2001-07-25 22:47:55 +000041 while (NumParams--) {
Chris Lattner1d670cc2001-09-07 16:37:43 +000042 if (read_vbr(Buf, EndBuf, Typ)) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000043 const Type *Ty = getType(Typ);
Chris Lattner1d670cc2001-09-07 16:37:43 +000044 if (Ty == 0) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000045 Params.push_back(Ty);
Chris Lattner00950542001-06-06 20:29:01 +000046 }
47
Chris Lattner05950c32001-10-13 06:47:01 +000048 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
49 if (isVarArg) Params.pop_back();
50
Chris Lattnerc9aa7df2002-03-29 03:51:11 +000051 return FunctionType::get(RetType, Params, isVarArg);
Chris Lattner00950542001-06-06 20:29:01 +000052 }
53 case Type::ArrayTyID: {
54 unsigned ElTyp;
Chris Lattner1d670cc2001-09-07 16:37:43 +000055 if (read_vbr(Buf, EndBuf, ElTyp)) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000056 const Type *ElementType = getType(ElTyp);
Chris Lattner1d670cc2001-09-07 16:37:43 +000057 if (ElementType == 0) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000058
Chris Lattner90865152001-12-14 16:30:51 +000059 unsigned NumElements;
Chris Lattner1d670cc2001-09-07 16:37:43 +000060 if (read_vbr(Buf, EndBuf, NumElements)) return failure(Val);
Chris Lattner7eadfa12001-10-24 06:21:22 +000061
62 BCR_TRACE(5, "Array Type Constant #" << ElTyp << " size="
Chris Lattner697954c2002-01-20 22:54:45 +000063 << NumElements << "\n");
Chris Lattner7eadfa12001-10-24 06:21:22 +000064 return ArrayType::get(ElementType, NumElements);
Chris Lattner00950542001-06-06 20:29:01 +000065 }
66 case Type::StructTyID: {
67 unsigned Typ;
Chris Lattner697954c2002-01-20 22:54:45 +000068 std::vector<const Type*> Elements;
Chris Lattner00950542001-06-06 20:29:01 +000069
Chris Lattner1d670cc2001-09-07 16:37:43 +000070 if (read_vbr(Buf, EndBuf, Typ)) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000071 while (Typ) { // List is terminated by void/0 typeid
72 const Type *Ty = getType(Typ);
Chris Lattner1d670cc2001-09-07 16:37:43 +000073 if (Ty == 0) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000074 Elements.push_back(Ty);
75
Chris Lattner1d670cc2001-09-07 16:37:43 +000076 if (read_vbr(Buf, EndBuf, Typ)) return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000077 }
78
Chris Lattner7eadfa12001-10-24 06:21:22 +000079 return StructType::get(Elements);
Chris Lattner00950542001-06-06 20:29:01 +000080 }
81 case Type::PointerTyID: {
82 unsigned ElTyp;
Chris Lattner1d670cc2001-09-07 16:37:43 +000083 if (read_vbr(Buf, EndBuf, ElTyp)) return failure(Val);
Chris Lattner697954c2002-01-20 22:54:45 +000084 BCR_TRACE(5, "Pointer Type Constant #" << (ElTyp-14) << "\n");
Chris Lattner00950542001-06-06 20:29:01 +000085 const Type *ElementType = getType(ElTyp);
Chris Lattner1d670cc2001-09-07 16:37:43 +000086 if (ElementType == 0) return failure(Val);
Chris Lattner7eadfa12001-10-24 06:21:22 +000087 return PointerType::get(ElementType);
Chris Lattner00950542001-06-06 20:29:01 +000088 }
89
Chris Lattnerd48d6c72001-10-23 01:53:01 +000090 case Type::OpaqueTyID: {
Chris Lattner7eadfa12001-10-24 06:21:22 +000091 return OpaqueType::get();
Chris Lattnerd48d6c72001-10-23 01:53:01 +000092 }
93
Chris Lattner00950542001-06-06 20:29:01 +000094 default:
95 cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to deserialize"
Chris Lattner7eadfa12001-10-24 06:21:22 +000096 << " primitive Type " << PrimType << "\n";
Chris Lattner1d670cc2001-09-07 16:37:43 +000097 return failure(Val);
Chris Lattner00950542001-06-06 20:29:01 +000098 }
Chris Lattner1d670cc2001-09-07 16:37:43 +000099}
100
101// refineAbstractType - The callback method is invoked when one of the
102// elements of TypeValues becomes more concrete...
103//
104void BytecodeParser::refineAbstractType(const DerivedType *OldType,
105 const Type *NewType) {
Chris Lattnere244a252001-11-03 03:27:53 +0000106 if (OldType == NewType &&
107 OldType->isAbstract()) return; // Type is modified, but same
Chris Lattner05950c32001-10-13 06:47:01 +0000108
Chris Lattner1d670cc2001-09-07 16:37:43 +0000109 TypeValuesListTy::iterator I = find(MethodTypeValues.begin(),
110 MethodTypeValues.end(), OldType);
111 if (I == MethodTypeValues.end()) {
112 I = find(ModuleTypeValues.begin(), ModuleTypeValues.end(), OldType);
113 assert(I != ModuleTypeValues.end() &&
114 "Can't refine a type I don't know about!");
115 }
116
Chris Lattnere244a252001-11-03 03:27:53 +0000117 if (OldType == NewType) {
118 assert(!OldType->isAbstract());
119 I->removeUserFromConcrete();
120 } else {
121 *I = NewType; // Update to point to new, more refined type.
122 }
Chris Lattner1d670cc2001-09-07 16:37:43 +0000123}
124
125
126
127// parseTypeConstants - We have to use this wierd code to handle recursive
128// types. We know that recursive types will only reference the current slab of
129// values in the type plane, but they can forward reference types before they
130// have been read. For example, Type #0 might be '{ Ty#1 }' and Type #1 might
131// be 'Ty#0*'. When reading Type #0, type number one doesn't exist. To fix
132// this ugly problem, we pesimistically insert an opaque type for each type we
133// are about to read. This means that forward references will resolve to
134// something and when we reread the type later, we can replace the opaque type
135// with a new resolved concrete type.
136//
Chris Lattner92940ac2002-04-07 06:11:22 +0000137void debug_type_tables();
Chris Lattner1d670cc2001-09-07 16:37:43 +0000138bool BytecodeParser::parseTypeConstants(const uchar *&Buf, const uchar *EndBuf,
139 TypeValuesListTy &Tab,
140 unsigned NumEntries) {
Chris Lattner05950c32001-10-13 06:47:01 +0000141 assert(Tab.size() == 0 && "should not have read type constants in before!");
Chris Lattner1d670cc2001-09-07 16:37:43 +0000142
143 // Insert a bunch of opaque types to be resolved later...
Chris Lattner7eadfa12001-10-24 06:21:22 +0000144 for (unsigned i = 0; i < NumEntries; ++i)
Chris Lattner1d670cc2001-09-07 16:37:43 +0000145 Tab.push_back(PATypeHandle<Type>(OpaqueType::get(), this));
146
147 // Loop through reading all of the types. Forward types will make use of the
148 // opaque types just inserted.
149 //
Chris Lattner7eadfa12001-10-24 06:21:22 +0000150 for (unsigned i = 0; i < NumEntries; ++i) {
Chris Lattner05950c32001-10-13 06:47:01 +0000151 const Type *NewTy = parseTypeConstant(Buf, EndBuf), *OldTy = Tab[i].get();
Chris Lattner1d670cc2001-09-07 16:37:43 +0000152 if (NewTy == 0) return failure(true);
Chris Lattner7eadfa12001-10-24 06:21:22 +0000153 BCR_TRACE(4, "#" << i << ": Read Type Constant: '" << NewTy <<
154 "' Replacing: " << OldTy << "\n");
Chris Lattner1d670cc2001-09-07 16:37:43 +0000155
156 // Don't insertValue the new type... instead we want to replace the opaque
157 // type with the new concrete value...
158 //
159
160 // Refine the abstract type to the new type. This causes all uses of the
161 // abstract type to use the newty. This also will cause the opaque type
162 // to be deleted...
163 //
Chris Lattner05950c32001-10-13 06:47:01 +0000164 cast<DerivedType>(Tab[i].get())->refineAbstractTypeTo(NewTy);
Chris Lattner1d670cc2001-09-07 16:37:43 +0000165
166 // This should have replace the old opaque type with the new type in the
Chris Lattner05950c32001-10-13 06:47:01 +0000167 // value table... or with a preexisting type that was already in the system
168 assert(Tab[i] != OldTy && "refineAbstractType didn't work!");
Chris Lattner1d670cc2001-09-07 16:37:43 +0000169 }
170
171 BCR_TRACE(5, "Resulting types:\n");
Chris Lattner7eadfa12001-10-24 06:21:22 +0000172 for (unsigned i = 0; i < NumEntries; ++i) {
Chris Lattner92940ac2002-04-07 06:11:22 +0000173 BCR_TRACE(5, (void*)Tab[i].get() << " - " << Tab[i].get() << "\n");
Chris Lattner1d670cc2001-09-07 16:37:43 +0000174 }
Chris Lattner92940ac2002-04-07 06:11:22 +0000175 debug_type_tables();
Chris Lattner00950542001-06-06 20:29:01 +0000176 return false;
177}
178
Chris Lattner1d670cc2001-09-07 16:37:43 +0000179
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000180bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf,
181 const Type *Ty, Constant *&V) {
Chris Lattner00950542001-06-06 20:29:01 +0000182 switch (Ty->getPrimitiveID()) {
183 case Type::BoolTyID: {
184 unsigned Val;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000185 if (read_vbr(Buf, EndBuf, Val)) return failure(true);
186 if (Val != 0 && Val != 1) return failure(true);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000187 V = ConstantBool::get(Val == 1);
Chris Lattner00950542001-06-06 20:29:01 +0000188 break;
189 }
190
191 case Type::UByteTyID: // Unsigned integer types...
192 case Type::UShortTyID:
193 case Type::UIntTyID: {
194 unsigned Val;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000195 if (read_vbr(Buf, EndBuf, Val)) return failure(true);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000196 if (!ConstantUInt::isValueValidForType(Ty, Val)) return failure(true);
197 V = ConstantUInt::get(Ty, Val);
Chris Lattner00950542001-06-06 20:29:01 +0000198 break;
199 }
200
201 case Type::ULongTyID: {
202 uint64_t Val;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000203 if (read_vbr(Buf, EndBuf, Val)) return failure(true);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000204 V = ConstantUInt::get(Ty, Val);
Chris Lattner00950542001-06-06 20:29:01 +0000205 break;
206 }
207
208 case Type::SByteTyID: // Unsigned integer types...
209 case Type::ShortTyID:
210 case Type::IntTyID: {
211 int Val;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000212 if (read_vbr(Buf, EndBuf, Val)) return failure(true);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000213 if (!ConstantSInt::isValueValidForType(Ty, Val)) return failure(true);
214 V = ConstantSInt::get(Ty, Val);
Chris Lattner00950542001-06-06 20:29:01 +0000215 break;
216 }
217
218 case Type::LongTyID: {
219 int64_t Val;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000220 if (read_vbr(Buf, EndBuf, Val)) return failure(true);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000221 V = ConstantSInt::get(Ty, Val);
Chris Lattner00950542001-06-06 20:29:01 +0000222 break;
223 }
224
Chris Lattnera1375302001-07-15 00:17:18 +0000225 case Type::FloatTyID: {
226 float F;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000227 if (input_data(Buf, EndBuf, &F, &F+1)) return failure(true);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000228 V = ConstantFP::get(Ty, F);
Chris Lattnera1375302001-07-15 00:17:18 +0000229 break;
230 }
231
232 case Type::DoubleTyID: {
233 double Val;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000234 if (input_data(Buf, EndBuf, &Val, &Val+1)) return failure(true);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000235 V = ConstantFP::get(Ty, Val);
Chris Lattnera1375302001-07-15 00:17:18 +0000236 break;
237 }
238
Chris Lattner00950542001-06-06 20:29:01 +0000239 case Type::TypeTyID:
Chris Lattner1d670cc2001-09-07 16:37:43 +0000240 assert(0 && "Type constants should be handled seperately!!!");
241 abort();
Chris Lattner00950542001-06-06 20:29:01 +0000242
243 case Type::ArrayTyID: {
Chris Lattnerb00c5822001-10-02 03:41:24 +0000244 const ArrayType *AT = cast<const ArrayType>(Ty);
Chris Lattner90865152001-12-14 16:30:51 +0000245 unsigned NumElements = AT->getNumElements();
Chris Lattner00950542001-06-06 20:29:01 +0000246
Chris Lattner697954c2002-01-20 22:54:45 +0000247 std::vector<Constant*> Elements;
Chris Lattner00950542001-06-06 20:29:01 +0000248 while (NumElements--) { // Read all of the elements of the constant.
249 unsigned Slot;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000250 if (read_vbr(Buf, EndBuf, Slot)) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +0000251 Value *V = getValue(AT->getElementType(), Slot, false);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000252 if (!V || !isa<Constant>(V)) return failure(true);
253 Elements.push_back(cast<Constant>(V));
Chris Lattner00950542001-06-06 20:29:01 +0000254 }
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000255 V = ConstantArray::get(AT, Elements);
Chris Lattner00950542001-06-06 20:29:01 +0000256 break;
257 }
258
259 case Type::StructTyID: {
Chris Lattnerb00c5822001-10-02 03:41:24 +0000260 const StructType *ST = cast<StructType>(Ty);
Chris Lattner00950542001-06-06 20:29:01 +0000261 const StructType::ElementTypes &ET = ST->getElementTypes();
262
Chris Lattner697954c2002-01-20 22:54:45 +0000263 std::vector<Constant *> Elements;
Chris Lattner00950542001-06-06 20:29:01 +0000264 for (unsigned i = 0; i < ET.size(); ++i) {
265 unsigned Slot;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000266 if (read_vbr(Buf, EndBuf, Slot)) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +0000267 Value *V = getValue(ET[i], Slot, false);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000268 if (!V || !isa<Constant>(V))
Chris Lattner3d3f2892001-07-28 17:50:18 +0000269 return failure(true);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000270 Elements.push_back(cast<Constant>(V));
Chris Lattner00950542001-06-06 20:29:01 +0000271 }
272
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000273 V = ConstantStruct::get(ST, Elements);
Chris Lattner00950542001-06-06 20:29:01 +0000274 break;
275 }
276
Chris Lattner1a1cb112001-09-30 22:46:54 +0000277 case Type::PointerTyID: {
Chris Lattnerb00c5822001-10-02 03:41:24 +0000278 const PointerType *PT = cast<const PointerType>(Ty);
Chris Lattner1a1cb112001-09-30 22:46:54 +0000279 unsigned SubClass;
280 if (read_vbr(Buf, EndBuf, SubClass)) return failure(true);
Chris Lattner05950c32001-10-13 06:47:01 +0000281 switch (SubClass) {
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000282 case 0: // ConstantPointerNull value...
283 V = ConstantPointerNull::get(PT);
Chris Lattner05950c32001-10-13 06:47:01 +0000284 break;
Chris Lattner1a1cb112001-09-30 22:46:54 +0000285
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000286 case 1: { // ConstantPointerRef value...
Chris Lattner05950c32001-10-13 06:47:01 +0000287 unsigned Slot;
288 if (read_vbr(Buf, EndBuf, Slot)) return failure(true);
289 BCR_TRACE(4, "CPPR: Type: '" << Ty << "' slot: " << Slot << "\n");
Chris Lattner1a1cb112001-09-30 22:46:54 +0000290
Chris Lattner05950c32001-10-13 06:47:01 +0000291 // Check to see if we have already read this global variable yet...
292 Value *Val = getValue(PT, Slot, false);
293 GlobalValue *GV;
294 if (Val) {
295 if (!(GV = dyn_cast<GlobalValue>(Val))) return failure(true);
296 BCR_TRACE(5, "Value Found in ValueTable!\n");
297 } else { // Nope... see if we have previously forward ref'd it
298 GlobalRefsType::iterator I = GlobalRefs.find(make_pair(PT, Slot));
299 if (I != GlobalRefs.end()) {
300 BCR_TRACE(5, "Previous forward ref found!\n");
301 GV = I->second;
302 } else {
303 BCR_TRACE(5, "Creating new forward ref variable!\n");
304
305 // Create a placeholder for the global variable reference...
Chris Lattnerd23b1d32001-11-26 18:56:10 +0000306 GlobalVariable *GVar =
Chris Lattner7a176752001-12-04 00:03:30 +0000307 new GlobalVariable(PT->getElementType(), false, true);
Chris Lattner05950c32001-10-13 06:47:01 +0000308
309 // Keep track of the fact that we have a forward ref to recycle it
310 GlobalRefs.insert(make_pair(make_pair(PT, Slot), GVar));
311
312 // Must temporarily push this value into the module table...
313 TheModule->getGlobalList().push_back(GVar);
314 GV = GVar;
315 }
316 }
317
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000318 V = ConstantPointerRef::get(GV);
Chris Lattner05950c32001-10-13 06:47:01 +0000319 break;
320 }
321 default:
Chris Lattner90865152001-12-14 16:30:51 +0000322 BCR_TRACE(5, "UNKNOWN Pointer Constant Type!\n");
Chris Lattner05950c32001-10-13 06:47:01 +0000323 return failure(true);
324 }
Chris Lattner1a1cb112001-09-30 22:46:54 +0000325 break;
326 }
327
Chris Lattner00950542001-06-06 20:29:01 +0000328 default:
329 cerr << __FILE__ << ":" << __LINE__
330 << ": Don't know how to deserialize constant value of type '"
331 << Ty->getName() << "'\n";
Chris Lattner3d3f2892001-07-28 17:50:18 +0000332 return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +0000333 }
Chris Lattner1d670cc2001-09-07 16:37:43 +0000334
Chris Lattner00950542001-06-06 20:29:01 +0000335 return false;
336}
337
338bool BytecodeParser::ParseConstantPool(const uchar *&Buf, const uchar *EndBuf,
Chris Lattner1d670cc2001-09-07 16:37:43 +0000339 ValueTable &Tab,
340 TypeValuesListTy &TypeTab) {
Chris Lattner00950542001-06-06 20:29:01 +0000341 while (Buf < EndBuf) {
342 unsigned NumEntries, Typ;
343
344 if (read_vbr(Buf, EndBuf, NumEntries) ||
Chris Lattner3d3f2892001-07-28 17:50:18 +0000345 read_vbr(Buf, EndBuf, Typ)) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +0000346 const Type *Ty = getType(Typ);
Chris Lattner3d3f2892001-07-28 17:50:18 +0000347 if (Ty == 0) return failure(true);
Chris Lattner1d670cc2001-09-07 16:37:43 +0000348 BCR_TRACE(3, "Type: '" << Ty << "' NumEntries: " << NumEntries << "\n");
Chris Lattner00950542001-06-06 20:29:01 +0000349
Chris Lattner1d670cc2001-09-07 16:37:43 +0000350 if (Typ == Type::TypeTyID) {
351 if (parseTypeConstants(Buf, EndBuf, TypeTab, NumEntries)) return true;
352 } else {
Chris Lattner7eadfa12001-10-24 06:21:22 +0000353 for (unsigned i = 0; i < NumEntries; ++i) {
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000354 Constant *I;
355 if (parseConstantValue(Buf, EndBuf, Ty, I)) return failure(true);
Chris Lattner1d670cc2001-09-07 16:37:43 +0000356 BCR_TRACE(4, "Read Constant: '" << I << "'\n");
Chris Lattner05950c32001-10-13 06:47:01 +0000357 if (insertValue(I, Tab) == -1) return failure(true);
Chris Lattner1d670cc2001-09-07 16:37:43 +0000358 }
Chris Lattner00950542001-06-06 20:29:01 +0000359 }
360 }
361
Chris Lattner3d3f2892001-07-28 17:50:18 +0000362 if (Buf > EndBuf) return failure(true);
363 return false;
Chris Lattner00950542001-06-06 20:29:01 +0000364}