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

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

Issue 10911206: Remove support for operator negate and replace occurrences with unary (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « runtime/lib/integers.dart ('k') | runtime/vm/token.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 2405 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 // empty parameter list is no longer supported. 2416 // empty parameter list is no longer supported.
2417 if (CurrentToken() == Token::kLPAREN) { 2417 if (CurrentToken() == Token::kLPAREN) {
2418 ConsumeToken(); 2418 ConsumeToken();
2419 ExpectToken(Token::kRPAREN); 2419 ExpectToken(Token::kRPAREN);
2420 } 2420 }
2421 } 2421 }
2422 2422
2423 // Now that we know the parameter list, we can distinguish between the 2423 // Now that we know the parameter list, we can distinguish between the
2424 // unary and binary operator -. 2424 // unary and binary operator -.
2425 if (method->has_operator && 2425 if (method->has_operator &&
2426 ((method->name->Equals(Token::Str(Token::kNEGATE))) || 2426 method->name->Equals("-") &&
2427 method->name->Equals("-")) &&
2428 (method->params.num_fixed_parameters == 1)) { 2427 (method->params.num_fixed_parameters == 1)) {
2429 // Patch up name for unary operator - so it does not clash with the 2428 // Patch up name for unary operator - so it does not clash with the
2430 // name for binary operator -. 2429 // name for binary operator -.
2431 *method->name = Symbols::New("unary-"); 2430 *method->name = Symbols::New("unary-");
2432 } 2431 }
2433 2432
2434 if (members->FunctionNameExists(*method->name, method->kind)) { 2433 if (members->FunctionNameExists(*method->name, method->kind)) {
2435 ErrorMsg(method->name_pos, 2434 ErrorMsg(method->name_pos,
2436 "field or method '%s' already defined", method->name->ToCString()); 2435 "field or method '%s' already defined", method->name->ToCString());
2437 } 2436 }
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
2762 intptr_t expected_num_parameters; // Includes receiver. 2761 intptr_t expected_num_parameters; // Includes receiver.
2763 if (operator_token == Token::kASSIGN_INDEX) { 2762 if (operator_token == Token::kASSIGN_INDEX) {
2764 expected_num_parameters = 3; 2763 expected_num_parameters = 3;
2765 } else if (operator_token == Token::kSUB) { 2764 } else if (operator_token == Token::kSUB) {
2766 if (member.params.num_fixed_parameters == 1) { 2765 if (member.params.num_fixed_parameters == 1) {
2767 // Unary operator minus (i.e. negate). 2766 // Unary operator minus (i.e. negate).
2768 expected_num_parameters = 1; 2767 expected_num_parameters = 1;
2769 } else { 2768 } else {
2770 expected_num_parameters = 2; 2769 expected_num_parameters = 2;
2771 } 2770 }
2772 } else if ((operator_token == Token::kNEGATE) || 2771 } else if (operator_token == Token::kBIT_NOT) {
2773 (operator_token == Token::kBIT_NOT)) {
2774 // TODO(hausner): Remove support for keyword 'negate'.
2775 expected_num_parameters = 1; 2772 expected_num_parameters = 1;
2776 } else { 2773 } else {
2777 expected_num_parameters = 2; 2774 expected_num_parameters = 2;
2778 } 2775 }
2779 if ((member.params.num_optional_parameters > 0) || 2776 if ((member.params.num_optional_parameters > 0) ||
2780 member.params.has_optional_positional_parameters || 2777 member.params.has_optional_positional_parameters ||
2781 member.params.has_optional_named_parameters || 2778 member.params.has_optional_named_parameters ||
2782 (member.params.num_fixed_parameters != expected_num_parameters)) { 2779 (member.params.num_fixed_parameters != expected_num_parameters)) {
2783 // Subtract receiver when reporting number of expected arguments. 2780 // Subtract receiver when reporting number of expected arguments.
2784 ErrorMsg(member.name_pos, "operator %s expects %"Pd" argument(s)", 2781 ErrorMsg(member.name_pos, "operator %s expects %"Pd" argument(s)",
(...skipping 6687 matching lines...) Expand 10 before | Expand all | Expand 10 after
9472 void Parser::SkipQualIdent() { 9469 void Parser::SkipQualIdent() {
9473 ASSERT(IsIdentifier()); 9470 ASSERT(IsIdentifier());
9474 ConsumeToken(); 9471 ConsumeToken();
9475 if (CurrentToken() == Token::kPERIOD) { 9472 if (CurrentToken() == Token::kPERIOD) {
9476 ConsumeToken(); // Consume the kPERIOD token. 9473 ConsumeToken(); // Consume the kPERIOD token.
9477 ExpectIdentifier("identifier expected after '.'"); 9474 ExpectIdentifier("identifier expected after '.'");
9478 } 9475 }
9479 } 9476 }
9480 9477
9481 } // namespace dart 9478 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/integers.dart ('k') | runtime/vm/token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698