Reid Spencer | dac69c8 | 2004-06-07 17:53:43 +0000 | [diff] [blame] | 1 | //===-- ReaderInternals.h - Definitions internal to the reader --*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This header file defines various stuff that is used by the bytecode reader. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef ANALYZER_INTERNALS_H |
| 15 | #define ANALYZER_INTERNALS_H |
| 16 | |
Reid Spencer | aee4f5b | 2004-06-08 05:52:29 +0000 | [diff] [blame^] | 17 | #include "ReaderPrimitives.h" |
Reid Spencer | dac69c8 | 2004-06-07 17:53:43 +0000 | [diff] [blame] | 18 | #include "Parser.h" |
| 19 | #include "llvm/Bytecode/Analyzer.h" |
Reid Spencer | aee4f5b | 2004-06-08 05:52:29 +0000 | [diff] [blame^] | 20 | #include "llvm/Constants.h" |
| 21 | #include "llvm/DerivedTypes.h" |
Reid Spencer | dac69c8 | 2004-06-07 17:53:43 +0000 | [diff] [blame] | 22 | |
| 23 | // Enable to trace to figure out what the heck is going on when parsing fails |
| 24 | //#define TRACE_LEVEL 10 |
| 25 | //#define DEBUG_OUTPUT |
| 26 | |
| 27 | #if TRACE_LEVEL // ByteCodeReading_TRACEr |
| 28 | #define BCR_TRACE(n, X) \ |
| 29 | if (n < TRACE_LEVEL) std::cerr << std::string(n*2, ' ') << X |
| 30 | #else |
| 31 | #define BCR_TRACE(n, X) |
| 32 | #endif |
| 33 | |
| 34 | namespace llvm { |
| 35 | |
Reid Spencer | aee4f5b | 2004-06-08 05:52:29 +0000 | [diff] [blame^] | 36 | inline void AbstractBytecodeParser::readBlock(const unsigned char *&Buf, |
| 37 | const unsigned char *EndBuf, |
| 38 | unsigned &Type, unsigned &Size) |
| 39 | { |
| 40 | Type = read(Buf, EndBuf); |
| 41 | Size = read(Buf, EndBuf); |
| 42 | } |
| 43 | |
Reid Spencer | dac69c8 | 2004-06-07 17:53:43 +0000 | [diff] [blame] | 44 | class BytecodeAnalyzer { |
| 45 | BytecodeAnalyzer(const BytecodeAnalyzer &); // DO NOT IMPLEMENT |
| 46 | void operator=(const BytecodeAnalyzer &); // DO NOT IMPLEMENT |
| 47 | public: |
| 48 | BytecodeAnalyzer() { } |
| 49 | ~BytecodeAnalyzer() { } |
| 50 | |
| 51 | void AnalyzeBytecode( |
| 52 | const unsigned char *Buf, |
| 53 | unsigned Length, |
| 54 | BytecodeAnalysis& bca, |
| 55 | const std::string &ModuleID |
| 56 | ); |
| 57 | |
| 58 | void DumpBytecode( |
| 59 | const unsigned char *Buf, |
| 60 | unsigned Length, |
| 61 | BytecodeAnalysis& bca, |
| 62 | const std::string &ModuleID |
| 63 | ); |
| 64 | |
| 65 | void dump() const { |
| 66 | std::cerr << "BytecodeParser instance!\n"; |
| 67 | } |
| 68 | private: |
| 69 | BytecodeAnalysis TheAnalysis; |
| 70 | }; |
| 71 | |
| 72 | } // End llvm namespace |
| 73 | |
| 74 | #endif |
| 75 | |
| 76 | // vim: sw=2 |