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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 11783089: Fix VariableDefinitions.endToken for formal parameters. (Closed) Base URL: https://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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/scanner/listener.dart » ('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 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 Element operator[](Node node); 8 Element operator[](Node node);
9 Selector getSelector(Send send); 9 Selector getSelector(Send send);
10 DartType getType(Node node); 10 DartType getType(Node node);
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 } 593 }
594 } 594 }
595 595
596 void checkUserDefinableOperator(Element member) { 596 void checkUserDefinableOperator(Element member) {
597 FunctionElement function = member.asFunctionElement(); 597 FunctionElement function = member.asFunctionElement();
598 if (function == null) return; 598 if (function == null) return;
599 String value = member.name.stringValue; 599 String value = member.name.stringValue;
600 if (value == null) return; 600 if (value == null) return;
601 if (!(isUserDefinableOperator(value) || identical(value, 'unary-'))) return; 601 if (!(isUserDefinableOperator(value) || identical(value, 'unary-'))) return;
602 602
603 bool isMinus = false;
603 int requiredParameterCount; 604 int requiredParameterCount;
604 MessageKind messageKind; 605 MessageKind messageKind;
605 FunctionSignature signature = function.computeSignature(compiler); 606 FunctionSignature signature = function.computeSignature(compiler);
606 if (identical(value, 'unary-')) { 607 if (identical(value, 'unary-')) {
608 isMinus = true;
607 messageKind = MessageKind.MINUS_OPERATOR_BAD_ARITY; 609 messageKind = MessageKind.MINUS_OPERATOR_BAD_ARITY;
608 requiredParameterCount = 0; 610 requiredParameterCount = 0;
609 } else if (isMinusOperator(value)) { 611 } else if (isMinusOperator(value)) {
612 isMinus = true;
610 messageKind = MessageKind.MINUS_OPERATOR_BAD_ARITY; 613 messageKind = MessageKind.MINUS_OPERATOR_BAD_ARITY;
611 requiredParameterCount = 1; 614 requiredParameterCount = 1;
612 } else if (isUnaryOperator(value)) { 615 } else if (isUnaryOperator(value)) {
613 messageKind = MessageKind.UNARY_OPERATOR_BAD_ARITY; 616 messageKind = MessageKind.UNARY_OPERATOR_BAD_ARITY;
614 requiredParameterCount = 0; 617 requiredParameterCount = 0;
615 } else if (isBinaryOperator(value)) { 618 } else if (isBinaryOperator(value)) {
616 messageKind = MessageKind.BINARY_OPERATOR_BAD_ARITY; 619 messageKind = MessageKind.BINARY_OPERATOR_BAD_ARITY;
617 requiredParameterCount = 1; 620 requiredParameterCount = 1;
618 } else if (isTernaryOperator(value)) { 621 } else if (isTernaryOperator(value)) {
619 messageKind = MessageKind.TERNARY_OPERATOR_BAD_ARITY; 622 messageKind = MessageKind.TERNARY_OPERATOR_BAD_ARITY;
620 requiredParameterCount = 2; 623 requiredParameterCount = 2;
621 } else { 624 } else {
622 compiler.internalErrorOnElement(function, 625 compiler.internalErrorOnElement(function,
623 'Unexpected user defined operator $value'); 626 'Unexpected user defined operator $value');
624 } 627 }
625 checkArity(function, requiredParameterCount, messageKind); 628 checkArity(function, requiredParameterCount, messageKind, isMinus);
626 } 629 }
627 630
628 void checkArity(FunctionElement function, 631 void checkArity(FunctionElement function,
629 int requiredParameterCount, MessageKind messageKind) { 632 int requiredParameterCount, MessageKind messageKind,
633 bool isMinus) {
630 FunctionExpression node = function.parseNode(compiler); 634 FunctionExpression node = function.parseNode(compiler);
631 FunctionSignature signature = function.computeSignature(compiler); 635 FunctionSignature signature = function.computeSignature(compiler);
632 if (signature.requiredParameterCount != requiredParameterCount) { 636 if (signature.requiredParameterCount != requiredParameterCount) {
633 Node errorNode = node; 637 Node errorNode = node;
634 if (node.parameters != null) { 638 if (node.parameters != null) {
635 if (signature.requiredParameterCount < requiredParameterCount) { 639 if (isMinus || // Point to the parameter list is case of operator -.
ngeoffray 2013/01/10 14:20:52 is -> in
640 signature.requiredParameterCount < requiredParameterCount) {
636 errorNode = node.parameters; 641 errorNode = node.parameters;
637 } else { 642 } else {
638 errorNode = node.parameters.nodes.skip(requiredParameterCount).head; 643 errorNode = node.parameters.nodes.skip(requiredParameterCount).head;
639 } 644 }
640 } 645 }
641 compiler.reportMessage( 646 compiler.reportMessage(
642 compiler.spanFromNode(errorNode), 647 compiler.spanFromNode(errorNode),
643 messageKind.error([function.name]), 648 messageKind.error([function.name]),
644 Diagnostic.ERROR); 649 Diagnostic.ERROR);
645 } 650 }
(...skipping 2759 matching lines...) Expand 10 before | Expand all | Expand 10 after
3405 return e; 3410 return e;
3406 } 3411 }
3407 3412
3408 /// Assumed to be called by [resolveRedirectingFactory]. 3413 /// Assumed to be called by [resolveRedirectingFactory].
3409 Element visitReturn(Return node) { 3414 Element visitReturn(Return node) {
3410 Node expression = node.expression; 3415 Node expression = node.expression;
3411 return finishConstructorReference(visit(expression), 3416 return finishConstructorReference(visit(expression),
3412 expression, expression); 3417 expression, expression);
3413 } 3418 }
3414 } 3419 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/scanner/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698