LLVM API Documentation
00001 //===- llvm/Support/StringRefMemoryObject.h ---------------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file contains the declaration of the StringRefMemObject class, a simple 00011 // wrapper around StringRef implementing the MemoryObject interface. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_SUPPORT_STRINGREFMEMORYOBJECT_H 00016 #define LLVM_SUPPORT_STRINGREFMEMORYOBJECT_H 00017 00018 #include "llvm/ADT/StringRef.h" 00019 #include "llvm/Support/Compiler.h" 00020 #include "llvm/Support/MemoryObject.h" 00021 00022 namespace llvm { 00023 00024 /// StringRefMemoryObject - Simple StringRef-backed MemoryObject 00025 class StringRefMemoryObject : public MemoryObject { 00026 StringRef Bytes; 00027 uint64_t Base; 00028 public: 00029 StringRefMemoryObject(StringRef Bytes, uint64_t Base = 0) 00030 : Bytes(Bytes), Base(Base) {} 00031 00032 uint64_t getBase() const override { return Base; } 00033 uint64_t getExtent() const override { return Bytes.size(); } 00034 00035 int readByte(uint64_t Addr, uint8_t *Byte) const override; 00036 int readBytes(uint64_t Addr, uint64_t Size, uint8_t *Buf) const override; 00037 }; 00038 00039 } 00040 00041 #endif