comparison gen/irstate.cpp @ 136:0e28624814e8 trunk

[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
author lindquist
date Thu, 17 Jan 2008 03:15:12 +0100
parents 27b9f749d9fe
children 8f704cb9969b
comparison
equal deleted inserted replaced
135:176bd52b3cf5 136:0e28624814e8
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
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
99 return !scopebb()->empty() && scopebb()->back().isTerminator(); 99 return !scopebb()->empty() && scopebb()->back().isTerminator();
100 } 100 }
101 101
102 ////////////////////////////////////////////////////////////////////////////////////////// 102 //////////////////////////////////////////////////////////////////////////////////////////
103 103
104 IRStruct::IRStruct(Type* t)
105 : recty((t->llvmType != NULL) ? *t->llvmType : llvm::OpaqueType::get())
106 {
107 type = t;
108 defined = false;
109 constinited = false;
110 interfaceInfosTy = NULL;
111 interfaceInfos = NULL;
112 }
113
114 //////////////////////////////////////////////////////////////////////////////////////////
115
116 IRFinally::IRFinally()
117 {
118 bb = 0;
119 retbb = 0;
120 }
121
122 IRFinally::IRFinally(llvm::BasicBlock* b, llvm::BasicBlock* rb)
123 {
124 bb = b;
125 retbb = rb;
126 }
127
128 //////////////////////////////////////////////////////////////////////////////////////////
129
130 LLVMBuilder* IRBuilderHelper::operator->() 104 LLVMBuilder* IRBuilderHelper::operator->()
131 { 105 {
132 LLVMBuilder& b = state->scope().builder; 106 LLVMBuilder& b = state->scope().builder;
133 assert(b.GetInsertBlock() != NULL); 107 assert(b.GetInsertBlock() != NULL);
134 return &b; 108 return &b;
135 }
136
137 //////////////////////////////////////////////////////////////////////////////////////////
138
139 IRFunction::IRFunction(FuncDeclaration* fd)
140 {
141 decl = fd;
142 Type* t = DtoDType(fd->type);
143 assert(t->ty == Tfunction);
144 type = (TypeFunction*)t;
145 func = NULL;
146 allocapoint = NULL;
147 finallyretval = NULL;
148 defined = false;
149 } 109 }
150 110
151 ////////////////////////////////////////////////////////////////////////////////////////// 111 //////////////////////////////////////////////////////////////////////////////////////////
152 112
153 IRExp::IRExp() 113 IRExp::IRExp()
160 { 120 {
161 e1 = l; 121 e1 = l;
162 e2 = r; 122 e2 = r;
163 v = val; 123 v = val;
164 } 124 }
165
166 //////////////////////////////////////////////////////////////////////////////////////////
167
168 IRGlobal::IRGlobal(VarDeclaration* v) :
169 type(llvm::OpaqueType::get())
170 {
171 var = v;
172 }