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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/tree/nodes.dart

Issue 21511003: Support symbol literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 part of tree; 5 part of tree;
6 6
7 abstract class Visitor<R> { 7 abstract class Visitor<R> {
8 const Visitor(); 8 const Visitor();
9 9
10 R visitNode(Node node); 10 R visitNode(Node node);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 R visitSend(Send node) => visitExpression(node); 69 R visitSend(Send node) => visitExpression(node);
70 R visitSendSet(SendSet node) => visitSend(node); 70 R visitSendSet(SendSet node) => visitSend(node);
71 R visitStatement(Statement node) => visitNode(node); 71 R visitStatement(Statement node) => visitNode(node);
72 R visitStringNode(StringNode node) => visitExpression(node); 72 R visitStringNode(StringNode node) => visitExpression(node);
73 R visitStringInterpolation(StringInterpolation node) => visitStringNode(node); 73 R visitStringInterpolation(StringInterpolation node) => visitStringNode(node);
74 R visitStringInterpolationPart(StringInterpolationPart node) { 74 R visitStringInterpolationPart(StringInterpolationPart node) {
75 return visitNode(node); 75 return visitNode(node);
76 } 76 }
77 R visitSwitchCase(SwitchCase node) => visitNode(node); 77 R visitSwitchCase(SwitchCase node) => visitNode(node);
78 R visitSwitchStatement(SwitchStatement node) => visitStatement(node); 78 R visitSwitchStatement(SwitchStatement node) => visitStatement(node);
79 R visitSymbolLiteral(SymbolLiteral node) => visitExpression(node);
79 R visitThrow(Throw node) => visitExpression(node); 80 R visitThrow(Throw node) => visitExpression(node);
80 R visitTryStatement(TryStatement node) => visitStatement(node); 81 R visitTryStatement(TryStatement node) => visitStatement(node);
81 R visitTypeAnnotation(TypeAnnotation node) => visitNode(node); 82 R visitTypeAnnotation(TypeAnnotation node) => visitNode(node);
82 R visitTypedef(Typedef node) => visitNode(node); 83 R visitTypedef(Typedef node) => visitNode(node);
83 R visitTypeVariable(TypeVariable node) => visitNode(node); 84 R visitTypeVariable(TypeVariable node) => visitNode(node);
84 R visitVariableDefinitions(VariableDefinitions node) => visitStatement(node); 85 R visitVariableDefinitions(VariableDefinitions node) => visitStatement(node);
85 R visitWhile(While node) => visitLoop(node); 86 R visitWhile(While node) => visitLoop(node);
86 } 87 }
87 88
88 Token firstBeginToken(Node first, Node second) { 89 Token firstBeginToken(Node first, Node second) {
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 } 941 }
941 942
942 Token getBeginToken() { 943 Token getBeginToken() {
943 if (constKeyword != null) return constKeyword; 944 if (constKeyword != null) return constKeyword;
944 return firstBeginToken(typeArguments, elements); 945 return firstBeginToken(typeArguments, elements);
945 } 946 }
946 947
947 Token getEndToken() => elements.getEndToken(); 948 Token getEndToken() => elements.getEndToken();
948 } 949 }
949 950
951 class SymbolLiteral extends Expression {
ahe 2013/08/06 12:20:55 This should be LiteralSymbol and it probably shoul
Johnni Winther 2013/09/03 12:27:50 Changed to LiteralSymbol. Don't think it should ex
952 final Token hashToken;
953 final Operator operator;
954 final NodeList identifiers;
ahe 2013/08/06 12:20:55 Feels to me like the natural way to represent this
Johnni Winther 2013/09/03 12:27:50 Done.
955
956 SymbolLiteral(this.hashToken, this.operator, this.identifiers);
957
958 SymbolLiteral asSymbolLiteral() => this;
959
960 void visitChildren(Visitor visitor) {
961 if (operator != null) operator.accept(visitor);
962 if (identifiers != null) identifiers.accept(visitor);
963 }
964
965 accept(Visitor visitor) => visitor.visitSymbolLiteral(this);
966
967 Token getBeginToken() => hashToken;
968
969 Token getEndToken() {
970 if (operator != null) return operator.getEndToken();
971 return identifiers.getEndToken();
972 }
973
974 String get nameString {
975 if (operator != null) {
976 return '${operator}';
977 } else {
978 return '${identifiers}';
979 }
980 }
981 }
982
983
950 class Identifier extends Expression { 984 class Identifier extends Expression {
951 final Token token; 985 final Token token;
952 986
953 SourceString get source => token.value; 987 SourceString get source => token.value;
954 988
955 Identifier(Token this.token); 989 Identifier(Token this.token);
956 990
957 bool isThis() => identical(source.stringValue, 'this'); 991 bool isThis() => identical(source.stringValue, 'this');
958 992
959 bool isSuper() => identical(source.stringValue, 'super'); 993 bool isSuper() => identical(source.stringValue, 'super');
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 * argument). 2086 * argument).
2053 * 2087 *
2054 * TODO(ahe): This method is controversial, the team needs to discuss 2088 * TODO(ahe): This method is controversial, the team needs to discuss
2055 * if top-level methods are acceptable and what naming conventions to 2089 * if top-level methods are acceptable and what naming conventions to
2056 * use. 2090 * use.
2057 */ 2091 */
2058 initializerDo(Node node, f(Node node)) { 2092 initializerDo(Node node, f(Node node)) {
2059 SendSet send = node.asSendSet(); 2093 SendSet send = node.asSendSet();
2060 if (send != null) return f(send.arguments.head); 2094 if (send != null) return f(send.arguments.head);
2061 } 2095 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698