comparison gen/irstate.cpp @ 100:5071469303d4 trunk

[svn r104] TONS OF FIXES. Split up declaration, constant initializer gen and definition for globals, structs, classes and functions. Improved ClassInfo support (not complete), not in vtable yet. Fixed a bunch of forward reference problems. Much more. Major commit! :)
author lindquist
date Fri, 16 Nov 2007 08:21:47 +0100
parents 61615fa85940
children 855adfdb8d38
comparison
equal deleted inserted replaced
99:a676a7743642 100:5071469303d4
38 emitMain = false; 38 emitMain = false;
39 mainFunc = 0; 39 mainFunc = 0;
40 ir.state = this; 40 ir.state = this;
41 } 41 }
42 42
43 IRFunction& IRState::func() 43 IRFunction* IRState::func()
44 { 44 {
45 assert(!functions.empty() && "Function stack is empty!"); 45 assert(!functions.empty() && "Function stack is empty!");
46 return functions.back(); 46 return functions.back();
47 } 47 }
48 48
49 llvm::Function* IRState::topfunc() 49 llvm::Function* IRState::topfunc()
50 { 50 {
51 assert(!functions.empty() && "Function stack is empty!"); 51 assert(!functions.empty() && "Function stack is empty!");
52 return functions.back().func; 52 return functions.back()->func;
53 } 53 }
54 54
55 TypeFunction* IRState::topfunctype() 55 TypeFunction* IRState::topfunctype()
56 { 56 {
57 assert(!functions.empty() && "Function stack is empty!"); 57 assert(!functions.empty() && "Function stack is empty!");
58 return functions.back().type; 58 return functions.back()->type;
59 } 59 }
60 60
61 llvm::Instruction* IRState::topallocapoint() 61 llvm::Instruction* IRState::topallocapoint()
62 { 62 {
63 assert(!functions.empty() && "AllocaPoint stack is empty!"); 63 assert(!functions.empty() && "AllocaPoint stack is empty!");
64 return functions.back().allocapoint; 64 return functions.back()->allocapoint;
65 } 65 }
66 66
67 IRStruct& IRState::topstruct() 67 IRStruct* IRState::topstruct()
68 { 68 {
69 assert(!structs.empty() && "Struct vector is empty!"); 69 assert(!structs.empty() && "Struct vector is empty!");
70 return structs.back(); 70 return structs.back();
71 } 71 }
72 72
107 107
108 IRStruct::IRStruct() 108 IRStruct::IRStruct()
109 : recty(llvm::OpaqueType::get()) 109 : recty(llvm::OpaqueType::get())
110 { 110 {
111 type = 0; 111 type = 0;
112 queueFuncs = true; 112 defined = false;
113 constinited = false;
113 } 114 }
114 115
115 IRStruct::IRStruct(Type* t) 116 IRStruct::IRStruct(Type* t)
116 : recty(llvm::OpaqueType::get()) 117 : recty(llvm::OpaqueType::get())
117 { 118 {
118 type = t; 119 type = t;
119 queueFuncs = true; 120 defined = false;
121 constinited = false;
120 } 122 }
121 123
122 ////////////////////////////////////////////////////////////////////////////////////////// 124 //////////////////////////////////////////////////////////////////////////////////////////
123 125
124 IRFinally::IRFinally() 126 IRFinally::IRFinally()
151 assert(t->ty == Tfunction); 153 assert(t->ty == Tfunction);
152 type = (TypeFunction*)t; 154 type = (TypeFunction*)t;
153 func = NULL; 155 func = NULL;
154 allocapoint = NULL; 156 allocapoint = NULL;
155 finallyretval = NULL; 157 finallyretval = NULL;
158 defined = false;
156 } 159 }
157 160
158 ////////////////////////////////////////////////////////////////////////////////////////// 161 //////////////////////////////////////////////////////////////////////////////////////////
159 162
160 IRExp::IRExp() 163 IRExp::IRExp()
167 { 170 {
168 e1 = l; 171 e1 = l;
169 e2 = r; 172 e2 = r;
170 v = val; 173 v = val;
171 } 174 }
175
176 //////////////////////////////////////////////////////////////////////////////////////////
177
178 IRGlobal::IRGlobal(VarDeclaration* v) :
179 type(llvm::OpaqueType::get())
180 {
181 var = v;
182 }