| OLD | NEW |
| 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 Loading... |
| 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 11600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11658 return left; | 11659 return left; |
| 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) { |
| 11669 if (FLAG_warn_new_tearoff_syntax) { |
| 11670 ReportWarning( |
| 11671 "Tear-offs using the x#id syntax is a deprecated feature," |
| 11672 "it will not be supported in the next release"); |
| 11673 } |
| 11668 ExpectToken(Token::kHASH); | 11674 ExpectToken(Token::kHASH); |
| 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(); |
| (...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13243 (la3 == Token::kLT) || (la3 == Token::kPERIOD) || (la3 == Token::kHASH); | 13249 (la3 == Token::kLT) || (la3 == Token::kPERIOD) || (la3 == Token::kHASH); |
| 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()); |
| 13259 if (FLAG_warn_new_tearoff_syntax) { |
| 13260 ReportWarning( |
| 13261 "Tear-offs using the x#id syntax is a deprecated feature," |
| 13262 "it will not be supported in the next release"); |
| 13263 } |
| 13253 ExpectToken(Token::kHASH); | 13264 ExpectToken(Token::kHASH); |
| 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(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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) { |
| 13808 if (FLAG_warn_new_tearoff_syntax) { |
| 13809 ReportWarning( |
| 13810 "Tear-offs using the x#id syntax is a deprecated feature," |
| 13811 "it will not be supported in the next release"); |
| 13812 } |
| 13792 // Closurization of top-level entity in prefix scope. | 13813 // Closurization of top-level entity in prefix scope. |
| 13793 return new (Z) LiteralNode(qual_ident_pos, prefix); | 13814 return new (Z) LiteralNode(qual_ident_pos, prefix); |
| 13794 } else { | 13815 } else { |
| 13795 ExpectToken(Token::kPERIOD); | 13816 ExpectToken(Token::kPERIOD); |
| 13796 } | 13817 } |
| 13797 } | 13818 } |
| 13798 String& ident = *CurrentLiteral(); | 13819 String& ident = *CurrentLiteral(); |
| 13799 ConsumeToken(); | 13820 ConsumeToken(); |
| 13800 if (prefix.IsNull()) { | 13821 if (prefix.IsNull()) { |
| 13801 intptr_t primary_func_level = 0; | 13822 intptr_t primary_func_level = 0; |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14485 const ArgumentListNode& function_args, | 14506 const ArgumentListNode& function_args, |
| 14486 const LocalVariable* temp_for_last_arg, | 14507 const LocalVariable* temp_for_last_arg, |
| 14487 bool is_super_invocation) { | 14508 bool is_super_invocation) { |
| 14488 UNREACHABLE(); | 14509 UNREACHABLE(); |
| 14489 return NULL; | 14510 return NULL; |
| 14490 } | 14511 } |
| 14491 | 14512 |
| 14492 } // namespace dart | 14513 } // namespace dart |
| 14493 | 14514 |
| 14494 #endif // DART_PRECOMPILED_RUNTIME | 14515 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |