comparison dmd/expression/Util.d @ 17:ddae60498573

Implemented mixin statements, DefaultInitExps, FileInitExps, LineInitExps and __traits.
author Robert Clipsham <robert@octarineparrot.com>
date Mon, 05 Apr 2010 03:24:08 +0100
parents 5c9b78899f5d
children a8b50ff7f201
comparison
equal deleted inserted replaced
16:5c9b78899f5d 17:ddae60498573
127 * Returns: 127 * Returns:
128 * 0 continue 128 * 0 continue
129 * 1 done 129 * 1 done
130 */ 130 */
131 131
132 int overloadApply(FuncDeclaration fstart, int delegate(FuncDeclaration) dg) 132 int overloadApply(FuncDeclaration fstart, int delegate(void*, FuncDeclaration) dg, void* param)
133 { 133 {
134 FuncDeclaration f; 134 FuncDeclaration f;
135 Declaration d; 135 Declaration d;
136 Declaration next; 136 Declaration next;
137 137
139 { 139 {
140 FuncAliasDeclaration fa = d.isFuncAliasDeclaration(); 140 FuncAliasDeclaration fa = d.isFuncAliasDeclaration();
141 141
142 if (fa) 142 if (fa)
143 { 143 {
144 if (overloadApply(fa.funcalias, dg)) 144 if (overloadApply(fa.funcalias, dg, param))
145 return 1; 145 return 1;
146 next = fa.overnext; 146 next = fa.overnext;
147 } 147 }
148 else 148 else
149 { 149 {
164 if (f is null) 164 if (f is null)
165 { 165 {
166 d.error("is aliased to a function"); 166 d.error("is aliased to a function");
167 break; // BUG: should print error message? 167 break; // BUG: should print error message?
168 } 168 }
169 if (dg(f)) 169 if (dg(param, f))
170 return 1; 170 return 1;
171 171
172 next = f.overnext; 172 next = f.overnext;
173 } 173 }
174 } 174 }
184 { 184 {
185 Match* m; 185 Match* m;
186 Expression ethis; 186 Expression ethis;
187 Expressions arguments; 187 Expressions arguments;
188 188
189 int fp2(FuncDeclaration f) 189 int fp2(void*, FuncDeclaration f)
190 { 190 {
191 MATCH match; 191 MATCH match;
192 192
193 if (f != m.lastf) // skip duplicates 193 if (f != m.lastf) // skip duplicates
194 { 194 {
248 struct Param1 248 struct Param1
249 { 249 {
250 Type t; // type to match 250 Type t; // type to match
251 FuncDeclaration f; // return value 251 FuncDeclaration f; // return value
252 252
253 int fp1(FuncDeclaration f) 253 int fp1(void*, FuncDeclaration f)
254 { 254 {
255 if (t.equals(f.type)) 255 if (t.equals(f.type))
256 { 256 {
257 this.f = f; 257 this.f = f;
258 return 1; 258 return 1;
281 { 281 {
282 Param2 p; 282 Param2 p;
283 p.m = m; 283 p.m = m;
284 p.ethis = ethis; 284 p.ethis = ethis;
285 p.arguments = arguments; 285 p.arguments = arguments;
286 overloadApply(fstart, &p.fp2); 286 overloadApply(fstart, &p.fp2, &p);
287 } 287 }
288 288
289 void templateResolve(Match* m, TemplateDeclaration td, Scope sc, Loc loc, Objects targsi, Expression ethis, Expressions arguments) 289 void templateResolve(Match* m, TemplateDeclaration td, Scope sc, Loc loc, Objects targsi, Expression ethis, Expressions arguments)
290 { 290 {
291 FuncDeclaration fd; 291 FuncDeclaration fd;
1256 /******************************** 1256 /********************************
1257 * Recursive helper function, 1257 * Recursive helper function,
1258 * analogous to func.overloadResolveX(). 1258 * analogous to func.overloadResolveX().
1259 */ 1259 */
1260 1260
1261 int fp3(FuncDeclaration f) 1261 int fp3(void*, FuncDeclaration f)
1262 { 1262 {
1263 TypeFunction tf = cast(TypeFunction)f.type; 1263 TypeFunction tf = cast(TypeFunction)f.type;
1264 if (inferApplyArgTypesY(tf, arguments) == 1) 1264 if (inferApplyArgTypesY(tf, arguments) == 1)
1265 return 0; 1265 return 0;
1266 1266
1275 1275
1276 void inferApplyArgTypesX(FuncDeclaration fstart, Arguments arguments) 1276 void inferApplyArgTypesX(FuncDeclaration fstart, Arguments arguments)
1277 { 1277 {
1278 Param3 p3; 1278 Param3 p3;
1279 p3.arguments = arguments; 1279 p3.arguments = arguments;
1280 overloadApply(fstart, &p3.fp3); 1280 overloadApply(fstart, &p3.fp3, cast(void*)arguments);
1281 } 1281 }
1282 1282
1283 /****************************** 1283 /******************************
1284 * Infer arguments from type of function. 1284 * Infer arguments from type of function.
1285 * Returns: 1285 * Returns: