Chromium Code Reviews| 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 4527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4538 } | 4538 } |
| 4539 | 4539 |
| 4540 | 4540 |
| 4541 void Parser::ParseClassDeclaration(const GrowableObjectArray& pending_classes, | 4541 void Parser::ParseClassDeclaration(const GrowableObjectArray& pending_classes, |
| 4542 const Object& tl_owner, | 4542 const Object& tl_owner, |
| 4543 TokenPosition metadata_pos) { | 4543 TokenPosition metadata_pos) { |
| 4544 TRACE_PARSER("ParseClassDeclaration"); | 4544 TRACE_PARSER("ParseClassDeclaration"); |
| 4545 bool is_patch = false; | 4545 bool is_patch = false; |
| 4546 bool is_abstract = false; | 4546 bool is_abstract = false; |
| 4547 TokenPosition declaration_pos = | 4547 TokenPosition declaration_pos = |
| 4548 metadata_pos.IsReal() ? metadata_pos : TokenPos(); | 4548 metadata_pos.IsReal() ? metadata_pos : TokenPos(); |
| 4549 if (is_patch_source() && | 4549 if (is_patch_source() && IsPatchAnnotation(metadata_pos)) { |
| 4550 is_patch = true; | |
| 4551 metadata_pos = TokenPosition::kNoSource; | |
| 4552 declaration_pos = TokenPos(); | |
| 4553 } else if (is_patch_source() && | |
| 4550 (CurrentToken() == Token::kIDENT) && | 4554 (CurrentToken() == Token::kIDENT) && |
| 4551 CurrentLiteral()->Equals("patch")) { | 4555 CurrentLiteral()->Equals("patch")) { |
| 4556 ReportWarning("deprecated use of patch annotation"); | |
|
kasperl
2016/08/09 11:48:09
patch annotation -> patch "keyword"?
hausner
2016/08/09 15:48:45
Done. This legacy support and warning should go aw
| |
| 4552 ConsumeToken(); | 4557 ConsumeToken(); |
| 4553 is_patch = true; | 4558 is_patch = true; |
| 4554 } else if (CurrentToken() == Token::kABSTRACT) { | 4559 } else if (CurrentToken() == Token::kABSTRACT) { |
| 4555 is_abstract = true; | 4560 is_abstract = true; |
| 4556 ConsumeToken(); | 4561 ConsumeToken(); |
| 4557 } | 4562 } |
| 4558 ExpectToken(Token::kCLASS); | 4563 ExpectToken(Token::kCLASS); |
| 4559 const TokenPosition classname_pos = TokenPos(); | 4564 const TokenPosition classname_pos = TokenPos(); |
| 4560 String& class_name = *ExpectUserDefinedTypeIdentifier("class name expected"); | 4565 String& class_name = *ExpectUserDefinedTypeIdentifier("class name expected"); |
| 4561 if (FLAG_trace_parser) { | 4566 if (FLAG_trace_parser) { |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5257 if (token_kind_ == Token::kGT) { | 5262 if (token_kind_ == Token::kGT) { |
| 5258 ConsumeToken(); | 5263 ConsumeToken(); |
| 5259 } else if (token_kind_ == Token::kSHR) { | 5264 } else if (token_kind_ == Token::kSHR) { |
| 5260 token_kind_ = Token::kGT; | 5265 token_kind_ = Token::kGT; |
| 5261 } else { | 5266 } else { |
| 5262 UNREACHABLE(); | 5267 UNREACHABLE(); |
| 5263 } | 5268 } |
| 5264 } | 5269 } |
| 5265 | 5270 |
| 5266 | 5271 |
| 5272 bool Parser::IsPatchAnnotation(TokenPosition pos) { | |
| 5273 if (pos == TokenPosition::kNoSource) { | |
| 5274 return false; | |
| 5275 } | |
| 5276 TokenPosition saved_pos = TokenPos(); | |
| 5277 SetPosition(pos); | |
| 5278 ExpectToken(Token::kAT); | |
| 5279 bool is_patch = IsSymbol(Symbols::Patch()); | |
| 5280 SetPosition(saved_pos); | |
| 5281 return is_patch; | |
| 5282 } | |
| 5283 | |
| 5284 | |
| 5267 TokenPosition Parser::SkipMetadata() { | 5285 TokenPosition Parser::SkipMetadata() { |
| 5268 if (CurrentToken() != Token::kAT) { | 5286 if (CurrentToken() != Token::kAT) { |
| 5269 return TokenPosition::kNoSource; | 5287 return TokenPosition::kNoSource; |
| 5270 } | 5288 } |
| 5271 TokenPosition metadata_pos = TokenPos(); | 5289 TokenPosition metadata_pos = TokenPos(); |
| 5272 while (CurrentToken() == Token::kAT) { | 5290 while (CurrentToken() == Token::kAT) { |
| 5273 ConsumeToken(); | 5291 ConsumeToken(); |
| 5274 ExpectIdentifier("identifier expected"); | 5292 ExpectIdentifier("identifier expected"); |
| 5275 if (CurrentToken() == Token::kPERIOD) { | 5293 if (CurrentToken() == Token::kPERIOD) { |
| 5276 ConsumeToken(); | 5294 ConsumeToken(); |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5599 | 5617 |
| 5600 void Parser::ParseTopLevelFunction(TopLevel* top_level, | 5618 void Parser::ParseTopLevelFunction(TopLevel* top_level, |
| 5601 const Object& owner, | 5619 const Object& owner, |
| 5602 TokenPosition metadata_pos) { | 5620 TokenPosition metadata_pos) { |
| 5603 TRACE_PARSER("ParseTopLevelFunction"); | 5621 TRACE_PARSER("ParseTopLevelFunction"); |
| 5604 const TokenPosition decl_begin_pos = TokenPos(); | 5622 const TokenPosition decl_begin_pos = TokenPos(); |
| 5605 AbstractType& result_type = Type::Handle(Z, Type::DynamicType()); | 5623 AbstractType& result_type = Type::Handle(Z, Type::DynamicType()); |
| 5606 const bool is_static = true; | 5624 const bool is_static = true; |
| 5607 bool is_external = false; | 5625 bool is_external = false; |
| 5608 bool is_patch = false; | 5626 bool is_patch = false; |
| 5609 if (is_patch_source() && | 5627 if (is_patch_source() && IsPatchAnnotation(metadata_pos)) { |
| 5628 is_patch = true; | |
| 5629 metadata_pos = TokenPosition::kNoSource; | |
| 5630 } else if (is_patch_source() && | |
| 5610 (CurrentToken() == Token::kIDENT) && | 5631 (CurrentToken() == Token::kIDENT) && |
| 5611 CurrentLiteral()->Equals("patch") && | 5632 CurrentLiteral()->Equals("patch") && |
| 5612 (LookaheadToken(1) != Token::kLPAREN)) { | 5633 (LookaheadToken(1) != Token::kLPAREN)) { |
| 5634 ReportWarning("deprecated use of patch annotation"); | |
| 5613 ConsumeToken(); | 5635 ConsumeToken(); |
| 5614 is_patch = true; | 5636 is_patch = true; |
| 5615 } else if (CurrentToken() == Token::kEXTERNAL) { | 5637 } else if (CurrentToken() == Token::kEXTERNAL) { |
| 5616 ConsumeToken(); | 5638 ConsumeToken(); |
| 5617 is_external = true; | 5639 is_external = true; |
| 5618 } | 5640 } |
| 5619 if (CurrentToken() == Token::kVOID) { | 5641 if (CurrentToken() == Token::kVOID) { |
| 5620 ConsumeToken(); | 5642 ConsumeToken(); |
| 5621 result_type = Type::VoidType(); | 5643 result_type = Type::VoidType(); |
| 5622 } else { | 5644 } else { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5722 | 5744 |
| 5723 void Parser::ParseTopLevelAccessor(TopLevel* top_level, | 5745 void Parser::ParseTopLevelAccessor(TopLevel* top_level, |
| 5724 const Object& owner, | 5746 const Object& owner, |
| 5725 TokenPosition metadata_pos) { | 5747 TokenPosition metadata_pos) { |
| 5726 TRACE_PARSER("ParseTopLevelAccessor"); | 5748 TRACE_PARSER("ParseTopLevelAccessor"); |
| 5727 const TokenPosition decl_begin_pos = TokenPos(); | 5749 const TokenPosition decl_begin_pos = TokenPos(); |
| 5728 const bool is_static = true; | 5750 const bool is_static = true; |
| 5729 bool is_external = false; | 5751 bool is_external = false; |
| 5730 bool is_patch = false; | 5752 bool is_patch = false; |
| 5731 AbstractType& result_type = AbstractType::Handle(Z); | 5753 AbstractType& result_type = AbstractType::Handle(Z); |
| 5732 if (is_patch_source() && | 5754 if (is_patch_source() && IsPatchAnnotation(metadata_pos)) { |
| 5755 is_patch = true; | |
| 5756 metadata_pos = TokenPosition::kNoSource; | |
| 5757 } else if (is_patch_source() && | |
| 5733 (CurrentToken() == Token::kIDENT) && | 5758 (CurrentToken() == Token::kIDENT) && |
| 5734 CurrentLiteral()->Equals("patch")) { | 5759 CurrentLiteral()->Equals("patch")) { |
| 5760 ReportWarning("deprecated use of patch annotation"); | |
| 5735 ConsumeToken(); | 5761 ConsumeToken(); |
| 5736 is_patch = true; | 5762 is_patch = true; |
| 5737 } else if (CurrentToken() == Token::kEXTERNAL) { | 5763 } else if (CurrentToken() == Token::kEXTERNAL) { |
| 5738 ConsumeToken(); | 5764 ConsumeToken(); |
| 5739 is_external = true; | 5765 is_external = true; |
| 5740 } | 5766 } |
| 5741 bool is_getter = (CurrentToken() == Token::kGET); | 5767 bool is_getter = (CurrentToken() == Token::kGET); |
| 5742 if (CurrentToken() == Token::kGET || | 5768 if (CurrentToken() == Token::kGET || |
| 5743 CurrentToken() == Token::kSET) { | 5769 CurrentToken() == Token::kSET) { |
| 5744 ConsumeToken(); | 5770 ConsumeToken(); |
| (...skipping 8987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14732 const ArgumentListNode& function_args, | 14758 const ArgumentListNode& function_args, |
| 14733 const LocalVariable* temp_for_last_arg, | 14759 const LocalVariable* temp_for_last_arg, |
| 14734 bool is_super_invocation) { | 14760 bool is_super_invocation) { |
| 14735 UNREACHABLE(); | 14761 UNREACHABLE(); |
| 14736 return NULL; | 14762 return NULL; |
| 14737 } | 14763 } |
| 14738 | 14764 |
| 14739 } // namespace dart | 14765 } // namespace dart |
| 14740 | 14766 |
| 14741 #endif // DART_PRECOMPILED_RUNTIME | 14767 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |