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

Unified Diff: runtime/vm/parser.cc

Issue 11996003: Remove support for old style function literals (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 17243)
+++ runtime/vm/parser.cc (working copy)
@@ -29,8 +29,6 @@
DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings.");
DEFINE_FLAG(bool, warn_legacy_map_literal, false,
"Warning on legacy map literal syntax (single type argument)");
-DEFINE_FLAG(bool, strict_function_literals, false,
- "enforce new function literal rules");
static void CheckedModeHandler(bool value) {
FLAG_enable_asserts = value;
@@ -4728,25 +4726,10 @@
result_type = Type::DynamicType();
intptr_t ident_pos = TokenPos();
- if (FLAG_strict_function_literals) {
- if (is_literal) {
- ASSERT(CurrentToken() == Token::kLPAREN);
- function_name = &Symbols::AnonymousClosure();
- } else {
- if (CurrentToken() == Token::kVOID) {
- ConsumeToken();
- result_type = Type::VoidType();
- } else if ((CurrentToken() == Token::kIDENT) &&
- (LookaheadToken(1) != Token::kLPAREN)) {
- result_type = ParseType(ClassFinalizer::kCanonicalize);
- }
- ident_pos = TokenPos();
- variable_name = ExpectIdentifier("function name expected");
- function_name = variable_name;
- }
+ if (is_literal) {
+ ASSERT(CurrentToken() == Token::kLPAREN);
+ function_name = &Symbols::AnonymousClosure();
} else {
- // TODO(hausner) remove this block once support for old-style function
- // literals is gone.
if (CurrentToken() == Token::kVOID) {
ConsumeToken();
result_type = Type::VoidType();
@@ -4755,16 +4738,8 @@
result_type = ParseType(ClassFinalizer::kCanonicalize);
}
ident_pos = TokenPos();
- if (IsIdentifier()) {
- variable_name = CurrentLiteral();
- function_name = variable_name;
- ConsumeToken();
- } else {
- if (!is_literal) {
- ErrorMsg("function name expected");
- }
- function_name = &Symbols::AnonymousClosure();
- }
+ variable_name = ExpectIdentifier("function name expected");
+ function_name = variable_name;
}
if (CurrentToken() != Token::kLPAREN) {
@@ -5171,46 +5146,18 @@
bool Parser::IsFunctionLiteral() {
- // TODO(hausner): Remove code block that supports old-style function
- // literals.
- if (FLAG_strict_function_literals) {
- if (CurrentToken() != Token::kLPAREN || !allow_function_literals_) {
- return false;
- }
- const intptr_t saved_pos = TokenPos();
- bool is_function_literal = false;
- SkipToMatchingParenthesis();
- if ((CurrentToken() == Token::kLBRACE) ||
- (CurrentToken() == Token::kARROW)) {
- is_function_literal = true;
- }
- SetPosition(saved_pos);
- return is_function_literal;
- } else {
- if (!allow_function_literals_) {
- return false;
- }
- const intptr_t saved_pos = TokenPos();
- bool is_function_literal = false;
- if (IsIdentifier() && (LookaheadToken(1) == Token::kLPAREN)) {
- ConsumeToken(); // Consume function identifier.
- } else if (TryParseReturnType()) {
- if (!IsIdentifier()) {
- SetPosition(saved_pos);
- return false;
- }
- ConsumeToken(); // Comsume function identifier.
- }
- if (CurrentToken() == Token::kLPAREN) {
- SkipToMatchingParenthesis();
- if ((CurrentToken() == Token::kLBRACE) ||
- (CurrentToken() == Token::kARROW)) {
- is_function_literal = true;
- }
- }
- SetPosition(saved_pos);
- return is_function_literal;
+ if (CurrentToken() != Token::kLPAREN || !allow_function_literals_) {
+ return false;
}
+ const intptr_t saved_pos = TokenPos();
+ bool is_function_literal = false;
+ SkipToMatchingParenthesis();
+ if ((CurrentToken() == Token::kLBRACE) ||
+ (CurrentToken() == Token::kARROW)) {
+ is_function_literal = true;
+ }
+ SetPosition(saved_pos);
+ return is_function_literal;
}
« 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