annotate dmd/StructLiteralExp.d @ 64:4290d870944a

More fixes
author korDen
date Mon, 23 Aug 2010 20:29:15 +0400
parents cab4c37afb89
children f708f0452e81
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.StructLiteralExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import dmd.Expression;
64
4290d870944a More fixes
korDen
parents: 63
diff changeset
4 import dmd.MOD;
4290d870944a More fixes
korDen
parents: 63
diff changeset
5 import dmd.TypeStruct;
63
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
6 import dmd.expression.Util;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
7 import dmd.ErrorExp;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
8 import dmd.Dsymbol;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
9 import dmd.VarDeclaration;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.StructDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.backend.elem;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.InterState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.MATCH;
56
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
14 import dmd.WANT;
63
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
15 import dmd.TY;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.InlineCostState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.IRState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.InlineDoState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.backend.Symbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 import dmd.backend.dt_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 import dmd.InlineScanState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 import dmd.ArrayTypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 class StructLiteralExp : Expression
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 StructDeclaration sd; // which aggregate this is for
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 Expressions elements; // parallels sd->fields[] with
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 // NULL entries for fields to skip
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 Symbol* sym; // back end symbol to initialize with literal
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 size_t soffset; // offset from start of s
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 int fillHoles; // fill alignment 'holes' with zero
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 this(Loc loc, StructDeclaration sd, Expressions elements)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 {
56
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
43 super(loc, TOKstructliteral, StructLiteralExp.sizeof);
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
44 this.sd = sd;
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
45 this.elements = elements;
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
46 this.sym = null;
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
47 this.soffset = 0;
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
48 this.fillHoles = 1;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 Expression syntaxCopy()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 Expression semantic(Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 {
63
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
58 Expression e;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
59 int nfields = sd.fields.dim - sd.isnested;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
60
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
61 version (LOGSEMANTIC) {
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
62 printf("StructLiteralExp.semantic('%s')\n", toChars());
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
63 }
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
64 if (type)
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
65 return this;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
66
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
67 // Run semantic() on each element
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
68 for (size_t i = 0; i < elements.dim; i++)
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
69 {
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
70 e = cast(Expression)elements.data[i];
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
71 if (!e)
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
72 continue;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
73 e = e.semantic(sc);
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
74 elements.data[i] = cast(void*)e;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
75 }
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
76 expandTuples(elements);
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
77 size_t offset = 0;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
78 for (size_t i = 0; i < elements.dim; i++)
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
79 {
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
80 e = cast(Expression)elements.data[i];
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
81 if (!e)
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
82 continue;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
83
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
84 if (!e.type)
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
85 error("%s has no value", e.toChars());
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
86 e = resolveProperties(sc, e);
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
87 if (i >= nfields)
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
88 {
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
89 error("more initializers than fields of %s", sd.toChars());
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
90 return new ErrorExp();
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
91 }
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
92 Dsymbol s = cast(Dsymbol)sd.fields.data[i];
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
93 VarDeclaration v = s.isVarDeclaration();
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
94 assert(v);
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
95 if (v.offset < offset)
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
96 error("overlapping initialization for %s", v.toChars());
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
97 offset = v.offset + cast(uint)v.type.size();
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
98
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
99 Type telem = v.type;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
100 while (!e.implicitConvTo(telem) && telem.toBasetype().ty == Tsarray)
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
101 {
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
102 /* Static array initialization, as in:
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
103 * T[3][5] = e;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
104 */
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
105 telem = telem.toBasetype().nextOf();
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
106 }
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
107
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
108 e = e.implicitCastTo(sc, telem);
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
109
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
110 elements.data[i] = cast(void*)e;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
111 }
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
112
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
113 /* Fill out remainder of elements[] with default initializers for fields[]
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
114 */
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
115 for (size_t i = elements.dim; i < nfields; i++)
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
116 {
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
117 Dsymbol s = cast(Dsymbol)sd.fields.data[i];
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
118 VarDeclaration v = s.isVarDeclaration();
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
119 assert(v);
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
120 assert(!v.isThisDeclaration());
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
121
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
122 if (v.offset < offset)
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
123 {
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
124 e = null;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
125 sd.hasUnions = 1;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
126 }
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
127 else
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
128 {
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
129 if (v.init)
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
130 {
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
131 e = v.init.toExpression();
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
132 if (!e)
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
133 error("cannot make expression out of initializer for %s", v.toChars());
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
134 }
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
135 else
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
136 {
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
137 e = v.type.defaultInit(Loc(0));
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
138 e.loc = loc;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
139 }
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
140 offset = v.offset + cast(uint)v.type.size();
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
141 }
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
142 elements.push(cast(void*)e);
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
143 }
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
144
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
145 type = sd.type;
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
146 return this;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 Expression getField(Type type, uint offset)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 int getFieldIndex(Type type, uint offset)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 elem* toElem(IRState* irs)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 bool checkSideEffect(int flag)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 void toCBuffer(OutBuffer buf, HdrGenState* hgs)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 void toMangleBuffer(OutBuffer buf)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 void scanForNestedRef(Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 Expression optimize(int result)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 {
56
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
186 if (elements)
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
187 {
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
188 for (size_t i = 0; i < elements.dim; i++)
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
189 {
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
190 Expression e = cast(Expression)elements.data[i];
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
191 if (!e)
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
192 continue;
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
193 e = e.optimize(WANTvalue | (result & WANTinterpret));
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
194 elements.data[i] = cast(void*)e;
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
195 }
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
196 }
51605de93870 TupleExp.optimize
korDen
parents: 0
diff changeset
197 return this;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199
63
cab4c37afb89 A bunch of implementations
korDen
parents: 56
diff changeset
200 Expression interpret(InterState istate)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 dt_t** toDt(dt_t** pdt)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 int isLvalue()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 Expression toLvalue(Scope sc, Expression e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 bool canThrow()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 {
64
4290d870944a More fixes
korDen
parents: 63
diff changeset
222 return arrayExpressionCanThrow(elements);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 MATCH implicitConvTo(Type t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 {
64
4290d870944a More fixes
korDen
parents: 63
diff changeset
227 static if (false) {
4290d870944a More fixes
korDen
parents: 63
diff changeset
228 printf("StructLiteralExp.implicitConvTo(this=%.*s, type=%.*s, t=%.*s)\n",
4290d870944a More fixes
korDen
parents: 63
diff changeset
229 toChars(), type.toChars(), t.toChars());
4290d870944a More fixes
korDen
parents: 63
diff changeset
230 }
4290d870944a More fixes
korDen
parents: 63
diff changeset
231 MATCH m = Expression.implicitConvTo(t);
4290d870944a More fixes
korDen
parents: 63
diff changeset
232 if (m != MATCHnomatch)
4290d870944a More fixes
korDen
parents: 63
diff changeset
233 return m;
4290d870944a More fixes
korDen
parents: 63
diff changeset
234 if (type.ty == t.ty && type.ty == Tstruct && (cast(TypeStruct)type).sym == (cast(TypeStruct)t).sym)
4290d870944a More fixes
korDen
parents: 63
diff changeset
235 {
4290d870944a More fixes
korDen
parents: 63
diff changeset
236 m = MATCHconst;
4290d870944a More fixes
korDen
parents: 63
diff changeset
237 for (int i = 0; i < elements.dim; i++)
4290d870944a More fixes
korDen
parents: 63
diff changeset
238 {
4290d870944a More fixes
korDen
parents: 63
diff changeset
239 Expression e = cast(Expression)elements.data[i];
4290d870944a More fixes
korDen
parents: 63
diff changeset
240 Type te = e.type;
4290d870944a More fixes
korDen
parents: 63
diff changeset
241 if (t.mod == 0)
4290d870944a More fixes
korDen
parents: 63
diff changeset
242 te = te.mutableOf();
4290d870944a More fixes
korDen
parents: 63
diff changeset
243 else
4290d870944a More fixes
korDen
parents: 63
diff changeset
244 {
4290d870944a More fixes
korDen
parents: 63
diff changeset
245 assert(t.mod == MODinvariant);
4290d870944a More fixes
korDen
parents: 63
diff changeset
246 te = te.invariantOf();
4290d870944a More fixes
korDen
parents: 63
diff changeset
247 }
4290d870944a More fixes
korDen
parents: 63
diff changeset
248 MATCH m2 = e.implicitConvTo(te);
4290d870944a More fixes
korDen
parents: 63
diff changeset
249 //printf("\t%s => %s, match = %d\n", e.toChars(), te.toChars(), m2);
4290d870944a More fixes
korDen
parents: 63
diff changeset
250 if (m2 < m)
4290d870944a More fixes
korDen
parents: 63
diff changeset
251 m = m2;
4290d870944a More fixes
korDen
parents: 63
diff changeset
252 }
4290d870944a More fixes
korDen
parents: 63
diff changeset
253 }
4290d870944a More fixes
korDen
parents: 63
diff changeset
254 return m;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 int inlineCost(InlineCostState* ics)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 Expression doInline(InlineDoState ids)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 Expression inlineScan(InlineScanState* iss)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272