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

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

Issue 11087025: Fix to dartbug.com/5170, explictly static library variables now get an appropriate error message. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Comments from Peter. Created 8 years, 2 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 abstract class Visitor<R> { 5 abstract class Visitor<R> {
6 const Visitor(); 6 const Visitor();
7 7
8 abstract R visitNode(Node node); 8 abstract R visitNode(Node node);
9 9
10 R visitBlock(Block node) => visitStatement(node); 10 R visitBlock(Block node) => visitStatement(node);
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 else if (value === 'abstract') flags |= FLAG_ABSTRACT; 1162 else if (value === 'abstract') flags |= FLAG_ABSTRACT;
1163 else if (value === 'final') flags |= FLAG_FINAL; 1163 else if (value === 'final') flags |= FLAG_FINAL;
1164 else if (value === 'var') flags |= FLAG_VAR; 1164 else if (value === 'var') flags |= FLAG_VAR;
1165 else if (value === 'const') flags |= FLAG_CONST; 1165 else if (value === 'const') flags |= FLAG_CONST;
1166 else if (value === 'factory') flags |= FLAG_FACTORY; 1166 else if (value === 'factory') flags |= FLAG_FACTORY;
1167 else if (value === 'external') flags |= FLAG_EXTERNAL; 1167 else if (value === 'external') flags |= FLAG_EXTERNAL;
1168 else throw 'internal error: ${nodes.head}'; 1168 else throw 'internal error: ${nodes.head}';
1169 } 1169 }
1170 return flags; 1170 return flags;
1171 } 1171 }
1172
1173 Node findModifier(String modifier) {
1174 Link<Node> nodeList = nodes.nodes;
1175 for (; !nodeList.isEmpty(); nodeList = nodeList.tail) {
1176 String value = nodeList.head.asIdentifier().source.stringValue;
1177 if(value === modifier) {
1178 return nodeList.head;
1179 }
1180 }
1181 return null;
1182 }
1172 1183
1173 Modifiers asModifiers() => this; 1184 Modifiers asModifiers() => this;
1174 Token getBeginToken() => nodes.getBeginToken(); 1185 Token getBeginToken() => nodes.getBeginToken();
1175 Token getEndToken() => nodes.getEndToken(); 1186 Token getEndToken() => nodes.getEndToken();
1176 accept(Visitor visitor) => visitor.visitModifiers(this); 1187 accept(Visitor visitor) => visitor.visitModifiers(this);
1177 visitChildren(Visitor visitor) => nodes.accept(visitor); 1188 visitChildren(Visitor visitor) => nodes.accept(visitor);
1178 1189
1179 bool isStatic() => (flags & FLAG_STATIC) != 0; 1190 bool isStatic() => (flags & FLAG_STATIC) != 0;
1180 bool isAbstract() => (flags & FLAG_ABSTRACT) != 0; 1191 bool isAbstract() => (flags & FLAG_ABSTRACT) != 0;
1181 bool isFinal() => (flags & FLAG_FINAL) != 0; 1192 bool isFinal() => (flags & FLAG_FINAL) != 0;
1182 bool isVar() => (flags & FLAG_VAR) != 0; 1193 bool isVar() => (flags & FLAG_VAR) != 0;
1183 bool isConst() => (flags & FLAG_CONST) != 0; 1194 bool isConst() => (flags & FLAG_CONST) != 0;
1184 bool isFactory() => (flags & FLAG_FACTORY) != 0; 1195 bool isFactory() => (flags & FLAG_FACTORY) != 0;
1185 bool isExternal() => (flags & FLAG_EXTERNAL) != 0; 1196 bool isExternal() => (flags & FLAG_EXTERNAL) != 0;
1186 1197
1198 Node getStatic() => findModifier('static');
1199
1187 /** 1200 /**
1188 * Use this to check if the declaration is either explicitly or implicitly 1201 * Use this to check if the declaration is either explicitly or implicitly
1189 * final. 1202 * final.
1190 */ 1203 */
1191 bool isFinalOrConst() => isFinal() || isConst(); 1204 bool isFinalOrConst() => isFinal() || isConst();
1192 1205
1193 String toString() { 1206 String toString() {
1194 LinkBuilder<String> builder = new LinkBuilder<String>(); 1207 LinkBuilder<String> builder = new LinkBuilder<String>();
1195 if (isStatic()) builder.addLast('static'); 1208 if (isStatic()) builder.addLast('static');
1196 if (isAbstract()) builder.addLast('abstract'); 1209 if (isAbstract()) builder.addLast('abstract');
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
1977 * argument). 1990 * argument).
1978 * 1991 *
1979 * TODO(ahe): This method is controversial, the team needs to discuss 1992 * TODO(ahe): This method is controversial, the team needs to discuss
1980 * if top-level methods are acceptable and what naming conventions to 1993 * if top-level methods are acceptable and what naming conventions to
1981 * use. 1994 * use.
1982 */ 1995 */
1983 initializerDo(Node node, f(Node node)) { 1996 initializerDo(Node node, f(Node node)) {
1984 SendSet send = node.asSendSet(); 1997 SendSet send = node.asSendSet();
1985 if (send !== null) return f(send.arguments.head); 1998 if (send !== null) return f(send.arguments.head);
1986 } 1999 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698