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

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

Issue 2556433004: Disallow deprecated typedef syntax for mixin apps in the VM (fixes #14410). (Closed)
Patch Set: dedup test 13 Created 4 years 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 | « runtime/vm/parser.h ('k') | tests/language/language_analyzer2.status » ('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 26 matching lines...) Expand all
37 #include "vm/symbols.h" 37 #include "vm/symbols.h"
38 #include "vm/tags.h" 38 #include "vm/tags.h"
39 #include "vm/timeline.h" 39 #include "vm/timeline.h"
40 #include "vm/timer.h" 40 #include "vm/timer.h"
41 #include "vm/zone.h" 41 #include "vm/zone.h"
42 42
43 namespace dart { 43 namespace dart {
44 44
45 DEFINE_FLAG(bool, enable_debug_break, false, "Allow use of break \"message\"."); 45 DEFINE_FLAG(bool, enable_debug_break, false, "Allow use of break \"message\".");
46 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); 46 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations.");
47 DEFINE_FLAG(bool, warn_mixin_typedef, true, "Warning on legacy mixin typedef.");
48 DEFINE_FLAG(bool, warn_new_tearoff_syntax, true, "Warning on new tear off."); 47 DEFINE_FLAG(bool, warn_new_tearoff_syntax, true, "Warning on new tear off.");
49 // TODO(floitsch): remove the conditional-directive flag, once we publicly 48 // TODO(floitsch): remove the conditional-directive flag, once we publicly
50 // committed to the current version. 49 // committed to the current version.
51 DEFINE_FLAG(bool, 50 DEFINE_FLAG(bool,
52 conditional_directives, 51 conditional_directives,
53 true, 52 true,
54 "Enable conditional directives"); 53 "Enable conditional directives");
55 DEFINE_FLAG(bool, generic_method_syntax, true, "Enable generic functions."); 54 DEFINE_FLAG(bool, generic_method_syntax, true, "Enable generic functions.");
56 DEFINE_FLAG(bool, 55 DEFINE_FLAG(bool,
57 initializing_formal_access, 56 initializing_formal_access,
(...skipping 5008 matching lines...) Expand 10 before | Expand all | Expand 10 after
5066 if (IsIdentifier() && (LookaheadToken(1) == Token::kLT)) { 5065 if (IsIdentifier() && (LookaheadToken(1) == Token::kLT)) {
5067 ConsumeToken(); 5066 ConsumeToken();
5068 if (TryParseTypeParameters() && (CurrentToken() == Token::kLPAREN)) { 5067 if (TryParseTypeParameters() && (CurrentToken() == Token::kLPAREN)) {
5069 return true; 5068 return true;
5070 } 5069 }
5071 } 5070 }
5072 return false; 5071 return false;
5073 } 5072 }
5074 5073
5075 5074
5076 // Look ahead to detect if we are seeing ident [ TypeParameters ] "=".
5077 // Token position remains unchanged.
5078 bool Parser::IsMixinAppAlias() {
5079 if (IsIdentifier() && (LookaheadToken(1) == Token::kASSIGN)) {
5080 return true;
5081 }
5082 const TokenPosScope saved_pos(this);
5083 if (IsIdentifier() && (LookaheadToken(1) == Token::kLT)) {
5084 ConsumeToken();
5085 if (TryParseTypeParameters() && (CurrentToken() == Token::kASSIGN)) {
5086 return true;
5087 }
5088 }
5089 return false;
5090 }
5091
5092
5093 void Parser::ParseTypedef(const GrowableObjectArray& pending_classes, 5075 void Parser::ParseTypedef(const GrowableObjectArray& pending_classes,
5094 const Object& tl_owner, 5076 const Object& tl_owner,
5095 TokenPosition metadata_pos) { 5077 TokenPosition metadata_pos) {
5096 TRACE_PARSER("ParseTypedef"); 5078 TRACE_PARSER("ParseTypedef");
5097 TokenPosition declaration_pos = 5079 TokenPosition declaration_pos =
5098 metadata_pos.IsReal() ? metadata_pos : TokenPos(); 5080 metadata_pos.IsReal() ? metadata_pos : TokenPos();
5099 ExpectToken(Token::kTYPEDEF); 5081 ExpectToken(Token::kTYPEDEF);
5100 5082
5101 if (IsMixinAppAlias()) {
5102 if (FLAG_warn_mixin_typedef) {
5103 ReportWarning(TokenPos(), "deprecated mixin application typedef");
5104 }
5105 ParseMixinAppAlias(pending_classes, tl_owner, metadata_pos);
5106 return;
5107 }
5108
5109 // Parse the result type of the function type. 5083 // Parse the result type of the function type.
5110 AbstractType& result_type = Type::Handle(Z, Type::DynamicType()); 5084 AbstractType& result_type = Type::Handle(Z, Type::DynamicType());
5111 if (CurrentToken() == Token::kVOID) { 5085 if (CurrentToken() == Token::kVOID) {
5112 ConsumeToken(); 5086 ConsumeToken();
5113 result_type = Type::VoidType(); 5087 result_type = Type::VoidType();
5114 } else if (!IsFunctionTypeAliasName()) { 5088 } else if (!IsFunctionTypeAliasName()) {
5115 // Type annotations in typedef are never ignored, even in production mode. 5089 // Type annotations in typedef are never ignored, even in production mode.
5116 // Wait until we have an owner class before resolving the result type. 5090 // Wait until we have an owner class before resolving the result type.
5117 result_type = ParseType(ClassFinalizer::kDoNotResolve); 5091 result_type = ParseType(ClassFinalizer::kDoNotResolve);
5118 } 5092 }
(...skipping 9391 matching lines...) Expand 10 before | Expand all | Expand 10 after
14510 const ArgumentListNode& function_args, 14484 const ArgumentListNode& function_args,
14511 const LocalVariable* temp_for_last_arg, 14485 const LocalVariable* temp_for_last_arg,
14512 bool is_super_invocation) { 14486 bool is_super_invocation) {
14513 UNREACHABLE(); 14487 UNREACHABLE();
14514 return NULL; 14488 return NULL;
14515 } 14489 }
14516 14490
14517 } // namespace dart 14491 } // namespace dart
14518 14492
14519 #endif // DART_PRECOMPILED_RUNTIME 14493 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« no previous file with comments | « runtime/vm/parser.h ('k') | tests/language/language_analyzer2.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698