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

Side by Side Diff: frog/leg/resolver.dart

Issue 9310066: Generate a resolution error if a unary + is used for something other than numbers. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 10 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 | frog/leg/ssa/builder.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 interface TreeElements { 5 interface TreeElements {
6 Element operator[](Node node); 6 Element operator[](Node node);
7 Selector getSelector(Send send); 7 Selector getSelector(Send send);
8 } 8 }
9 9
10 class TreeElementMapping implements TreeElements { 10 class TreeElementMapping implements TreeElements {
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 NamedArgument named = argument; 616 NamedArgument named = argument;
617 namedArguments.add(named.name.source); 617 namedArguments.add(named.name.source);
618 } 618 }
619 } 619 }
620 mapping.setSelector(node, new Invocation(count, namedArguments)); 620 mapping.setSelector(node, new Invocation(count, namedArguments));
621 } 621 }
622 622
623 visitSend(Send node) { 623 visitSend(Send node) {
624 Element target = resolveSend(node); 624 Element target = resolveSend(node);
625 if (node.isOperator) { 625 if (node.isOperator) {
626 if (node.selector.asIdentifier().source.stringValue === 'is') { 626 Operator op = node.selector.asOperator();
627 if (op.source.stringValue === 'is') {
627 resolveTypeTest(node.arguments.head); 628 resolveTypeTest(node.arguments.head);
628 assert(node.arguments.tail.isEmpty()); 629 assert(node.arguments.tail.isEmpty());
629 mapping.setSelector(node, Selector.BINARY_OPERATOR); 630 mapping.setSelector(node, Selector.BINARY_OPERATOR);
630 } else if (node.arguments.isEmpty()) { 631 } else if (node.arguments.isEmpty()) {
632 if (node.isPrefix && op.source.stringValue === '+'
633 && node.receiver.asLiteralInt() === null
634 && node.receiver.asLiteralDouble() === null) {
635 error(node, MessageKind.EXPECTED_LITERAL_NUMBER);
636 }
631 mapping.setSelector(node, Selector.UNARY_OPERATOR); 637 mapping.setSelector(node, Selector.UNARY_OPERATOR);
632 } else { 638 } else {
633 visit(node.argumentsNode); 639 visit(node.argumentsNode);
634 mapping.setSelector(node, Selector.BINARY_OPERATOR); 640 mapping.setSelector(node, Selector.BINARY_OPERATOR);
635 } 641 }
636 } else if (node.isIndex) { 642 } else if (node.isIndex) {
637 visit(node.argumentsNode); 643 visit(node.argumentsNode);
638 assert(node.arguments.tail.isEmpty()); 644 assert(node.arguments.tail.isEmpty());
639 mapping.setSelector(node, Selector.INDEX); 645 mapping.setSelector(node, Selector.INDEX);
640 } else if (node.isPropertyAccess) { 646 } else if (node.isPropertyAccess) {
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 class TopScope extends Scope { 1166 class TopScope extends Scope {
1161 LibraryElement library; 1167 LibraryElement library;
1162 1168
1163 TopScope(LibraryElement this.library) : super(null, null); 1169 TopScope(LibraryElement this.library) : super(null, null);
1164 Element lookup(SourceString name) => library.find(name); 1170 Element lookup(SourceString name) => library.find(name);
1165 1171
1166 Element add(Element element) { 1172 Element add(Element element) {
1167 throw "Cannot add an element in the top scope"; 1173 throw "Cannot add an element in the top scope";
1168 } 1174 }
1169 } 1175 }
OLDNEW
« no previous file with comments | « no previous file | frog/leg/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698