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

Unified Diff: runtime/vm/parser.cc

Issue 2220883004: Use metadata annotation @patch for patch classes (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: wip Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« runtime/bin/common_patch.dart ('K') | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 8626a5f91f2a31ff50b019d4a65dccb289b76b8c..f529389486013538a1c2c0e6d3b0d207973cc744 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -4545,10 +4545,15 @@ void Parser::ParseClassDeclaration(const GrowableObjectArray& pending_classes,
bool is_patch = false;
bool is_abstract = false;
TokenPosition declaration_pos =
- metadata_pos.IsReal() ? metadata_pos : TokenPos();
- if (is_patch_source() &&
+ metadata_pos.IsReal() ? metadata_pos : TokenPos();
+ if (is_patch_source() && IsPatchAnnotation(metadata_pos)) {
+ is_patch = true;
+ metadata_pos = TokenPosition::kNoSource;
+ declaration_pos = TokenPos();
+ } else if (is_patch_source() &&
(CurrentToken() == Token::kIDENT) &&
CurrentLiteral()->Equals("patch")) {
+ 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
ConsumeToken();
is_patch = true;
} else if (CurrentToken() == Token::kABSTRACT) {
@@ -5264,6 +5269,19 @@ void Parser::ConsumeRightAngleBracket() {
}
+bool Parser::IsPatchAnnotation(TokenPosition pos) {
+ if (pos == TokenPosition::kNoSource) {
+ return false;
+ }
+ TokenPosition saved_pos = TokenPos();
+ SetPosition(pos);
+ ExpectToken(Token::kAT);
+ bool is_patch = IsSymbol(Symbols::Patch());
+ SetPosition(saved_pos);
+ return is_patch;
+}
+
+
TokenPosition Parser::SkipMetadata() {
if (CurrentToken() != Token::kAT) {
return TokenPosition::kNoSource;
@@ -5606,10 +5624,14 @@ void Parser::ParseTopLevelFunction(TopLevel* top_level,
const bool is_static = true;
bool is_external = false;
bool is_patch = false;
- if (is_patch_source() &&
+ if (is_patch_source() && IsPatchAnnotation(metadata_pos)) {
+ is_patch = true;
+ metadata_pos = TokenPosition::kNoSource;
+ } else if (is_patch_source() &&
(CurrentToken() == Token::kIDENT) &&
CurrentLiteral()->Equals("patch") &&
(LookaheadToken(1) != Token::kLPAREN)) {
+ ReportWarning("deprecated use of patch annotation");
ConsumeToken();
is_patch = true;
} else if (CurrentToken() == Token::kEXTERNAL) {
@@ -5729,9 +5751,13 @@ void Parser::ParseTopLevelAccessor(TopLevel* top_level,
bool is_external = false;
bool is_patch = false;
AbstractType& result_type = AbstractType::Handle(Z);
- if (is_patch_source() &&
+ if (is_patch_source() && IsPatchAnnotation(metadata_pos)) {
+ is_patch = true;
+ metadata_pos = TokenPosition::kNoSource;
+ } else if (is_patch_source() &&
(CurrentToken() == Token::kIDENT) &&
CurrentLiteral()->Equals("patch")) {
+ ReportWarning("deprecated use of patch annotation");
ConsumeToken();
is_patch = true;
} else if (CurrentToken() == Token::kEXTERNAL) {
« runtime/bin/common_patch.dart ('K') | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698