Mercurial > projects > ldc
comparison gen/irstate.h @ 113:27b9f749d9fe trunk
[svn r117] Initial working implementation of interfaces.
Groundwork for all the different types of class/interface casts laid out.
author | lindquist |
---|---|
date | Sat, 24 Nov 2007 06:33:00 +0100 |
parents | 288fe1029e1f |
children | fd7ad91fd713 |
comparison
equal
deleted
inserted
replaced
112:368547b1cbe6 | 113:27b9f749d9fe |
---|---|
6 #include <deque> | 6 #include <deque> |
7 #include <map> | 7 #include <map> |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "root.h" | 10 #include "root.h" |
11 #include "aggregate.h" | |
11 | 12 |
12 // global ir state for current module | 13 // global ir state for current module |
13 struct IRState; | 14 struct IRState; |
14 extern IRState* gIR; | 15 extern IRState* gIR; |
15 extern const llvm::TargetData* gTargetData; | 16 extern const llvm::TargetData* gTargetData; |
18 struct TypeStruct; | 19 struct TypeStruct; |
19 struct ClassDeclaration; | 20 struct ClassDeclaration; |
20 struct FuncDeclaration; | 21 struct FuncDeclaration; |
21 struct Module; | 22 struct Module; |
22 struct TypeStruct; | 23 struct TypeStruct; |
24 struct BaseClass; | |
23 | 25 |
24 /* | 26 /* |
25 struct LLVMValue | 27 struct LLVMValue |
26 { | 28 { |
27 std::vector<llvm::Value*> vals; | 29 std::vector<llvm::Value*> vals; |
35 llvm::BasicBlock* end; | 37 llvm::BasicBlock* end; |
36 LLVMBuilder builder; | 38 LLVMBuilder builder; |
37 | 39 |
38 IRScope(); | 40 IRScope(); |
39 IRScope(llvm::BasicBlock* b, llvm::BasicBlock* e); | 41 IRScope(llvm::BasicBlock* b, llvm::BasicBlock* e); |
42 }; | |
43 | |
44 struct IRInterface : Object | |
45 { | |
46 BaseClass* base; | |
47 ClassDeclaration* decl; | |
48 | |
49 const llvm::StructType* vtblTy; | |
50 llvm::ConstantStruct* vtblInit; | |
51 llvm::GlobalVariable* vtbl; | |
52 | |
53 const llvm::StructType* infoTy; | |
54 llvm::ConstantStruct* infoInit; | |
55 llvm::Constant* info; | |
56 | |
57 IRInterface(BaseClass* b, const llvm::StructType* vt) | |
58 { | |
59 base = b; | |
60 decl = b->base; | |
61 vtblTy = vt; | |
62 vtblInit = NULL; | |
63 vtbl = NULL; | |
64 infoTy = NULL; | |
65 infoInit = NULL; | |
66 info = NULL; | |
67 } | |
40 }; | 68 }; |
41 | 69 |
42 // represents a struct or class | 70 // represents a struct or class |
43 struct IRStruct : Object | 71 struct IRStruct : Object |
44 { | 72 { |
52 : var(v), type(ty), init(NULL) {} | 80 : var(v), type(ty), init(NULL) {} |
53 }; | 81 }; |
54 | 82 |
55 typedef std::multimap<unsigned, Offset> OffsetMap; | 83 typedef std::multimap<unsigned, Offset> OffsetMap; |
56 typedef std::vector<VarDeclaration*> VarDeclVector; | 84 typedef std::vector<VarDeclaration*> VarDeclVector; |
85 typedef std::map<ClassDeclaration*, IRInterface*> InterfaceMap; | |
86 typedef InterfaceMap::iterator InterfaceIter; | |
57 | 87 |
58 public: | 88 public: |
59 IRStruct(Type*); | 89 IRStruct(Type*); |
60 | 90 |
61 Type* type; | 91 Type* type; |
62 llvm::PATypeHolder recty; | 92 llvm::PATypeHolder recty; |
63 OffsetMap offsets; | 93 OffsetMap offsets; |
64 VarDeclVector defaultFields; | 94 VarDeclVector defaultFields; |
95 | |
96 InterfaceMap interfaces; | |
97 const llvm::ArrayType* interfaceInfosTy; | |
98 llvm::GlobalVariable* interfaceInfos; | |
65 | 99 |
66 bool defined; | 100 bool defined; |
67 bool constinited; | 101 bool constinited; |
68 }; | 102 }; |
69 | 103 |