0
|
1 module dmd.StructLiteralExp;
|
|
2
|
|
3 import dmd.Expression;
|
|
4 import dmd.StructDeclaration;
|
|
5 import dmd.backend.elem;
|
|
6 import dmd.InterState;
|
|
7 import dmd.MATCH;
|
56
|
8 import dmd.WANT;
|
0
|
9 import dmd.Type;
|
|
10 import dmd.OutBuffer;
|
|
11 import dmd.Loc;
|
|
12 import dmd.Scope;
|
|
13 import dmd.InlineCostState;
|
|
14 import dmd.IRState;
|
|
15 import dmd.InlineDoState;
|
|
16 import dmd.backend.Symbol;
|
|
17 import dmd.HdrGenState;
|
|
18 import dmd.backend.dt_t;
|
|
19 import dmd.InlineScanState;
|
|
20 import dmd.ArrayTypes;
|
|
21 import dmd.TOK;
|
|
22
|
|
23
|
|
24 class StructLiteralExp : Expression
|
|
25 {
|
|
26 StructDeclaration sd; // which aggregate this is for
|
|
27 Expressions elements; // parallels sd->fields[] with
|
|
28 // NULL entries for fields to skip
|
|
29
|
|
30 Symbol* sym; // back end symbol to initialize with literal
|
|
31 size_t soffset; // offset from start of s
|
|
32 int fillHoles; // fill alignment 'holes' with zero
|
|
33
|
|
34 this(Loc loc, StructDeclaration sd, Expressions elements)
|
|
35 {
|
56
|
36 super(loc, TOKstructliteral, StructLiteralExp.sizeof);
|
|
37 this.sd = sd;
|
|
38 this.elements = elements;
|
|
39 this.sym = null;
|
|
40 this.soffset = 0;
|
|
41 this.fillHoles = 1;
|
0
|
42 }
|
|
43
|
|
44 Expression syntaxCopy()
|
|
45 {
|
|
46 assert(false);
|
|
47 }
|
|
48
|
|
49 Expression semantic(Scope sc)
|
|
50 {
|
|
51 assert(false);
|
|
52 }
|
|
53
|
|
54 Expression getField(Type type, uint offset)
|
|
55 {
|
|
56 assert(false);
|
|
57 }
|
|
58
|
|
59 int getFieldIndex(Type type, uint offset)
|
|
60 {
|
|
61 assert(false);
|
|
62 }
|
|
63
|
|
64 elem* toElem(IRState* irs)
|
|
65 {
|
|
66 assert(false);
|
|
67 }
|
|
68
|
|
69 bool checkSideEffect(int flag)
|
|
70 {
|
|
71 assert(false);
|
|
72 }
|
|
73
|
|
74 void toCBuffer(OutBuffer buf, HdrGenState* hgs)
|
|
75 {
|
|
76 assert(false);
|
|
77 }
|
|
78
|
|
79 void toMangleBuffer(OutBuffer buf)
|
|
80 {
|
|
81 assert(false);
|
|
82 }
|
|
83
|
|
84 void scanForNestedRef(Scope sc)
|
|
85 {
|
|
86 assert(false);
|
|
87 }
|
|
88
|
|
89 Expression optimize(int result)
|
|
90 {
|
56
|
91 if (elements)
|
|
92 {
|
|
93 for (size_t i = 0; i < elements.dim; i++)
|
|
94 {
|
|
95 Expression e = cast(Expression)elements.data[i];
|
|
96 if (!e)
|
|
97 continue;
|
|
98 e = e.optimize(WANTvalue | (result & WANTinterpret));
|
|
99 elements.data[i] = cast(void*)e;
|
|
100 }
|
|
101 }
|
|
102 return this;
|
0
|
103 }
|
|
104
|
|
105 Expression interpret(InterState* istate)
|
|
106 {
|
|
107 assert(false);
|
|
108 }
|
|
109
|
|
110 dt_t** toDt(dt_t** pdt)
|
|
111 {
|
|
112 assert(false);
|
|
113 }
|
|
114
|
|
115 int isLvalue()
|
|
116 {
|
|
117 assert(false);
|
|
118 }
|
|
119
|
|
120 Expression toLvalue(Scope sc, Expression e)
|
|
121 {
|
|
122 assert(false);
|
|
123 }
|
|
124
|
|
125 bool canThrow()
|
|
126 {
|
|
127 assert(false);
|
|
128 }
|
|
129
|
|
130 MATCH implicitConvTo(Type t)
|
|
131 {
|
|
132 assert(false);
|
|
133 }
|
|
134
|
|
135 int inlineCost(InlineCostState* ics)
|
|
136 {
|
|
137 assert(false);
|
|
138 }
|
|
139
|
|
140 Expression doInline(InlineDoState ids)
|
|
141 {
|
|
142 assert(false);
|
|
143 }
|
|
144
|
|
145 Expression inlineScan(InlineScanState* iss)
|
|
146 {
|
|
147 assert(false);
|
|
148 }
|
|
149 }
|
|
150
|