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;
26 class BitcodeReader : public ModuleProvider {
27 const char *ErrorString;
29 std::vector<PATypeHolder> TypeList;
30 std::vector<Value*> ValueList;
32 virtual ~BitcodeReader() {}
34 virtual void FreeState() {}
36 virtual bool materializeFunction(Function *F, std::string *ErrInfo = 0) {
41 virtual Module *materializeModule(std::string *ErrInfo = 0) {
43 //if (ParseAllFunctionBodies(ErrMsg))
48 bool Error(const char *Str) {
52 const char *getErrorString() const { return ErrorString; }
54 /// @brief Main interface to parsing a bitcode buffer.
55 /// @returns true if an error occurred.
56 bool ParseBitcode(unsigned char *Buf, unsigned Length,
57 const std::string &ModuleID);
59 const Type *getTypeByID(unsigned ID, bool isTypeTable = false);
61 bool ParseModule(BitstreamReader &Stream, const std::string &ModuleID);
62 bool ParseTypeTable(BitstreamReader &Stream);
63 bool ParseTypeSymbolTable(BitstreamReader &Stream);
64 bool ParseValueSymbolTable(BitstreamReader &Stream);
67 } // End llvm namespace