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

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

Issue 10697003: Various token issues fixed in the compiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merged Created 8 years, 5 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 visitCascade(Cascade node); 8 R visitCascade(Cascade node);
9 R visitCascadeReceiver(CascadeReceiver node); 9 R visitCascadeReceiver(CascadeReceiver node);
10 R visitCaseMatch(CaseMatch node); 10 R visitCaseMatch(CaseMatch node);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 R visitThrow(Throw node); 49 R visitThrow(Throw node);
50 R visitTryStatement(TryStatement node); 50 R visitTryStatement(TryStatement node);
51 R visitTypeAnnotation(TypeAnnotation node); 51 R visitTypeAnnotation(TypeAnnotation node);
52 R visitTypedef(Typedef node); 52 R visitTypedef(Typedef node);
53 R visitTypeVariable(TypeVariable node); 53 R visitTypeVariable(TypeVariable node);
54 R visitVariableDefinitions(VariableDefinitions node); 54 R visitVariableDefinitions(VariableDefinitions node);
55 R visitWhile(While node); 55 R visitWhile(While node);
56 } 56 }
57 57
58 Token firstBeginToken(Node first, Node second) { 58 Token firstBeginToken(Node first, Node second) {
59 if (first !== null) return first.getBeginToken(); 59 var token = null;
Lasse Reichstein Nielsen 2012/06/27 09:22:16 var -> Token. Style-guide be damned!
60 if (second !== null) return second.getBeginToken(); 60 if (first !== null) {
61 return null; 61 token = first.getBeginToken();
62 }
63 if (token === null && second !== null) {
64 // token might be null even when first is not, e.g. for empty Modifiers.
Lasse Reichstein Nielsen 2012/06/27 09:22:16 Make "token" and "first" stand out here, e.g., by
65 token = second.getBeginToken();
66 }
67 return token;
62 } 68 }
63 69
64 class NodeAssertionFailure implements Exception { 70 class NodeAssertionFailure implements Exception {
65 final Node node; 71 final Node node;
66 final String message; 72 final String message;
67 NodeAssertionFailure(this.node, this.message); 73 NodeAssertionFailure(this.node, this.message);
68 } 74 }
69 75
70 /** 76 /**
71 * A node in a syntax tree. 77 * A node in a syntax tree.
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 VariableDefinitions asVariableDefinitions() => this; 974 VariableDefinitions asVariableDefinitions() => this;
969 975
970 accept(Visitor visitor) => visitor.visitVariableDefinitions(this); 976 accept(Visitor visitor) => visitor.visitVariableDefinitions(this);
971 977
972 visitChildren(Visitor visitor) { 978 visitChildren(Visitor visitor) {
973 if (type !== null) type.accept(visitor); 979 if (type !== null) type.accept(visitor);
974 if (definitions !== null) definitions.accept(visitor); 980 if (definitions !== null) definitions.accept(visitor);
975 } 981 }
976 982
977 Token getBeginToken() { 983 Token getBeginToken() {
978 return firstBeginToken(type, definitions); 984 var token = firstBeginToken(modifiers, type);
985 if (token === null) {
986 token = definitions.getBeginToken();
987 }
988 return token;
979 } 989 }
980 990
981 Token getEndToken() => endToken; 991 Token getEndToken() => endToken;
982 } 992 }
983 993
984 class Loop extends Statement { 994 class Loop extends Statement {
985 abstract Expression get condition(); 995 abstract Expression get condition();
986 final Statement body; 996 final Statement body;
987 997
988 Loop(this.body); 998 Loop(this.body);
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 * argument). 1716 * argument).
1707 * 1717 *
1708 * TODO(ahe): This method is controversial, the team needs to discuss 1718 * TODO(ahe): This method is controversial, the team needs to discuss
1709 * if top-level methods are acceptable and what naming conventions to 1719 * if top-level methods are acceptable and what naming conventions to
1710 * use. 1720 * use.
1711 */ 1721 */
1712 initializerDo(Node node, f(Node node)) { 1722 initializerDo(Node node, f(Node node)) {
1713 SendSet send = node.asSendSet(); 1723 SendSet send = node.asSendSet();
1714 if (send !== null) return f(send.arguments.head); 1724 if (send !== null) return f(send.arguments.head);
1715 } 1725 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698