Mercurial > projects > ddmd
comparison dmd/Parser.d @ 126:1765f3ef917d
ClassDeclarations, Arguments -> Vector
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Fri, 03 Sep 2010 23:25:55 +0100 |
parents | 767a01c2a272 |
children | e6e542f37b94 |
comparison
equal
deleted
inserted
replaced
125:767a01c2a272 | 126:1765f3ef917d |
---|---|
1220 * for regular function declarations, assume the identifier | 1220 * for regular function declarations, assume the identifier |
1221 * is the parameter name, and we're building a template with | 1221 * is the parameter name, and we're building a template with |
1222 * a deduced type. | 1222 * a deduced type. |
1223 */ | 1223 */ |
1224 TemplateParameters tpl = null; | 1224 TemplateParameters tpl = null; |
1225 for (int i = 0; i < tf.parameters.dim; i++) | 1225 foreach (param; tf.parameters) |
1226 { | 1226 { |
1227 Argument param = cast(Argument)tf.parameters.data[i]; | |
1228 if (param.ident is null && | 1227 if (param.ident is null && |
1229 param.type && | 1228 param.type && |
1230 param.type.ty == Tident && | 1229 param.type.ty == Tident && |
1231 (cast(TypeIdentifier)param.type).idents.dim == 0 | 1230 (cast(TypeIdentifier)param.type).idents.dim == 0 |
1232 ) | 1231 ) |
1233 { | 1232 { |
1234 /* Switch parameter type to parameter identifier, | 1233 /* Switch parameter type to parameter identifier, |
1235 * parameterize with template type parameter _T | 1234 * parameterize with template type parameter _T |
1236 */ | 1235 */ |
1237 TypeIdentifier pt = cast(TypeIdentifier)param.type; | 1236 auto pt = cast(TypeIdentifier)param.type; |
1238 param.ident = pt.ident; | 1237 param.ident = pt.ident; |
1239 Identifier id = Lexer.uniqueId("__T"); | 1238 Identifier id = Lexer.uniqueId("__T"); |
1240 param.type = new TypeIdentifier(pt.loc, id); | 1239 param.type = new TypeIdentifier(pt.loc, id); |
1241 auto tp = new TemplateTypeParameter(fd.loc, id, null, null); | 1240 auto tp = new TemplateTypeParameter(fd.loc, id, null, null); |
1242 if (!tpl) | 1241 if (!tpl) |
1880 | 1879 |
1881 if (storageClass & (STC.STCout | STC.STCref)) | 1880 if (storageClass & (STC.STCout | STC.STCref)) |
1882 error("variadic argument cannot be out or ref"); | 1881 error("variadic argument cannot be out or ref"); |
1883 varargs = 2; | 1882 varargs = 2; |
1884 a = new Argument(storageClass, at, ai, ae); | 1883 a = new Argument(storageClass, at, ai, ae); |
1885 arguments.push(cast(void*)a); | 1884 arguments.push(a); |
1886 nextToken(); | 1885 nextToken(); |
1887 break; | 1886 break; |
1888 } | 1887 } |
1889 L3: | 1888 L3: |
1890 a = new Argument(storageClass, at, ai, ae); | 1889 a = new Argument(storageClass, at, ai, ae); |
1891 arguments.push(cast(void*)a); | 1890 arguments.push(a); |
1892 if (token.value == TOK.TOKcomma) | 1891 if (token.value == TOK.TOKcomma) |
1893 { nextToken(); | 1892 { nextToken(); |
1894 goto L1; | 1893 goto L1; |
1895 } | 1894 } |
1896 break; | 1895 break; |
3467 at = parseType(&ai); | 3466 at = parseType(&ai); |
3468 if (!ai) | 3467 if (!ai) |
3469 error("no identifier for declarator %s", at.toChars()); | 3468 error("no identifier for declarator %s", at.toChars()); |
3470 Larg: | 3469 Larg: |
3471 a = new Argument(storageClass, at, ai, null); | 3470 a = new Argument(storageClass, at, ai, null); |
3472 arguments.push(cast(void*)a); | 3471 arguments.push(a); |
3473 if (token.value == TOK.TOKcomma) | 3472 if (token.value == TOK.TOKcomma) |
3474 { nextToken(); | 3473 { nextToken(); |
3475 continue; | 3474 continue; |
3476 } | 3475 } |
3477 break; | 3476 break; |
3479 check(TOK.TOKsemicolon); | 3478 check(TOK.TOKsemicolon); |
3480 | 3479 |
3481 aggr = parseExpression(); | 3480 aggr = parseExpression(); |
3482 if (token.value == TOK.TOKslice && arguments.dim == 1) | 3481 if (token.value == TOK.TOKslice && arguments.dim == 1) |
3483 { | 3482 { |
3484 Argument a = cast(Argument)arguments.data[0]; | 3483 auto a = arguments[0]; |
3485 delete arguments; | 3484 delete arguments; |
3486 nextToken(); | 3485 nextToken(); |
3487 Expression upr = parseExpression(); | 3486 Expression upr = parseExpression(); |
3488 check(TOK.TOKrparen); | 3487 check(TOK.TOKrparen); |
3489 body_ = parseStatement(cast(ParseStatementFlags)0); | 3488 body_ = parseStatement(cast(ParseStatementFlags)0); |