1 //===- llvm/Support/StringRefMemoryObject.h ---------------------*- 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 contains the declaration of the StringRefMemObject class, a simple
11 // wrapper around StringRef implementing the MemoryObject interface.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_SUPPORT_STRINGREFMEMORYOBJECT_H
16 #define LLVM_SUPPORT_STRINGREFMEMORYOBJECT_H
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/Support/MemoryObject.h"
23 /// StringRefMemoryObject - Simple StringRef-backed MemoryObject
24 class StringRefMemoryObject : public MemoryObject {
28 StringRefMemoryObject(StringRef Bytes, uint64_t Base = 0)
29 : Bytes(Bytes), Base(Base) {}
31 uint64_t getBase() const { return Base; }
32 uint64_t getExtent() const { return Bytes.size(); }
34 int readByte(uint64_t Addr, uint8_t *Byte) const;
35 int readBytes(uint64_t Addr, uint64_t Size,
36 uint8_t *Buf, uint64_t *Copied) const;