use (llvm 3.4) built in StringRefMemoryObject instead of BytesMemoryObject

This commit is contained in:
anthony cantor 2013-08-16 14:58:27 -06:00 • committed by Siu Kwan Lam
commit bc02b3d90a
5 changed files with 23 additions and 43 deletions

View file

@ -93,7 +93,7 @@ class Disassembler:
#decode some bytes into instructions. yields each instruction
#as it is decoded.
def decode(self, bs):
code = api.llvm.BytesMemoryObject.new(bs)
code = api.llvm.StringRefMemoryObject.new(bs, 0)
idx = code.getBase()
while(idx < code.getExtent()):

View file

@ -35,30 +35,6 @@
#include "auto_pyobject.h"
namespace llvm {
class BytesMemoryObject : public MemoryObject {
private:
StringRef m_bytes;
public:
BytesMemoryObject(StringRef bytes) {
m_bytes = bytes;
}
uint64_t getBase() const { return 0; }
uint64_t getExtent() const { return (uint64_t) m_bytes.size(); }
int readByte(uint64_t addr, uint8_t *byte) const {
if (addr >= getExtent())
return -1;
*byte = (uint8_t) m_bytes[(size_t) addr];
return 0;
}
};
}
namespace extra{
using namespace llvm;

View file

@ -1,17 +0,0 @@
from binding import *
from .namespace import llvm
from .ADT.StringRef import StringRef
MemoryObject = llvm.Class()
BytesMemoryObject = llvm.Class(MemoryObject)
@MemoryObject
class MemoryObject:
pass
@BytesMemoryObject
class BytesMemoryObject:
new = Constructor(cast(bytes, StringRef))
getBase = Method(cast(Uint64, int))
getExtent = Method(cast(Uint64, int))

View file

@ -1,6 +1,6 @@
from binding import *
from ..namespace import llvm
from ..BytesMemoryObject import MemoryObject
from ..Support.StringRefMemoryObject import MemoryObject
from ..Support.raw_ostream import raw_ostream
MCSubtargetInfo = llvm.Class()

View file

@ -0,0 +1,21 @@
from binding import *
from ..namespace import llvm
from ..ADT.StringRef import StringRef
MemoryObject = llvm.Class()
if LLVM_VERSION >= (3, 4):
StringRefMemoryObject = llvm.Class(MemoryObject)
@MemoryObject
class MemoryObject:
pass
if LLVM_VERSION >= (3, 4):
@StringRefMemoryObject
class StringRefMemoryObject:
_include_ = "llvm/Support/StringRefMemoryObject.h"
new = Constructor(cast(bytes, StringRef), cast(int, Uint64))
getBase = Method(cast(Uint64, int))
getExtent = Method(cast(Uint64, int))