Mercurial > projects > ddmd
comparison dmd/StructInitializer.d @ 56:51605de93870
TupleExp.optimize
UnrolledLoopStatement.ctor
UnrolledLoopStatement.semantic
UnrolledLoopStatement.blockExit
OrOrExp.checkSideEffect
FuncExp.syntaxCopy
FuncLiteralDeclaration.syntaxCopy
WhileStatement.hasBreak
StructInitializer.toExpression
StructLiteralExp.ctor
StructLiteralExp.optimize
BinExp.commonSemanticAssign
ModAssignExp.opId
Argument.isLazyArray
CommaExp.implicitConvTo
CommaExp.castTo
TypeClass.isBaseOf
createTypeInfoArray
TypeTuple.getTypeInfoDeclaration
TypeInfoTupleDeclaration.ctor
TypeNext.constConv
XorExp.implicitConvTo
TemplateParameter.isTemplateValueParameter
author | korDen |
---|---|
date | Sat, 21 Aug 2010 14:16:53 +0400 |
parents | b7d29f613539 |
children | f708f0452e81 |
comparison
equal
deleted
inserted
replaced
55:8c2c7b7579f8 | 56:51605de93870 |
---|---|
2 | 2 |
3 import dmd.Initializer; | 3 import dmd.Initializer; |
4 import dmd.TOK; | 4 import dmd.TOK; |
5 import dmd.FuncLiteralDeclaration; | 5 import dmd.FuncLiteralDeclaration; |
6 import dmd.TypeFunction; | 6 import dmd.TypeFunction; |
7 import dmd.StructDeclaration; | |
8 import dmd.StructLiteralExp; | |
7 import dmd.ArrayTypes; | 9 import dmd.ArrayTypes; |
8 import dmd.Array; | 10 import dmd.Array; |
9 import dmd.Loc; | 11 import dmd.Loc; |
10 import dmd.Type; | 12 import dmd.Type; |
11 import dmd.Scope; | 13 import dmd.Scope; |
168 vars.setDim(0); | 170 vars.setDim(0); |
169 } | 171 } |
170 return this; | 172 return this; |
171 } | 173 } |
172 | 174 |
175 /*************************************** | |
176 * This works by transforming a struct initializer into | |
177 * a struct literal. In the future, the two should be the | |
178 * same thing. | |
179 */ | |
173 Expression toExpression() | 180 Expression toExpression() |
174 { | 181 { |
175 assert(false); | 182 Expression e; |
183 | |
184 //printf("StructInitializer.toExpression() %s\n", toChars()); | |
185 if (!ad) // if fwd referenced | |
186 { | |
187 return null; | |
188 } | |
189 StructDeclaration sd = ad.isStructDeclaration(); | |
190 if (!sd) | |
191 return null; | |
192 Expressions elements = new Expressions(); | |
193 for (size_t i = 0; i < value.dim; i++) | |
194 { | |
195 if (field.data[i]) | |
196 goto Lno; | |
197 Initializer iz = cast(Initializer)value.data[i]; | |
198 if (!iz) | |
199 goto Lno; | |
200 Expression ex = iz.toExpression(); | |
201 if (!ex) | |
202 goto Lno; | |
203 elements.push(cast(void*)ex); | |
204 } | |
205 e = new StructLiteralExp(loc, sd, elements); | |
206 e.type = sd.type; | |
207 return e; | |
208 | |
209 Lno: | |
210 delete elements; | |
211 //error(loc, "struct initializers as expressions are not allowed"); | |
212 return null; | |
176 } | 213 } |
177 | 214 |
178 void toCBuffer(OutBuffer buf, HdrGenState* hgs) | 215 void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
179 { | 216 { |
180 assert(false); | 217 assert(false); |