| OLD | NEW |
| 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 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 else if (value === 'abstract') flags |= FLAG_ABSTRACT; | 1164 else if (value === 'abstract') flags |= FLAG_ABSTRACT; |
| 1165 else if (value === 'final') flags |= FLAG_FINAL; | 1165 else if (value === 'final') flags |= FLAG_FINAL; |
| 1166 else if (value === 'var') flags |= FLAG_VAR; | 1166 else if (value === 'var') flags |= FLAG_VAR; |
| 1167 else if (value === 'const') flags |= FLAG_CONST; | 1167 else if (value === 'const') flags |= FLAG_CONST; |
| 1168 else if (value === 'factory') flags |= FLAG_FACTORY; | 1168 else if (value === 'factory') flags |= FLAG_FACTORY; |
| 1169 else if (value === 'external') flags |= FLAG_EXTERNAL; | 1169 else if (value === 'external') flags |= FLAG_EXTERNAL; |
| 1170 else throw 'internal error: ${nodes.head}'; | 1170 else throw 'internal error: ${nodes.head}'; |
| 1171 } | 1171 } |
| 1172 return flags; | 1172 return flags; |
| 1173 } | 1173 } |
| 1174 |
| 1175 Node findModifier(String modifier) { |
| 1176 Link<Node> nodeList = nodes.nodes; |
| 1177 for (; !nodeList.isEmpty(); nodeList = nodeList.tail) { |
| 1178 String value = nodeList.head.asIdentifier().source.stringValue; |
| 1179 if(value === modifier) { |
| 1180 return nodeList.head; |
| 1181 } |
| 1182 } |
| 1183 return null; |
| 1184 } |
| 1174 | 1185 |
| 1175 Modifiers asModifiers() => this; | 1186 Modifiers asModifiers() => this; |
| 1176 Token getBeginToken() => nodes.getBeginToken(); | 1187 Token getBeginToken() => nodes.getBeginToken(); |
| 1177 Token getEndToken() => nodes.getEndToken(); | 1188 Token getEndToken() => nodes.getEndToken(); |
| 1178 accept(Visitor visitor) => visitor.visitModifiers(this); | 1189 accept(Visitor visitor) => visitor.visitModifiers(this); |
| 1179 visitChildren(Visitor visitor) => nodes.accept(visitor); | 1190 visitChildren(Visitor visitor) => nodes.accept(visitor); |
| 1180 | 1191 |
| 1181 bool isStatic() => (flags & FLAG_STATIC) != 0; | 1192 bool isStatic() => (flags & FLAG_STATIC) != 0; |
| 1182 bool isAbstract() => (flags & FLAG_ABSTRACT) != 0; | 1193 bool isAbstract() => (flags & FLAG_ABSTRACT) != 0; |
| 1183 bool isFinal() => (flags & FLAG_FINAL) != 0; | 1194 bool isFinal() => (flags & FLAG_FINAL) != 0; |
| 1184 bool isVar() => (flags & FLAG_VAR) != 0; | 1195 bool isVar() => (flags & FLAG_VAR) != 0; |
| 1185 bool isConst() => (flags & FLAG_CONST) != 0; | 1196 bool isConst() => (flags & FLAG_CONST) != 0; |
| 1186 bool isFactory() => (flags & FLAG_FACTORY) != 0; | 1197 bool isFactory() => (flags & FLAG_FACTORY) != 0; |
| 1187 bool isExternal() => (flags & FLAG_EXTERNAL) != 0; | 1198 bool isExternal() => (flags & FLAG_EXTERNAL) != 0; |
| 1188 | 1199 |
| 1200 Node getStatic() => findModifier('static'); |
| 1201 |
| 1189 /** | 1202 /** |
| 1190 * Use this to check if the declaration is either explicitly or implicitly | 1203 * Use this to check if the declaration is either explicitly or implicitly |
| 1191 * final. | 1204 * final. |
| 1192 */ | 1205 */ |
| 1193 bool isFinalOrConst() => isFinal() || isConst(); | 1206 bool isFinalOrConst() => isFinal() || isConst(); |
| 1194 | 1207 |
| 1195 String toString() { | 1208 String toString() { |
| 1196 LinkBuilder<String> builder = new LinkBuilder<String>(); | 1209 LinkBuilder<String> builder = new LinkBuilder<String>(); |
| 1197 if (isStatic()) builder.addLast('static'); | 1210 if (isStatic()) builder.addLast('static'); |
| 1198 if (isAbstract()) builder.addLast('abstract'); | 1211 if (isAbstract()) builder.addLast('abstract'); |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1979 * argument). | 1992 * argument). |
| 1980 * | 1993 * |
| 1981 * TODO(ahe): This method is controversial, the team needs to discuss | 1994 * TODO(ahe): This method is controversial, the team needs to discuss |
| 1982 * if top-level methods are acceptable and what naming conventions to | 1995 * if top-level methods are acceptable and what naming conventions to |
| 1983 * use. | 1996 * use. |
| 1984 */ | 1997 */ |
| 1985 initializerDo(Node node, f(Node node)) { | 1998 initializerDo(Node node, f(Node node)) { |
| 1986 SendSet send = node.asSendSet(); | 1999 SendSet send = node.asSendSet(); |
| 1987 if (send !== null) return f(send.arguments.head); | 2000 if (send !== null) return f(send.arguments.head); |
| 1988 } | 2001 } |
| OLD | NEW |