comparison gen/dvalue.h @ 361:932229a851a4 trunk

[svn r382] In CastExp, after the cast to CastExp.to force the type to be CastExp.type. This is used for c.im for instance, where the cast is to idouble but type is double.
author ChristianK
date Mon, 14 Jul 2008 19:17:25 +0200
parents 926f65e39246
children 74101be2a553
comparison
equal deleted inserted replaced
360:9c9544fd769d 361:932229a851a4
35 struct DComplexValue; 35 struct DComplexValue;
36 36
37 // base class for d-values 37 // base class for d-values
38 struct DValue : Object 38 struct DValue : Object
39 { 39 {
40 virtual Type* getType() = 0; 40 virtual Type*& getType() = 0;
41 41
42 virtual LLValue* getLVal() { assert(0); return 0; } 42 virtual LLValue* getLVal() { assert(0); return 0; }
43 virtual LLValue* getRVal() { assert(0); return 0; } 43 virtual LLValue* getRVal() { assert(0); return 0; }
44 44
45 virtual bool isLVal() { return false; } 45 virtual bool isLVal() { return false; }
73 73
74 DImValue(Type* t, LLValue* v, bool in_place = false) { type = t; val = v; inplace = in_place; } 74 DImValue(Type* t, LLValue* v, bool in_place = false) { type = t; val = v; inplace = in_place; }
75 75
76 virtual LLValue* getRVal() { assert(val); return val; } 76 virtual LLValue* getRVal() { assert(val); return val; }
77 77
78 virtual Type* getType() { assert(type); return type; } 78 virtual Type*& getType() { assert(type); return type; }
79 virtual DImValue* isIm() { return this; } 79 virtual DImValue* isIm() { return this; }
80 80
81 virtual bool inPlace() { return inplace; } 81 virtual bool inPlace() { return inplace; }
82 }; 82 };
83 83
89 89
90 DConstValue(Type* t, LLConstant* con) { type = t; c = con; } 90 DConstValue(Type* t, LLConstant* con) { type = t; c = con; }
91 91
92 virtual LLValue* getRVal(); 92 virtual LLValue* getRVal();
93 93
94 virtual Type* getType() { assert(type); return type; } 94 virtual Type*& getType() { assert(type); return type; }
95 virtual DConstValue* isConst() { return this; } 95 virtual DConstValue* isConst() { return this; }
96 }; 96 };
97 97
98 // null d-value 98 // null d-value
99 struct DNullValue : DConstValue 99 struct DNullValue : DConstValue
117 117
118 virtual bool isLVal() { return val && lval; } 118 virtual bool isLVal() { return val && lval; }
119 virtual LLValue* getLVal(); 119 virtual LLValue* getLVal();
120 virtual LLValue* getRVal(); 120 virtual LLValue* getRVal();
121 121
122 virtual Type* getType() { assert(type); return type; } 122 virtual Type*& getType() { assert(type); return type; }
123 virtual DVarValue* isVar() { return this; } 123 virtual DVarValue* isVar() { return this; }
124 }; 124 };
125 125
126 // field d-value 126 // field d-value
127 struct DFieldValue : DVarValue 127 struct DFieldValue : DVarValue
144 LLValue* len; 144 LLValue* len;
145 LLValue* ptr; 145 LLValue* ptr;
146 146
147 DSliceValue(Type* t, LLValue* l, LLValue* p) { type=t; ptr=p; len=l; } 147 DSliceValue(Type* t, LLValue* l, LLValue* p) { type=t; ptr=p; len=l; }
148 148
149 virtual Type* getType() { assert(type); return type; } 149 virtual Type*& getType() { assert(type); return type; }
150 virtual DSliceValue* isSlice() { return this; } 150 virtual DSliceValue* isSlice() { return this; }
151 }; 151 };
152 152
153 // function d-value 153 // function d-value
154 struct DFuncValue : DValue 154 struct DFuncValue : DValue
160 160
161 DFuncValue(FuncDeclaration* fd, LLValue* v, LLValue* vt = 0); 161 DFuncValue(FuncDeclaration* fd, LLValue* v, LLValue* vt = 0);
162 162
163 virtual LLValue* getRVal(); 163 virtual LLValue* getRVal();
164 164
165 virtual Type* getType() { assert(type); return type; } 165 virtual Type*& getType() { assert(type); return type; }
166 virtual DFuncValue* isFunc() { return this; } 166 virtual DFuncValue* isFunc() { return this; }
167 }; 167 };
168 168
169 // l-value and r-value pair d-value 169 // l-value and r-value pair d-value
170 struct DLRValue : DValue 170 struct DLRValue : DValue
179 179
180 virtual bool isLVal() { return true; } 180 virtual bool isLVal() { return true; }
181 virtual LLValue* getLVal() { return lvalue->isLVal() ? lvalue->getLVal() : lvalue->getRVal(); } 181 virtual LLValue* getLVal() { return lvalue->isLVal() ? lvalue->getLVal() : lvalue->getRVal(); }
182 virtual LLValue* getRVal() { return rvalue->getRVal(); } 182 virtual LLValue* getRVal() { return rvalue->getRVal(); }
183 183
184 Type* getLType() { return lvalue->getType(); } 184 Type*& getLType() { return lvalue->getType(); }
185 Type* getRType() { return rvalue->getType(); } 185 Type*& getRType() { return rvalue->getType(); }
186 virtual Type* getType() { return getRType(); } 186 virtual Type*& getType() { return getRType(); }
187 virtual DLRValue* isLRValue() { return this; } 187 virtual DLRValue* isLRValue() { return this; }
188 }; 188 };
189 189
190 // complex number immediate d-value (much like slice) 190 // complex number immediate d-value (much like slice)
191 struct DComplexValue : DValue 191 struct DComplexValue : DValue
198 type = t; 198 type = t;
199 re = r; 199 re = r;
200 im = i; 200 im = i;
201 } 201 }
202 202
203 virtual Type* getType() { assert(type); return type; } 203 virtual Type*& getType() { assert(type); return type; }
204 virtual DComplexValue* isComplex() { return this; } 204 virtual DComplexValue* isComplex() { return this; }
205 }; 205 };
206 206
207 #endif // LLVMDC_GEN_DVALUE_H 207 #endif // LLVMDC_GEN_DVALUE_H