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

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

Issue 11225006: Handle super != and ? (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('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 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 operator_args->Add(index_expr); 1456 operator_args->Add(index_expr);
1457 operator_args->Add(value); 1457 operator_args->Add(value);
1458 1458
1459 if (is_no_such_method) { 1459 if (is_no_such_method) {
1460 operator_args = BuildNoSuchMethodArguments(assign_index_operator_name, 1460 operator_args = BuildNoSuchMethodArguments(assign_index_operator_name,
1461 *operator_args); 1461 *operator_args);
1462 } 1462 }
1463 super_op = new StaticCallNode( 1463 super_op = new StaticCallNode(
1464 operator_pos, assign_index_operator, operator_args); 1464 operator_pos, assign_index_operator, operator_args);
1465 } 1465 }
1466 } else if (Token::CanBeOverloaded(CurrentToken())) { 1466 } else if (Token::CanBeOverloaded(CurrentToken()) ||
1467 (CurrentToken() == Token::kNE)) {
1467 Token::Kind op = CurrentToken(); 1468 Token::Kind op = CurrentToken();
1468 ConsumeToken(); 1469 ConsumeToken();
1469 1470
1471 bool negate_result = false;
1472 if (op == Token::kNE) {
1473 op = Token::kEQ;
1474 negate_result = true;
1475 }
1476
1470 // Resolve the operator function in the superclass. 1477 // Resolve the operator function in the superclass.
1471 const String& operator_function_name = 1478 const String& operator_function_name =
1472 String::Handle(Symbols::New(Token::Str(op))); 1479 String::Handle(Symbols::New(Token::Str(op)));
1473 const bool kResolveGetter = false; 1480 const bool kResolveGetter = false;
1474 bool is_no_such_method = false; 1481 bool is_no_such_method = false;
1475 const Function& super_operator = Function::ZoneHandle( 1482 const Function& super_operator = Function::ZoneHandle(
1476 GetSuperFunction(operator_pos, 1483 GetSuperFunction(operator_pos,
1477 operator_function_name, 1484 operator_function_name,
1478 kResolveGetter, 1485 kResolveGetter,
1479 &is_no_such_method)); 1486 &is_no_such_method));
1480 1487
1481 ASSERT(Token::Precedence(op) >= Token::Precedence(Token::kBIT_OR)); 1488 ASSERT(Token::Precedence(op) >= Token::Precedence(Token::kBIT_OR));
1482 AstNode* other_operand = ParseBinaryExpr(Token::Precedence(op) + 1); 1489 AstNode* other_operand = ParseBinaryExpr(Token::Precedence(op) + 1);
1483 1490
1484 ArgumentListNode* op_arguments = new ArgumentListNode(operator_pos); 1491 ArgumentListNode* op_arguments = new ArgumentListNode(operator_pos);
1485 AstNode* receiver = LoadReceiver(operator_pos); 1492 AstNode* receiver = LoadReceiver(operator_pos);
1486 op_arguments->Add(receiver); 1493 op_arguments->Add(receiver);
1487 op_arguments->Add(other_operand); 1494 op_arguments->Add(other_operand);
1488 1495
1489 CheckFunctionIsCallable(operator_pos, super_operator); 1496 CheckFunctionIsCallable(operator_pos, super_operator);
1490 if (is_no_such_method) { 1497 if (is_no_such_method) {
1491 op_arguments = BuildNoSuchMethodArguments(operator_function_name, 1498 op_arguments = BuildNoSuchMethodArguments(operator_function_name,
1492 *op_arguments); 1499 *op_arguments);
1493 } 1500 }
1494 super_op = new StaticCallNode(operator_pos, super_operator, op_arguments); 1501 super_op = new StaticCallNode(operator_pos, super_operator, op_arguments);
1502 if (negate_result) {
1503 super_op = new UnaryOpNode(operator_pos, Token::kNOT, super_op);
1504 }
1495 } 1505 }
1496 return super_op; 1506 return super_op;
1497 } 1507 }
1498 1508
1499 1509
1500 AstNode* Parser::CreateImplicitClosureNode(const Function& func, 1510 AstNode* Parser::CreateImplicitClosureNode(const Function& func,
1501 intptr_t token_pos, 1511 intptr_t token_pos,
1502 AstNode* receiver) { 1512 AstNode* receiver) {
1503 Function& implicit_closure_function = 1513 Function& implicit_closure_function =
1504 Function::ZoneHandle(func.ImplicitClosureFunction()); 1514 Function::ZoneHandle(func.ImplicitClosureFunction());
(...skipping 7916 matching lines...) Expand 10 before | Expand all | Expand 10 after
9421 ConsumeToken(); 9431 ConsumeToken();
9422 if (CurrentToken() == Token::kPERIOD) { 9432 if (CurrentToken() == Token::kPERIOD) {
9423 ConsumeToken(); 9433 ConsumeToken();
9424 const String& ident = *ExpectIdentifier("identifier expected"); 9434 const String& ident = *ExpectIdentifier("identifier expected");
9425 if (CurrentToken() == Token::kLPAREN) { 9435 if (CurrentToken() == Token::kLPAREN) {
9426 primary = ParseSuperCall(ident); 9436 primary = ParseSuperCall(ident);
9427 } else { 9437 } else {
9428 primary = ParseSuperFieldAccess(ident); 9438 primary = ParseSuperFieldAccess(ident);
9429 } 9439 }
9430 } else if ((CurrentToken() == Token::kLBRACK) || 9440 } else if ((CurrentToken() == Token::kLBRACK) ||
9431 Token::CanBeOverloaded(CurrentToken())) { 9441 Token::CanBeOverloaded(CurrentToken()) ||
9442 (CurrentToken() == Token::kNE)) {
9432 primary = ParseSuperOperator(); 9443 primary = ParseSuperOperator();
9433 } else { 9444 } else {
9434 ErrorMsg("illegal super call"); 9445 ErrorMsg("illegal super call");
9435 } 9446 }
9436 } else if (CurrentToken() == Token::kCONDITIONAL) { 9447 } else if (CurrentToken() == Token::kCONDITIONAL) {
9437 primary = ParseArgumentDefinitionTest(); 9448 primary = ParseArgumentDefinitionTest();
9438 } else { 9449 } else {
9439 UnexpectedToken(); 9450 UnexpectedToken();
9440 } 9451 }
9441 return primary; 9452 return primary;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
9625 } else { 9636 } else {
9626 SkipNewOperator(); 9637 SkipNewOperator();
9627 } 9638 }
9628 break; 9639 break;
9629 case Token::kLT: 9640 case Token::kLT:
9630 case Token::kLBRACE: 9641 case Token::kLBRACE:
9631 case Token::kLBRACK: 9642 case Token::kLBRACK:
9632 case Token::kINDEX: 9643 case Token::kINDEX:
9633 SkipCompoundLiteral(); 9644 SkipCompoundLiteral();
9634 break; 9645 break;
9646 case Token::kCONDITIONAL:
9647 ConsumeToken();
9648 if (IsIdentifier()) {
9649 ConsumeToken();
9650 }
9651 break;
9635 default: 9652 default:
9636 if (IsIdentifier()) { 9653 if (IsIdentifier()) {
9637 ConsumeToken(); // Handle pseudo-keyword identifiers. 9654 ConsumeToken(); // Handle pseudo-keyword identifiers.
9638 } else { 9655 } else {
9639 UnexpectedToken(); 9656 UnexpectedToken();
9640 UNREACHABLE(); 9657 UNREACHABLE();
9641 } 9658 }
9642 break; 9659 break;
9643 } 9660 }
9644 } 9661 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
9741 void Parser::SkipQualIdent() { 9758 void Parser::SkipQualIdent() {
9742 ASSERT(IsIdentifier()); 9759 ASSERT(IsIdentifier());
9743 ConsumeToken(); 9760 ConsumeToken();
9744 if (CurrentToken() == Token::kPERIOD) { 9761 if (CurrentToken() == Token::kPERIOD) {
9745 ConsumeToken(); // Consume the kPERIOD token. 9762 ConsumeToken(); // Consume the kPERIOD token.
9746 ExpectIdentifier("identifier expected after '.'"); 9763 ExpectIdentifier("identifier expected after '.'");
9747 } 9764 }
9748 } 9765 }
9749 9766
9750 } // namespace dart 9767 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698