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

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

Issue 9802023: Correctly handle constness for list and map literals inside bodies. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add TODOs. Created 8 years, 9 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 Visitor<R> { 5 interface Visitor<R> {
6 R visitBlock(Block node); 6 R visitBlock(Block node);
7 R visitBreakStatement(BreakStatement node); 7 R visitBreakStatement(BreakStatement node);
8 R visitCatchBlock(CatchBlock node); 8 R visitCatchBlock(CatchBlock node);
9 R visitClassNode(ClassNode node); 9 R visitClassNode(ClassNode node);
10 R visitConditional(Conditional node); 10 R visitConditional(Conditional node);
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 1213
1214 Token getBeginToken() => semicolonToken; 1214 Token getBeginToken() => semicolonToken;
1215 1215
1216 Token getEndToken() => semicolonToken; 1216 Token getEndToken() => semicolonToken;
1217 } 1217 }
1218 1218
1219 class LiteralMap extends Expression { 1219 class LiteralMap extends Expression {
1220 final NodeList typeArguments; 1220 final NodeList typeArguments;
1221 final NodeList entries; 1221 final NodeList entries;
1222 1222
1223 LiteralMap(this.typeArguments, this.entries); 1223 final Token constKeyword;
1224 1224
1225 bool isConst() => false; // TODO(ahe): Store constness. 1225 LiteralMap(this.typeArguments, this.entries, this.constKeyword);
1226
1227 bool isConst() => constKeyword !== null;
1226 1228
1227 LiteralMap asLiteralMap() => this; 1229 LiteralMap asLiteralMap() => this;
1228 1230
1229 accept(Visitor visitor) => visitor.visitLiteralMap(this); 1231 accept(Visitor visitor) => visitor.visitLiteralMap(this);
1230 1232
1231 visitChildren(Visitor visitor) { 1233 visitChildren(Visitor visitor) {
1232 if (typeArguments != null) typeArguments.accept(visitor); 1234 if (typeArguments != null) typeArguments.accept(visitor);
1233 entries.accept(visitor); 1235 entries.accept(visitor);
1234 } 1236 }
1235 1237
1236 Token getBeginToken() => firstBeginToken(typeArguments, entries); 1238 Token getBeginToken() {
1239 if (constKeyword !== null) return constKeyword;
1240 return firstBeginToken(typeArguments, entries);
1241 }
1237 1242
1238 Token getEndToken() => entries.getEndToken(); 1243 Token getEndToken() => entries.getEndToken();
1239 } 1244 }
1240 1245
1241 class LiteralMapEntry extends Node { 1246 class LiteralMapEntry extends Node {
1242 final Expression key; 1247 final Expression key;
1243 final Expression value; 1248 final Expression value;
1244 1249
1245 final Token colonToken; 1250 final Token colonToken;
1246 1251
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 * argument). 1640 * argument).
1636 * 1641 *
1637 * TODO(ahe): This method is controversial, the team needs to discuss 1642 * TODO(ahe): This method is controversial, the team needs to discuss
1638 * if top-level methods are acceptable and what naming conventions to 1643 * if top-level methods are acceptable and what naming conventions to
1639 * use. 1644 * use.
1640 */ 1645 */
1641 initializerDo(Node node, f(Node node)) { 1646 initializerDo(Node node, f(Node node)) {
1642 SendSet send = node.asSendSet(); 1647 SendSet send = node.asSendSet();
1643 if (send !== null) return f(send.arguments.head); 1648 if (send !== null) return f(send.arguments.head);
1644 } 1649 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/builder.dart ('k') | lib/compiler/implementation/tree/unparser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698