Mercurial > projects > ldc
comparison gen/dvalue.h @ 1151:3cf0066e6faf
- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
- Eliminated the DLRValue DValue.
- Implemented proactive handling of l-value CastExpS.
- Minor tweak in runtime memory.d .
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Sat, 28 Mar 2009 05:00:43 +0100 |
parents | 30b42a283c8e |
children | f5729209a1d4 |
comparison
equal
deleted
inserted
replaced
1150:2a687353c84d | 1151:3cf0066e6faf |
---|---|
27 struct DNullValue; | 27 struct DNullValue; |
28 struct DVarValue; | 28 struct DVarValue; |
29 struct DFieldValue; | 29 struct DFieldValue; |
30 struct DFuncValue; | 30 struct DFuncValue; |
31 struct DSliceValue; | 31 struct DSliceValue; |
32 struct DLRValue; | |
33 | 32 |
34 // base class for d-values | 33 // base class for d-values |
35 struct DValue : Object | 34 struct DValue : Object |
36 { | 35 { |
37 virtual Type*& getType() = 0; | 36 virtual Type*& getType() = 0; |
46 virtual DNullValue* isNull() { return NULL; } | 45 virtual DNullValue* isNull() { return NULL; } |
47 virtual DVarValue* isVar() { return NULL; } | 46 virtual DVarValue* isVar() { return NULL; } |
48 virtual DFieldValue* isField() { return NULL; } | 47 virtual DFieldValue* isField() { return NULL; } |
49 virtual DSliceValue* isSlice() { return NULL; } | 48 virtual DSliceValue* isSlice() { return NULL; } |
50 virtual DFuncValue* isFunc() { return NULL; } | 49 virtual DFuncValue* isFunc() { return NULL; } |
51 virtual DLRValue* isLRValue() { return NULL; } | |
52 | 50 |
53 protected: | 51 protected: |
54 DValue() {} | 52 DValue() {} |
55 DValue(const DValue&) { } | 53 DValue(const DValue&) { } |
56 DValue& operator=(const DValue&) { return *this; } | 54 DValue& operator=(const DValue&) { return *this; } |
145 | 143 |
146 virtual Type*& getType() { assert(type); return type; } | 144 virtual Type*& getType() { assert(type); return type; } |
147 virtual DFuncValue* isFunc() { return this; } | 145 virtual DFuncValue* isFunc() { return this; } |
148 }; | 146 }; |
149 | 147 |
150 // l-value and r-value pair d-value | |
151 struct DLRValue : DValue | |
152 { | |
153 DValue* lvalue; | |
154 DValue* rvalue; | |
155 | |
156 DLRValue(DValue* lval, DValue* rval) { | |
157 lvalue = lval; | |
158 rvalue = rval; | |
159 } | |
160 | |
161 virtual bool isLVal() { return true; } | |
162 virtual LLValue* getLVal() { return lvalue->isLVal() ? lvalue->getLVal() : lvalue->getRVal(); } | |
163 virtual LLValue* getRVal() { return rvalue->getRVal(); } | |
164 | |
165 Type*& getLType(); | |
166 Type*& getRType() { return rvalue->getType(); } | |
167 virtual Type*& getType() { return getRType(); } | |
168 virtual DLRValue* isLRValue() { return this; } | |
169 }; | |
170 | |
171 #endif // LDC_GEN_DVALUE_H | 148 #endif // LDC_GEN_DVALUE_H |