OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library elements.modelx; | 5 library elements.modelx; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/names.dart' show Identifiers; | 8 import '../common/names.dart' show Identifiers; |
9 import '../common/resolution.dart' show Resolution, ParsingContext; | 9 import '../common/resolution.dart' show Resolution, ParsingContext; |
10 import '../compiler.dart' show Compiler; | 10 import '../compiler.dart' show Compiler; |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 Iterable<MetadataAnnotation> get metadata => unsupported(); | 243 Iterable<MetadataAnnotation> get metadata => unsupported(); |
244 bool get hasNode => false; | 244 bool get hasNode => false; |
245 get node => unsupported(); | 245 get node => unsupported(); |
246 get hasResolvedAst => false; | 246 get hasResolvedAst => false; |
247 get resolvedAst => unsupported(); | 247 get resolvedAst => unsupported(); |
248 get type => unsupported(); | 248 get type => unsupported(); |
249 get cachedNode => unsupported(); | 249 get cachedNode => unsupported(); |
250 get functionSignature => unsupported(); | 250 get functionSignature => unsupported(); |
251 get parameterStructure => unsupported(); | 251 get parameterStructure => unsupported(); |
252 get parameters => unsupported(); | 252 get parameters => unsupported(); |
253 Element get patch => null; | 253 FunctionElement get patch => null; |
254 Element get origin => this; | 254 FunctionElement get origin => this; |
255 get immediateRedirectionTarget => unsupported(); | 255 get immediateRedirectionTarget => unsupported(); |
256 get nestedClosures => unsupported(); | 256 get nestedClosures => unsupported(); |
257 get memberContext => unsupported(); | 257 get memberContext => unsupported(); |
258 get executableContext => unsupported(); | 258 get executableContext => unsupported(); |
259 get isExternal => unsupported(); | 259 get isExternal => unsupported(); |
260 get constantConstructor => null; | 260 get constantConstructor => null; |
261 | 261 |
262 bool get isRedirectingGenerative => unsupported(); | 262 bool get isRedirectingGenerative => unsupported(); |
263 bool get isRedirectingFactory => unsupported(); | 263 bool get isRedirectingFactory => unsupported(); |
264 | 264 |
(...skipping 3282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3547 | 3547 |
3548 bool get hasNode => true; | 3548 bool get hasNode => true; |
3549 | 3549 |
3550 Metadata get node => metadata; | 3550 Metadata get node => metadata; |
3551 } | 3551 } |
3552 | 3552 |
3553 /// Mixin for the implementation of patched elements. | 3553 /// Mixin for the implementation of patched elements. |
3554 /// | 3554 /// |
3555 /// See `patch_parser.dart` for a description of the terminology. | 3555 /// See `patch_parser.dart` for a description of the terminology. |
3556 abstract class PatchMixin<E extends Element> implements Element { | 3556 abstract class PatchMixin<E extends Element> implements Element { |
3557 // TODO(johnniwinther): Use type variables. | 3557 E patch = null; |
3558 Element /* E */ patch = null; | 3558 E origin = null; |
3559 Element /* E */ origin = null; | |
3560 | 3559 |
3561 bool get isPatch => origin != null; | 3560 bool get isPatch => origin != null; |
3562 bool get isPatched => patch != null; | 3561 bool get isPatched => patch != null; |
3563 | 3562 |
3564 bool get isImplementation => !isPatched; | 3563 bool get isImplementation => !isPatched; |
3565 bool get isDeclaration => !isPatch; | 3564 bool get isDeclaration => !isPatch; |
3566 | 3565 |
3567 Element /* E */ get implementation => isPatched ? patch : this; | 3566 E get implementation => isPatched ? patch : this; |
3568 Element /* E */ get declaration => isPatch ? origin : this; | 3567 E get declaration => isPatch ? origin : this; |
3569 | 3568 |
3570 /// Applies a patch to this element. This method must be called at most once. | 3569 /// Applies a patch to this element. This method must be called at most once. |
3571 void applyPatch(PatchMixin<E> patch) { | 3570 void applyPatch(PatchMixin<E> patch) { |
3572 assert(this.patch == null, failedAt(this, "Element is patched twice.")); | 3571 assert(this.patch == null, failedAt(this, "Element is patched twice.")); |
3573 assert(this.origin == null, failedAt(this, "Origin element is a patch.")); | 3572 assert(this.origin == null, failedAt(this, "Origin element is a patch.")); |
3574 assert(patch.origin == null, failedAt(patch, "Element is patched twice.")); | 3573 assert(patch.origin == null, failedAt(patch, "Element is patched twice.")); |
3575 assert(patch.patch == null, failedAt(patch, "Patch element is patched.")); | 3574 assert(patch.patch == null, failedAt(patch, "Patch element is patched.")); |
3575 // ignore: INVALID_ASSIGNMENT | |
3576 this.patch = patch; | 3576 this.patch = patch; |
Siggi Cherem (dart-lang)
2017/07/24 23:02:23
the alternative is to add `as E` here. I might wan
| |
3577 // ignore: INVALID_ASSIGNMENT | |
3577 patch.origin = this; | 3578 patch.origin = this; |
3578 } | 3579 } |
3579 } | 3580 } |
3580 | 3581 |
3581 /// Abstract implementation of the [AstElement] interface. | 3582 /// Abstract implementation of the [AstElement] interface. |
3582 abstract class AstElementMixin implements AstElement { | 3583 abstract class AstElementMixin implements AstElement { |
3583 /// The element whose node defines this element. | 3584 /// The element whose node defines this element. |
3584 /// | 3585 /// |
3585 /// For patched functions the defining element is the patch element found | 3586 /// For patched functions the defining element is the patch element found |
3586 /// through [implementation] since its node define the implementation of the | 3587 /// through [implementation] since its node define the implementation of the |
(...skipping 17 matching lines...) Expand all Loading... | |
3604 body = node.asFunctionExpression().body; | 3605 body = node.asFunctionExpression().body; |
3605 } | 3606 } |
3606 return new ParsedResolvedAst( | 3607 return new ParsedResolvedAst( |
3607 declaration, | 3608 declaration, |
3608 node, | 3609 node, |
3609 body, | 3610 body, |
3610 definingElement.treeElements, | 3611 definingElement.treeElements, |
3611 definingElement.compilationUnit.script.resourceUri); | 3612 definingElement.compilationUnit.script.resourceUri); |
3612 } | 3613 } |
3613 } | 3614 } |
OLD | NEW |