push bytecode decompressor out through APIs. Now the bytecode reader

api's look like this:

ModuleProvider *getBytecodeModuleProvider(
  const std::string &Filename,  ///< Name of file to be read
  BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer,
  std::string* ErrMsg = 0,      ///< Optional error message holder
  BytecodeHandler* H = 0        ///< Optional handler for reader events
);

This is ugly, but allows a client to say:

  getBytecodeModuleProvider("foo", 0);

If they do this, there is no dependency on the compression libraries, saving
codesize.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34012 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2007-02-07 21:41:02 +00:00
parent 403e4a4725
commit f2e292ce58
25 changed files with 140 additions and 106 deletions
+3 -14
View File
@@ -20,9 +20,10 @@
#define LLVM_BYTECODE_ANALYZER_H
#include "llvm/Bytecode/Format.h"
#include "llvm/Bytecode/Reader.h"
#include <string>
#include <map>
#include <ostream>
#include <iosfwd>
namespace llvm {
@@ -102,23 +103,11 @@ struct BytecodeAnalysis {
Module* AnalyzeBytecodeFile(
const std::string& Filename, ///< The name of the bytecode file to read
BytecodeAnalysis& Results, ///< The results of the analysis
BCDecompressor_t *BCDC = 0, ///< Optional decompressor to use.
std::string* ErrorStr = 0, ///< Errors, if any.
std::ostream* output = 0 ///< Stream for dump output, if wanted
);
/// This function is an alternate entry point into the bytecode analysis
/// library. It allows you to provide an arbitrary memory buffer which is
/// assumed to contain a complete bytecode file. The \p Buffer is analyzed and
/// the \p Results are filled in.
/// @brief Analyze contents of a bytecode buffer.
Module* AnalyzeBytecodeBuffer(
const unsigned char* Buffer, ///< Pointer to start of bytecode buffer
unsigned BufferSize, ///< Size of the bytecode buffer
const std::string& ModuleID, ///< Identifier for the module
BytecodeAnalysis& Results, ///< The results of the analysis
std::string* ErrorStr = 0, ///< Errors, if any.
std::ostream* output = 0 ///< Stream for dump output, if wanted
);
/// This function prints the contents of rhe BytecodeAnalysis structure in
/// a human legible form.