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 import 'dart:collection' show IterableMixin; | 5 import 'dart:collection' show IterableMixin; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../elements/elements.dart' show MetadataAnnotation; | 8 import '../elements/elements.dart' show MetadataAnnotation; |
9 import '../resolution/secret_tree_element.dart' | |
10 show NullTreeElementMixin, StoredTreeElementMixin; | |
11 import 'package:front_end/src/fasta/scanner/precedence.dart' as Precedence | 9 import 'package:front_end/src/fasta/scanner/precedence.dart' as Precedence |
12 show FUNCTION_INFO; | 10 show FUNCTION_INFO; |
13 import 'package:front_end/src/fasta/scanner.dart' show BeginGroupToken, Token; | 11 import 'package:front_end/src/fasta/scanner.dart' show BeginGroupToken, Token; |
14 import 'package:front_end/src/fasta/scanner/token_constants.dart' as Tokens | 12 import 'package:front_end/src/fasta/scanner/token_constants.dart' as Tokens |
15 show PLUS_TOKEN; | 13 show PLUS_TOKEN; |
16 import 'package:front_end/src/fasta/scanner/characters.dart'; | 14 import 'package:front_end/src/fasta/scanner/characters.dart'; |
17 import '../util/util.dart'; | 15 import '../util/util.dart'; |
18 import 'dartstring.dart'; | 16 import 'dartstring.dart'; |
19 import 'prettyprint.dart'; | 17 import 'prettyprint.dart'; |
20 import 'unparser.dart'; | 18 import 'unparser.dart'; |
(...skipping 3196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3217 get metadata => null; | 3215 get metadata => null; |
3218 get type => null; | 3216 get type => null; |
3219 | 3217 |
3220 // Typedef. | 3218 // Typedef. |
3221 get isGeneralizedTypeAlias => null; | 3219 get isGeneralizedTypeAlias => null; |
3222 get templateParameters => null; | 3220 get templateParameters => null; |
3223 get typeParameters => null; | 3221 get typeParameters => null; |
3224 get formals => null; | 3222 get formals => null; |
3225 get typedefKeyword => null; | 3223 get typedefKeyword => null; |
3226 } | 3224 } |
| 3225 |
| 3226 /** |
| 3227 * Encapsulates the field [TreeElementMixin._element]. |
| 3228 * |
| 3229 * This library is an implementation detail of dart2js, and should not |
| 3230 * be imported except by resolution and tree node libraries, or for |
| 3231 * testing. |
| 3232 * |
| 3233 * We have taken great care to ensure AST nodes can be cached between |
| 3234 * compiler instances. Part of this requires that we always access |
| 3235 * resolution results through TreeElements. |
| 3236 * |
| 3237 * So please, do not add additional elements to this library, and do |
| 3238 * not import it. |
| 3239 */ |
| 3240 /// Interface for associating |
| 3241 abstract class TreeElementMixin { |
| 3242 Object get _element; |
| 3243 void set _element(Object value); |
| 3244 } |
| 3245 |
| 3246 /// Null implementation of [TreeElementMixin] which does not allow association |
| 3247 /// of elements. |
| 3248 /// |
| 3249 /// This class is the superclass of all AST nodes. |
| 3250 abstract class NullTreeElementMixin implements TreeElementMixin, Spannable { |
| 3251 // Deliberately using [Object] here to thwart code completion. |
| 3252 // You're not really supposed to access this field anyways. |
| 3253 Object get _element => null; |
| 3254 set _element(_) { |
| 3255 assert(invariant(this, false, |
| 3256 message: "Elements cannot be associated with ${runtimeType}.")); |
| 3257 } |
| 3258 } |
| 3259 |
| 3260 /// Actual implementation of [TreeElementMixin] which stores the associated |
| 3261 /// element in the private field [_element]. |
| 3262 /// |
| 3263 /// This class is mixed into the node classes that are actually associated with |
| 3264 /// elements. |
| 3265 abstract class StoredTreeElementMixin implements TreeElementMixin { |
| 3266 Object _element; |
| 3267 } |
| 3268 |
| 3269 /** |
| 3270 * Do not call this method directly. Instead, use an instance of |
| 3271 * TreeElements. |
| 3272 * |
| 3273 * Using [Object] as return type to thwart code completion. |
| 3274 */ |
| 3275 Object getTreeElement(TreeElementMixin node) => node._element; |
| 3276 |
| 3277 /** |
| 3278 * Do not call this method directly. Instead, use an instance of |
| 3279 * TreeElements. |
| 3280 */ |
| 3281 void setTreeElement(TreeElementMixin node, Object value) { |
| 3282 node._element = value; |
| 3283 } |
OLD | NEW |