Read global symtab
[oota-llvm.git] / lib / Bitcode / Reader / BitcodeReader.h
1 //===- BitcodeReader.h - Internal BitcodeReader impl ------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This header defines the BitcodeReader class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef BITCODE_READER_H
15 #define BITCODE_READER_H
16
17 #include "llvm/Type.h"
18 #include "llvm/ModuleProvider.h"
19 #include "llvm/Bitcode/LLVMBitCodes.h"
20 #include <vector>
21
22 namespace llvm {
23   class BitstreamReader;
24   class Value;
25
26 class BitcodeReader : public ModuleProvider {
27   const char *ErrorString;
28   
29   std::vector<PATypeHolder> TypeList;
30   std::vector<Value*> ValueList;
31 public:
32   virtual ~BitcodeReader() {}
33   
34   virtual void FreeState() {}
35   
36   virtual bool materializeFunction(Function *F, std::string *ErrInfo = 0) {
37     // FIXME: TODO
38     return false;
39   }
40   
41   virtual Module *materializeModule(std::string *ErrInfo = 0) {
42     // FIXME: TODO
43     //if (ParseAllFunctionBodies(ErrMsg))
44     //  return 0;
45     return TheModule;
46   }
47   
48   bool Error(const char *Str) {
49     ErrorString = Str;
50     return true;
51   }
52   const char *getErrorString() const { return ErrorString; }
53   
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);
58 private:
59   const Type *getTypeByID(unsigned ID, bool isTypeTable = false);
60   
61   bool ParseModule(BitstreamReader &Stream, const std::string &ModuleID);
62   bool ParseTypeTable(BitstreamReader &Stream);
63   bool ParseTypeSymbolTable(BitstreamReader &Stream);
64   bool ParseValueSymbolTable(BitstreamReader &Stream);
65 };
66   
67 } // End llvm namespace
68
69 #endif