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

Side by Side Diff: runtime/vm/parser.cc

Issue 2411633002: Add `=` as default-value separator for named parameters. (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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 2166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2177 2177
2178 if ((CurrentToken() == Token::kASSIGN) || (CurrentToken() == Token::kCOLON)) { 2178 if ((CurrentToken() == Token::kASSIGN) || (CurrentToken() == Token::kCOLON)) {
2179 if ((!params->has_optional_positional_parameters && 2179 if ((!params->has_optional_positional_parameters &&
2180 !params->has_optional_named_parameters) || 2180 !params->has_optional_named_parameters) ||
2181 !allow_explicit_default_value) { 2181 !allow_explicit_default_value) {
2182 ReportError("parameter must not specify a default value"); 2182 ReportError("parameter must not specify a default value");
2183 } 2183 }
2184 if (params->has_optional_positional_parameters) { 2184 if (params->has_optional_positional_parameters) {
2185 ExpectToken(Token::kASSIGN); 2185 ExpectToken(Token::kASSIGN);
2186 } else { 2186 } else {
2187 ExpectToken(Token::kCOLON); 2187 ConsumeToken();
eernst 2016/10/11 20:59:50 It was not obvious to me why this would work, but
Lasse Reichstein Nielsen 2016/10/12 06:10:58 Correct. ConsumeToken is used to drop the current
2188 } 2188 }
2189 params->num_optional_parameters++; 2189 params->num_optional_parameters++;
2190 params->has_explicit_default_values = true; // Also if explicitly NULL. 2190 params->has_explicit_default_values = true; // Also if explicitly NULL.
2191 if (is_top_level_) { 2191 if (is_top_level_) {
2192 // Skip default value parsing. 2192 // Skip default value parsing.
2193 SkipExpr(); 2193 SkipExpr();
2194 } else { 2194 } else {
2195 const Instance& const_value = ParseConstExpr()->literal(); 2195 const Instance& const_value = ParseConstExpr()->literal();
2196 parameter.default_value = &const_value; 2196 parameter.default_value = &const_value;
2197 } 2197 }
(...skipping 12896 matching lines...) Expand 10 before | Expand all | Expand 10 after
15094 const ArgumentListNode& function_args, 15094 const ArgumentListNode& function_args,
15095 const LocalVariable* temp_for_last_arg, 15095 const LocalVariable* temp_for_last_arg,
15096 bool is_super_invocation) { 15096 bool is_super_invocation) {
15097 UNREACHABLE(); 15097 UNREACHABLE();
15098 return NULL; 15098 return NULL;
15099 } 15099 }
15100 15100
15101 } // namespace dart 15101 } // namespace dart
15102 15102
15103 #endif // DART_PRECOMPILED_RUNTIME 15103 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698