Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Side by Side Diff: runtime/vm/parser.cc

Issue 2673893002: Accept instance members and locals named "Function" (fixes #28610). (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/language/regress_28610_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 #include "vm/flags.h" 6 #include "vm/flags.h"
7 7
8 #ifndef DART_PRECOMPILED_RUNTIME 8 #ifndef DART_PRECOMPILED_RUNTIME
9 9
10 #include "lib/invocation_mirror.h" 10 #include "lib/invocation_mirror.h"
(...skipping 5413 matching lines...) Expand 10 before | Expand all | Expand 10 after
5424 TokenPosition void_pos = TokenPos(); 5424 TokenPosition void_pos = TokenPos();
5425 ConsumeToken(); 5425 ConsumeToken();
5426 // 'void' is always allowed as result type of a function type. 5426 // 'void' is always allowed as result type of a function type.
5427 if (!allow_void && !IsFunctionTypeSymbol()) { 5427 if (!allow_void && !IsFunctionTypeSymbol()) {
5428 ReportError(void_pos, "'void' not allowed here"); 5428 ReportError(void_pos, "'void' not allowed here");
5429 } 5429 }
5430 } else if (!IsFunctionTypeSymbol()) { 5430 } else if (!IsFunctionTypeSymbol()) {
5431 // Including 'Function' not followed by '(' or '<'. 5431 // Including 'Function' not followed by '(' or '<'.
5432 SkipType(false); 5432 SkipType(false);
5433 } 5433 }
5434 while (IsSymbol(Symbols::Function())) { 5434 while (IsFunctionTypeSymbol()) {
5435 ConsumeToken(); 5435 ConsumeToken();
5436 SkipTypeArguments(); 5436 SkipTypeArguments();
5437 if (CurrentToken() == Token::kLPAREN) { 5437 if (CurrentToken() == Token::kLPAREN) {
5438 SkipToMatchingParenthesis(); 5438 SkipToMatchingParenthesis();
5439 } else { 5439 } else {
5440 ReportError("'(' expected"); 5440 ReportError("'(' expected");
5441 } 5441 }
5442 } 5442 }
5443 } 5443 }
5444 5444
(...skipping 2780 matching lines...) Expand 10 before | Expand all | Expand 10 after
8225 } else if ((CurrentToken() == Token::kIDENT) && !IsFunctionTypeSymbol()) { 8225 } else if ((CurrentToken() == Token::kIDENT) && !IsFunctionTypeSymbol()) {
8226 // 'Function' not followed by '(' or '<' means the Function class. 8226 // 'Function' not followed by '(' or '<' means the Function class.
8227 if (!TryParseQualIdent()) { 8227 if (!TryParseQualIdent()) {
8228 return false; 8228 return false;
8229 } 8229 }
8230 if ((CurrentToken() == Token::kLT) && !TryParseTypeParameters()) { 8230 if ((CurrentToken() == Token::kLT) && !TryParseTypeParameters()) {
8231 return false; 8231 return false;
8232 } 8232 }
8233 found = true; 8233 found = true;
8234 } 8234 }
8235 while (IsSymbol(Symbols::Function())) { 8235 while (IsFunctionTypeSymbol()) {
8236 ConsumeToken(); 8236 ConsumeToken();
8237 if ((CurrentToken() == Token::kLT) && !TryParseTypeParameters()) { 8237 if ((CurrentToken() == Token::kLT) && !TryParseTypeParameters()) {
8238 return false; 8238 return false;
8239 } 8239 }
8240 if (CurrentToken() == Token::kLPAREN) { 8240 if (CurrentToken() == Token::kLPAREN) {
8241 SkipToMatchingParenthesis(); 8241 SkipToMatchingParenthesis();
8242 } else { 8242 } else {
8243 return false; 8243 return false;
8244 } 8244 }
8245 found = true; 8245 found = true;
(...skipping 4735 matching lines...) Expand 10 before | Expand all | Expand 10 after
12981 // 'void' is always allowed as result type of a function type. 12981 // 'void' is always allowed as result type of a function type.
12982 if (!allow_void && !IsFunctionTypeSymbol()) { 12982 if (!allow_void && !IsFunctionTypeSymbol()) {
12983 ReportError(void_pos, "'void' not allowed here"); 12983 ReportError(void_pos, "'void' not allowed here");
12984 } 12984 }
12985 } else if (!IsFunctionTypeSymbol()) { 12985 } else if (!IsFunctionTypeSymbol()) {
12986 // Including 'Function' not followed by '(' or '<'. 12986 // Including 'Function' not followed by '(' or '<'.
12987 // It is too early to resolve the type here, since it can 12987 // It is too early to resolve the type here, since it can
12988 // refer to a not yet declared function type parameter. 12988 // refer to a not yet declared function type parameter.
12989 type = ParseType(ClassFinalizer::kDoNotResolve); 12989 type = ParseType(ClassFinalizer::kDoNotResolve);
12990 } 12990 }
12991 while (IsSymbol(Symbols::Function())) { 12991 while (IsFunctionTypeSymbol()) {
12992 if (type.IsNull()) { 12992 if (type.IsNull()) {
12993 type = Type::DynamicType(); 12993 type = Type::DynamicType();
12994 } 12994 }
12995 // 'type' is the result type of the function type. 12995 // 'type' is the result type of the function type.
12996 type = ParseFunctionType(type, ClassFinalizer::kDoNotResolve); 12996 type = ParseFunctionType(type, ClassFinalizer::kDoNotResolve);
12997 } 12997 }
12998 // At this point, all type parameters have been parsed, resolve the type. 12998 // At this point, all type parameters have been parsed, resolve the type.
12999 if (finalization == ClassFinalizer::kIgnore) { 12999 if (finalization == ClassFinalizer::kIgnore) {
13000 return Type::DynamicType(); 13000 return Type::DynamicType();
13001 } 13001 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
13059 13059
13060 const bool use_function_type_syntax = true; 13060 const bool use_function_type_syntax = true;
13061 const bool allow_explicit_default_values = false; 13061 const bool allow_explicit_default_values = false;
13062 const bool evaluate_metadata = false; 13062 const bool evaluate_metadata = false;
13063 ParseFormalParameterList(use_function_type_syntax, 13063 ParseFormalParameterList(use_function_type_syntax,
13064 allow_explicit_default_values, evaluate_metadata, 13064 allow_explicit_default_values, evaluate_metadata,
13065 &params); 13065 &params);
13066 AddFormalParamsToFunction(&params, signature_function); 13066 AddFormalParamsToFunction(&params, signature_function);
13067 innermost_function_ = innermost_function_.parent_function(); 13067 innermost_function_ = innermost_function_.parent_function();
13068 type = signature_function.SignatureType(); 13068 type = signature_function.SignatureType();
13069 } while (IsSymbol(Symbols::Function())); 13069 } while (IsFunctionTypeSymbol());
13070 // At this point, all type parameters have been parsed, resolve the type. 13070 // At this point, all type parameters have been parsed, resolve the type.
13071 if (finalization == ClassFinalizer::kIgnore) { 13071 if (finalization == ClassFinalizer::kIgnore) {
13072 return Type::DynamicType(); 13072 return Type::DynamicType();
13073 } 13073 }
13074 if (finalization >= ClassFinalizer::kResolveTypeParameters) { 13074 if (finalization >= ClassFinalizer::kResolveTypeParameters) {
13075 ResolveType(finalization, &type); 13075 ResolveType(finalization, &type);
13076 if (finalization >= ClassFinalizer::kCanonicalize) { 13076 if (finalization >= ClassFinalizer::kCanonicalize) {
13077 type ^= ClassFinalizer::FinalizeType(current_class(), type, finalization); 13077 type ^= ClassFinalizer::FinalizeType(current_class(), type, finalization);
13078 } 13078 }
13079 } 13079 }
(...skipping 1956 matching lines...) Expand 10 before | Expand all | Expand 10 after
15036 const ArgumentListNode& function_args, 15036 const ArgumentListNode& function_args,
15037 const LocalVariable* temp_for_last_arg, 15037 const LocalVariable* temp_for_last_arg,
15038 bool is_super_invocation) { 15038 bool is_super_invocation) {
15039 UNREACHABLE(); 15039 UNREACHABLE();
15040 return NULL; 15040 return NULL;
15041 } 15041 }
15042 15042
15043 } // namespace dart 15043 } // namespace dart
15044 15044
15045 #endif // DART_PRECOMPILED_RUNTIME 15045 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« no previous file with comments | « no previous file | tests/language/regress_28610_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698