comparison gen/irstate.c @ 54:28e99b04a132 trunk

[svn r58] Fixed cond expression resulting in a non-basic type. Fixed identity expression for dynamic arrays. Revamped the system to keep track of lvalues and rvalues and their relations. Typedef declaration now generate the custom typeinfo. Other bugfixes.
author lindquist
date Wed, 24 Oct 2007 01:37:34 +0200
parents 8b0e809563df
children b706170e24a9
comparison
equal deleted inserted replaced
53:06ccc817acd4 54:28e99b04a132
33 ////////////////////////////////////////////////////////////////////////////////////////// 33 //////////////////////////////////////////////////////////////////////////////////////////
34 IRState::IRState() 34 IRState::IRState()
35 { 35 {
36 dmodule = 0; 36 dmodule = 0;
37 module = 0; 37 module = 0;
38 inLvalue = false;
39 emitMain = false; 38 emitMain = false;
40 mainFunc = 0; 39 mainFunc = 0;
41 ir.state = this; 40 ir.state = this;
42 } 41 }
43 42
69 { 68 {
70 assert(!structs.empty() && "Struct vector is empty!"); 69 assert(!structs.empty() && "Struct vector is empty!");
71 return structs.back(); 70 return structs.back();
72 } 71 }
73 72
74 llvm::Value* IRState::toplval() 73 IRExp* IRState::topexp()
75 { 74 {
76 assert(!lvals.empty() && "Lval vector is empty!"); 75 return exps.empty() ? NULL : &exps.back();
77 return lvals.back();
78 } 76 }
79 77
80 IRScope& IRState::scope() 78 IRScope& IRState::scope()
81 { 79 {
82 assert(!scopes.empty()); 80 assert(!scopes.empty());
151 assert(t->ty == Tfunction); 149 assert(t->ty == Tfunction);
152 type = (TypeFunction*)t; 150 type = (TypeFunction*)t;
153 func = NULL; 151 func = NULL;
154 allocapoint = NULL; 152 allocapoint = NULL;
155 } 153 }
154
155 //////////////////////////////////////////////////////////////////////////////////////////
156
157 IRExp::IRExp()
158 {
159 e1 = e2 = NULL;
160 v = NULL;
161 }
162
163 IRExp::IRExp(Expression* l, Expression* r, llvm::Value* val)
164 {
165 e1 = l;
166 e2 = r;
167 v = val;
168 }