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

Side by Side Diff: lib/compiler/implementation/resolver.dart

Issue 10540048: Implement 'as' operator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make "as" a builtin identifier. Created 8 years, 6 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
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 Type getType(TypeAnnotation annotation); 8 Type getType(TypeAnnotation annotation);
9 } 9 }
10 10
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 error(argument, MessageKind.INVALID_ARGUMENT_AFTER_NAMED); 1021 error(argument, MessageKind.INVALID_ARGUMENT_AFTER_NAMED);
1022 } 1022 }
1023 } 1023 }
1024 mapping.setSelector(node, new Selector.invocation(count, namedArguments)); 1024 mapping.setSelector(node, new Selector.invocation(count, namedArguments));
1025 } 1025 }
1026 1026
1027 visitSend(Send node) { 1027 visitSend(Send node) {
1028 Element target = resolveSend(node); 1028 Element target = resolveSend(node);
1029 if (node.isOperator) { 1029 if (node.isOperator) {
1030 Operator op = node.selector.asOperator(); 1030 Operator op = node.selector.asOperator();
1031 if (op.source.stringValue === 'is') { 1031 if (op.source.stringValue === 'is' || op.source.stringValue === 'as') {
1032 resolveTypeTest(node.arguments.head); 1032 resolveTypeTest(node.arguments.head);
1033 assert(node.arguments.tail.isEmpty()); 1033 assert(node.arguments.tail.isEmpty());
1034 mapping.setSelector(node, Selector.BINARY_OPERATOR); 1034 mapping.setSelector(node, Selector.BINARY_OPERATOR);
1035 } else if (node.arguments.isEmpty()) { 1035 } else if (node.arguments.isEmpty()) {
1036 assert(op.token.kind !== PLUS_TOKEN); 1036 assert(op.token.kind !== PLUS_TOKEN);
1037 mapping.setSelector(node, Selector.UNARY_OPERATOR); 1037 mapping.setSelector(node, Selector.UNARY_OPERATOR);
1038 } else { 1038 } else {
1039 visit(node.argumentsNode); 1039 visit(node.argumentsNode);
1040 mapping.setSelector(node, Selector.BINARY_OPERATOR); 1040 mapping.setSelector(node, Selector.BINARY_OPERATOR);
1041 } 1041 }
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 2004
2005 TopScope(LibraryElement library) : super(null, library); 2005 TopScope(LibraryElement library) : super(null, library);
2006 Element lookup(SourceString name) { 2006 Element lookup(SourceString name) {
2007 return library.find(name); 2007 return library.find(name);
2008 } 2008 }
2009 2009
2010 Element add(Element newElement) { 2010 Element add(Element newElement) {
2011 throw "Cannot add an element in the top scope"; 2011 throw "Cannot add an element in the top scope";
2012 } 2012 }
2013 } 2013 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698