Mercurial > projects > ldc
comparison dmd/parse.c @ 1607:207a8a438dea
Merge DMD r253: refactor: Argument => Parameter
---
dmd/arrayop.c | 30 ++++----
dmd/arraytypes.h | 2 +-
dmd/class.c | 8 +-
dmd/declaration.c | 10 ++--
dmd/declaration.h | 16 ++--
dmd/doc.c | 12 ++--
dmd/dsymbol.c | 4 +-
dmd/expression.c | 48 +++++++-------
dmd/expression.h | 32 +++++-----
dmd/func.c | 78 +++++++++++-----------
dmd/init.c | 2 +-
dmd/interpret.c | 8 +-
dmd/mtype.c | 190 ++++++++++++++++++++++++++--------------------------
dmd/mtype.h | 32 +++++-----
dmd/opover.c | 34 +++++-----
dmd/parse.c | 40 ++++++------
dmd/parse.h | 2 +-
dmd/statement.c | 90 +++++++++++++-------------
dmd/statement.h | 14 ++--
dmd/struct.c | 8 +-
dmd/template.c | 30 ++++----
gen/functions.cpp | 10 ++--
gen/functions.h | 2 +-
gen/tocall.cpp | 10 ++--
gen/typinf.cpp | 6 +-
25 files changed, 359 insertions(+), 359 deletions(-)
author | Leandro Lucarella <llucax@gmail.com> |
---|---|
date | Wed, 06 Jan 2010 15:18:20 -0300 |
parents | eae495e6ae8d |
children | c61782a76dff |
comparison
equal
deleted
inserted
replaced
1606:1b24e9c7cc26 | 1607:207a8a438dea |
---|---|
786 */ | 786 */ |
787 | 787 |
788 Dsymbol *Parser::parseCtor() | 788 Dsymbol *Parser::parseCtor() |
789 { | 789 { |
790 CtorDeclaration *f; | 790 CtorDeclaration *f; |
791 Arguments *arguments; | 791 Parameters *arguments; |
792 int varargs; | 792 int varargs; |
793 Loc loc = this->loc; | 793 Loc loc = this->loc; |
794 | 794 |
795 nextToken(); | 795 nextToken(); |
796 arguments = parseParameters(&varargs); | 796 arguments = parseParameters(&varargs); |
912 */ | 912 */ |
913 | 913 |
914 NewDeclaration *Parser::parseNew() | 914 NewDeclaration *Parser::parseNew() |
915 { | 915 { |
916 NewDeclaration *f; | 916 NewDeclaration *f; |
917 Arguments *arguments; | 917 Parameters *arguments; |
918 int varargs; | 918 int varargs; |
919 Loc loc = this->loc; | 919 Loc loc = this->loc; |
920 | 920 |
921 nextToken(); | 921 nextToken(); |
922 arguments = parseParameters(&varargs); | 922 arguments = parseParameters(&varargs); |
932 */ | 932 */ |
933 | 933 |
934 DeleteDeclaration *Parser::parseDelete() | 934 DeleteDeclaration *Parser::parseDelete() |
935 { | 935 { |
936 DeleteDeclaration *f; | 936 DeleteDeclaration *f; |
937 Arguments *arguments; | 937 Parameters *arguments; |
938 int varargs; | 938 int varargs; |
939 Loc loc = this->loc; | 939 Loc loc = this->loc; |
940 | 940 |
941 nextToken(); | 941 nextToken(); |
942 arguments = parseParameters(&varargs); | 942 arguments = parseParameters(&varargs); |
949 | 949 |
950 /********************************************** | 950 /********************************************** |
951 * Parse parameter list. | 951 * Parse parameter list. |
952 */ | 952 */ |
953 | 953 |
954 Arguments *Parser::parseParameters(int *pvarargs) | 954 Parameters *Parser::parseParameters(int *pvarargs) |
955 { | 955 { |
956 Arguments *arguments = new Arguments(); | 956 Parameters *arguments = new Parameters(); |
957 int varargs = 0; | 957 int varargs = 0; |
958 int hasdefault = 0; | 958 int hasdefault = 0; |
959 | 959 |
960 check(TOKlparen); | 960 check(TOKlparen); |
961 while (1) | 961 while (1) |
962 { Type *tb; | 962 { Type *tb; |
963 Identifier *ai = NULL; | 963 Identifier *ai = NULL; |
964 Type *at; | 964 Type *at; |
965 Argument *a; | 965 Parameter *a; |
966 StorageClass storageClass = 0; | 966 StorageClass storageClass = 0; |
967 Expression *ae; | 967 Expression *ae; |
968 | 968 |
969 storageClass = STCin; // parameter is "in" by default | 969 storageClass = STCin; // parameter is "in" by default |
970 switch (token.value) | 970 switch (token.value) |
1019 */ | 1019 */ |
1020 | 1020 |
1021 if (storageClass & (STCout | STCref)) | 1021 if (storageClass & (STCout | STCref)) |
1022 error("variadic argument cannot be out or ref"); | 1022 error("variadic argument cannot be out or ref"); |
1023 varargs = 2; | 1023 varargs = 2; |
1024 a = new Argument(storageClass, at, ai, ae); | 1024 a = new Parameter(storageClass, at, ai, ae); |
1025 arguments->push(a); | 1025 arguments->push(a); |
1026 nextToken(); | 1026 nextToken(); |
1027 break; | 1027 break; |
1028 } | 1028 } |
1029 a = new Argument(storageClass, at, ai, ae); | 1029 a = new Parameter(storageClass, at, ai, ae); |
1030 arguments->push(a); | 1030 arguments->push(a); |
1031 if (token.value == TOKcomma) | 1031 if (token.value == TOKcomma) |
1032 { nextToken(); | 1032 { nextToken(); |
1033 continue; | 1033 continue; |
1034 } | 1034 } |
1948 case TOKdelegate: | 1948 case TOKdelegate: |
1949 case TOKfunction: | 1949 case TOKfunction: |
1950 { // Handle delegate declaration: | 1950 { // Handle delegate declaration: |
1951 // t delegate(parameter list) | 1951 // t delegate(parameter list) |
1952 // t function(parameter list) | 1952 // t function(parameter list) |
1953 Arguments *arguments; | 1953 Parameters *arguments; |
1954 int varargs; | 1954 int varargs; |
1955 enum TOK save = token.value; | 1955 enum TOK save = token.value; |
1956 | 1956 |
1957 nextToken(); | 1957 nextToken(); |
1958 arguments = parseParameters(&varargs); | 1958 arguments = parseParameters(&varargs); |
2056 *pt = ta; | 2056 *pt = ta; |
2057 continue; | 2057 continue; |
2058 } | 2058 } |
2059 #endif | 2059 #endif |
2060 case TOKlparen: | 2060 case TOKlparen: |
2061 { Arguments *arguments; | 2061 { Parameters *arguments; |
2062 int varargs; | 2062 int varargs; |
2063 | 2063 |
2064 if (tpl) | 2064 if (tpl) |
2065 { | 2065 { |
2066 /* Look ahead to see if this is (...)(...), | 2066 /* Look ahead to see if this is (...)(...), |
3007 | 3007 |
3008 case TOKforeach: | 3008 case TOKforeach: |
3009 case TOKforeach_reverse: | 3009 case TOKforeach_reverse: |
3010 { | 3010 { |
3011 enum TOK op = token.value; | 3011 enum TOK op = token.value; |
3012 Arguments *arguments; | 3012 Parameters *arguments; |
3013 | 3013 |
3014 Statement *d; | 3014 Statement *d; |
3015 Statement *body; | 3015 Statement *body; |
3016 Expression *aggr; | 3016 Expression *aggr; |
3017 | 3017 |
3018 nextToken(); | 3018 nextToken(); |
3019 check(TOKlparen); | 3019 check(TOKlparen); |
3020 | 3020 |
3021 arguments = new Arguments(); | 3021 arguments = new Parameters(); |
3022 | 3022 |
3023 while (1) | 3023 while (1) |
3024 { | 3024 { |
3025 Type *tb; | 3025 Type *tb; |
3026 Identifier *ai = NULL; | 3026 Identifier *ai = NULL; |
3027 Type *at; | 3027 Type *at; |
3028 unsigned storageClass; | 3028 unsigned storageClass; |
3029 Argument *a; | 3029 Parameter *a; |
3030 | 3030 |
3031 storageClass = STCin; | 3031 storageClass = STCin; |
3032 if (token.value == TOKinout || token.value == TOKref) | 3032 if (token.value == TOKinout || token.value == TOKref) |
3033 { storageClass = STCref; | 3033 { storageClass = STCref; |
3034 nextToken(); | 3034 nextToken(); |
3046 tb = parseBasicType(); | 3046 tb = parseBasicType(); |
3047 at = parseDeclarator(tb, &ai); | 3047 at = parseDeclarator(tb, &ai); |
3048 if (!ai) | 3048 if (!ai) |
3049 error("no identifier for declarator %s", at->toChars()); | 3049 error("no identifier for declarator %s", at->toChars()); |
3050 Larg: | 3050 Larg: |
3051 a = new Argument(storageClass, at, ai, NULL); | 3051 a = new Parameter(storageClass, at, ai, NULL); |
3052 arguments->push(a); | 3052 arguments->push(a); |
3053 if (token.value == TOKcomma) | 3053 if (token.value == TOKcomma) |
3054 { nextToken(); | 3054 { nextToken(); |
3055 continue; | 3055 continue; |
3056 } | 3056 } |
3064 s = new ForeachStatement(loc, op, arguments, aggr, body); | 3064 s = new ForeachStatement(loc, op, arguments, aggr, body); |
3065 break; | 3065 break; |
3066 } | 3066 } |
3067 | 3067 |
3068 case TOKif: | 3068 case TOKif: |
3069 { Argument *arg = NULL; | 3069 { Parameter *arg = NULL; |
3070 Expression *condition; | 3070 Expression *condition; |
3071 Statement *ifbody; | 3071 Statement *ifbody; |
3072 Statement *elsebody; | 3072 Statement *elsebody; |
3073 | 3073 |
3074 nextToken(); | 3074 nextToken(); |
3080 if (token.value == TOKidentifier) | 3080 if (token.value == TOKidentifier) |
3081 { | 3081 { |
3082 Token *t = peek(&token); | 3082 Token *t = peek(&token); |
3083 if (t->value == TOKassign) | 3083 if (t->value == TOKassign) |
3084 { | 3084 { |
3085 arg = new Argument(STCin, NULL, token.ident, NULL); | 3085 arg = new Parameter(STCin, NULL, token.ident, NULL); |
3086 nextToken(); | 3086 nextToken(); |
3087 nextToken(); | 3087 nextToken(); |
3088 } | 3088 } |
3089 else | 3089 else |
3090 { error("= expected following auto identifier"); | 3090 { error("= expected following auto identifier"); |
3103 Identifier *ai; | 3103 Identifier *ai; |
3104 | 3104 |
3105 tb = parseBasicType(); | 3105 tb = parseBasicType(); |
3106 at = parseDeclarator(tb, &ai); | 3106 at = parseDeclarator(tb, &ai); |
3107 check(TOKassign); | 3107 check(TOKassign); |
3108 arg = new Argument(STCin, at, ai, NULL); | 3108 arg = new Parameter(STCin, at, ai, NULL); |
3109 } | 3109 } |
3110 | 3110 |
3111 // Check for " ident;" | 3111 // Check for " ident;" |
3112 else if (token.value == TOKidentifier) | 3112 else if (token.value == TOKidentifier) |
3113 { | 3113 { |
3114 Token *t = peek(&token); | 3114 Token *t = peek(&token); |
3115 if (t->value == TOKcomma || t->value == TOKsemicolon) | 3115 if (t->value == TOKcomma || t->value == TOKsemicolon) |
3116 { | 3116 { |
3117 arg = new Argument(STCin, NULL, token.ident, NULL); | 3117 arg = new Parameter(STCin, NULL, token.ident, NULL); |
3118 nextToken(); | 3118 nextToken(); |
3119 nextToken(); | 3119 nextToken(); |
3120 if (1 || !global.params.useDeprecated) | 3120 if (1 || !global.params.useDeprecated) |
3121 error("if (v; e) is deprecated, use if (auto v = e)"); | 3121 error("if (v; e) is deprecated, use if (auto v = e)"); |
3122 } | 3122 } |
4486 case_delegate: | 4486 case_delegate: |
4487 { | 4487 { |
4488 /* function type(parameters) { body } | 4488 /* function type(parameters) { body } |
4489 * delegate type(parameters) { body } | 4489 * delegate type(parameters) { body } |
4490 */ | 4490 */ |
4491 Arguments *arguments; | 4491 Parameters *arguments; |
4492 int varargs; | 4492 int varargs; |
4493 FuncLiteralDeclaration *fd; | 4493 FuncLiteralDeclaration *fd; |
4494 Type *t; | 4494 Type *t; |
4495 | 4495 |
4496 if (token.value == TOKlcurly) | 4496 if (token.value == TOKlcurly) |
4497 { | 4497 { |
4498 t = NULL; | 4498 t = NULL; |
4499 varargs = 0; | 4499 varargs = 0; |
4500 arguments = new Arguments(); | 4500 arguments = new Parameters(); |
4501 } | 4501 } |
4502 else | 4502 else |
4503 { | 4503 { |
4504 if (token.value == TOKlparen) | 4504 if (token.value == TOKlparen) |
4505 t = NULL; | 4505 t = NULL; |