1 //===- BitcodeReader.h - Internal BitcodeReader impl ------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Chris Lattner and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This header defines the BitcodeReader class.
12 //===----------------------------------------------------------------------===//
14 #ifndef BITCODE_READER_H
15 #define BITCODE_READER_H
17 #include "llvm/Type.h"
18 #include "llvm/ModuleProvider.h"
19 #include "llvm/Bitcode/LLVMBitCodes.h"
23 class BitstreamReader;
27 class BitcodeReader : public ModuleProvider {
28 const char *ErrorString;
30 std::vector<PATypeHolder> TypeList;
31 std::vector<Value*> ValueList;
32 std::vector<std::pair<GlobalValue*, unsigned> > GlobalInits;
34 virtual ~BitcodeReader() {}
36 virtual void FreeState() {}
38 virtual bool materializeFunction(Function *F, std::string *ErrInfo = 0) {
43 virtual Module *materializeModule(std::string *ErrInfo = 0) {
45 //if (ParseAllFunctionBodies(ErrMsg))
50 bool Error(const char *Str) {
54 const char *getErrorString() const { return ErrorString; }
56 /// @brief Main interface to parsing a bitcode buffer.
57 /// @returns true if an error occurred.
58 bool ParseBitcode(unsigned char *Buf, unsigned Length,
59 const std::string &ModuleID);
61 const Type *getTypeByID(unsigned ID, bool isTypeTable = false);
63 bool ParseModule(BitstreamReader &Stream, const std::string &ModuleID);
64 bool ParseTypeTable(BitstreamReader &Stream);
65 bool ParseTypeSymbolTable(BitstreamReader &Stream);
66 bool ParseValueSymbolTable(BitstreamReader &Stream);
69 } // End llvm namespace