comparison dmd/expression/Util.d @ 126:1765f3ef917d

ClassDeclarations, Arguments -> Vector
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Fri, 03 Sep 2010 23:25:55 +0100
parents e28b18c23469
children 010eb8f0e18d
comparison
equal deleted inserted replaced
125:767a01c2a272 126:1765f3ef917d
950 * point at its elements[]. 950 * point at its elements[].
951 */ 951 */
952 952
953 /* Create the TypeTuple corresponding to the types of args[] 953 /* Create the TypeTuple corresponding to the types of args[]
954 */ 954 */
955 Arguments args = new Arguments; 955 auto args = new Arguments;
956 args.setDim(dim); 956 args.setDim(dim);
957 for (size_t i = 0; i < dim; i++) 957 for (size_t i = 0; i < dim; i++)
958 { 958 {
959 Argument arg = new Argument(STCin, exps[i].type, null, null); 959 auto arg = new Argument(STCin, exps[i].type, null, null);
960 args.data[i] = cast(void*)arg; 960 args[i] = arg;
961 } 961 }
962 TypeTuple tup = new TypeTuple(args); 962 TypeTuple tup = new TypeTuple(args);
963 Expression e = tup.getTypeInfo(sc); 963 Expression e = tup.getTypeInfo(sc);
964 e = e.optimize(WANTvalue); 964 e = e.optimize(WANTvalue);
965 assert(e.op == TOKsymoff); // should be SymOffExp 965 assert(e.op == TOKsymoff); // should be SymOffExp
1282 for (size_t u = 0; 1; u++) 1282 for (size_t u = 0; 1; u++)
1283 { 1283 {
1284 if (u == arguments.dim) 1284 if (u == arguments.dim)
1285 return; 1285 return;
1286 1286
1287 Argument arg = cast(Argument)arguments.data[u]; 1287 auto arg = arguments[u];
1288 if (!arg.type) 1288 if (!arg.type)
1289 break; 1289 break;
1290 } 1290 }
1291 1291
1292 AggregateDeclaration ad; 1292 AggregateDeclaration ad;
1293 1293
1294 Argument arg = cast(Argument)arguments.data[0]; 1294 auto arg = arguments[0];
1295 Type taggr = aggr.type; 1295 Type taggr = aggr.type;
1296 if (!taggr) 1296 if (!taggr)
1297 return; 1297 return;
1298 Type tab = taggr.toBasetype(); 1298 Type tab = taggr.toBasetype();
1299 switch (tab.ty) 1299 switch (tab.ty)
1303 case TY.Ttuple: 1303 case TY.Ttuple:
1304 if (arguments.dim == 2) 1304 if (arguments.dim == 2)
1305 { 1305 {
1306 if (!arg.type) 1306 if (!arg.type)
1307 arg.type = Type.tsize_t; // key type 1307 arg.type = Type.tsize_t; // key type
1308 arg = cast(Argument)arguments.data[1]; 1308 arg = arguments[1];
1309 } 1309 }
1310 if (!arg.type && tab.ty != TY.Ttuple) 1310 if (!arg.type && tab.ty != TY.Ttuple)
1311 arg.type = tab.nextOf(); // value type 1311 arg.type = tab.nextOf(); // value type
1312 break; 1312 break;
1313 1313
1317 1317
1318 if (arguments.dim == 2) 1318 if (arguments.dim == 2)
1319 { 1319 {
1320 if (!arg.type) 1320 if (!arg.type)
1321 arg.type = taa.index; // key type 1321 arg.type = taa.index; // key type
1322 arg = cast(Argument)arguments.data[1]; 1322 arg = arguments[1];
1323 } 1323 }
1324 if (!arg.type) 1324 if (!arg.type)
1325 arg.type = taa.next; // value type 1325 arg.type = taa.next; // value type
1326 break; 1326 break;
1327 } 1327 }
1463 if (arguments.dim != nparams) 1463 if (arguments.dim != nparams)
1464 goto Lnomatch; // not enough parameters 1464 goto Lnomatch; // not enough parameters
1465 1465
1466 for (size_t u = 0; u < nparams; u++) 1466 for (size_t u = 0; u < nparams; u++)
1467 { 1467 {
1468 Argument arg = cast(Argument)arguments.data[u]; 1468 auto arg = arguments[u];
1469 Argument param = Argument.getNth(tf.parameters, u); 1469 Argument param = Argument.getNth(tf.parameters, u);
1470 if (arg.type) 1470 if (arg.type)
1471 { 1471 {
1472 if (!arg.type.equals(param.type)) 1472 if (!arg.type.equals(param.type))
1473 { 1473 {