Mercurial > projects > ldc
comparison gen/dvalue.h @ 104:4d1e9eb001e0 trunk
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
author | lindquist |
---|---|
date | Mon, 19 Nov 2007 02:58:58 +0100 |
parents | 058d3925950e |
children | 3efbcc81ba45 |
comparison
equal
deleted
inserted
replaced
103:855adfdb8d38 | 104:4d1e9eb001e0 |
---|---|
30 struct DThisValue; | 30 struct DThisValue; |
31 struct DFuncValue; | 31 struct DFuncValue; |
32 struct DSliceValue; | 32 struct DSliceValue; |
33 struct DArrayLenValue; | 33 struct DArrayLenValue; |
34 struct DLValueCast; | 34 struct DLValueCast; |
35 struct DComplexValue; | |
35 | 36 |
36 // base class for d-values | 37 // base class for d-values |
37 struct DValue : Object | 38 struct DValue : Object |
38 { | 39 { |
39 virtual Type* getType() = 0; | 40 virtual Type* getType() = 0; |
49 virtual DThisValue* isThis() { return NULL; } | 50 virtual DThisValue* isThis() { return NULL; } |
50 virtual DSliceValue* isSlice() { return NULL; } | 51 virtual DSliceValue* isSlice() { return NULL; } |
51 virtual DFuncValue* isFunc() { return NULL; } | 52 virtual DFuncValue* isFunc() { return NULL; } |
52 virtual DArrayLenValue* isArrayLen() { return NULL; } | 53 virtual DArrayLenValue* isArrayLen() { return NULL; } |
53 virtual DLValueCast* isLValueCast() { return NULL; } | 54 virtual DLValueCast* isLValueCast() { return NULL; } |
55 virtual DComplexValue* isComplex() { return NULL; }; | |
54 | 56 |
55 virtual bool inPlace() { return false; } | 57 virtual bool inPlace() { return false; } |
56 | 58 |
57 protected: | 59 protected: |
58 DValue() {} | 60 DValue() {} |
188 | 190 |
189 virtual Type* getType() { assert(type); return type; } | 191 virtual Type* getType() { assert(type); return type; } |
190 virtual DLValueCast* isLValueCast() { return this; } | 192 virtual DLValueCast* isLValueCast() { return this; } |
191 }; | 193 }; |
192 | 194 |
195 // complex number immediate d-value (much like slice) | |
196 struct DComplexValue : DValue | |
197 { | |
198 Type* type; | |
199 llvm::Value* re; | |
200 llvm::Value* im; | |
201 | |
202 DComplexValue(Type* t, llvm::Value* r, llvm::Value* i) { | |
203 type = t; | |
204 re = r; | |
205 im = i; | |
206 } | |
207 | |
208 virtual Type* getType() { assert(type); return type; } | |
209 virtual DComplexValue* isComplex() { return this; } | |
210 }; | |
211 | |
193 #endif // LLVMDC_GEN_DVALUE_H | 212 #endif // LLVMDC_GEN_DVALUE_H |