1 //===--- ObjectBuffer.h - Utility class to wrap object memory ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares a wrapper class to hold the memory into which an
11 // object will be generated.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_EXECUTIONENGINE_OBJECTBUFFER_H
16 #define LLVM_EXECUTIONENGINE_OBJECTBUFFER_H
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/Support/MemoryBuffer.h"
20 #include "llvm/Support/raw_ostream.h"
24 class ObjectMemoryBuffer : public MemoryBuffer {
27 ObjectMemoryBuffer(SmallVector<char, N> SV)
28 : SV(SV), BufferName("<in-memory object>") {
29 init(this->SV.begin(), this->SV.end(), false);
33 ObjectMemoryBuffer(SmallVector<char, N> SV, StringRef Name)
34 : SV(SV), BufferName(Name) {
35 init(this->SV.begin(), this->SV.end(), false);
37 const char* getBufferIdentifier() const override { return BufferName.c_str(); }
39 BufferKind getBufferKind() const override { return MemoryBuffer_Malloc; }
42 SmallVector<char, 4096> SV;
43 std::string BufferName;