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

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

Issue 2491983003: Changes for https://github.com/dart-lang/sdk/issues/27742 mark tear-offs using the id#x syntax as d… (Closed)
Patch Set: Created 4 years, 1 month 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 | no next file » | 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 27 matching lines...) Expand all
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."); 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.");
48 // TODO(floitsch): remove the conditional-directive flag, once we publicly 49 // TODO(floitsch): remove the conditional-directive flag, once we publicly
49 // committed to the current version. 50 // committed to the current version.
50 DEFINE_FLAG(bool, 51 DEFINE_FLAG(bool,
51 conditional_directives, 52 conditional_directives,
52 true, 53 true,
53 "Enable conditional directives"); 54 "Enable conditional directives");
54 DEFINE_FLAG(bool, generic_method_syntax, false, "Enable generic functions."); 55 DEFINE_FLAG(bool, generic_method_syntax, false, "Enable generic functions.");
55 DEFINE_FLAG(bool, 56 DEFINE_FLAG(bool,
56 initializing_formal_access, 57 initializing_formal_access,
57 false, 58 false,
(...skipping 11601 matching lines...) Expand 10 before | Expand all | Expand 10 after
11659 } 11660 }
11660 ASSERT(selector != NULL); 11661 ASSERT(selector != NULL);
11661 left = selector; 11662 left = selector;
11662 } 11663 }
11663 } 11664 }
11664 11665
11665 11666
11666 // Closurization e#m of getter, setter, method or operator. 11667 // Closurization e#m of getter, setter, method or operator.
11667 AstNode* Parser::ParseClosurization(AstNode* primary) { 11668 AstNode* Parser::ParseClosurization(AstNode* primary) {
11668 ExpectToken(Token::kHASH); 11669 ExpectToken(Token::kHASH);
11670 if (FLAG_warn_new_tearoff_syntax) {
hausner 2016/11/11 18:10:38 Nit: I'd move the warning to before the ExpectTpke
siva 2016/11/11 18:58:01 Done.
11671 ReportWarning(
11672 "Tear-offs using the x#id syntax is a deprecated feature,"
11673 "it will not be supported in the next release");
11674 }
11669 TokenPosition property_pos = TokenPos(); 11675 TokenPosition property_pos = TokenPos();
11670 bool is_setter_name = false; 11676 bool is_setter_name = false;
11671 11677
11672 String& extractor_name = String::ZoneHandle(Z); 11678 String& extractor_name = String::ZoneHandle(Z);
11673 if (IsIdentifier()) { 11679 if (IsIdentifier()) {
11674 extractor_name = CurrentLiteral()->raw(); 11680 extractor_name = CurrentLiteral()->raw();
11675 ConsumeToken(); 11681 ConsumeToken();
11676 if (CurrentToken() == Token::kASSIGN) { 11682 if (CurrentToken() == Token::kASSIGN) {
11677 ConsumeToken(); 11683 ConsumeToken();
11678 is_setter_name = true; 11684 is_setter_name = true;
(...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after
13244 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(Z); 13250 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(Z);
13245 AbstractType& type = 13251 AbstractType& type =
13246 AbstractType::Handle(Z, ParseType(ClassFinalizer::kCanonicalizeWellFormed, 13252 AbstractType::Handle(Z, ParseType(ClassFinalizer::kCanonicalizeWellFormed,
13247 true, // allow deferred type 13253 true, // allow deferred type
13248 consume_unresolved_prefix, &prefix)); 13254 consume_unresolved_prefix, &prefix));
13249 // A constructor tear-off closure can only have been created for a 13255 // A constructor tear-off closure can only have been created for a
13250 // type that is loaded. 13256 // type that is loaded.
13251 ASSERT(prefix.IsNull() || prefix.is_loaded()); 13257 ASSERT(prefix.IsNull() || prefix.is_loaded());
13252 ASSERT(!type.IsMalformed() && !type.IsTypeParameter()); 13258 ASSERT(!type.IsMalformed() && !type.IsTypeParameter());
13253 ExpectToken(Token::kHASH); 13259 ExpectToken(Token::kHASH);
13260 if (FLAG_warn_new_tearoff_syntax) {
hausner 2016/11/11 18:10:38 Nit: I'd move the check to before the ExpectToken(
siva 2016/11/11 18:58:00 Done.
13261 ReportWarning(
13262 "Tear-offs using the x#id syntax is a deprecated feature,"
13263 "it will not be supported in the next release");
13264 }
13254 String* named_constructor = NULL; 13265 String* named_constructor = NULL;
13255 if (IsIdentifier()) { 13266 if (IsIdentifier()) {
13256 named_constructor = CurrentLiteral(); 13267 named_constructor = CurrentLiteral();
13257 ConsumeToken(); 13268 ConsumeToken();
13258 } 13269 }
13259 // Resolve the type and optional identifier to a constructor or factory. 13270 // Resolve the type and optional identifier to a constructor or factory.
13260 Class& type_class = Class::Handle(Z, type.type_class()); 13271 Class& type_class = Class::Handle(Z, type.type_class());
13261 String& type_class_name = String::Handle(Z, type_class.Name()); 13272 String& type_class_name = String::Handle(Z, type_class.Name());
13262 *type_arguments = type.arguments(); 13273 *type_arguments = type.arguments();
13263 String& constructor_name = 13274 String& constructor_name =
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
13341 // The type can be followed by an optional named constructor identifier. 13352 // The type can be followed by an optional named constructor identifier.
13342 // Note that we tell ParseType() above not to consume it as part of 13353 // Note that we tell ParseType() above not to consume it as part of
13343 // a misinterpreted qualified identifier. Only a valid library 13354 // a misinterpreted qualified identifier. Only a valid library
13344 // prefix is accepted as qualifier. 13355 // prefix is accepted as qualifier.
13345 String* named_constructor = NULL; 13356 String* named_constructor = NULL;
13346 const bool is_tearoff_expression = (CurrentToken() == Token::kHASH); 13357 const bool is_tearoff_expression = (CurrentToken() == Token::kHASH);
13347 if (is_tearoff_expression) { 13358 if (is_tearoff_expression) {
13348 if (is_const) { 13359 if (is_const) {
13349 ReportError("tear-off closure not allowed with const allocation"); 13360 ReportError("tear-off closure not allowed with const allocation");
13350 } 13361 }
13362 if (FLAG_warn_new_tearoff_syntax) {
13363 ReportWarning(
13364 "Tear-offs using the x#id syntax is a deprecated feature,"
13365 "and will not be supported in the next release");
13366 }
13351 ConsumeToken(); 13367 ConsumeToken();
13352 if (IsIdentifier()) { 13368 if (IsIdentifier()) {
13353 named_constructor = ExpectIdentifier("name of constructor expected"); 13369 named_constructor = ExpectIdentifier("name of constructor expected");
13354 } 13370 }
13355 } else if (CurrentToken() == Token::kPERIOD) { 13371 } else if (CurrentToken() == Token::kPERIOD) {
13356 ConsumeToken(); 13372 ConsumeToken();
13357 named_constructor = ExpectIdentifier("name of constructor expected"); 13373 named_constructor = ExpectIdentifier("name of constructor expected");
13358 } 13374 }
13359 13375
13360 // Parse constructor parameters. 13376 // Parse constructor parameters.
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
13782 // The name of a literal function is visible from inside the function, but 13798 // The name of a literal function is visible from inside the function, but
13783 // must not collide with names in the scope declaring the literal. 13799 // must not collide with names in the scope declaring the literal.
13784 OpenBlock(); 13800 OpenBlock();
13785 primary = ParseFunctionStatement(true); 13801 primary = ParseFunctionStatement(true);
13786 CloseBlock(); 13802 CloseBlock();
13787 } else if (IsIdentifier()) { 13803 } else if (IsIdentifier()) {
13788 TokenPosition qual_ident_pos = TokenPos(); 13804 TokenPosition qual_ident_pos = TokenPos();
13789 const LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(Z, ParsePrefix()); 13805 const LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(Z, ParsePrefix());
13790 if (!prefix.IsNull()) { 13806 if (!prefix.IsNull()) {
13791 if (CurrentToken() == Token::kHASH) { 13807 if (CurrentToken() == Token::kHASH) {
13792 // Closurization of top-level entity in prefix scope. 13808 // Closurization of top-level entity in prefix scope.
hausner 2016/11/11 18:10:38 Need a warning here, I think.
siva 2016/11/11 18:58:00 Done.
13793 return new (Z) LiteralNode(qual_ident_pos, prefix); 13809 return new (Z) LiteralNode(qual_ident_pos, prefix);
13794 } else { 13810 } else {
13795 ExpectToken(Token::kPERIOD); 13811 ExpectToken(Token::kPERIOD);
13796 } 13812 }
13797 } 13813 }
13798 String& ident = *CurrentLiteral(); 13814 String& ident = *CurrentLiteral();
13799 ConsumeToken(); 13815 ConsumeToken();
13800 if (prefix.IsNull()) { 13816 if (prefix.IsNull()) {
13801 intptr_t primary_func_level = 0; 13817 intptr_t primary_func_level = 0;
13802 ResolveIdentInLocalScope(qual_ident_pos, ident, &primary, 13818 ResolveIdentInLocalScope(qual_ident_pos, ident, &primary,
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
14485 const ArgumentListNode& function_args, 14501 const ArgumentListNode& function_args,
14486 const LocalVariable* temp_for_last_arg, 14502 const LocalVariable* temp_for_last_arg,
14487 bool is_super_invocation) { 14503 bool is_super_invocation) {
14488 UNREACHABLE(); 14504 UNREACHABLE();
14489 return NULL; 14505 return NULL;
14490 } 14506 }
14491 14507
14492 } // namespace dart 14508 } // namespace dart
14493 14509
14494 #endif // DART_PRECOMPILED_RUNTIME 14510 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698