Remove IterToList, llvm_extra.h.
Add CustomMethod.
This commit is contained in:
parent
d939728938
commit
af7962a2ca
7 changed files with 61 additions and 64 deletions
|
|
@ -1,10 +1,43 @@
|
|||
#include <Python.h>
|
||||
#include <llvm/ADT/SmallVector.h>
|
||||
#include <llvm/Value.h>
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
|
||||
|
||||
namespace extra{
|
||||
using namespace llvm;
|
||||
|
||||
class raw_svector_ostream_helper: public raw_svector_ostream {
|
||||
SmallVectorImpl<char> *SV;
|
||||
public:
|
||||
static
|
||||
raw_svector_ostream_helper* create(){
|
||||
SmallVectorImpl<char>* sv = new SmallVector<char, 16>();
|
||||
return new raw_svector_ostream_helper(sv);
|
||||
}
|
||||
|
||||
~raw_svector_ostream_helper(){
|
||||
delete SV;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
explicit
|
||||
raw_svector_ostream_helper(SmallVectorImpl<char>* sv)
|
||||
: raw_svector_ostream(*sv), SV(sv) {}
|
||||
|
||||
private:
|
||||
// no copy
|
||||
raw_svector_ostream_helper(const raw_svector_ostream_helper&);
|
||||
// no assign
|
||||
void operator = (const raw_svector_ostream_helper&);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
static
|
||||
PyObject* make_raw_ostream_for_printing(PyObject* self, PyObject* args) {
|
||||
using llvm::raw_svector_ostream_helper;
|
||||
using extra::raw_svector_ostream_helper;
|
||||
using llvm::raw_svector_ostream;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
|
|
@ -18,7 +51,7 @@ PyObject* make_raw_ostream_for_printing(PyObject* self, PyObject* args) {
|
|||
static
|
||||
PyObject* make_small_vector_from_types(PyObject* self, PyObject* args) {
|
||||
using llvm::Type;
|
||||
using llvm::SmallVector_Type;
|
||||
typedef llvm::SmallVector<llvm::Type*, 8> SmallVector_Type;
|
||||
|
||||
SmallVector_Type* SV = new SmallVector_Type;
|
||||
Py_ssize_t size = PyTuple_Size(args);
|
||||
|
|
@ -33,7 +66,7 @@ PyObject* make_small_vector_from_types(PyObject* self, PyObject* args) {
|
|||
}
|
||||
SV->push_back(type);
|
||||
}
|
||||
return pycapsule_new(SV, "llvm::SmallVector_Type");
|
||||
return pycapsule_new(SV, "llvm::SmallVector<llvm::Type*,8>");
|
||||
}
|
||||
|
||||
static PyMethodDef extra_methodtable[] = {
|
||||
|
|
@ -43,3 +76,17 @@ static PyMethodDef extra_methodtable[] = {
|
|||
#undef method
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
||||
////////////
|
||||
|
||||
PyObject* Value_use_iterator_to_list(llvm::Value* val){
|
||||
typedef llvm::Value::use_iterator iterator;
|
||||
PyObject* list = PyList_New(0);
|
||||
for (iterator it = val->use_begin(), end = val->use_end(); it != end; ++it) {
|
||||
PyObject* cap = pycapsule_new(*it, "llvm::Value", "llvm::User");
|
||||
PyList_Append(list, cap);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
#include <Python.h>
|
||||
#include <llvm/ADT/SmallVector.h>
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
|
||||
namespace llvm{
|
||||
|
||||
class Type; //forward declaration
|
||||
|
||||
class raw_svector_ostream_helper: public raw_svector_ostream {
|
||||
SmallVectorImpl<char> *SV;
|
||||
public:
|
||||
static
|
||||
raw_svector_ostream_helper* create(){
|
||||
SmallVectorImpl<char>* sv = new SmallVector<char, 16>();
|
||||
return new raw_svector_ostream_helper(sv);
|
||||
}
|
||||
|
||||
~raw_svector_ostream_helper(){
|
||||
delete SV;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
explicit
|
||||
raw_svector_ostream_helper(SmallVectorImpl<char>* sv)
|
||||
: raw_svector_ostream(*sv), SV(sv) {}
|
||||
|
||||
private:
|
||||
// no copy
|
||||
raw_svector_ostream_helper(const raw_svector_ostream_helper&);
|
||||
// no assign
|
||||
void operator = (const raw_svector_ostream_helper&);
|
||||
};
|
||||
|
||||
typedef SmallVector<Type*, 8> SmallVector_Type;
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue