annotate tools/binding/llvm-typemonitor.cpp @ 1274:4ff9ab0d472c

Check in some old changes to the binding, from before I had commit access. - Add bindings for InsertValue and ExtractValue - Updates to use new APIs where they were renamed or removed. - Add generic error messages if LLVM didn't provide one. - Enable typesafe variadic arguments for GetGEP.
author Frits van Bommel <fvbommel wxs.nl>
date Mon, 27 Apr 2009 22:34:36 +0200
parents 1ba61de8796b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1273
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
1 /// Support for callbacks when an abstract type becomes more concrete.
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
2
1274
4ff9ab0d472c Check in some old changes to the binding, from before I had commit access.
Frits van Bommel <fvbommel wxs.nl>
parents: 1273
diff changeset
3 #include "llvm/Support/Streams.h"
1273
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
4 #include "llvm/Type.h"
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
5 #include "llvm-c/Core.h"
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
6
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
7 using namespace llvm;
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
8
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
9 extern "C" typedef int (*RefineCallback)(void *handle, LLVMTypeRef newT);
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
10
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
11 class TypeMonitor : AbstractTypeUser {
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
12 void *handle_;
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
13 RefineCallback callback_;
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
14
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
15 void onRefineType(const Type* oldT, const Type* newT) {
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
16 callback_(handle_, wrap(newT));
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
17 oldT->removeAbstractTypeUser(this);
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
18 delete this;
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
19 }
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
20
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
21 public:
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
22
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
23 TypeMonitor(Type* T, void *handle, RefineCallback callback)
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
24 : handle_(handle), callback_(callback) {
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
25 T->addAbstractTypeUser(this);
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
26 }
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
27
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
28 virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) {
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
29 onRefineType(OldTy, NewTy);
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
30 }
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
31
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
32 virtual void typeBecameConcrete(const DerivedType *AbsTy) {
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
33 onRefineType(AbsTy, AbsTy);
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
34 }
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
35
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
36 virtual void dump() const {
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
37 cerr << "<TypeMonitor>";
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
38 }
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
39 };
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
40
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
41 extern "C" void LLVMRegisterAbstractTypeCallback(LLVMTypeRef T,
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
42 void *handle,
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
43 RefineCallback callback)
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
44 {
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
45 new TypeMonitor(unwrap(T), handle, callback);
1ba61de8796b Committing LLVM binding for D as it currently exists in the SVN repository.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
46 }