Mercurial > projects > ldc
comparison gen/dvalue.h @ 585:fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 09 Sep 2008 16:49:47 -0700 |
parents | a34078905d01 |
children | 03a5e609eef3 |
comparison
equal
deleted
inserted
replaced
584:c7d7e2282ba3 | 585:fbb1a366cfbc |
---|---|
29 struct DFieldValue; | 29 struct DFieldValue; |
30 struct DFuncValue; | 30 struct DFuncValue; |
31 struct DSliceValue; | 31 struct DSliceValue; |
32 struct DArrayLenValue; | 32 struct DArrayLenValue; |
33 struct DLRValue; | 33 struct DLRValue; |
34 struct DComplexValue; | |
35 | 34 |
36 // base class for d-values | 35 // base class for d-values |
37 struct DValue : Object | 36 struct DValue : Object |
38 { | 37 { |
39 virtual Type*& getType() = 0; | 38 virtual Type*& getType() = 0; |
49 virtual DVarValue* isVar() { return NULL; } | 48 virtual DVarValue* isVar() { return NULL; } |
50 virtual DFieldValue* isField() { return NULL; } | 49 virtual DFieldValue* isField() { return NULL; } |
51 virtual DSliceValue* isSlice() { return NULL; } | 50 virtual DSliceValue* isSlice() { return NULL; } |
52 virtual DFuncValue* isFunc() { return NULL; } | 51 virtual DFuncValue* isFunc() { return NULL; } |
53 virtual DArrayLenValue* isArrayLen() { return NULL; } | 52 virtual DArrayLenValue* isArrayLen() { return NULL; } |
54 virtual DComplexValue* isComplex() { return NULL; } | |
55 virtual DLRValue* isLRValue() { return NULL; } | 53 virtual DLRValue* isLRValue() { return NULL; } |
56 | 54 |
57 protected: | 55 protected: |
58 DValue() {} | 56 DValue() {} |
59 DValue(const DValue&) { } | 57 DValue(const DValue&) { } |
99 struct DVarValue : DValue | 97 struct DVarValue : DValue |
100 { | 98 { |
101 Type* type; | 99 Type* type; |
102 VarDeclaration* var; | 100 VarDeclaration* var; |
103 LLValue* val; | 101 LLValue* val; |
104 LLValue* rval; | |
105 bool lval; | |
106 | 102 |
107 DVarValue(Type* t, VarDeclaration* vd, LLValue* llvmValue, bool lvalue); | 103 DVarValue(Type* t, VarDeclaration* vd, LLValue* llvmValue); |
108 DVarValue(Type* t, LLValue* lv, LLValue* rv); | 104 DVarValue(Type* t, LLValue* llvmValue); |
109 DVarValue(Type* t, LLValue* llvmValue, bool lvalue); | |
110 | 105 |
111 virtual bool isLVal() { return val && lval; } | 106 virtual bool isLVal() { return true; } |
112 virtual LLValue* getLVal(); | 107 virtual LLValue* getLVal(); |
113 virtual LLValue* getRVal(); | 108 virtual LLValue* getRVal(); |
114 | 109 |
115 virtual Type*& getType() { assert(type); return type; } | 110 virtual Type*& getType() { assert(type); return type; } |
116 virtual DVarValue* isVar() { return this; } | 111 virtual DVarValue* isVar() { return this; } |
117 }; | 112 }; |
118 | 113 |
119 // field d-value | 114 // field d-value |
120 struct DFieldValue : DVarValue | 115 struct DFieldValue : DVarValue |
121 { | 116 { |
122 DFieldValue(Type* t, LLValue* llvmValue, bool l) : DVarValue(t, llvmValue, l) {} | 117 DFieldValue(Type* t, LLValue* llvmValue) : DVarValue(t, llvmValue) {} |
123 virtual DFieldValue* isField() { return this; } | 118 virtual DFieldValue* isField() { return this; } |
124 }; | 119 }; |
125 | 120 |
126 // slice d-value | 121 // slice d-value |
127 struct DSliceValue : DValue | 122 struct DSliceValue : DValue |
171 Type*& getRType() { return rvalue->getType(); } | 166 Type*& getRType() { return rvalue->getType(); } |
172 virtual Type*& getType() { return getRType(); } | 167 virtual Type*& getType() { return getRType(); } |
173 virtual DLRValue* isLRValue() { return this; } | 168 virtual DLRValue* isLRValue() { return this; } |
174 }; | 169 }; |
175 | 170 |
176 // complex number immediate d-value (much like slice) | |
177 struct DComplexValue : DValue | |
178 { | |
179 Type* type; | |
180 LLValue* re; | |
181 LLValue* im; | |
182 | |
183 DComplexValue(Type* t, LLValue* r, LLValue* i) { | |
184 type = t; | |
185 re = r; | |
186 im = i; | |
187 } | |
188 | |
189 virtual Type*& getType() { assert(type); return type; } | |
190 virtual DComplexValue* isComplex() { return this; } | |
191 }; | |
192 | |
193 #endif // LLVMDC_GEN_DVALUE_H | 171 #endif // LLVMDC_GEN_DVALUE_H |