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

Unified Diff: runtime/vm/parser.cc

Issue 1851753002: Enable conditional directives by default. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 8eb3d515abfffe158757b339f49a04ddeb28102e..80398ea7fdbd3f199335f6dd68af2badeb0b4150 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -44,8 +44,6 @@ namespace dart {
DEFINE_FLAG(bool, enable_debug_break, false, "Allow use of break \"message\".");
DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations.");
DEFINE_FLAG(bool, warn_mixin_typedef, true, "Warning on legacy mixin typedef.");
-DEFINE_FLAG(bool, conditional_directives, false,
- "Enable conditional directives");
DEFINE_FLAG(bool, warn_super, false,
"Warning if super initializer not last in initializer list.");
DEFINE_FLAG(bool, await_is_keyword, false,
@@ -5798,51 +5796,49 @@ void Parser::ParseLibraryImportExport(const Object& tl_owner,
ConsumeToken();
CheckToken(Token::kSTRING, "library url expected");
AstNode* url_literal = ParseStringLiteral(false);
- if (FLAG_conditional_directives) {
- bool condition_triggered = false;
- while (CurrentToken() == Token::kIF) {
- // Conditional import: if (env == val) uri.
+ bool condition_triggered = false;
+ while (CurrentToken() == Token::kIF) {
+ // Conditional import: if (env == val) uri.
+ ConsumeToken();
+ ExpectToken(Token::kLPAREN);
+ // Parse dotted name.
+ const GrowableObjectArray& pieces =
+ GrowableObjectArray::Handle(Z, GrowableObjectArray::New());
+ pieces.Add(*ExpectIdentifier("identifier expected"));
+ while (CurrentToken() == Token::kPERIOD) {
+ pieces.Add(Symbols::Dot());
ConsumeToken();
- ExpectToken(Token::kLPAREN);
- // Parse dotted name.
- const GrowableObjectArray& pieces =
- GrowableObjectArray::Handle(Z, GrowableObjectArray::New());
pieces.Add(*ExpectIdentifier("identifier expected"));
- while (CurrentToken() == Token::kPERIOD) {
- pieces.Add(Symbols::Dot());
- ConsumeToken();
- pieces.Add(*ExpectIdentifier("identifier expected"));
- }
- AstNode* valueNode = NULL;
- if (CurrentToken() == Token::kEQ) {
- ConsumeToken();
- CheckToken(Token::kSTRING, "string literal expected");
- valueNode = ParseStringLiteral(false);
- ASSERT(valueNode->IsLiteralNode());
- ASSERT(valueNode->AsLiteralNode()->literal().IsString());
- }
- ExpectToken(Token::kRPAREN);
- CheckToken(Token::kSTRING, "library url expected");
- AstNode* conditional_url_literal = ParseStringLiteral(false);
-
- // If there was already a condition that triggered, don't try to match
- // again.
- if (condition_triggered) {
- continue;
- }
- // Check if this conditional line overrides the default import.
- const String& key = String::Handle(
- String::ConcatAll(Array::Handle(Array::MakeArray(pieces))));
- const String& value = (valueNode == NULL)
- ? Symbols::True()
- : String::Cast(valueNode->AsLiteralNode()->literal());
- // Call the embedder to supply us with the environment.
- const String& env_value =
- String::Handle(Api::GetEnvironmentValue(T, key));
- if (!env_value.IsNull() && env_value.Equals(value)) {
- condition_triggered = true;
- url_literal = conditional_url_literal;
- }
+ }
+ AstNode* valueNode = NULL;
+ if (CurrentToken() == Token::kEQ) {
+ ConsumeToken();
+ CheckToken(Token::kSTRING, "string literal expected");
+ valueNode = ParseStringLiteral(false);
+ ASSERT(valueNode->IsLiteralNode());
+ ASSERT(valueNode->AsLiteralNode()->literal().IsString());
+ }
+ ExpectToken(Token::kRPAREN);
+ CheckToken(Token::kSTRING, "library url expected");
+ AstNode* conditional_url_literal = ParseStringLiteral(false);
+
+ // If there was already a condition that triggered, don't try to match
+ // again.
+ if (condition_triggered) {
+ continue;
+ }
+ // Check if this conditional line overrides the default import.
+ const String& key = String::Handle(
+ String::ConcatAll(Array::Handle(Array::MakeArray(pieces))));
+ const String& value = (valueNode == NULL)
+ ? Symbols::True()
+ : String::Cast(valueNode->AsLiteralNode()->literal());
+ // Call the embedder to supply us with the environment.
+ const String& env_value =
+ String::Handle(Api::GetEnvironmentValue(T, key));
+ if (!env_value.IsNull() && env_value.Equals(value)) {
+ condition_triggered = true;
+ url_literal = conditional_url_literal;
}
}
ASSERT(url_literal->IsLiteralNode());

Powered by Google App Engine
This is Rietveld 408576698