Mercurial > projects > ldc
comparison gen/dvalue.h @ 1206:a5bfed1f6775
Reduce include-order dependencies
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Sun, 12 Apr 2009 12:52:01 +0200 |
parents | f5729209a1d4 |
children |
comparison
equal
deleted
inserted
replaced
1200:3171f67ad006 | 1206:a5bfed1f6775 |
---|---|
36 Type* type; | 36 Type* type; |
37 DValue(Type* ty) : type(ty) {} | 37 DValue(Type* ty) : type(ty) {} |
38 | 38 |
39 Type*& getType() { assert(type); return type; } | 39 Type*& getType() { assert(type); return type; } |
40 | 40 |
41 virtual LLValue* getLVal() { assert(0); return 0; } | 41 virtual llvm::Value* getLVal() { assert(0); return 0; } |
42 virtual LLValue* getRVal() { assert(0); return 0; } | 42 virtual llvm::Value* getRVal() { assert(0); return 0; } |
43 | 43 |
44 virtual bool isLVal() { return false; } | 44 virtual bool isLVal() { return false; } |
45 | 45 |
46 virtual DImValue* isIm() { return NULL; } | 46 virtual DImValue* isIm() { return NULL; } |
47 virtual DConstValue* isConst() { return NULL; } | 47 virtual DConstValue* isConst() { return NULL; } |
58 }; | 58 }; |
59 | 59 |
60 // immediate d-value | 60 // immediate d-value |
61 struct DImValue : DValue | 61 struct DImValue : DValue |
62 { | 62 { |
63 LLValue* val; | 63 llvm::Value* val; |
64 | 64 |
65 DImValue(Type* t, LLValue* v) : DValue(t), val(v) { } | 65 DImValue(Type* t, llvm::Value* v) : DValue(t), val(v) { } |
66 | 66 |
67 virtual LLValue* getRVal() { assert(val); return val; } | 67 virtual llvm::Value* getRVal() { assert(val); return val; } |
68 | 68 |
69 virtual DImValue* isIm() { return this; } | 69 virtual DImValue* isIm() { return this; } |
70 }; | 70 }; |
71 | 71 |
72 // constant d-value | 72 // constant d-value |
73 struct DConstValue : DValue | 73 struct DConstValue : DValue |
74 { | 74 { |
75 LLConstant* c; | 75 llvm::Constant* c; |
76 | 76 |
77 DConstValue(Type* t, LLConstant* con) : DValue(t), c(con) {} | 77 DConstValue(Type* t, llvm::Constant* con) : DValue(t), c(con) {} |
78 | 78 |
79 virtual LLValue* getRVal(); | 79 virtual llvm::Value* getRVal(); |
80 | 80 |
81 virtual DConstValue* isConst() { return this; } | 81 virtual DConstValue* isConst() { return this; } |
82 }; | 82 }; |
83 | 83 |
84 // null d-value | 84 // null d-value |
85 struct DNullValue : DConstValue | 85 struct DNullValue : DConstValue |
86 { | 86 { |
87 DNullValue(Type* t, LLConstant* con) : DConstValue(t,con) {} | 87 DNullValue(Type* t, llvm::Constant* con) : DConstValue(t,con) {} |
88 virtual DNullValue* isNull() { return this; } | 88 virtual DNullValue* isNull() { return this; } |
89 }; | 89 }; |
90 | 90 |
91 // variable d-value | 91 // variable d-value |
92 struct DVarValue : DValue | 92 struct DVarValue : DValue |
93 { | 93 { |
94 VarDeclaration* var; | 94 VarDeclaration* var; |
95 LLValue* val; | 95 llvm::Value* val; |
96 | 96 |
97 DVarValue(Type* t, VarDeclaration* vd, LLValue* llvmValue); | 97 DVarValue(Type* t, VarDeclaration* vd, llvm::Value* llvmValue); |
98 DVarValue(Type* t, LLValue* llvmValue); | 98 DVarValue(Type* t, llvm::Value* llvmValue); |
99 | 99 |
100 virtual bool isLVal() { return true; } | 100 virtual bool isLVal() { return true; } |
101 virtual LLValue* getLVal(); | 101 virtual llvm::Value* getLVal(); |
102 virtual LLValue* getRVal(); | 102 virtual llvm::Value* getRVal(); |
103 | 103 |
104 virtual DVarValue* isVar() { return this; } | 104 virtual DVarValue* isVar() { return this; } |
105 }; | 105 }; |
106 | 106 |
107 // field d-value | 107 // field d-value |
108 struct DFieldValue : DVarValue | 108 struct DFieldValue : DVarValue |
109 { | 109 { |
110 DFieldValue(Type* t, LLValue* llvmValue) : DVarValue(t, llvmValue) {} | 110 DFieldValue(Type* t, llvm::Value* llvmValue) : DVarValue(t, llvmValue) {} |
111 virtual DFieldValue* isField() { return this; } | 111 virtual DFieldValue* isField() { return this; } |
112 }; | 112 }; |
113 | 113 |
114 // slice d-value | 114 // slice d-value |
115 struct DSliceValue : DValue | 115 struct DSliceValue : DValue |
116 { | 116 { |
117 LLValue* len; | 117 llvm::Value* len; |
118 LLValue* ptr; | 118 llvm::Value* ptr; |
119 | 119 |
120 DSliceValue(Type* t, LLValue* l, LLValue* p) : DValue(t), len(l), ptr(p) {} | 120 DSliceValue(Type* t, llvm::Value* l, llvm::Value* p) : DValue(t), len(l), ptr(p) {} |
121 | 121 |
122 virtual LLValue* getRVal(); | 122 virtual llvm::Value* getRVal(); |
123 | 123 |
124 virtual DSliceValue* isSlice() { return this; } | 124 virtual DSliceValue* isSlice() { return this; } |
125 }; | 125 }; |
126 | 126 |
127 // function d-value | 127 // function d-value |
128 struct DFuncValue : DValue | 128 struct DFuncValue : DValue |
129 { | 129 { |
130 FuncDeclaration* func; | 130 FuncDeclaration* func; |
131 LLValue* val; | 131 llvm::Value* val; |
132 LLValue* vthis; | 132 llvm::Value* vthis; |
133 | 133 |
134 DFuncValue(FuncDeclaration* fd, LLValue* v, LLValue* vt = 0); | 134 DFuncValue(FuncDeclaration* fd, llvm::Value* v, llvm::Value* vt = 0); |
135 | 135 |
136 virtual LLValue* getRVal(); | 136 virtual llvm::Value* getRVal(); |
137 | 137 |
138 virtual DFuncValue* isFunc() { return this; } | 138 virtual DFuncValue* isFunc() { return this; } |
139 }; | 139 }; |
140 | 140 |
141 #endif // LDC_GEN_DVALUE_H | 141 #endif // LDC_GEN_DVALUE_H |