LLVM API Documentation

MemoryObject.cpp
Go to the documentation of this file.
00001 //===- MemoryObject.cpp - Abstract memory interface -----------------------===//
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 #include "llvm/Support/MemoryObject.h"
00011 using namespace llvm;
00012   
00013 MemoryObject::~MemoryObject() {
00014 }
00015 
00016 int MemoryObject::readBytes(uint64_t address,
00017                             uint64_t size,
00018                             uint8_t* buf) const {
00019   uint64_t current = address;
00020   uint64_t limit = getBase() + getExtent();
00021 
00022   if (current + size > limit)
00023     return -1;
00024 
00025   while (current - address < size) {
00026     if (readByte(current, &buf[(current - address)]))
00027       return -1;
00028     
00029     current++;
00030   }
00031   
00032   return 0;
00033 }